
_screen:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:
#include "types.h"
#include "user.h"

int main(int argc, char *argv[]) {    
   0:	8d 4c 24 04          	lea    0x4(%esp),%ecx
   4:	83 e4 f0             	and    $0xfffffff0,%esp
   7:	ff 71 fc             	push   -0x4(%ecx)
   a:	55                   	push   %ebp
   b:	89 e5                	mov    %esp,%ebp
   d:	57                   	push   %edi
   e:	56                   	push   %esi
   f:	53                   	push   %ebx
  10:	51                   	push   %ecx
  11:	83 ec 38             	sub    $0x38,%esp
  14:	8b 39                	mov    (%ecx),%edi
  16:	8b 71 04             	mov    0x4(%ecx),%esi
  19:	89 7d c4             	mov    %edi,-0x3c(%ebp)
    int pid;
    int selopt = getpid() % 10;
  1c:	e8 aa 04 00 00       	call   4cb <getpid>
  21:	ba 67 66 66 66       	mov    $0x66666667,%edx
  26:	89 c1                	mov    %eax,%ecx
  28:	f7 ea                	imul   %edx
  2a:	89 c8                	mov    %ecx,%eax
  2c:	c1 f8 1f             	sar    $0x1f,%eax
  2f:	c1 fa 02             	sar    $0x2,%edx
  32:	29 c2                	sub    %eax,%edx
  34:	8d 04 92             	lea    (%edx,%edx,4),%eax
  37:	01 c0                	add    %eax,%eax
  39:	29 c1                	sub    %eax,%ecx
  3b:	89 4d c0             	mov    %ecx,-0x40(%ebp)
    int bgcol = 0x4F00;
    char title[20];
    int accepttitle = 0;
    int currenttitlelen = 0;
    
    for (int i = 1; i < argc; i++) {
  3e:	83 ff 01             	cmp    $0x1,%edi
  41:	7e 6c                	jle    af <main+0xaf>
    int currenttitlelen = 0;
  43:	c7 45 bc 00 00 00 00 	movl   $0x0,-0x44(%ebp)
    for (int i = 1; i < argc; i++) {
  4a:	bb 01 00 00 00       	mov    $0x1,%ebx
    int accepttitle = 0;
  4f:	31 ff                	xor    %edi,%edi
  51:	eb 21                	jmp    74 <main+0x74>
  53:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  57:	90                   	nop
        if (strcmp(argv[i],  "-bg") == 0) 
        {
            accepttitle = 0;
            selopt = atoi(argv[i + 1]);            
  58:	83 ec 0c             	sub    $0xc,%esp
  5b:	ff 74 9e 04          	push   0x4(%esi,%ebx,4)
            accepttitle = 0;
  5f:	31 ff                	xor    %edi,%edi
            selopt = atoi(argv[i + 1]);            
  61:	e8 aa 03 00 00       	call   410 <atoi>
  66:	83 c4 10             	add    $0x10,%esp
  69:	89 45 c0             	mov    %eax,-0x40(%ebp)
    for (int i = 1; i < argc; i++) {
  6c:	83 c3 01             	add    $0x1,%ebx
  6f:	39 5d c4             	cmp    %ebx,-0x3c(%ebp)
  72:	74 3b                	je     af <main+0xaf>
        if (strcmp(argv[i],  "-bg") == 0) 
  74:	83 ec 08             	sub    $0x8,%esp
  77:	68 40 09 00 00       	push   $0x940
  7c:	ff 34 9e             	push   (%esi,%ebx,4)
  7f:	e8 dc 01 00 00       	call   260 <strcmp>
  84:	83 c4 10             	add    $0x10,%esp
  87:	85 c0                	test   %eax,%eax
  89:	74 cd                	je     58 <main+0x58>
        }
        else if (strcmp(argv[i], "-t") == 0)
  8b:	83 ec 08             	sub    $0x8,%esp
  8e:	68 44 09 00 00       	push   $0x944
  93:	ff 34 9e             	push   (%esi,%ebx,4)
  96:	e8 c5 01 00 00       	call   260 <strcmp>
  9b:	83 c4 10             	add    $0x10,%esp
  9e:	85 c0                	test   %eax,%eax
  a0:	75 3e                	jne    e0 <main+0xe0>
        {
            accepttitle = 1;
  a2:	bf 01 00 00 00       	mov    $0x1,%edi
    for (int i = 1; i < argc; i++) {
  a7:	83 c3 01             	add    $0x1,%ebx
  aa:	39 5d c4             	cmp    %ebx,-0x3c(%ebp)
  ad:	75 c5                	jne    74 <main+0x74>
            }
        }
    }

    // Set the variable to the selected bg/fg preset option
    switch(selopt)
  af:	8b 45 c0             	mov    -0x40(%ebp),%eax
  b2:	bb 00 4f 00 00       	mov    $0x4f00,%ebx
  b7:	83 e8 01             	sub    $0x1,%eax
  ba:	83 f8 08             	cmp    $0x8,%eax
  bd:	0f 86 9a 00 00 00    	jbe    15d <main+0x15d>
            bgcol = 0xCF00;
            break;
    }

    // Fork into a new process and create the screen
    pid = fork();    
  c3:	e8 b3 03 00 00       	call   47b <fork>
    if (pid < 0) {
  c8:	85 c0                	test   %eax,%eax
  ca:	0f 88 f7 00 00 00    	js     1c7 <main+0x1c7>
        printf(1, "screen: fork failed\n");
    }
    if (pid == 0) {
  d0:	0f 84 93 00 00 00    	je     169 <main+0x169>
        else
        {
            
        }
    }    
    exit();
  d6:	e8 a8 03 00 00       	call   483 <exit>
  db:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  df:	90                   	nop
        else if (strcmp(argv[i],  "-help") == 0)
  e0:	83 ec 08             	sub    $0x8,%esp
  e3:	68 47 09 00 00       	push   $0x947
  e8:	ff 34 9e             	push   (%esi,%ebx,4)
  eb:	e8 70 01 00 00       	call   260 <strcmp>
  f0:	83 c4 10             	add    $0x10,%esp
  f3:	85 c0                	test   %eax,%eax
  f5:	0f 84 e2 00 00 00    	je     1dd <main+0x1dd>
            if (accepttitle)
  fb:	85 ff                	test   %edi,%edi
  fd:	0f 84 69 ff ff ff    	je     6c <main+0x6c>
                if (currenttitlelen > 0) 
 103:	8b 45 bc             	mov    -0x44(%ebp),%eax
                for (sx = argv[i]; *sx != '\0'; sx++)
 106:	8b 0c 9e             	mov    (%esi,%ebx,4),%ecx
                if (currenttitlelen > 0) 
 109:	85 c0                	test   %eax,%eax
 10b:	0f 84 92 00 00 00    	je     1a3 <main+0x1a3>
                    title[currenttitlelen] = ' ';
 111:	c6 44 05 d4 20       	movb   $0x20,-0x2c(%ebp,%eax,1)
                    currenttitlelen++;
 116:	8d 50 01             	lea    0x1(%eax),%edx
                for (sx = argv[i]; *sx != '\0'; sx++)
 119:	0f b6 01             	movzbl (%ecx),%eax
 11c:	84 c0                	test   %al,%al
 11e:	0f 84 f6 00 00 00    	je     21a <main+0x21a>
                    currenttitlelen++;
 124:	83 45 bc 02          	addl   $0x2,-0x44(%ebp)
                    title[currenttitlelen] = *sx;
 128:	88 44 15 d4          	mov    %al,-0x2c(%ebp,%edx,1)
                    currenttitlelen++;
 12c:	8b 45 bc             	mov    -0x44(%ebp),%eax
                    if (currenttitlelen >= 20)
 12f:	83 f8 13             	cmp    $0x13,%eax
 132:	0f 8f 88 00 00 00    	jg     1c0 <main+0x1c0>
                    currenttitlelen++;
 138:	8b 45 bc             	mov    -0x44(%ebp),%eax
                for (sx = argv[i]; *sx != '\0'; sx++)
 13b:	29 c1                	sub    %eax,%ecx
 13d:	eb 0d                	jmp    14c <main+0x14c>
 13f:	90                   	nop
                    title[currenttitlelen] = *sx;
 140:	88 54 05 d4          	mov    %dl,-0x2c(%ebp,%eax,1)
                    currenttitlelen++;
 144:	83 c0 01             	add    $0x1,%eax
                    if (currenttitlelen >= 20)
 147:	83 f8 14             	cmp    $0x14,%eax
 14a:	74 6d                	je     1b9 <main+0x1b9>
                for (sx = argv[i]; *sx != '\0'; sx++)
 14c:	0f b6 54 01 01       	movzbl 0x1(%ecx,%eax,1),%edx
 151:	84 d2                	test   %dl,%dl
 153:	75 eb                	jne    140 <main+0x140>
 155:	89 45 bc             	mov    %eax,-0x44(%ebp)
 158:	e9 0f ff ff ff       	jmp    6c <main+0x6c>
 15d:	8b 1c 85 20 0a 00 00 	mov    0xa20(,%eax,4),%ebx
 164:	e9 5a ff ff ff       	jmp    c3 <main+0xc3>
        if (screen(title, bgcol) != 0)
 169:	8d 45 d4             	lea    -0x2c(%ebp),%eax
 16c:	57                   	push   %edi
 16d:	57                   	push   %edi
 16e:	53                   	push   %ebx
 16f:	50                   	push   %eax
 170:	e8 c6 03 00 00       	call   53b <screen>
 175:	83 c4 10             	add    $0x10,%esp
 178:	85 c0                	test   %eax,%eax
 17a:	0f 84 56 ff ff ff    	je     d6 <main+0xd6>
            exec("sh", argv);                                    
 180:	50                   	push   %eax
 181:	50                   	push   %eax
 182:	56                   	push   %esi
 183:	68 6c 09 00 00       	push   $0x96c
 188:	e8 1e 03 00 00       	call   4ab <exec>
            printf(1, "screen: exec sh failed\n");            
 18d:	5a                   	pop    %edx
 18e:	59                   	pop    %ecx
 18f:	68 6f 09 00 00       	push   $0x96f
 194:	6a 01                	push   $0x1
 196:	e8 65 04 00 00       	call   600 <printf>
 19b:	83 c4 10             	add    $0x10,%esp
 19e:	e9 33 ff ff ff       	jmp    d6 <main+0xd6>
                for (sx = argv[i]; *sx != '\0'; sx++)
 1a3:	0f b6 01             	movzbl (%ecx),%eax
 1a6:	84 c0                	test   %al,%al
 1a8:	0f 84 be fe ff ff    	je     6c <main+0x6c>
                    title[currenttitlelen] = *sx;
 1ae:	88 45 d4             	mov    %al,-0x2c(%ebp)
                    currenttitlelen++;
 1b1:	89 7d bc             	mov    %edi,-0x44(%ebp)
 1b4:	e9 7f ff ff ff       	jmp    138 <main+0x138>
 1b9:	c7 45 bc 14 00 00 00 	movl   $0x14,-0x44(%ebp)
                        accepttitle = 0;
 1c0:	31 ff                	xor    %edi,%edi
 1c2:	e9 a5 fe ff ff       	jmp    6c <main+0x6c>
        printf(1, "screen: fork failed\n");
 1c7:	50                   	push   %eax
 1c8:	50                   	push   %eax
 1c9:	68 57 09 00 00       	push   $0x957
 1ce:	6a 01                	push   $0x1
 1d0:	e8 2b 04 00 00       	call   600 <printf>
 1d5:	83 c4 10             	add    $0x10,%esp
 1d8:	e9 f9 fe ff ff       	jmp    d6 <main+0xd6>
            printf(1, "Creates a new virtual console.\n");
 1dd:	50                   	push   %eax
 1de:	50                   	push   %eax
 1df:	68 88 09 00 00       	push   $0x988
 1e4:	6a 01                	push   $0x1
 1e6:	e8 15 04 00 00       	call   600 <printf>
            printf(1, "Options:\n");
 1eb:	58                   	pop    %eax
 1ec:	5a                   	pop    %edx
 1ed:	68 4d 09 00 00       	push   $0x94d
 1f2:	6a 01                	push   $0x1
 1f4:	e8 07 04 00 00       	call   600 <printf>
            printf(1, "-bg [0 - 9] : Sets a background preset for the title bar.\n");
 1f9:	59                   	pop    %ecx
 1fa:	5b                   	pop    %ebx
 1fb:	68 a8 09 00 00       	push   $0x9a8
 200:	6a 01                	push   $0x1
 202:	e8 f9 03 00 00       	call   600 <printf>
            printf(1, "-t [String] : Sets a custom title for the console.\n");
 207:	5e                   	pop    %esi
 208:	5f                   	pop    %edi
 209:	68 e4 09 00 00       	push   $0x9e4
 20e:	6a 01                	push   $0x1
 210:	e8 eb 03 00 00       	call   600 <printf>
            exit();
 215:	e8 69 02 00 00       	call   483 <exit>
                    currenttitlelen++;
 21a:	89 55 bc             	mov    %edx,-0x44(%ebp)
 21d:	e9 4a fe ff ff       	jmp    6c <main+0x6c>
 222:	66 90                	xchg   %ax,%ax
 224:	66 90                	xchg   %ax,%ax
 226:	66 90                	xchg   %ax,%ax
 228:	66 90                	xchg   %ax,%ax
 22a:	66 90                	xchg   %ax,%ax
 22c:	66 90                	xchg   %ax,%ax
 22e:	66 90                	xchg   %ax,%ax

00000230 <strcpy>:
#include "stat.h"
#include "fcntl.h"
#include "user.h"
#include "x86.h"

char*strcpy(char *s, const char *t) {
 230:	55                   	push   %ebp
    char *os;

    os = s;
    while ((*s++ = *t++) != 0) {
 231:	31 c0                	xor    %eax,%eax
char*strcpy(char *s, const char *t) {
 233:	89 e5                	mov    %esp,%ebp
 235:	53                   	push   %ebx
 236:	8b 4d 08             	mov    0x8(%ebp),%ecx
 239:	8b 5d 0c             	mov    0xc(%ebp),%ebx
 23c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    while ((*s++ = *t++) != 0) {
 240:	0f b6 14 03          	movzbl (%ebx,%eax,1),%edx
 244:	88 14 01             	mov    %dl,(%ecx,%eax,1)
 247:	83 c0 01             	add    $0x1,%eax
 24a:	84 d2                	test   %dl,%dl
 24c:	75 f2                	jne    240 <strcpy+0x10>
        ;
    }
    return os;
}
 24e:	8b 5d fc             	mov    -0x4(%ebp),%ebx
 251:	89 c8                	mov    %ecx,%eax
 253:	c9                   	leave  
 254:	c3                   	ret    
 255:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 25c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00000260 <strcmp>:

int strcmp(const char *p, const char *q) {
 260:	55                   	push   %ebp
 261:	89 e5                	mov    %esp,%ebp
 263:	53                   	push   %ebx
 264:	8b 55 08             	mov    0x8(%ebp),%edx
 267:	8b 4d 0c             	mov    0xc(%ebp),%ecx
    while (*p && *p == *q) {
 26a:	0f b6 02             	movzbl (%edx),%eax
 26d:	84 c0                	test   %al,%al
 26f:	75 17                	jne    288 <strcmp+0x28>
 271:	eb 3a                	jmp    2ad <strcmp+0x4d>
 273:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 277:	90                   	nop
 278:	0f b6 42 01          	movzbl 0x1(%edx),%eax
        p++, q++;
 27c:	83 c2 01             	add    $0x1,%edx
 27f:	8d 59 01             	lea    0x1(%ecx),%ebx
    while (*p && *p == *q) {
 282:	84 c0                	test   %al,%al
 284:	74 1a                	je     2a0 <strcmp+0x40>
        p++, q++;
 286:	89 d9                	mov    %ebx,%ecx
    while (*p && *p == *q) {
 288:	0f b6 19             	movzbl (%ecx),%ebx
 28b:	38 c3                	cmp    %al,%bl
 28d:	74 e9                	je     278 <strcmp+0x18>
    }
    return (uchar) * p - (uchar) * q;
 28f:	29 d8                	sub    %ebx,%eax
}
 291:	8b 5d fc             	mov    -0x4(%ebp),%ebx
 294:	c9                   	leave  
 295:	c3                   	ret    
 296:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 29d:	8d 76 00             	lea    0x0(%esi),%esi
    return (uchar) * p - (uchar) * q;
 2a0:	0f b6 59 01          	movzbl 0x1(%ecx),%ebx
 2a4:	31 c0                	xor    %eax,%eax
 2a6:	29 d8                	sub    %ebx,%eax
}
 2a8:	8b 5d fc             	mov    -0x4(%ebp),%ebx
 2ab:	c9                   	leave  
 2ac:	c3                   	ret    
    return (uchar) * p - (uchar) * q;
 2ad:	0f b6 19             	movzbl (%ecx),%ebx
 2b0:	31 c0                	xor    %eax,%eax
 2b2:	eb db                	jmp    28f <strcmp+0x2f>
 2b4:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 2bb:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 2bf:	90                   	nop

000002c0 <strlen>:

uint strlen(const char *s)      {
 2c0:	55                   	push   %ebp
 2c1:	89 e5                	mov    %esp,%ebp
 2c3:	8b 55 08             	mov    0x8(%ebp),%edx
    int n;

    for (n = 0; s[n]; n++) {
 2c6:	80 3a 00             	cmpb   $0x0,(%edx)
 2c9:	74 15                	je     2e0 <strlen+0x20>
 2cb:	31 c0                	xor    %eax,%eax
 2cd:	8d 76 00             	lea    0x0(%esi),%esi
 2d0:	83 c0 01             	add    $0x1,%eax
 2d3:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
 2d7:	89 c1                	mov    %eax,%ecx
 2d9:	75 f5                	jne    2d0 <strlen+0x10>
        ;
    }
    return n;
}
 2db:	89 c8                	mov    %ecx,%eax
 2dd:	5d                   	pop    %ebp
 2de:	c3                   	ret    
 2df:	90                   	nop
    for (n = 0; s[n]; n++) {
 2e0:	31 c9                	xor    %ecx,%ecx
}
 2e2:	5d                   	pop    %ebp
 2e3:	89 c8                	mov    %ecx,%eax
 2e5:	c3                   	ret    
 2e6:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 2ed:	8d 76 00             	lea    0x0(%esi),%esi

000002f0 <memset>:

void* memset(void *dst, int c, uint n) {
 2f0:	55                   	push   %ebp
 2f1:	89 e5                	mov    %esp,%ebp
 2f3:	57                   	push   %edi
 2f4:	8b 55 08             	mov    0x8(%ebp),%edx
                  "d" (port), "0" (addr), "1" (cnt) :
                  "cc");
}

static inline void stosb(void *addr, int data, int cnt)  {
    asm volatile ("cld; rep stosb" :
 2f7:	8b 4d 10             	mov    0x10(%ebp),%ecx
 2fa:	8b 45 0c             	mov    0xc(%ebp),%eax
 2fd:	89 d7                	mov    %edx,%edi
 2ff:	fc                   	cld    
 300:	f3 aa                	rep stos %al,%es:(%edi)
    stosb(dst, c, n);
    return dst;
}
 302:	8b 7d fc             	mov    -0x4(%ebp),%edi
 305:	89 d0                	mov    %edx,%eax
 307:	c9                   	leave  
 308:	c3                   	ret    
 309:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00000310 <strchr>:

char* strchr(const char *s, char c) {
 310:	55                   	push   %ebp
 311:	89 e5                	mov    %esp,%ebp
 313:	8b 45 08             	mov    0x8(%ebp),%eax
 316:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
    for (; *s; s++) {
 31a:	0f b6 10             	movzbl (%eax),%edx
 31d:	84 d2                	test   %dl,%dl
 31f:	75 12                	jne    333 <strchr+0x23>
 321:	eb 1d                	jmp    340 <strchr+0x30>
 323:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 327:	90                   	nop
 328:	0f b6 50 01          	movzbl 0x1(%eax),%edx
 32c:	83 c0 01             	add    $0x1,%eax
 32f:	84 d2                	test   %dl,%dl
 331:	74 0d                	je     340 <strchr+0x30>
        if (*s == c) {
 333:	38 d1                	cmp    %dl,%cl
 335:	75 f1                	jne    328 <strchr+0x18>
            return (char*)s;
        }
    }
    return 0;
}
 337:	5d                   	pop    %ebp
 338:	c3                   	ret    
 339:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    return 0;
 340:	31 c0                	xor    %eax,%eax
}
 342:	5d                   	pop    %ebp
 343:	c3                   	ret    
 344:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 34b:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 34f:	90                   	nop

00000350 <gets>:

char* gets(char *buf, int max) {
 350:	55                   	push   %ebp
 351:	89 e5                	mov    %esp,%ebp
 353:	57                   	push   %edi
 354:	56                   	push   %esi
    int i, cc;
    char c;

    for (i = 0; i + 1 < max;) {
        cc = read(0, &c, 1);
 355:	8d 7d e7             	lea    -0x19(%ebp),%edi
char* gets(char *buf, int max) {
 358:	53                   	push   %ebx
    for (i = 0; i + 1 < max;) {
 359:	31 db                	xor    %ebx,%ebx
char* gets(char *buf, int max) {
 35b:	83 ec 1c             	sub    $0x1c,%esp
    for (i = 0; i + 1 < max;) {
 35e:	eb 27                	jmp    387 <gets+0x37>
        cc = read(0, &c, 1);
 360:	83 ec 04             	sub    $0x4,%esp
 363:	6a 01                	push   $0x1
 365:	57                   	push   %edi
 366:	6a 00                	push   $0x0
 368:	e8 2e 01 00 00       	call   49b <read>
        if (cc < 1) {
 36d:	83 c4 10             	add    $0x10,%esp
 370:	85 c0                	test   %eax,%eax
 372:	7e 1d                	jle    391 <gets+0x41>
            break;
        }
        buf[i++] = c;
 374:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
 378:	8b 55 08             	mov    0x8(%ebp),%edx
 37b:	88 44 1a ff          	mov    %al,-0x1(%edx,%ebx,1)
        if (c == '\n' || c == '\r') {
 37f:	3c 0a                	cmp    $0xa,%al
 381:	74 1d                	je     3a0 <gets+0x50>
 383:	3c 0d                	cmp    $0xd,%al
 385:	74 19                	je     3a0 <gets+0x50>
    for (i = 0; i + 1 < max;) {
 387:	89 de                	mov    %ebx,%esi
 389:	83 c3 01             	add    $0x1,%ebx
 38c:	3b 5d 0c             	cmp    0xc(%ebp),%ebx
 38f:	7c cf                	jl     360 <gets+0x10>
            break;
        }
    }
    buf[i] = '\0';
 391:	8b 45 08             	mov    0x8(%ebp),%eax
 394:	c6 04 30 00          	movb   $0x0,(%eax,%esi,1)
    return buf;
}
 398:	8d 65 f4             	lea    -0xc(%ebp),%esp
 39b:	5b                   	pop    %ebx
 39c:	5e                   	pop    %esi
 39d:	5f                   	pop    %edi
 39e:	5d                   	pop    %ebp
 39f:	c3                   	ret    
    buf[i] = '\0';
 3a0:	8b 45 08             	mov    0x8(%ebp),%eax
 3a3:	89 de                	mov    %ebx,%esi
 3a5:	c6 04 30 00          	movb   $0x0,(%eax,%esi,1)
}
 3a9:	8d 65 f4             	lea    -0xc(%ebp),%esp
 3ac:	5b                   	pop    %ebx
 3ad:	5e                   	pop    %esi
 3ae:	5f                   	pop    %edi
 3af:	5d                   	pop    %ebp
 3b0:	c3                   	ret    
 3b1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 3b8:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 3bf:	90                   	nop

000003c0 <stat>:

int stat(const char *n, struct stat *st) {
 3c0:	55                   	push   %ebp
 3c1:	89 e5                	mov    %esp,%ebp
 3c3:	56                   	push   %esi
 3c4:	53                   	push   %ebx
    int fd;
    int r;

    fd = open(n, O_RDONLY);
 3c5:	83 ec 08             	sub    $0x8,%esp
 3c8:	6a 00                	push   $0x0
 3ca:	ff 75 08             	push   0x8(%ebp)
 3cd:	e8 19 01 00 00       	call   4eb <open>
    if (fd < 0) {
 3d2:	83 c4 10             	add    $0x10,%esp
 3d5:	85 c0                	test   %eax,%eax
 3d7:	78 27                	js     400 <stat+0x40>
        return -1;
    }
    r = fstat(fd, st);
 3d9:	83 ec 08             	sub    $0x8,%esp
 3dc:	ff 75 0c             	push   0xc(%ebp)
 3df:	89 c3                	mov    %eax,%ebx
 3e1:	50                   	push   %eax
 3e2:	e8 cc 00 00 00       	call   4b3 <fstat>
    close(fd);
 3e7:	89 1c 24             	mov    %ebx,(%esp)
    r = fstat(fd, st);
 3ea:	89 c6                	mov    %eax,%esi
    close(fd);
 3ec:	e8 2a 01 00 00       	call   51b <close>
    return r;
 3f1:	83 c4 10             	add    $0x10,%esp
}
 3f4:	8d 65 f8             	lea    -0x8(%ebp),%esp
 3f7:	89 f0                	mov    %esi,%eax
 3f9:	5b                   	pop    %ebx
 3fa:	5e                   	pop    %esi
 3fb:	5d                   	pop    %ebp
 3fc:	c3                   	ret    
 3fd:	8d 76 00             	lea    0x0(%esi),%esi
        return -1;
 400:	be ff ff ff ff       	mov    $0xffffffff,%esi
 405:	eb ed                	jmp    3f4 <stat+0x34>
 407:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 40e:	66 90                	xchg   %ax,%ax

00000410 <atoi>:

int atoi(const char *s) {
 410:	55                   	push   %ebp
 411:	89 e5                	mov    %esp,%ebp
 413:	53                   	push   %ebx
 414:	8b 55 08             	mov    0x8(%ebp),%edx
    int n;

    n = 0;
    while ('0' <= *s && *s <= '9') {
 417:	0f be 02             	movsbl (%edx),%eax
 41a:	8d 48 d0             	lea    -0x30(%eax),%ecx
 41d:	80 f9 09             	cmp    $0x9,%cl
    n = 0;
 420:	b9 00 00 00 00       	mov    $0x0,%ecx
    while ('0' <= *s && *s <= '9') {
 425:	77 1e                	ja     445 <atoi+0x35>
 427:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 42e:	66 90                	xchg   %ax,%ax
        n = n * 10 + *s++ - '0';
 430:	83 c2 01             	add    $0x1,%edx
 433:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
 436:	8d 4c 48 d0          	lea    -0x30(%eax,%ecx,2),%ecx
    while ('0' <= *s && *s <= '9') {
 43a:	0f be 02             	movsbl (%edx),%eax
 43d:	8d 58 d0             	lea    -0x30(%eax),%ebx
 440:	80 fb 09             	cmp    $0x9,%bl
 443:	76 eb                	jbe    430 <atoi+0x20>
    }
    return n;
}
 445:	8b 5d fc             	mov    -0x4(%ebp),%ebx
 448:	89 c8                	mov    %ecx,%eax
 44a:	c9                   	leave  
 44b:	c3                   	ret    
 44c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00000450 <memmove>:

void* memmove(void *vdst, const void *vsrc, int n) {
 450:	55                   	push   %ebp
 451:	89 e5                	mov    %esp,%ebp
 453:	57                   	push   %edi
 454:	8b 45 10             	mov    0x10(%ebp),%eax
 457:	8b 55 08             	mov    0x8(%ebp),%edx
 45a:	56                   	push   %esi
 45b:	8b 75 0c             	mov    0xc(%ebp),%esi
    char *dst;
    const char *src;

    dst = vdst;
    src = vsrc;
    while (n-- > 0) {
 45e:	85 c0                	test   %eax,%eax
 460:	7e 13                	jle    475 <memmove+0x25>
 462:	01 d0                	add    %edx,%eax
    dst = vdst;
 464:	89 d7                	mov    %edx,%edi
 466:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 46d:	8d 76 00             	lea    0x0(%esi),%esi
        *dst++ = *src++;
 470:	a4                   	movsb  %ds:(%esi),%es:(%edi)
    while (n-- > 0) {
 471:	39 f8                	cmp    %edi,%eax
 473:	75 fb                	jne    470 <memmove+0x20>
    }
    return vdst;
}
 475:	5e                   	pop    %esi
 476:	89 d0                	mov    %edx,%eax
 478:	5f                   	pop    %edi
 479:	5d                   	pop    %ebp
 47a:	c3                   	ret    

0000047b <fork>:
name: \
	movl	$SYS_ ## name, %eax; \
	int	$T_SYSCALL; \
	ret

SYSCALL(fork)
 47b:	b8 01 00 00 00       	mov    $0x1,%eax
 480:	cd 40                	int    $0x40
 482:	c3                   	ret    

00000483 <exit>:
SYSCALL(exit)
 483:	b8 02 00 00 00       	mov    $0x2,%eax
 488:	cd 40                	int    $0x40
 48a:	c3                   	ret    

0000048b <wait>:
SYSCALL(wait)
 48b:	b8 03 00 00 00       	mov    $0x3,%eax
 490:	cd 40                	int    $0x40
 492:	c3                   	ret    

00000493 <pipe>:
SYSCALL(pipe)
 493:	b8 04 00 00 00       	mov    $0x4,%eax
 498:	cd 40                	int    $0x40
 49a:	c3                   	ret    

0000049b <read>:
SYSCALL(read)
 49b:	b8 05 00 00 00       	mov    $0x5,%eax
 4a0:	cd 40                	int    $0x40
 4a2:	c3                   	ret    

000004a3 <kill>:
SYSCALL(kill)
 4a3:	b8 06 00 00 00       	mov    $0x6,%eax
 4a8:	cd 40                	int    $0x40
 4aa:	c3                   	ret    

000004ab <exec>:
SYSCALL(exec)
 4ab:	b8 07 00 00 00       	mov    $0x7,%eax
 4b0:	cd 40                	int    $0x40
 4b2:	c3                   	ret    

000004b3 <fstat>:
SYSCALL(fstat)
 4b3:	b8 08 00 00 00       	mov    $0x8,%eax
 4b8:	cd 40                	int    $0x40
 4ba:	c3                   	ret    

000004bb <chdir>:
SYSCALL(chdir)
 4bb:	b8 09 00 00 00       	mov    $0x9,%eax
 4c0:	cd 40                	int    $0x40
 4c2:	c3                   	ret    

000004c3 <dup>:
SYSCALL(dup)
 4c3:	b8 0a 00 00 00       	mov    $0xa,%eax
 4c8:	cd 40                	int    $0x40
 4ca:	c3                   	ret    

000004cb <getpid>:
SYSCALL(getpid)
 4cb:	b8 0b 00 00 00       	mov    $0xb,%eax
 4d0:	cd 40                	int    $0x40
 4d2:	c3                   	ret    

000004d3 <sbrk>:
SYSCALL(sbrk)
 4d3:	b8 0c 00 00 00       	mov    $0xc,%eax
 4d8:	cd 40                	int    $0x40
 4da:	c3                   	ret    

000004db <sleep>:
SYSCALL(sleep)
 4db:	b8 0d 00 00 00       	mov    $0xd,%eax
 4e0:	cd 40                	int    $0x40
 4e2:	c3                   	ret    

000004e3 <uptime>:
SYSCALL(uptime)
 4e3:	b8 0e 00 00 00       	mov    $0xe,%eax
 4e8:	cd 40                	int    $0x40
 4ea:	c3                   	ret    

000004eb <open>:
SYSCALL(open)
 4eb:	b8 0f 00 00 00       	mov    $0xf,%eax
 4f0:	cd 40                	int    $0x40
 4f2:	c3                   	ret    

000004f3 <write>:
SYSCALL(write)
 4f3:	b8 10 00 00 00       	mov    $0x10,%eax
 4f8:	cd 40                	int    $0x40
 4fa:	c3                   	ret    

000004fb <mknod>:
SYSCALL(mknod)
 4fb:	b8 11 00 00 00       	mov    $0x11,%eax
 500:	cd 40                	int    $0x40
 502:	c3                   	ret    

00000503 <unlink>:
SYSCALL(unlink)
 503:	b8 12 00 00 00       	mov    $0x12,%eax
 508:	cd 40                	int    $0x40
 50a:	c3                   	ret    

0000050b <link>:
SYSCALL(link)
 50b:	b8 13 00 00 00       	mov    $0x13,%eax
 510:	cd 40                	int    $0x40
 512:	c3                   	ret    

00000513 <mkdir>:
SYSCALL(mkdir)
 513:	b8 14 00 00 00       	mov    $0x14,%eax
 518:	cd 40                	int    $0x40
 51a:	c3                   	ret    

0000051b <close>:
SYSCALL(close)
 51b:	b8 15 00 00 00       	mov    $0x15,%eax
 520:	cd 40                	int    $0x40
 522:	c3                   	ret    

00000523 <getch>:
SYSCALL(getch)
 523:	b8 16 00 00 00       	mov    $0x16,%eax
 528:	cd 40                	int    $0x40
 52a:	c3                   	ret    

0000052b <greeting>:
SYSCALL(greeting)
 52b:	b8 17 00 00 00       	mov    $0x17,%eax
 530:	cd 40                	int    $0x40
 532:	c3                   	ret    

00000533 <shutdown>:
SYSCALL(shutdown)
 533:	b8 18 00 00 00       	mov    $0x18,%eax
 538:	cd 40                	int    $0x40
 53a:	c3                   	ret    

0000053b <screen>:
SYSCALL(screen)
 53b:	b8 19 00 00 00       	mov    $0x19,%eax
 540:	cd 40                	int    $0x40
 542:	c3                   	ret    

00000543 <cls>:
SYSCALL(cls)
 543:	b8 1a 00 00 00       	mov    $0x1a,%eax
 548:	cd 40                	int    $0x40
 54a:	c3                   	ret    
 54b:	66 90                	xchg   %ax,%ax
 54d:	66 90                	xchg   %ax,%ax
 54f:	90                   	nop

00000550 <printint>:

static void putc(int fd, char c) {
    write(fd, &c, 1);
}

static void printint(int fd, int xx, int base, int sgn) {
 550:	55                   	push   %ebp
 551:	89 e5                	mov    %esp,%ebp
 553:	57                   	push   %edi
 554:	56                   	push   %esi
 555:	53                   	push   %ebx
 556:	83 ec 3c             	sub    $0x3c,%esp
 559:	89 4d c4             	mov    %ecx,-0x3c(%ebp)
    uint x;

    neg = 0;
    if (sgn && xx < 0) {
        neg = 1;
        x = -xx;
 55c:	89 d1                	mov    %edx,%ecx
static void printint(int fd, int xx, int base, int sgn) {
 55e:	89 45 b8             	mov    %eax,-0x48(%ebp)
    if (sgn && xx < 0) {
 561:	85 d2                	test   %edx,%edx
 563:	0f 89 7f 00 00 00    	jns    5e8 <printint+0x98>
 569:	f6 45 08 01          	testb  $0x1,0x8(%ebp)
 56d:	74 79                	je     5e8 <printint+0x98>
        neg = 1;
 56f:	c7 45 bc 01 00 00 00 	movl   $0x1,-0x44(%ebp)
        x = -xx;
 576:	f7 d9                	neg    %ecx
    }
    else {
        x = xx;
    }

    i = 0;
 578:	31 db                	xor    %ebx,%ebx
 57a:	8d 75 d7             	lea    -0x29(%ebp),%esi
 57d:	8d 76 00             	lea    0x0(%esi),%esi
    do {
        buf[i++] = digits[x % base];
 580:	89 c8                	mov    %ecx,%eax
 582:	31 d2                	xor    %edx,%edx
 584:	89 cf                	mov    %ecx,%edi
 586:	f7 75 c4             	divl   -0x3c(%ebp)
 589:	0f b6 92 a4 0a 00 00 	movzbl 0xaa4(%edx),%edx
 590:	89 45 c0             	mov    %eax,-0x40(%ebp)
 593:	89 d8                	mov    %ebx,%eax
 595:	8d 5b 01             	lea    0x1(%ebx),%ebx
    }
    while ((x /= base) != 0);
 598:	8b 4d c0             	mov    -0x40(%ebp),%ecx
        buf[i++] = digits[x % base];
 59b:	88 14 1e             	mov    %dl,(%esi,%ebx,1)
    while ((x /= base) != 0);
 59e:	39 7d c4             	cmp    %edi,-0x3c(%ebp)
 5a1:	76 dd                	jbe    580 <printint+0x30>
    if (neg) {
 5a3:	8b 4d bc             	mov    -0x44(%ebp),%ecx
 5a6:	85 c9                	test   %ecx,%ecx
 5a8:	74 0c                	je     5b6 <printint+0x66>
        buf[i++] = '-';
 5aa:	c6 44 1d d8 2d       	movb   $0x2d,-0x28(%ebp,%ebx,1)
        buf[i++] = digits[x % base];
 5af:	89 d8                	mov    %ebx,%eax
        buf[i++] = '-';
 5b1:	ba 2d 00 00 00       	mov    $0x2d,%edx
    }

    while (--i >= 0) {
 5b6:	8b 7d b8             	mov    -0x48(%ebp),%edi
 5b9:	8d 5c 05 d7          	lea    -0x29(%ebp,%eax,1),%ebx
 5bd:	eb 07                	jmp    5c6 <printint+0x76>
 5bf:	90                   	nop
        putc(fd, buf[i]);
 5c0:	0f b6 13             	movzbl (%ebx),%edx
 5c3:	83 eb 01             	sub    $0x1,%ebx
    write(fd, &c, 1);
 5c6:	83 ec 04             	sub    $0x4,%esp
 5c9:	88 55 d7             	mov    %dl,-0x29(%ebp)
 5cc:	6a 01                	push   $0x1
 5ce:	56                   	push   %esi
 5cf:	57                   	push   %edi
 5d0:	e8 1e ff ff ff       	call   4f3 <write>
    while (--i >= 0) {
 5d5:	83 c4 10             	add    $0x10,%esp
 5d8:	39 de                	cmp    %ebx,%esi
 5da:	75 e4                	jne    5c0 <printint+0x70>
    }
}
 5dc:	8d 65 f4             	lea    -0xc(%ebp),%esp
 5df:	5b                   	pop    %ebx
 5e0:	5e                   	pop    %esi
 5e1:	5f                   	pop    %edi
 5e2:	5d                   	pop    %ebp
 5e3:	c3                   	ret    
 5e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    neg = 0;
 5e8:	c7 45 bc 00 00 00 00 	movl   $0x0,-0x44(%ebp)
 5ef:	eb 87                	jmp    578 <printint+0x28>
 5f1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 5f8:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 5ff:	90                   	nop

00000600 <printf>:

// Print to the given fd. Only understands %d, %x, %p, %s.
void printf(int fd, const char *fmt, ...) {
 600:	55                   	push   %ebp
 601:	89 e5                	mov    %esp,%ebp
 603:	57                   	push   %edi
 604:	56                   	push   %esi
 605:	53                   	push   %ebx
 606:	83 ec 2c             	sub    $0x2c,%esp
    int c, i, state;
    uint *ap;

    state = 0;
    ap = (uint*)(void*)&fmt + 1;
    for (i = 0; fmt[i]; i++) {
 609:	8b 5d 0c             	mov    0xc(%ebp),%ebx
void printf(int fd, const char *fmt, ...) {
 60c:	8b 75 08             	mov    0x8(%ebp),%esi
    for (i = 0; fmt[i]; i++) {
 60f:	0f b6 13             	movzbl (%ebx),%edx
 612:	84 d2                	test   %dl,%dl
 614:	74 6a                	je     680 <printf+0x80>
    ap = (uint*)(void*)&fmt + 1;
 616:	8d 45 10             	lea    0x10(%ebp),%eax
 619:	83 c3 01             	add    $0x1,%ebx
    write(fd, &c, 1);
 61c:	8d 7d e7             	lea    -0x19(%ebp),%edi
    state = 0;
 61f:	31 c9                	xor    %ecx,%ecx
    ap = (uint*)(void*)&fmt + 1;
 621:	89 45 d0             	mov    %eax,-0x30(%ebp)
 624:	eb 36                	jmp    65c <printf+0x5c>
 626:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 62d:	8d 76 00             	lea    0x0(%esi),%esi
 630:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
        c = fmt[i] & 0xff;
        if (state == 0) {
            if (c == '%') {
                state = '%';
 633:	b9 25 00 00 00       	mov    $0x25,%ecx
            if (c == '%') {
 638:	83 f8 25             	cmp    $0x25,%eax
 63b:	74 15                	je     652 <printf+0x52>
    write(fd, &c, 1);
 63d:	83 ec 04             	sub    $0x4,%esp
 640:	88 55 e7             	mov    %dl,-0x19(%ebp)
 643:	6a 01                	push   $0x1
 645:	57                   	push   %edi
 646:	56                   	push   %esi
 647:	e8 a7 fe ff ff       	call   4f3 <write>
 64c:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
            }
            else {
                putc(fd, c);
 64f:	83 c4 10             	add    $0x10,%esp
    for (i = 0; fmt[i]; i++) {
 652:	0f b6 13             	movzbl (%ebx),%edx
 655:	83 c3 01             	add    $0x1,%ebx
 658:	84 d2                	test   %dl,%dl
 65a:	74 24                	je     680 <printf+0x80>
        c = fmt[i] & 0xff;
 65c:	0f b6 c2             	movzbl %dl,%eax
        if (state == 0) {
 65f:	85 c9                	test   %ecx,%ecx
 661:	74 cd                	je     630 <printf+0x30>
            }
        }
        else if (state == '%') {
 663:	83 f9 25             	cmp    $0x25,%ecx
 666:	75 ea                	jne    652 <printf+0x52>
            if (c == 'd') {
 668:	83 f8 25             	cmp    $0x25,%eax
 66b:	0f 84 07 01 00 00    	je     778 <printf+0x178>
 671:	83 e8 63             	sub    $0x63,%eax
 674:	83 f8 15             	cmp    $0x15,%eax
 677:	77 17                	ja     690 <printf+0x90>
 679:	ff 24 85 4c 0a 00 00 	jmp    *0xa4c(,%eax,4)
                putc(fd, c);
            }
            state = 0;
        }
    }
}
 680:	8d 65 f4             	lea    -0xc(%ebp),%esp
 683:	5b                   	pop    %ebx
 684:	5e                   	pop    %esi
 685:	5f                   	pop    %edi
 686:	5d                   	pop    %ebp
 687:	c3                   	ret    
 688:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 68f:	90                   	nop
    write(fd, &c, 1);
 690:	83 ec 04             	sub    $0x4,%esp
 693:	88 55 d4             	mov    %dl,-0x2c(%ebp)
 696:	6a 01                	push   $0x1
 698:	57                   	push   %edi
 699:	56                   	push   %esi
 69a:	c6 45 e7 25          	movb   $0x25,-0x19(%ebp)
 69e:	e8 50 fe ff ff       	call   4f3 <write>
                putc(fd, c);
 6a3:	0f b6 55 d4          	movzbl -0x2c(%ebp),%edx
    write(fd, &c, 1);
 6a7:	83 c4 0c             	add    $0xc,%esp
 6aa:	88 55 e7             	mov    %dl,-0x19(%ebp)
 6ad:	6a 01                	push   $0x1
 6af:	57                   	push   %edi
 6b0:	56                   	push   %esi
 6b1:	e8 3d fe ff ff       	call   4f3 <write>
                putc(fd, c);
 6b6:	83 c4 10             	add    $0x10,%esp
            state = 0;
 6b9:	31 c9                	xor    %ecx,%ecx
 6bb:	eb 95                	jmp    652 <printf+0x52>
 6bd:	8d 76 00             	lea    0x0(%esi),%esi
                printint(fd, *ap, 16, 0);
 6c0:	83 ec 0c             	sub    $0xc,%esp
 6c3:	b9 10 00 00 00       	mov    $0x10,%ecx
 6c8:	6a 00                	push   $0x0
 6ca:	8b 45 d0             	mov    -0x30(%ebp),%eax
 6cd:	8b 10                	mov    (%eax),%edx
 6cf:	89 f0                	mov    %esi,%eax
 6d1:	e8 7a fe ff ff       	call   550 <printint>
                ap++;
 6d6:	83 45 d0 04          	addl   $0x4,-0x30(%ebp)
 6da:	83 c4 10             	add    $0x10,%esp
            state = 0;
 6dd:	31 c9                	xor    %ecx,%ecx
 6df:	e9 6e ff ff ff       	jmp    652 <printf+0x52>
 6e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
                s = (char*)*ap;
 6e8:	8b 45 d0             	mov    -0x30(%ebp),%eax
 6eb:	8b 10                	mov    (%eax),%edx
                ap++;
 6ed:	83 c0 04             	add    $0x4,%eax
 6f0:	89 45 d0             	mov    %eax,-0x30(%ebp)
                if (s == 0) {
 6f3:	85 d2                	test   %edx,%edx
 6f5:	0f 84 8d 00 00 00    	je     788 <printf+0x188>
                while (*s != 0) {
 6fb:	0f b6 02             	movzbl (%edx),%eax
            state = 0;
 6fe:	31 c9                	xor    %ecx,%ecx
                while (*s != 0) {
 700:	84 c0                	test   %al,%al
 702:	0f 84 4a ff ff ff    	je     652 <printf+0x52>
 708:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
 70b:	89 d3                	mov    %edx,%ebx
 70d:	8d 76 00             	lea    0x0(%esi),%esi
    write(fd, &c, 1);
 710:	83 ec 04             	sub    $0x4,%esp
                    s++;
 713:	83 c3 01             	add    $0x1,%ebx
 716:	88 45 e7             	mov    %al,-0x19(%ebp)
    write(fd, &c, 1);
 719:	6a 01                	push   $0x1
 71b:	57                   	push   %edi
 71c:	56                   	push   %esi
 71d:	e8 d1 fd ff ff       	call   4f3 <write>
                while (*s != 0) {
 722:	0f b6 03             	movzbl (%ebx),%eax
 725:	83 c4 10             	add    $0x10,%esp
 728:	84 c0                	test   %al,%al
 72a:	75 e4                	jne    710 <printf+0x110>
            state = 0;
 72c:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
 72f:	31 c9                	xor    %ecx,%ecx
 731:	e9 1c ff ff ff       	jmp    652 <printf+0x52>
 736:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 73d:	8d 76 00             	lea    0x0(%esi),%esi
                printint(fd, *ap, 10, 1);
 740:	83 ec 0c             	sub    $0xc,%esp
 743:	b9 0a 00 00 00       	mov    $0xa,%ecx
 748:	6a 01                	push   $0x1
 74a:	e9 7b ff ff ff       	jmp    6ca <printf+0xca>
 74f:	90                   	nop
                putc(fd, *ap);
 750:	8b 45 d0             	mov    -0x30(%ebp),%eax
    write(fd, &c, 1);
 753:	83 ec 04             	sub    $0x4,%esp
                putc(fd, *ap);
 756:	8b 00                	mov    (%eax),%eax
    write(fd, &c, 1);
 758:	6a 01                	push   $0x1
 75a:	57                   	push   %edi
 75b:	56                   	push   %esi
                putc(fd, *ap);
 75c:	88 45 e7             	mov    %al,-0x19(%ebp)
    write(fd, &c, 1);
 75f:	e8 8f fd ff ff       	call   4f3 <write>
                ap++;
 764:	83 45 d0 04          	addl   $0x4,-0x30(%ebp)
 768:	83 c4 10             	add    $0x10,%esp
            state = 0;
 76b:	31 c9                	xor    %ecx,%ecx
 76d:	e9 e0 fe ff ff       	jmp    652 <printf+0x52>
 772:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
                putc(fd, c);
 778:	88 55 e7             	mov    %dl,-0x19(%ebp)
    write(fd, &c, 1);
 77b:	83 ec 04             	sub    $0x4,%esp
 77e:	e9 2a ff ff ff       	jmp    6ad <printf+0xad>
 783:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 787:	90                   	nop
                    s = "(null)";
 788:	ba 44 0a 00 00       	mov    $0xa44,%edx
                while (*s != 0) {
 78d:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
 790:	b8 28 00 00 00       	mov    $0x28,%eax
 795:	89 d3                	mov    %edx,%ebx
 797:	e9 74 ff ff ff       	jmp    710 <printf+0x110>
 79c:	66 90                	xchg   %ax,%ax
 79e:	66 90                	xchg   %ax,%ax

000007a0 <free>:
typedef union header Header;

static Header base;
static Header *freep;

void free(void *ap) {
 7a0:	55                   	push   %ebp
    Header *bp, *p;

    bp = (Header*)ap - 1;
    for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) {
 7a1:	a1 58 0d 00 00       	mov    0xd58,%eax
void free(void *ap) {
 7a6:	89 e5                	mov    %esp,%ebp
 7a8:	57                   	push   %edi
 7a9:	56                   	push   %esi
 7aa:	53                   	push   %ebx
 7ab:	8b 5d 08             	mov    0x8(%ebp),%ebx
    bp = (Header*)ap - 1;
 7ae:	8d 4b f8             	lea    -0x8(%ebx),%ecx
    for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) {
 7b1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 7b8:	89 c2                	mov    %eax,%edx
 7ba:	8b 00                	mov    (%eax),%eax
 7bc:	39 ca                	cmp    %ecx,%edx
 7be:	73 30                	jae    7f0 <free+0x50>
 7c0:	39 c1                	cmp    %eax,%ecx
 7c2:	72 04                	jb     7c8 <free+0x28>
        if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) {
 7c4:	39 c2                	cmp    %eax,%edx
 7c6:	72 f0                	jb     7b8 <free+0x18>
            break;
        }
    }
    if (bp + bp->s.size == p->s.ptr) {
 7c8:	8b 73 fc             	mov    -0x4(%ebx),%esi
 7cb:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
 7ce:	39 f8                	cmp    %edi,%eax
 7d0:	74 30                	je     802 <free+0x62>
        bp->s.size += p->s.ptr->s.size;
        bp->s.ptr = p->s.ptr->s.ptr;
 7d2:	89 43 f8             	mov    %eax,-0x8(%ebx)
    }
    else {
        bp->s.ptr = p->s.ptr;
    }
    if (p + p->s.size == bp) {
 7d5:	8b 42 04             	mov    0x4(%edx),%eax
 7d8:	8d 34 c2             	lea    (%edx,%eax,8),%esi
 7db:	39 f1                	cmp    %esi,%ecx
 7dd:	74 3a                	je     819 <free+0x79>
        p->s.size += bp->s.size;
        p->s.ptr = bp->s.ptr;
 7df:	89 0a                	mov    %ecx,(%edx)
    }
    else {
        p->s.ptr = bp;
    }
    freep = p;
}
 7e1:	5b                   	pop    %ebx
    freep = p;
 7e2:	89 15 58 0d 00 00    	mov    %edx,0xd58
}
 7e8:	5e                   	pop    %esi
 7e9:	5f                   	pop    %edi
 7ea:	5d                   	pop    %ebp
 7eb:	c3                   	ret    
 7ec:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
        if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) {
 7f0:	39 c2                	cmp    %eax,%edx
 7f2:	72 c4                	jb     7b8 <free+0x18>
 7f4:	39 c1                	cmp    %eax,%ecx
 7f6:	73 c0                	jae    7b8 <free+0x18>
    if (bp + bp->s.size == p->s.ptr) {
 7f8:	8b 73 fc             	mov    -0x4(%ebx),%esi
 7fb:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
 7fe:	39 f8                	cmp    %edi,%eax
 800:	75 d0                	jne    7d2 <free+0x32>
        bp->s.size += p->s.ptr->s.size;
 802:	03 70 04             	add    0x4(%eax),%esi
 805:	89 73 fc             	mov    %esi,-0x4(%ebx)
        bp->s.ptr = p->s.ptr->s.ptr;
 808:	8b 02                	mov    (%edx),%eax
 80a:	8b 00                	mov    (%eax),%eax
 80c:	89 43 f8             	mov    %eax,-0x8(%ebx)
    if (p + p->s.size == bp) {
 80f:	8b 42 04             	mov    0x4(%edx),%eax
 812:	8d 34 c2             	lea    (%edx,%eax,8),%esi
 815:	39 f1                	cmp    %esi,%ecx
 817:	75 c6                	jne    7df <free+0x3f>
        p->s.size += bp->s.size;
 819:	03 43 fc             	add    -0x4(%ebx),%eax
    freep = p;
 81c:	89 15 58 0d 00 00    	mov    %edx,0xd58
        p->s.size += bp->s.size;
 822:	89 42 04             	mov    %eax,0x4(%edx)
        p->s.ptr = bp->s.ptr;
 825:	8b 4b f8             	mov    -0x8(%ebx),%ecx
 828:	89 0a                	mov    %ecx,(%edx)
}
 82a:	5b                   	pop    %ebx
 82b:	5e                   	pop    %esi
 82c:	5f                   	pop    %edi
 82d:	5d                   	pop    %ebp
 82e:	c3                   	ret    
 82f:	90                   	nop

00000830 <malloc>:
    hp->s.size = nu;
    free((void*)(hp + 1));
    return freep;
}

void* malloc(uint nbytes) {
 830:	55                   	push   %ebp
 831:	89 e5                	mov    %esp,%ebp
 833:	57                   	push   %edi
 834:	56                   	push   %esi
 835:	53                   	push   %ebx
 836:	83 ec 1c             	sub    $0x1c,%esp
    Header *p, *prevp;
    uint nunits;

    nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1;
 839:	8b 45 08             	mov    0x8(%ebp),%eax
    if ((prevp = freep) == 0) {
 83c:	8b 3d 58 0d 00 00    	mov    0xd58,%edi
    nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1;
 842:	8d 70 07             	lea    0x7(%eax),%esi
 845:	c1 ee 03             	shr    $0x3,%esi
 848:	83 c6 01             	add    $0x1,%esi
    if ((prevp = freep) == 0) {
 84b:	85 ff                	test   %edi,%edi
 84d:	0f 84 9d 00 00 00    	je     8f0 <malloc+0xc0>
        base.s.ptr = freep = prevp = &base;
        base.s.size = 0;
    }
    for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) {
 853:	8b 17                	mov    (%edi),%edx
        if (p->s.size >= nunits) {
 855:	8b 4a 04             	mov    0x4(%edx),%ecx
 858:	39 f1                	cmp    %esi,%ecx
 85a:	73 6a                	jae    8c6 <malloc+0x96>
 85c:	bb 00 10 00 00       	mov    $0x1000,%ebx
 861:	39 de                	cmp    %ebx,%esi
 863:	0f 43 de             	cmovae %esi,%ebx
    p = sbrk(nu * sizeof(Header));
 866:	8d 04 dd 00 00 00 00 	lea    0x0(,%ebx,8),%eax
 86d:	89 45 e4             	mov    %eax,-0x1c(%ebp)
 870:	eb 17                	jmp    889 <malloc+0x59>
 872:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) {
 878:	8b 02                	mov    (%edx),%eax
        if (p->s.size >= nunits) {
 87a:	8b 48 04             	mov    0x4(%eax),%ecx
 87d:	39 f1                	cmp    %esi,%ecx
 87f:	73 4f                	jae    8d0 <malloc+0xa0>
                p->s.size = nunits;
            }
            freep = prevp;
            return (void*)(p + 1);
        }
        if (p == freep) {
 881:	8b 3d 58 0d 00 00    	mov    0xd58,%edi
 887:	89 c2                	mov    %eax,%edx
 889:	39 d7                	cmp    %edx,%edi
 88b:	75 eb                	jne    878 <malloc+0x48>
    p = sbrk(nu * sizeof(Header));
 88d:	83 ec 0c             	sub    $0xc,%esp
 890:	ff 75 e4             	push   -0x1c(%ebp)
 893:	e8 3b fc ff ff       	call   4d3 <sbrk>
    if (p == (char*)-1) {
 898:	83 c4 10             	add    $0x10,%esp
 89b:	83 f8 ff             	cmp    $0xffffffff,%eax
 89e:	74 1c                	je     8bc <malloc+0x8c>
    hp->s.size = nu;
 8a0:	89 58 04             	mov    %ebx,0x4(%eax)
    free((void*)(hp + 1));
 8a3:	83 ec 0c             	sub    $0xc,%esp
 8a6:	83 c0 08             	add    $0x8,%eax
 8a9:	50                   	push   %eax
 8aa:	e8 f1 fe ff ff       	call   7a0 <free>
    return freep;
 8af:	8b 15 58 0d 00 00    	mov    0xd58,%edx
            if ((p = morecore(nunits)) == 0) {
 8b5:	83 c4 10             	add    $0x10,%esp
 8b8:	85 d2                	test   %edx,%edx
 8ba:	75 bc                	jne    878 <malloc+0x48>
                return 0;
            }
        }
    }
}
 8bc:	8d 65 f4             	lea    -0xc(%ebp),%esp
                return 0;
 8bf:	31 c0                	xor    %eax,%eax
}
 8c1:	5b                   	pop    %ebx
 8c2:	5e                   	pop    %esi
 8c3:	5f                   	pop    %edi
 8c4:	5d                   	pop    %ebp
 8c5:	c3                   	ret    
        if (p->s.size >= nunits) {
 8c6:	89 d0                	mov    %edx,%eax
 8c8:	89 fa                	mov    %edi,%edx
 8ca:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
            if (p->s.size == nunits) {
 8d0:	39 ce                	cmp    %ecx,%esi
 8d2:	74 4c                	je     920 <malloc+0xf0>
                p->s.size -= nunits;
 8d4:	29 f1                	sub    %esi,%ecx
 8d6:	89 48 04             	mov    %ecx,0x4(%eax)
                p += p->s.size;
 8d9:	8d 04 c8             	lea    (%eax,%ecx,8),%eax
                p->s.size = nunits;
 8dc:	89 70 04             	mov    %esi,0x4(%eax)
            freep = prevp;
 8df:	89 15 58 0d 00 00    	mov    %edx,0xd58
}
 8e5:	8d 65 f4             	lea    -0xc(%ebp),%esp
            return (void*)(p + 1);
 8e8:	83 c0 08             	add    $0x8,%eax
}
 8eb:	5b                   	pop    %ebx
 8ec:	5e                   	pop    %esi
 8ed:	5f                   	pop    %edi
 8ee:	5d                   	pop    %ebp
 8ef:	c3                   	ret    
        base.s.ptr = freep = prevp = &base;
 8f0:	c7 05 58 0d 00 00 5c 	movl   $0xd5c,0xd58
 8f7:	0d 00 00 
        base.s.size = 0;
 8fa:	bf 5c 0d 00 00       	mov    $0xd5c,%edi
        base.s.ptr = freep = prevp = &base;
 8ff:	c7 05 5c 0d 00 00 5c 	movl   $0xd5c,0xd5c
 906:	0d 00 00 
    for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) {
 909:	89 fa                	mov    %edi,%edx
        base.s.size = 0;
 90b:	c7 05 60 0d 00 00 00 	movl   $0x0,0xd60
 912:	00 00 00 
        if (p->s.size >= nunits) {
 915:	e9 42 ff ff ff       	jmp    85c <malloc+0x2c>
 91a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
                prevp->s.ptr = p->s.ptr;
 920:	8b 08                	mov    (%eax),%ecx
 922:	89 0a                	mov    %ecx,(%edx)
 924:	eb b9                	jmp    8df <malloc+0xaf>
