
_cat:     file format elf32-i386

Disassembly of section .text:

00000000 <cat>:
char buf[512];

void
cat(int fd)
{
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	53                   	push   %ebx
   4:	83 ec 14             	sub    $0x14,%esp
   7:	8b 5d 08             	mov    0x8(%ebp),%ebx
   a:	eb 1d                	jmp    29 <cat+0x29>
   c:	8d 74 26 00          	lea    0x0(%esi),%esi
  int n;

  while((n = read(fd, buf, sizeof(buf))) > 0)
    write(1, buf, n);
  10:	89 44 24 08          	mov    %eax,0x8(%esp)
  14:	b8 e0 07 00 00       	mov    $0x7e0,%eax
  19:	89 44 24 04          	mov    %eax,0x4(%esp)
  1d:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  24:	e8 23 03 00 00       	call   34c <write>
  29:	b9 00 02 00 00       	mov    $0x200,%ecx
  2e:	ba e0 07 00 00       	mov    $0x7e0,%edx
  33:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  37:	89 54 24 04          	mov    %edx,0x4(%esp)
  3b:	89 1c 24             	mov    %ebx,(%esp)
  3e:	e8 01 03 00 00       	call   344 <read>
  43:	83 f8 00             	cmp    $0x0,%eax
  46:	7f c8                	jg     10 <cat+0x10>
  if(n < 0){
  48:	75 07                	jne    51 <cat+0x51>
    printf(1, "cat: read error\n");
    exit();
  }
}
  4a:	83 c4 14             	add    $0x14,%esp
  4d:	5b                   	pop    %ebx
  4e:	5d                   	pop    %ebp
  4f:	90                   	nop    
  50:	c3                   	ret    
  51:	b8 7a 07 00 00       	mov    $0x77a,%eax
  56:	89 44 24 04          	mov    %eax,0x4(%esp)
  5a:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  61:	e8 2a 04 00 00       	call   490 <printf>
  66:	e8 c1 02 00 00       	call   32c <exit>
  6b:	90                   	nop    
  6c:	8d 74 26 00          	lea    0x0(%esi),%esi

00000070 <main>:

int
main(int argc, char *argv[])
{
  70:	8d 4c 24 04          	lea    0x4(%esp),%ecx
  74:	83 e4 f0             	and    $0xfffffff0,%esp
  77:	ff 71 fc             	pushl  0xfffffffc(%ecx)
  7a:	55                   	push   %ebp
  7b:	89 e5                	mov    %esp,%ebp
  7d:	57                   	push   %edi
  7e:	56                   	push   %esi
  7f:	53                   	push   %ebx
  80:	51                   	push   %ecx
  81:	83 ec 18             	sub    $0x18,%esp
  84:	8b 01                	mov    (%ecx),%eax
  86:	89 45 ec             	mov    %eax,0xffffffec(%ebp)
  89:	8b 41 04             	mov    0x4(%ecx),%eax
  int fd, i;

  if(argc <= 1){
  8c:	83 7d ec 01          	cmpl   $0x1,0xffffffec(%ebp)
  90:	7e 62                	jle    f4 <main+0x84>
    cat(0);
    exit();
  92:	8d 70 04             	lea    0x4(%eax),%esi
  95:	bf 01 00 00 00       	mov    $0x1,%edi
  9a:	eb 1d                	jmp    b9 <main+0x49>
  9c:	8d 74 26 00          	lea    0x0(%esi),%esi
  }

  for(i = 1; i < argc; i++){
  a0:	47                   	inc    %edi
  a1:	83 c6 04             	add    $0x4,%esi
    if((fd = open(argv[i], 0)) < 0){
      printf(1, "cat: cannot open %s\n", argv[i]);
      exit();
    }
    cat(fd);
  a4:	89 04 24             	mov    %eax,(%esp)
  a7:	e8 54 ff ff ff       	call   0 <cat>
    close(fd);
  ac:	89 1c 24             	mov    %ebx,(%esp)
  af:	e8 a0 02 00 00       	call   354 <close>
  b4:	39 7d ec             	cmp    %edi,0xffffffec(%ebp)
  b7:	74 36                	je     ef <main+0x7f>
  b9:	31 c0                	xor    %eax,%eax
  bb:	89 44 24 04          	mov    %eax,0x4(%esp)
  bf:	8b 06                	mov    (%esi),%eax
  c1:	89 04 24             	mov    %eax,(%esp)
  c4:	e8 a3 02 00 00       	call   36c <open>
  c9:	85 c0                	test   %eax,%eax
  cb:	89 c3                	mov    %eax,%ebx
  cd:	79 d1                	jns    a0 <main+0x30>
  cf:	8b 06                	mov    (%esi),%eax
  d1:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  d8:	89 44 24 08          	mov    %eax,0x8(%esp)
  dc:	b8 8b 07 00 00       	mov    $0x78b,%eax
  e1:	89 44 24 04          	mov    %eax,0x4(%esp)
  e5:	e8 a6 03 00 00       	call   490 <printf>
  ea:	e8 3d 02 00 00       	call   32c <exit>
  }
  exit();
  ef:	e8 38 02 00 00       	call   32c <exit>
  f4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  fb:	e8 00 ff ff ff       	call   0 <cat>
 100:	e8 27 02 00 00       	call   32c <exit>
 105:	90                   	nop    
 106:	90                   	nop    
 107:	90                   	nop    
 108:	90                   	nop    
 109:	90                   	nop    
 10a:	90                   	nop    
 10b:	90                   	nop    
 10c:	90                   	nop    
 10d:	90                   	nop    
 10e:	90                   	nop    
 10f:	90                   	nop    

00000110 <strcpy>:
#include "user.h"

char*
strcpy(char *s, char *t)
{
 110:	55                   	push   %ebp
 111:	89 e5                	mov    %esp,%ebp
 113:	53                   	push   %ebx
 114:	8b 5d 08             	mov    0x8(%ebp),%ebx
 117:	8b 4d 0c             	mov    0xc(%ebp),%ecx
 11a:	89 da                	mov    %ebx,%edx
 11c:	8d 74 26 00          	lea    0x0(%esi),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 120:	0f b6 01             	movzbl (%ecx),%eax
 123:	41                   	inc    %ecx
 124:	88 02                	mov    %al,(%edx)
 126:	42                   	inc    %edx
 127:	84 c0                	test   %al,%al
 129:	75 f5                	jne    120 <strcpy+0x10>
    ;
  return os;
}
 12b:	89 d8                	mov    %ebx,%eax
 12d:	5b                   	pop    %ebx
 12e:	5d                   	pop    %ebp
 12f:	c3                   	ret    

00000130 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 130:	55                   	push   %ebp
 131:	89 e5                	mov    %esp,%ebp
 133:	8b 55 08             	mov    0x8(%ebp),%edx
 136:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  while(*p && *p == *q)
 139:	0f b6 02             	movzbl (%edx),%eax
 13c:	84 c0                	test   %al,%al
 13e:	75 0c                	jne    14c <strcmp+0x1c>
 140:	eb 10                	jmp    152 <strcmp+0x22>
 142:	0f b6 42 01          	movzbl 0x1(%edx),%eax
    p++, q++;
 146:	41                   	inc    %ecx
 147:	84 c0                	test   %al,%al
 149:	74 07                	je     152 <strcmp+0x22>
 14b:	42                   	inc    %edx
 14c:	3a 01                	cmp    (%ecx),%al
 14e:	89 f6                	mov    %esi,%esi
 150:	74 f0                	je     142 <strcmp+0x12>
 152:	0f b6 11             	movzbl (%ecx),%edx
 155:	0f b6 c0             	movzbl %al,%eax
  return (uchar)*p - (uchar)*q;
}
 158:	5d                   	pop    %ebp
 159:	29 d0                	sub    %edx,%eax
 15b:	c3                   	ret    
 15c:	8d 74 26 00          	lea    0x0(%esi),%esi

00000160 <strlen>:

uint
strlen(char *s)
{
 160:	55                   	push   %ebp
  int n;

  for(n = 0; s[n]; n++)
 161:	31 c0                	xor    %eax,%eax
 163:	89 e5                	mov    %esp,%ebp
 165:	8b 55 08             	mov    0x8(%ebp),%edx
 168:	80 3a 00             	cmpb   $0x0,(%edx)
 16b:	74 0a                	je     177 <strlen+0x17>
 16d:	8d 76 00             	lea    0x0(%esi),%esi
 170:	40                   	inc    %eax
 171:	80 3c 10 00          	cmpb   $0x0,(%eax,%edx,1)
 175:	75 f9                	jne    170 <strlen+0x10>
    ;
  return n;
}
 177:	5d                   	pop    %ebp
 178:	c3                   	ret    
 179:	8d b4 26 00 00 00 00 	lea    0x0(%esi),%esi

00000180 <memset>:

void*
memset(void *dst, int c, uint n)
{
 180:	55                   	push   %ebp
 181:	89 e5                	mov    %esp,%ebp
 183:	8b 45 10             	mov    0x10(%ebp),%eax
 186:	53                   	push   %ebx
 187:	8b 5d 08             	mov    0x8(%ebp),%ebx
  char *d;
  
  d = dst;
  while(n-- > 0)
 18a:	85 c0                	test   %eax,%eax
 18c:	74 1a                	je     1a8 <memset+0x28>
 18e:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
 192:	31 d2                	xor    %edx,%edx
 194:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 19a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi
    *d++ = c;
 1a0:	88 0c 1a             	mov    %cl,(%edx,%ebx,1)
 1a3:	42                   	inc    %edx
 1a4:	39 d0                	cmp    %edx,%eax
 1a6:	75 f8                	jne    1a0 <memset+0x20>
  return dst;
}
 1a8:	89 d8                	mov    %ebx,%eax
 1aa:	5b                   	pop    %ebx
 1ab:	5d                   	pop    %ebp
 1ac:	c3                   	ret    
 1ad:	8d 76 00             	lea    0x0(%esi),%esi

000001b0 <strchr>:

char*
strchr(const char *s, char c)
{
 1b0:	55                   	push   %ebp
 1b1:	89 e5                	mov    %esp,%ebp
 1b3:	8b 45 08             	mov    0x8(%ebp),%eax
 1b6:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  for(; *s; s++)
 1ba:	0f b6 10             	movzbl (%eax),%edx
 1bd:	84 d2                	test   %dl,%dl
 1bf:	74 19                	je     1da <strchr+0x2a>
    if(*s == c)
 1c1:	38 d1                	cmp    %dl,%cl
 1c3:	75 0d                	jne    1d2 <strchr+0x22>
 1c5:	eb 15                	jmp    1dc <strchr+0x2c>
 1c7:	38 ca                	cmp    %cl,%dl
 1c9:	8d b4 26 00 00 00 00 	lea    0x0(%esi),%esi
 1d0:	74 0a                	je     1dc <strchr+0x2c>
 1d2:	40                   	inc    %eax
 1d3:	0f b6 10             	movzbl (%eax),%edx
 1d6:	84 d2                	test   %dl,%dl
 1d8:	75 ed                	jne    1c7 <strchr+0x17>
 1da:	31 c0                	xor    %eax,%eax
      return (char*) s;
  return 0;
}
 1dc:	5d                   	pop    %ebp
 1dd:	c3                   	ret    
 1de:	89 f6                	mov    %esi,%esi

000001e0 <atoi>:

char*
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
      break;
  }
  buf[i] = '\0';
  return buf;
}

int
stat(char *n, struct stat *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
  close(fd);
  return r;
}

int
atoi(const char *s)
{
 1e0:	55                   	push   %ebp
 1e1:	89 e5                	mov    %esp,%ebp
 1e3:	8b 4d 08             	mov    0x8(%ebp),%ecx
 1e6:	53                   	push   %ebx
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 1e7:	31 db                	xor    %ebx,%ebx
 1e9:	0f b6 11             	movzbl (%ecx),%edx
 1ec:	88 d0                	mov    %dl,%al
 1ee:	2c 30                	sub    $0x30,%al
 1f0:	3c 09                	cmp    $0x9,%al
 1f2:	77 23                	ja     217 <atoi+0x37>
 1f4:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 1fa:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi
    n = n*10 + *s++ - '0';
 200:	8d 04 9b             	lea    (%ebx,%ebx,4),%eax
 203:	0f be d2             	movsbl %dl,%edx
 206:	8d 5c 42 d0          	lea    0xffffffd0(%edx,%eax,2),%ebx
 20a:	0f b6 51 01          	movzbl 0x1(%ecx),%edx
 20e:	41                   	inc    %ecx
 20f:	88 d0                	mov    %dl,%al
 211:	2c 30                	sub    $0x30,%al
 213:	3c 09                	cmp    $0x9,%al
 215:	76 e9                	jbe    200 <atoi+0x20>
  return n;
}
 217:	89 d8                	mov    %ebx,%eax
 219:	5b                   	pop    %ebx
 21a:	5d                   	pop    %ebp
 21b:	c3                   	ret    
 21c:	8d 74 26 00          	lea    0x0(%esi),%esi

00000220 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
 220:	55                   	push   %ebp
 221:	89 e5                	mov    %esp,%ebp
 223:	8b 4d 10             	mov    0x10(%ebp),%ecx
 226:	56                   	push   %esi
 227:	8b 75 08             	mov    0x8(%ebp),%esi
 22a:	53                   	push   %ebx
 22b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 22e:	85 c9                	test   %ecx,%ecx
 230:	7e 1a                	jle    24c <memmove+0x2c>
 232:	31 d2                	xor    %edx,%edx
 234:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 23a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi
    *dst++ = *src++;
 240:	0f b6 04 1a          	movzbl (%edx,%ebx,1),%eax
 244:	88 04 32             	mov    %al,(%edx,%esi,1)
 247:	42                   	inc    %edx
 248:	39 ca                	cmp    %ecx,%edx
 24a:	75 f4                	jne    240 <memmove+0x20>
  return vdst;
}
 24c:	5b                   	pop    %ebx
 24d:	89 f0                	mov    %esi,%eax
 24f:	5e                   	pop    %esi
 250:	5d                   	pop    %ebp
 251:	c3                   	ret    
 252:	8d b4 26 00 00 00 00 	lea    0x0(%esi),%esi
 259:	8d bc 27 00 00 00 00 	lea    0x0(%edi),%edi

00000260 <stat>:
 260:	55                   	push   %ebp
 261:	31 c0                	xor    %eax,%eax
 263:	89 e5                	mov    %esp,%ebp
 265:	83 ec 18             	sub    $0x18,%esp
 268:	89 44 24 04          	mov    %eax,0x4(%esp)
 26c:	8b 45 08             	mov    0x8(%ebp),%eax
 26f:	89 5d f8             	mov    %ebx,0xfffffff8(%ebp)
 272:	89 75 fc             	mov    %esi,0xfffffffc(%ebp)
 275:	be ff ff ff ff       	mov    $0xffffffff,%esi
 27a:	89 04 24             	mov    %eax,(%esp)
 27d:	e8 ea 00 00 00       	call   36c <open>
 282:	85 c0                	test   %eax,%eax
 284:	89 c3                	mov    %eax,%ebx
 286:	78 19                	js     2a1 <stat+0x41>
 288:	8b 45 0c             	mov    0xc(%ebp),%eax
 28b:	89 1c 24             	mov    %ebx,(%esp)
 28e:	89 44 24 04          	mov    %eax,0x4(%esp)
 292:	e8 ed 00 00 00       	call   384 <fstat>
 297:	89 1c 24             	mov    %ebx,(%esp)
 29a:	89 c6                	mov    %eax,%esi
 29c:	e8 b3 00 00 00       	call   354 <close>
 2a1:	89 f0                	mov    %esi,%eax
 2a3:	8b 5d f8             	mov    0xfffffff8(%ebp),%ebx
 2a6:	8b 75 fc             	mov    0xfffffffc(%ebp),%esi
 2a9:	89 ec                	mov    %ebp,%esp
 2ab:	5d                   	pop    %ebp
 2ac:	c3                   	ret    
 2ad:	8d 76 00             	lea    0x0(%esi),%esi

000002b0 <gets>:
 2b0:	55                   	push   %ebp
 2b1:	89 e5                	mov    %esp,%ebp
 2b3:	57                   	push   %edi
 2b4:	56                   	push   %esi
 2b5:	31 f6                	xor    %esi,%esi
 2b7:	53                   	push   %ebx
 2b8:	83 ec 1c             	sub    $0x1c,%esp
 2bb:	8d 5e 01             	lea    0x1(%esi),%ebx
 2be:	8b 7d 08             	mov    0x8(%ebp),%edi
 2c1:	3b 5d 0c             	cmp    0xc(%ebp),%ebx
 2c4:	7d 3e                	jge    304 <gets+0x54>
 2c6:	ba 01 00 00 00       	mov    $0x1,%edx
 2cb:	8d 45 f3             	lea    0xfffffff3(%ebp),%eax
 2ce:	89 54 24 08          	mov    %edx,0x8(%esp)
 2d2:	89 44 24 04          	mov    %eax,0x4(%esp)
 2d6:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 2dd:	e8 62 00 00 00       	call   344 <read>
 2e2:	85 c0                	test   %eax,%eax
 2e4:	7e 1e                	jle    304 <gets+0x54>
 2e6:	0f b6 45 f3          	movzbl 0xfffffff3(%ebp),%eax
 2ea:	88 44 3b ff          	mov    %al,0xffffffff(%ebx,%edi,1)
 2ee:	0f b6 45 f3          	movzbl 0xfffffff3(%ebp),%eax
 2f2:	3c 0a                	cmp    $0xa,%al
 2f4:	74 1c                	je     312 <gets+0x62>
 2f6:	3c 0d                	cmp    $0xd,%al
 2f8:	74 18                	je     312 <gets+0x62>
 2fa:	89 de                	mov    %ebx,%esi
 2fc:	8d 5e 01             	lea    0x1(%esi),%ebx
 2ff:	3b 5d 0c             	cmp    0xc(%ebp),%ebx
 302:	7c c2                	jl     2c6 <gets+0x16>
 304:	c6 04 3e 00          	movb   $0x0,(%esi,%edi,1)
 308:	83 c4 1c             	add    $0x1c,%esp
 30b:	89 f8                	mov    %edi,%eax
 30d:	5b                   	pop    %ebx
 30e:	5e                   	pop    %esi
 30f:	5f                   	pop    %edi
 310:	5d                   	pop    %ebp
 311:	c3                   	ret    
 312:	89 de                	mov    %ebx,%esi
 314:	89 f8                	mov    %edi,%eax
 316:	c6 04 3e 00          	movb   $0x0,(%esi,%edi,1)
 31a:	83 c4 1c             	add    $0x1c,%esp
 31d:	5b                   	pop    %ebx
 31e:	5e                   	pop    %esi
 31f:	5f                   	pop    %edi
 320:	5d                   	pop    %ebp
 321:	c3                   	ret    
 322:	90                   	nop    
 323:	90                   	nop    

00000324 <fork>:
 324:	b8 01 00 00 00       	mov    $0x1,%eax
 329:	cd 30                	int    $0x30
 32b:	c3                   	ret    

0000032c <exit>:
 32c:	b8 02 00 00 00       	mov    $0x2,%eax
 331:	cd 30                	int    $0x30
 333:	c3                   	ret    

00000334 <wait>:
 334:	b8 03 00 00 00       	mov    $0x3,%eax
 339:	cd 30                	int    $0x30
 33b:	c3                   	ret    

0000033c <pipe>:
 33c:	b8 04 00 00 00       	mov    $0x4,%eax
 341:	cd 30                	int    $0x30
 343:	c3                   	ret    

00000344 <read>:
 344:	b8 06 00 00 00       	mov    $0x6,%eax
 349:	cd 30                	int    $0x30
 34b:	c3                   	ret    

0000034c <write>:
 34c:	b8 05 00 00 00       	mov    $0x5,%eax
 351:	cd 30                	int    $0x30
 353:	c3                   	ret    

00000354 <close>:
 354:	b8 07 00 00 00       	mov    $0x7,%eax
 359:	cd 30                	int    $0x30
 35b:	c3                   	ret    

0000035c <kill>:
 35c:	b8 08 00 00 00       	mov    $0x8,%eax
 361:	cd 30                	int    $0x30
 363:	c3                   	ret    

00000364 <exec>:
 364:	b8 09 00 00 00       	mov    $0x9,%eax
 369:	cd 30                	int    $0x30
 36b:	c3                   	ret    

0000036c <open>:
 36c:	b8 0a 00 00 00       	mov    $0xa,%eax
 371:	cd 30                	int    $0x30
 373:	c3                   	ret    

00000374 <mknod>:
 374:	b8 0b 00 00 00       	mov    $0xb,%eax
 379:	cd 30                	int    $0x30
 37b:	c3                   	ret    

0000037c <unlink>:
 37c:	b8 0c 00 00 00       	mov    $0xc,%eax
 381:	cd 30                	int    $0x30
 383:	c3                   	ret    

00000384 <fstat>:
 384:	b8 0d 00 00 00       	mov    $0xd,%eax
 389:	cd 30                	int    $0x30
 38b:	c3                   	ret    

0000038c <link>:
 38c:	b8 0e 00 00 00       	mov    $0xe,%eax
 391:	cd 30                	int    $0x30
 393:	c3                   	ret    

00000394 <mkdir>:
 394:	b8 0f 00 00 00       	mov    $0xf,%eax
 399:	cd 30                	int    $0x30
 39b:	c3                   	ret    

0000039c <chdir>:
 39c:	b8 10 00 00 00       	mov    $0x10,%eax
 3a1:	cd 30                	int    $0x30
 3a3:	c3                   	ret    

000003a4 <dup>:
 3a4:	b8 11 00 00 00       	mov    $0x11,%eax
 3a9:	cd 30                	int    $0x30
 3ab:	c3                   	ret    

000003ac <getpid>:
 3ac:	b8 12 00 00 00       	mov    $0x12,%eax
 3b1:	cd 30                	int    $0x30
 3b3:	c3                   	ret    

000003b4 <sbrk>:
 3b4:	b8 13 00 00 00       	mov    $0x13,%eax
 3b9:	cd 30                	int    $0x30
 3bb:	c3                   	ret    

000003bc <sleep>:
 3bc:	b8 14 00 00 00       	mov    $0x14,%eax
 3c1:	cd 30                	int    $0x30
 3c3:	c3                   	ret    
 3c4:	90                   	nop    
 3c5:	90                   	nop    
 3c6:	90                   	nop    
 3c7:	90                   	nop    
 3c8:	90                   	nop    
 3c9:	90                   	nop    
 3ca:	90                   	nop    
 3cb:	90                   	nop    
 3cc:	90                   	nop    
 3cd:	90                   	nop    
 3ce:	90                   	nop    
 3cf:	90                   	nop    

000003d0 <putc>:
#include "user.h"

static void
putc(int fd, char c)
{
 3d0:	55                   	push   %ebp
 3d1:	89 e5                	mov    %esp,%ebp
 3d3:	83 ec 18             	sub    $0x18,%esp
 3d6:	88 55 fc             	mov    %dl,0xfffffffc(%ebp)
  write(fd, &c, 1);
 3d9:	ba 01 00 00 00       	mov    $0x1,%edx
 3de:	89 54 24 08          	mov    %edx,0x8(%esp)
 3e2:	8d 55 fc             	lea    0xfffffffc(%ebp),%edx
 3e5:	89 54 24 04          	mov    %edx,0x4(%esp)
 3e9:	89 04 24             	mov    %eax,(%esp)
 3ec:	e8 5b ff ff ff       	call   34c <write>
}
 3f1:	c9                   	leave  
 3f2:	c3                   	ret    
 3f3:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 3f9:	8d bc 27 00 00 00 00 	lea    0x0(%edi),%edi

00000400 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 400:	55                   	push   %ebp
 401:	89 e5                	mov    %esp,%ebp
 403:	57                   	push   %edi
 404:	56                   	push   %esi
 405:	89 ce                	mov    %ecx,%esi
 407:	53                   	push   %ebx
 408:	83 ec 1c             	sub    $0x1c,%esp
  static char digits[] = "0123456789ABCDEF";
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 40b:	8b 5d 08             	mov    0x8(%ebp),%ebx
 40e:	89 45 dc             	mov    %eax,0xffffffdc(%ebp)
 411:	85 db                	test   %ebx,%ebx
 413:	74 04                	je     419 <printint+0x19>
 415:	85 d2                	test   %edx,%edx
 417:	78 62                	js     47b <printint+0x7b>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 419:	89 d0                	mov    %edx,%eax
 41b:	c7 45 e0 00 00 00 00 	movl   $0x0,0xffffffe0(%ebp)
 422:	31 db                	xor    %ebx,%ebx
 424:	8d 7d e4             	lea    0xffffffe4(%ebp),%edi
 427:	89 f6                	mov    %esi,%esi
 429:	8d bc 27 00 00 00 00 	lea    0x0(%edi),%edi
  }

  i = 0;
  do{
    buf[i++] = digits[x % base];
 430:	31 d2                	xor    %edx,%edx
 432:	f7 f6                	div    %esi
 434:	89 c1                	mov    %eax,%ecx
 436:	0f b6 82 a7 07 00 00 	movzbl 0x7a7(%edx),%eax
 43d:	88 04 3b             	mov    %al,(%ebx,%edi,1)
 440:	43                   	inc    %ebx
  }while((x /= base) != 0);
 441:	85 c9                	test   %ecx,%ecx
 443:	89 c8                	mov    %ecx,%eax
 445:	75 e9                	jne    430 <printint+0x30>
  if(neg)
 447:	8b 4d e0             	mov    0xffffffe0(%ebp),%ecx
 44a:	85 c9                	test   %ecx,%ecx
 44c:	74 06                	je     454 <printint+0x54>
    buf[i++] = '-';
 44e:	c6 44 1d e4 2d       	movb   $0x2d,0xffffffe4(%ebp,%ebx,1)
 453:	43                   	inc    %ebx

  while(--i >= 0)
 454:	4b                   	dec    %ebx
 455:	78 1c                	js     473 <printint+0x73>
 457:	89 f6                	mov    %esi,%esi
 459:	8d bc 27 00 00 00 00 	lea    0x0(%edi),%edi
    putc(fd, buf[i]);
 460:	0f be 54 1d e4       	movsbl 0xffffffe4(%ebp,%ebx,1),%edx
 465:	4b                   	dec    %ebx
 466:	8b 45 dc             	mov    0xffffffdc(%ebp),%eax
 469:	e8 62 ff ff ff       	call   3d0 <putc>
 46e:	83 fb ff             	cmp    $0xffffffff,%ebx
 471:	75 ed                	jne    460 <printint+0x60>
}
 473:	83 c4 1c             	add    $0x1c,%esp
 476:	5b                   	pop    %ebx
 477:	5e                   	pop    %esi
 478:	5f                   	pop    %edi
 479:	5d                   	pop    %ebp
 47a:	c3                   	ret    
 47b:	89 d0                	mov    %edx,%eax
 47d:	f7 d8                	neg    %eax
 47f:	c7 45 e0 01 00 00 00 	movl   $0x1,0xffffffe0(%ebp)
 486:	eb 9a                	jmp    422 <printint+0x22>
 488:	90                   	nop    
 489:	8d b4 26 00 00 00 00 	lea    0x0(%esi),%esi

00000490 <printf>:

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 490:	55                   	push   %ebp
 491:	89 e5                	mov    %esp,%ebp
 493:	57                   	push   %edi
 494:	56                   	push   %esi
 495:	53                   	push   %ebx
 496:	83 ec 0c             	sub    $0xc,%esp
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 499:	8b 55 0c             	mov    0xc(%ebp),%edx
 49c:	0f b6 02             	movzbl (%edx),%eax
 49f:	84 c0                	test   %al,%al
 4a1:	0f 84 99 00 00 00    	je     540 <printf+0xb0>
 4a7:	8d 4d 10             	lea    0x10(%ebp),%ecx
 4aa:	31 ff                	xor    %edi,%edi
 4ac:	31 f6                	xor    %esi,%esi
 4ae:	89 4d f0             	mov    %ecx,0xfffffff0(%ebp)
 4b1:	eb 26                	jmp    4d9 <printf+0x49>
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
 4b3:	83 fb 25             	cmp    $0x25,%ebx
 4b6:	0f 85 8c 00 00 00    	jne    548 <printf+0xb8>
 4bc:	be 25 00 00 00       	mov    $0x25,%esi
 4c1:	eb 0d                	jmp    4d0 <printf+0x40>
 4c3:	90                   	nop    
 4c4:	90                   	nop    
 4c5:	90                   	nop    
 4c6:	90                   	nop    
 4c7:	90                   	nop    
 4c8:	90                   	nop    
 4c9:	90                   	nop    
 4ca:	90                   	nop    
 4cb:	90                   	nop    
 4cc:	90                   	nop    
 4cd:	90                   	nop    
 4ce:	90                   	nop    
 4cf:	90                   	nop    
 4d0:	47                   	inc    %edi
 4d1:	0f b6 04 3a          	movzbl (%edx,%edi,1),%eax
 4d5:	84 c0                	test   %al,%al
 4d7:	74 67                	je     540 <printf+0xb0>
 4d9:	85 f6                	test   %esi,%esi
 4db:	0f b6 d8             	movzbl %al,%ebx
 4de:	74 d3                	je     4b3 <printf+0x23>
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 4e0:	83 fe 25             	cmp    $0x25,%esi
 4e3:	75 eb                	jne    4d0 <printf+0x40>
      if(c == 'd'){
 4e5:	83 fb 64             	cmp    $0x64,%ebx
 4e8:	0f 84 e0 00 00 00    	je     5ce <printf+0x13e>
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
 4ee:	83 fb 78             	cmp    $0x78,%ebx
 4f1:	74 68                	je     55b <printf+0xcb>
 4f3:	83 fb 70             	cmp    $0x70,%ebx
 4f6:	74 63                	je     55b <printf+0xcb>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
 4f8:	83 fb 73             	cmp    $0x73,%ebx
 4fb:	90                   	nop    
 4fc:	8d 74 26 00          	lea    0x0(%esi),%esi
 500:	0f 84 7c 00 00 00    	je     582 <printf+0xf2>
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 506:	83 fb 63             	cmp    $0x63,%ebx
 509:	0f 84 e4 00 00 00    	je     5f3 <printf+0x163>
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 50f:	83 fb 25             	cmp    $0x25,%ebx
 512:	0f 84 c4 00 00 00    	je     5dc <printf+0x14c>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 518:	8b 45 08             	mov    0x8(%ebp),%eax
 51b:	ba 25 00 00 00       	mov    $0x25,%edx
 520:	47                   	inc    %edi
        putc(fd, c);
 521:	31 f6                	xor    %esi,%esi
 523:	e8 a8 fe ff ff       	call   3d0 <putc>
 528:	8b 45 08             	mov    0x8(%ebp),%eax
 52b:	0f be d3             	movsbl %bl,%edx
 52e:	e8 9d fe ff ff       	call   3d0 <putc>
 533:	8b 55 0c             	mov    0xc(%ebp),%edx
 536:	0f b6 04 3a          	movzbl (%edx,%edi,1),%eax
 53a:	84 c0                	test   %al,%al
 53c:	75 9b                	jne    4d9 <printf+0x49>
 53e:	89 f6                	mov    %esi,%esi
      }
      state = 0;
    }
  }
}
 540:	83 c4 0c             	add    $0xc,%esp
 543:	5b                   	pop    %ebx
 544:	5e                   	pop    %esi
 545:	5f                   	pop    %edi
 546:	5d                   	pop    %ebp
 547:	c3                   	ret    
 548:	8b 45 08             	mov    0x8(%ebp),%eax
 54b:	0f be d3             	movsbl %bl,%edx
 54e:	e8 7d fe ff ff       	call   3d0 <putc>
 553:	8b 55 0c             	mov    0xc(%ebp),%edx
 556:	e9 75 ff ff ff       	jmp    4d0 <printf+0x40>
 55b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 562:	b9 10 00 00 00       	mov    $0x10,%ecx
 567:	8b 45 f0             	mov    0xfffffff0(%ebp),%eax
 56a:	31 f6                	xor    %esi,%esi
 56c:	8b 10                	mov    (%eax),%edx
 56e:	8b 45 08             	mov    0x8(%ebp),%eax
 571:	e8 8a fe ff ff       	call   400 <printint>
 576:	8b 55 0c             	mov    0xc(%ebp),%edx
 579:	83 45 f0 04          	addl   $0x4,0xfffffff0(%ebp)
 57d:	e9 4e ff ff ff       	jmp    4d0 <printf+0x40>
 582:	8b 4d f0             	mov    0xfffffff0(%ebp),%ecx
 585:	8b 01                	mov    (%ecx),%eax
 587:	83 c1 04             	add    $0x4,%ecx
 58a:	89 4d f0             	mov    %ecx,0xfffffff0(%ebp)
 58d:	b9 a0 07 00 00       	mov    $0x7a0,%ecx
 592:	85 c0                	test   %eax,%eax
 594:	74 02                	je     598 <printf+0x108>
 596:	89 c1                	mov    %eax,%ecx
 598:	0f b6 01             	movzbl (%ecx),%eax
 59b:	84 c0                	test   %al,%al
 59d:	74 28                	je     5c7 <printf+0x137>
 59f:	89 cb                	mov    %ecx,%ebx
 5a1:	eb 0d                	jmp    5b0 <printf+0x120>
 5a3:	90                   	nop    
 5a4:	90                   	nop    
 5a5:	90                   	nop    
 5a6:	90                   	nop    
 5a7:	90                   	nop    
 5a8:	90                   	nop    
 5a9:	90                   	nop    
 5aa:	90                   	nop    
 5ab:	90                   	nop    
 5ac:	90                   	nop    
 5ad:	90                   	nop    
 5ae:	90                   	nop    
 5af:	90                   	nop    
 5b0:	0f be d0             	movsbl %al,%edx
 5b3:	8b 45 08             	mov    0x8(%ebp),%eax
 5b6:	e8 15 fe ff ff       	call   3d0 <putc>
 5bb:	0f b6 43 01          	movzbl 0x1(%ebx),%eax
 5bf:	43                   	inc    %ebx
 5c0:	84 c0                	test   %al,%al
 5c2:	75 ec                	jne    5b0 <printf+0x120>
 5c4:	8b 55 0c             	mov    0xc(%ebp),%edx
 5c7:	31 f6                	xor    %esi,%esi
 5c9:	e9 02 ff ff ff       	jmp    4d0 <printf+0x40>
 5ce:	b9 0a 00 00 00       	mov    $0xa,%ecx
 5d3:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 5da:	eb 8b                	jmp    567 <printf+0xd7>
 5dc:	8b 45 08             	mov    0x8(%ebp),%eax
 5df:	ba 25 00 00 00       	mov    $0x25,%edx
 5e4:	31 f6                	xor    %esi,%esi
 5e6:	e8 e5 fd ff ff       	call   3d0 <putc>
 5eb:	8b 55 0c             	mov    0xc(%ebp),%edx
 5ee:	e9 dd fe ff ff       	jmp    4d0 <printf+0x40>
 5f3:	8b 45 f0             	mov    0xfffffff0(%ebp),%eax
 5f6:	31 f6                	xor    %esi,%esi
 5f8:	0f be 10             	movsbl (%eax),%edx
 5fb:	8b 45 08             	mov    0x8(%ebp),%eax
 5fe:	e8 cd fd ff ff       	call   3d0 <putc>
 603:	8b 55 0c             	mov    0xc(%ebp),%edx
 606:	83 45 f0 04          	addl   $0x4,0xfffffff0(%ebp)
 60a:	e9 c1 fe ff ff       	jmp    4d0 <printf+0x40>
 60f:	90                   	nop    

00000610 <free>:
static Header *freep;

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

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 611:	8b 0d c8 07 00 00    	mov    0x7c8,%ecx
 617:	89 e5                	mov    %esp,%ebp
 619:	56                   	push   %esi
 61a:	53                   	push   %ebx
 61b:	8b 5d 08             	mov    0x8(%ebp),%ebx
 61e:	83 eb 08             	sub    $0x8,%ebx
 621:	eb 0d                	jmp    630 <free+0x20>
 623:	90                   	nop    
 624:	90                   	nop    
 625:	90                   	nop    
 626:	90                   	nop    
 627:	90                   	nop    
 628:	90                   	nop    
 629:	90                   	nop    
 62a:	90                   	nop    
 62b:	90                   	nop    
 62c:	90                   	nop    
 62d:	90                   	nop    
 62e:	90                   	nop    
 62f:	90                   	nop    
 630:	39 d9                	cmp    %ebx,%ecx
 632:	73 04                	jae    638 <free+0x28>
 634:	3b 19                	cmp    (%ecx),%ebx
 636:	72 12                	jb     64a <free+0x3a>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 638:	8b 11                	mov    (%ecx),%edx
 63a:	39 d1                	cmp    %edx,%ecx
 63c:	72 08                	jb     646 <free+0x36>
 63e:	39 d9                	cmp    %ebx,%ecx
 640:	72 0a                	jb     64c <free+0x3c>
 642:	39 d3                	cmp    %edx,%ebx
 644:	72 06                	jb     64c <free+0x3c>
 646:	89 d1                	mov    %edx,%ecx
 648:	eb e6                	jmp    630 <free+0x20>
 64a:	8b 11                	mov    (%ecx),%edx
      break;
  if(bp + bp->s.size == p->s.ptr){
 64c:	8b 73 04             	mov    0x4(%ebx),%esi
 64f:	8d 04 f3             	lea    (%ebx,%esi,8),%eax
 652:	39 d0                	cmp    %edx,%eax
 654:	74 2e                	je     684 <free+0x74>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
 656:	89 13                	mov    %edx,(%ebx)
  if(p + p->s.size == bp){
 658:	8b 51 04             	mov    0x4(%ecx),%edx
 65b:	8d 04 d1             	lea    (%ecx,%edx,8),%eax
 65e:	39 c3                	cmp    %eax,%ebx
 660:	74 0c                	je     66e <free+0x5e>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
 662:	89 19                	mov    %ebx,(%ecx)
  freep = p;
}
 664:	5b                   	pop    %ebx
 665:	89 0d c8 07 00 00    	mov    %ecx,0x7c8
 66b:	5e                   	pop    %esi
 66c:	5d                   	pop    %ebp
 66d:	c3                   	ret    
 66e:	8b 43 04             	mov    0x4(%ebx),%eax
 671:	01 c2                	add    %eax,%edx
 673:	8b 03                	mov    (%ebx),%eax
 675:	89 51 04             	mov    %edx,0x4(%ecx)
 678:	89 01                	mov    %eax,(%ecx)
 67a:	5b                   	pop    %ebx
 67b:	89 0d c8 07 00 00    	mov    %ecx,0x7c8
 681:	5e                   	pop    %esi
 682:	5d                   	pop    %ebp
 683:	c3                   	ret    
 684:	8b 42 04             	mov    0x4(%edx),%eax
 687:	01 c6                	add    %eax,%esi
 689:	8b 02                	mov    (%edx),%eax
 68b:	89 73 04             	mov    %esi,0x4(%ebx)
 68e:	89 03                	mov    %eax,(%ebx)
 690:	eb c6                	jmp    658 <free+0x48>
 692:	8d b4 26 00 00 00 00 	lea    0x0(%esi),%esi
 699:	8d bc 27 00 00 00 00 	lea    0x0(%edi),%edi

000006a0 <malloc>:

static Header*
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
    nu = PAGE;
  p = sbrk(nu * sizeof(Header));
  if(p == (char*) -1)
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
  free((void*)(hp + 1));
  return freep;
}

void*
malloc(uint nbytes)
{
 6a0:	55                   	push   %ebp
 6a1:	89 e5                	mov    %esp,%ebp
 6a3:	57                   	push   %edi
 6a4:	56                   	push   %esi
 6a5:	53                   	push   %ebx
 6a6:	83 ec 0c             	sub    $0xc,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 6a9:	8b 45 08             	mov    0x8(%ebp),%eax
  if((prevp = freep) == 0){
 6ac:	8b 15 c8 07 00 00    	mov    0x7c8,%edx
 6b2:	83 c0 07             	add    $0x7,%eax
 6b5:	c1 e8 03             	shr    $0x3,%eax
 6b8:	85 d2                	test   %edx,%edx
 6ba:	8d 58 01             	lea    0x1(%eax),%ebx
 6bd:	0f 84 92 00 00 00    	je     755 <malloc+0xb5>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 6c3:	8b 0a                	mov    (%edx),%ecx
    if(p->s.size >= nunits){
 6c5:	8b 41 04             	mov    0x4(%ecx),%eax
 6c8:	39 c3                	cmp    %eax,%ebx
 6ca:	76 63                	jbe    72f <malloc+0x8f>
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 6cc:	8d 3c dd 00 00 00 00 	lea    0x0(,%ebx,8),%edi
 6d3:	eb 09                	jmp    6de <malloc+0x3e>
 6d5:	8b 0a                	mov    (%edx),%ecx
 6d7:	8b 41 04             	mov    0x4(%ecx),%eax
 6da:	39 c3                	cmp    %eax,%ebx
 6dc:	76 51                	jbe    72f <malloc+0x8f>
    }
    if(p == freep)
 6de:	39 0d c8 07 00 00    	cmp    %ecx,0x7c8
 6e4:	89 ca                	mov    %ecx,%edx
 6e6:	75 ed                	jne    6d5 <malloc+0x35>
 6e8:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
 6ee:	77 39                	ja     729 <malloc+0x89>
 6f0:	be 00 10 00 00       	mov    $0x1000,%esi
 6f5:	b8 00 80 00 00       	mov    $0x8000,%eax
 6fa:	89 04 24             	mov    %eax,(%esp)
 6fd:	e8 b2 fc ff ff       	call   3b4 <sbrk>
 702:	83 f8 ff             	cmp    $0xffffffff,%eax
 705:	74 18                	je     71f <malloc+0x7f>
 707:	89 70 04             	mov    %esi,0x4(%eax)
 70a:	83 c0 08             	add    $0x8,%eax
 70d:	89 04 24             	mov    %eax,(%esp)
 710:	e8 fb fe ff ff       	call   610 <free>
 715:	8b 15 c8 07 00 00    	mov    0x7c8,%edx
      if((p = morecore(nunits)) == 0)
 71b:	85 d2                	test   %edx,%edx
 71d:	75 b6                	jne    6d5 <malloc+0x35>
        return 0;
  }
}
 71f:	83 c4 0c             	add    $0xc,%esp
 722:	31 c0                	xor    %eax,%eax
 724:	5b                   	pop    %ebx
 725:	5e                   	pop    %esi
 726:	5f                   	pop    %edi
 727:	5d                   	pop    %ebp
 728:	c3                   	ret    
 729:	89 de                	mov    %ebx,%esi
 72b:	89 f8                	mov    %edi,%eax
 72d:	eb cb                	jmp    6fa <malloc+0x5a>
 72f:	39 c3                	cmp    %eax,%ebx
 731:	74 1c                	je     74f <malloc+0xaf>
 733:	29 d8                	sub    %ebx,%eax
 735:	89 41 04             	mov    %eax,0x4(%ecx)
 738:	8d 0c c1             	lea    (%ecx,%eax,8),%ecx
 73b:	89 59 04             	mov    %ebx,0x4(%ecx)
 73e:	89 15 c8 07 00 00    	mov    %edx,0x7c8
 744:	83 c4 0c             	add    $0xc,%esp
 747:	5b                   	pop    %ebx
 748:	8d 41 08             	lea    0x8(%ecx),%eax
 74b:	5e                   	pop    %esi
 74c:	5f                   	pop    %edi
 74d:	5d                   	pop    %ebp
 74e:	c3                   	ret    
 74f:	8b 01                	mov    (%ecx),%eax
 751:	89 02                	mov    %eax,(%edx)
 753:	eb e9                	jmp    73e <malloc+0x9e>
 755:	b8 c0 07 00 00       	mov    $0x7c0,%eax
 75a:	ba c0 07 00 00       	mov    $0x7c0,%edx
 75f:	a3 c8 07 00 00       	mov    %eax,0x7c8
 764:	b8 c0 07 00 00       	mov    $0x7c0,%eax
 769:	a3 c0 07 00 00       	mov    %eax,0x7c0
 76e:	31 c0                	xor    %eax,%eax
 770:	a3 c4 07 00 00       	mov    %eax,0x7c4
 775:	e9 49 ff ff ff       	jmp    6c3 <malloc+0x23>
