int test_file(char *path, char *buffer, int size, int max_size) {
  int i, large, fd;
  if (size > max_size)
    return -1;
  large = (size > 20);
  if (large) {
    for (i = 0; i < size; i++)
      buffer[i] = i % 128;
    buffer[0] = 0x77;
    if (size / 2 > 1025)
      buffer[1025] = 0x99;
    if (size / 2 > 1024 * 256 + 21)
      buffer[1024 * 256 + 21] = 0x42;
  }
  if ((fd = my_creat(path)) < 0) {
    printf("error, unable to recreate %s, aborting\n", path);
    exit(1);
  }
  printf("successfully created file %s\n", path);
  if (my_write(fd, buffer, size) != size) {
    printf("error, unable to write %d bytes to %s, aborting\n", size, path);
    exit(1);
  }
  printf("successfully wrote %d bytes to file %s\n", size, path);
  if (my_close(fd) < 0) {
    printf("error, unable to close %s, aborting\n", path);
    exit(1);
  }
  printf("successfully closed file %s\n", path);
  if (large) {
    buffer[0] = 0;
    if (size / 2 > 1025)
      buffer[1025] = 1025 % 128;
    if (size / 2 > 1024 * 256 + 21)
      buffer[1024 * 256 + 21] = (1024 * 256 + 21) % 128;
  }
  if ((fd = my_open(path)) < 0) {
    printf("error, unable to reopen %s, aborting\n", path);
    exit(1);
  }
  printf("successfully reopened file %s\n", path);
  if (my_write(fd, buffer, size / 2) != size / 2) {
    printf("error, unable to rewrite part of %s, aborting\n", path);
    exit(1);
  }
  printf("successfully wrote initial %d bytes to file %s\n", size / 2, path);
  for (i = size / 2; i < size; i++)
    buffer[i] = 0;
  if (my_read(fd, buffer + size / 2, size - size / 2) != size - size / 2) {
    printf("error, read failed for %s, aborting\n", path);
    exit(1);
  }
  printf("successfully read final %d bytes from file %s\n", size - size / 2,
         path);
  if (my_close(fd) < 0) {
    printf("error, unable to close %s, aborting\n", path);
    exit(1);
  }
  printf("successfully closed file %s after reading\n", path);
  for (i = 0; i < size / 2; i++)
    buffer[i] = 0;
  if ((fd = my_open(path)) < 0) {
    printf("error, unable to re-reopen %s, aborting\n", path);
    exit(1);
  }
  printf("successfully re-reopened file %s\n", path);
  if (my_read(fd, buffer, size / 2) != size / 2) {
    printf("error, read failed for initial %d bytes of %s, aborting\n",
           size / 2, path);
    exit(1);
  }
  printf("successfully read initial %d bytes from file %s\n", size / 2, path);
  if (large) {
    for (i = 0; i < size; i++) {
      if (((buffer[i]) & 0xff) != ((i % 128) & 0xff)) {
        printf("error at index %d (of %d), value %d, expected %d\n", i, size,
               ((buffer[i]) & 0xff), ((i % 128) & 0xff));
        exit(1);
      }
    }
  } else {
    if (strcmp(buffer, "hello world") != 0) {
      printf("error, value written was 'hello world', value returned %s\n",
             buffer);
      exit(1);
    }
  }
  printf("test completed successfully on a file of size %d\n", size);
  return fd;
}


x86 assembly (clang, -O0):
<test_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    11ae <test_file+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1738 <test_file+0x5b8>
cmpl   $0x14,-0x1c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     124c <test_file+0xcc>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11fe <test_file+0x7e>
mov    -0x24(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ce <test_file+0x4e>
mov    -0x18(%rbp),%rax
movb   $0x77,(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x401,%eax
jle    1226 <test_file+0xa6>
mov    -0x18(%rbp),%rax
movb   $0x99,0x401(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x40015,%eax
jle    1247 <test_file+0xc7>
mov    -0x18(%rbp),%rax
movb   $0x42,0x40015(%rax)
jmp    124c <test_file+0xcc>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1080 <my_creat@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    127f <test_file+0xff>
mov    -0x10(%rbp),%rsi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    $0x0,%al
call   1090 <my_write@plt>
cmp    -0x1c(%rbp),%eax
je     12ca <test_file+0x14a>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    $0x0,%al
call   1050 <my_close@plt>
cmp    $0x0,%eax
jge    130e <test_file+0x18e>
mov    -0x10(%rbp),%rsi
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
je     1378 <test_file+0x1f8>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x401,%eax
jle    1352 <test_file+0x1d2>
mov    -0x18(%rbp),%rax
movb   $0x1,0x401(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x40015,%eax
jle    1373 <test_file+0x1f3>
mov    -0x18(%rbp),%rax
movb   $0x15,0x40015(%rax)
jmp    1378 <test_file+0x1f8>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <my_open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    13ab <test_file+0x22b>
mov    -0x10(%rbp),%rsi
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    $0x0,%al
call   1090 <my_write@plt>
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
je     140f <test_file+0x28f>
mov    -0x10(%rbp),%rsi
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1462 <test_file+0x2e2>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    143c <test_file+0x2bc>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
add    %rax,%rsi
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x38(%rbp),%edx
sub    %eax,%edx
mov    $0x0,%al
call   1030 <my_read@plt>
mov    %eax,-0x34(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x34(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
je     14d2 <test_file+0x352>
mov    -0x10(%rbp),%rsi
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%esi
mov    -0x10(%rbp),%rdx
lea    0xcbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    $0x0,%al
call   1050 <my_close@plt>
cmp    $0x0,%eax
jge    1523 <test_file+0x3a3>
mov    -0x10(%rbp),%rsi
lea    0xb8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    1574 <test_file+0x3f4>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    153c <test_file+0x3bc>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <my_open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    15a7 <test_file+0x427>
mov    -0x10(%rbp),%rsi
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xc7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    $0x0,%al
call   1030 <my_read@plt>
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
je     1618 <test_file+0x498>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
lea    0xc48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
lea    0xc58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
je     16e7 <test_file+0x567>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    16e2 <test_file+0x562>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    -0x44(%rbp),%eax
and    $0xff,%edx
cmp    %edx,%eax
je     16cf <test_file+0x54f>
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
and    $0xff,%ecx
mov    -0x24(%rbp),%eax
mov    $0x80,%edi
cltd
idiv   %edi
mov    %edx,%r8d
mov    -0x48(%rbp),%edx
and    $0xff,%r8d
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    16d4 <test_file+0x554>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1648 <test_file+0x4c8>
jmp    1721 <test_file+0x5a1>
mov    -0x18(%rbp),%rdi
lea    0xbf9(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     171c <test_file+0x59c>
mov    -0x18(%rbp),%rsi
lea    0xbec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1721 <test_file+0x5a1>
mov    -0x1c(%rbp),%esi
lea    0xc07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0xffffffff,%r13d
cmp    %ecx,%edx
jg     1553 <test_file+0x3c3>
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%r12d
cmp    $0x15,%edx
jl     1317 <test_file+0x187>
mov    %r12d,%eax
and    $0xfffffff0,%eax
lea    -0x10(%rax),%rdx
mov    %rdx,%rsi
shr    $0x4,%rsi
add    $0x1,%rsi
mov    %esi,%ecx
and    $0x3,%ecx
cmp    $0x30,%rdx
jae    11f0 <test_file+0x60>
movdqa 0xe17(%rip),%xmm0
xor    %edx,%edx
jmp    1281 <test_file+0xf1>
and    $0xfffffffffffffffc,%rsi
movdqa 0xe04(%rip),%xmm0
xor    %edx,%edx
movdqa 0xe0a(%rip),%xmm1
movdqa 0xe12(%rip),%xmm2
movdqa 0xe1a(%rip),%xmm3
movdqa 0xe22(%rip),%xmm4
movdqa 0xe2a(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
movdqa %xmm0,%xmm6
pand   %xmm1,%xmm6
movdqu %xmm6,(%rbx,%rdx,1)
movdqa %xmm0,%xmm6
paddb  %xmm2,%xmm6
pand   %xmm1,%xmm6
movdqu %xmm6,0x10(%rbx,%rdx,1)
movdqa %xmm0,%xmm6
paddb  %xmm3,%xmm6
pand   %xmm1,%xmm6
movdqu %xmm6,0x20(%rbx,%rdx,1)
movdqa %xmm0,%xmm6
paddb  %xmm4,%xmm6
pand   %xmm1,%xmm6
movdqu %xmm6,0x30(%rbx,%rdx,1)
add    $0x40,%rdx
paddb  %xmm5,%xmm0
add    $0xfffffffffffffffc,%rsi
jne    1230 <test_file+0xa0>
test   %rcx,%rcx
je     12ba <test_file+0x12a>
add    %rbx,%rdx
shl    $0x4,%rcx
xor    %esi,%esi
movdqa 0xd79(%rip),%xmm1
movdqa 0xd81(%rip),%xmm2
nop
movdqa %xmm0,%xmm3
pand   %xmm1,%xmm3
movdqu %xmm3,(%rdx,%rsi,1)
paddb  %xmm2,%xmm0
add    $0x10,%rsi
cmp    %rsi,%rcx
jne    12a0 <test_file+0x110>
cmp    %r12,%rax
je     12f4 <test_file+0x164>
mov    %r12d,%ecx
and    $0xf0,%ecx
lea    (%rbx,%rax,1),%rdx
mov    %r12,%rsi
sub    %rax,%rsi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rcx,%rax,1),%edi
and    $0x7f,%dil
mov    %dil,(%rdx,%rax,1)
add    $0x1,%rax
cmp    %rax,%rsi
jne    12e0 <test_file+0x150>
movb   $0x77,(%rbx)
cmp    $0x804,%r15d
jl     1317 <test_file+0x187>
movb   $0x99,0x401(%rbx)
cmp    $0x8002c,%r15d
jb     1317 <test_file+0x187>
movb   $0x42,0x40015(%rbx)
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <my_creat@plt>
test   %eax,%eax
js     1589 <test_file+0x3f9>
mov    %eax,%ebp
lea    0xd56(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   10a0 <my_write@plt>
cmp    %r15d,%eax
jne    1592 <test_file+0x402>
lea    0xd7c(%rip),%rdi
mov    %r15d,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <my_close@plt>
test   %eax,%eax
js     1580 <test_file+0x3f0>
lea    0xda4(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x15,%r15d
jl     13b3 <test_file+0x223>
movb   $0x0,(%rbx)
cmp    $0x804,%r15d
jb     13b3 <test_file+0x223>
movb   $0x1,0x401(%rbx)
cmp    $0x8002c,%r15d
jb     13b3 <test_file+0x223>
movb   $0x15,0x40015(%rbx)
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <my_open@plt>
test   %eax,%eax
js     159e <test_file+0x40e>
mov    %eax,%r13d
lea    0xd98(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%ebp
shr    $0x1f,%ebp
add    %r15d,%ebp
sar    %ebp
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <my_write@plt>
cmp    %ebp,%eax
jne    15a7 <test_file+0x417>
lea    0xdb3(%rip),%rdi
mov    %ebp,%esi
mov    %r14,0x10(%rsp)
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebp,%r14
cmp    %r15d,%ebp
jge    1431 <test_file+0x2a1>
lea    (%rbx,%r14,1),%rdi
mov    %ebp,%edx
not    %edx
add    %r15d,%edx
add    $0x1,%rdx
xor    %esi,%esi
call   1050 <memset@plt>
add    %rbx,%r14
mov    %r15d,0xc(%rsp)
sub    %ebp,%r15d
mov    %r13d,%edi
mov    %r14,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <my_read@plt>
cmp    %r15d,%eax
jne    15b0 <test_file+0x420>
lea    0xdae(%rip),%rdi
mov    %r15d,%esi
mov    0x10(%rsp),%r14
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <my_close@plt>
test   %eax,%eax
js     1580 <test_file+0x3f0>
lea    0xdb2(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%r15d
cmp    $0x2,%r15d
jl     14ad <test_file+0x31d>
lea    -0x1(%rbp),%edx
add    $0x1,%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <my_open@plt>
test   %eax,%eax
js     15be <test_file+0x42e>
mov    %eax,%r13d
lea    0xdc4(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <my_read@plt>
cmp    %ebp,%eax
jne    15d9 <test_file+0x449>
lea    0xdf7(%rip),%rdi
mov    %ebp,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x15,%r15d
jl     152b <test_file+0x39b>
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx,%rsi,1),%ecx
mov    %esi,%r8d
and    $0x7f,%r8d
cmp    %ecx,%r8d
jne    1565 <test_file+0x3d5>
add    $0x1,%rsi
cmp    %rsi,%r12
jne    1510 <test_file+0x380>
jmp    1542 <test_file+0x3b2>
lea    0xe19(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    15f6 <test_file+0x466>
lea    0xe49(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdad(%rip),%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xb78(%rip),%rdi
jmp    15c5 <test_file+0x435>
lea    0xad0(%rip),%rdi
jmp    15c5 <test_file+0x435>
lea    0xb0d(%rip),%rdi
mov    %r15d,%esi
jmp    15e2 <test_file+0x452>
lea    0xb9c(%rip),%rdi
jmp    15c5 <test_file+0x435>
lea    0xbd8(%rip),%rdi
jmp    15c5 <test_file+0x435>
lea    0xc2e(%rip),%rdi
mov    0x10(%rsp),%rsi
jmp    15c8 <test_file+0x438>
lea    0xc9f(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xccf(%rip),%rdi
mov    %ebp,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xd5a(%rip),%rdi
mov    %rbx,%rsi
jmp    15c8 <test_file+0x438>

LLVM IR (-O0):
@.str = [40 x i8] c"error, unable to recreate %s, aborting\0A\00"
@.str.1 = [30 x i8] c"successfully created file %s\0A\00"
@.str.2 = [49 x i8] c"error, unable to write %d bytes to %s, aborting\0A\00"
@.str.3 = [40 x i8] c"successfully wrote %d bytes to file %s\0A\00"
@.str.4 = [37 x i8] c"error, unable to close %s, aborting\0A\00"
@.str.5 = [29 x i8] c"successfully closed file %s\0A\00"
@.str.6 = [38 x i8] c"error, unable to reopen %s, aborting\0A\00"
@.str.7 = [31 x i8] c"successfully reopened file %s\0A\00"
@.str.8 = [47 x i8] c"error, unable to rewrite part of %s, aborting\0A\00"
@.str.9 = [48 x i8] c"successfully wrote initial %d bytes to file %s\0A\00"
@.str.10 = [37 x i8] c"error, read failed for %s, aborting\0A\00"
@.str.11 = [47 x i8] c"successfully read final %d bytes from file %s\0A\00"
@.str.12 = [43 x i8] c"successfully closed file %s after reading\0A\00"
@.str.13 = [41 x i8] c"error, unable to re-reopen %s, aborting\0A\00"
@.str.14 = [34 x i8] c"successfully re-reopened file %s\0A\00"
@.str.15 = [57 x i8] c"error, read failed for initial %d bytes of %s, aborting\0A\00"
@.str.16 = [49 x i8] c"successfully read initial %d bytes from file %s\0A\00"
@.str.17 = [50 x i8] c"error at index %d (of %d), value %d, expected %d\0A\00"
@.str.18 = [12 x i8] c"hello world\00"
@.str.19 = [59 x i8] c"error, value written was 'hello world', value returned %s\0A\00"
@.str.20 = [50 x i8] c"test completed successfully on a file of size %d\0A\00"
define i32 @test_file(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %4
store i32 -1, i32* %5
br label %275
17: ; preds = %4
%18 = load i32, i32* %8
%19 = icmp sgt i32 %18, 20
%20 = zext i1 %19 to i32
store i32 %20, i32* %11
%21 = load i32, i32* %11
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %56
23: ; preds = %17
store i32 0, i32* %10
br label %24
24: ; preds = %36, %23
%25 = load i32, i32* %10
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %39
28: ; preds = %24
%29 = load i32, i32* %10
%30 = srem i32 %29, 128
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %7
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %28
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %24
39: ; preds = %24
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i64 0
store i8 119, i8* %41
%42 = load i32, i32* %8
%43 = sdiv i32 %42, 2
%44 = icmp sgt i32 %43, 1025
br i1 %44, label %45, label %48
45: ; preds = %39
%46 = load i8*, i8** %7
%47 = getelementptr inbounds i8, i8* %46, i64 1025
store i8 -103, i8* %47
br label %48
48: ; preds = %45, %39
%49 = load i32, i32* %8
%50 = sdiv i32 %49, 2
%51 = icmp sgt i32 %50, 262165
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i8*, i8** %7
%54 = getelementptr inbounds i8, i8* %53, i64 262165
store i8 66, i8* %54
br label %55
55: ; preds = %52, %48
br label %56
56: ; preds = %55, %17
%57 = load i8*, i8** %6
%58 = call i32 (i8*, ...) bitcast (i32 (...)* @my_creat to i32 (i8*, ...)*)(i8* %57)
store i32 %58, i32* %12
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load i8*, i8** %6
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %61)
unreachable
63: ; preds = %56
%64 = load i8*, i8** %6
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %64)
%66 = load i32, i32* %12
%67 = load i8*, i8** %7
%68 = load i32, i32* %8
%69 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @my_write to i32 (i32, i8*, i32, ...)*)(i32 %66, i8* %67, i32 %68)
%70 = load i32, i32* %8
%71 = icmp ne i32 %69, %70
br i1 %71, label %72, label %76
72: ; preds = %63
%73 = load i32, i32* %8
%74 = load i8*, i8** %6
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %73, i8* %74)
unreachable
76: ; preds = %63
%77 = load i32, i32* %8
%78 = load i8*, i8** %6
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %77, i8* %78)
%80 = load i32, i32* %12
%81 = call i32 (i32, ...) bitcast (i32 (...)* @my_close to i32 (i32, ...)*)(i32 %80)
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %76
%84 = load i8*, i8** %6
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %84)
unreachable
86: ; preds = %76
%87 = load i8*, i8** %6
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %87)
%89 = load i32, i32* %11
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %108
91: ; preds = %86
%92 = load i8*, i8** %7
%93 = getelementptr inbounds i8, i8* %92, i64 0
store i8 0, i8* %93
%94 = load i32, i32* %8
%95 = sdiv i32 %94, 2
%96 = icmp sgt i32 %95, 1025
br i1 %96, label %97, label %100
97: ; preds = %91
%98 = load i8*, i8** %7
%99 = getelementptr inbounds i8, i8* %98, i64 1025
store i8 1, i8* %99
br label %100
100: ; preds = %97, %91
%101 = load i32, i32* %8
%102 = sdiv i32 %101, 2
%103 = icmp sgt i32 %102, 262165
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = load i8*, i8** %7
%106 = getelementptr inbounds i8, i8* %105, i64 262165
store i8 21, i8* %106
br label %107
107: ; preds = %104, %100
br label %108
108: ; preds = %107, %86
%109 = load i8*, i8** %6
%110 = call i32 (i8*, ...) bitcast (i32 (...)* @my_open to i32 (i8*, ...)*)(i8* %109)
store i32 %110, i32* %12
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %115
112: ; preds = %108
%113 = load i8*, i8** %6
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* %113)
unreachable
115: ; preds = %108
%116 = load i8*, i8** %6
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %116)
%118 = load i32, i32* %12
%119 = load i8*, i8** %7
%120 = load i32, i32* %8
%121 = sdiv i32 %120, 2
%122 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @my_write to i32 (i32, i8*, i32, ...)*)(i32 %118, i8* %119, i32 %121)
%123 = load i32, i32* %8
%124 = sdiv i32 %123, 2
%125 = icmp ne i32 %122, %124
br i1 %125, label %126, label %129
126: ; preds = %115
%127 = load i8*, i8** %6
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i8* %127)
unreachable
129: ; preds = %115
%130 = load i32, i32* %8
%131 = sdiv i32 %130, 2
%132 = load i8*, i8** %6
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i32 %131, i8* %132)
%134 = load i32, i32* %8
%135 = sdiv i32 %134, 2
store i32 %135, i32* %10
br label %136
136: ; preds = %145, %129
%137 = load i32, i32* %10
%138 = load i32, i32* %8
%139 = icmp slt i32 %137, %138
br i1 %139, label %140, label %148
140: ; preds = %136
%141 = load i8*, i8** %7
%142 = load i32, i32* %10
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds i8, i8* %141, i64 %143
store i8 0, i8* %144
br label %145
145: ; preds = %140
%146 = load i32, i32* %10
%147 = add nsw i32 %146, 1
store i32 %147, i32* %10
br label %136
148: ; preds = %136
%149 = load i32, i32* %12
%150 = load i8*, i8** %7
%151 = load i32, i32* %8
%152 = sdiv i32 %151, 2
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i8, i8* %150, i64 %153
%155 = load i32, i32* %8
%156 = load i32, i32* %8
%157 = sdiv i32 %156, 2
%158 = sub nsw i32 %155, %157
%159 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @my_read to i32 (i32, i8*, i32, ...)*)(i32 %149, i8* %154, i32 %158)
%160 = load i32, i32* %8
%161 = load i32, i32* %8
%162 = sdiv i32 %161, 2
%163 = sub nsw i32 %160, %162
%164 = icmp ne i32 %159, %163
br i1 %164, label %165, label %168
165: ; preds = %148
%166 = load i8*, i8** %6
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %166)
unreachable
168: ; preds = %148
%169 = load i32, i32* %8
%170 = load i32, i32* %8
%171 = sdiv i32 %170, 2
%172 = sub nsw i32 %169, %171
%173 = load i8*, i8** %6
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.11, i64 0, i64 0), i32 %172, i8* %173)
%175 = load i32, i32* %12
%176 = call i32 (i32, ...) bitcast (i32 (...)* @my_close to i32 (i32, ...)*)(i32 %175)
%177 = icmp slt i32 %176, 0
br i1 %177, label %178, label %181
178: ; preds = %168
%179 = load i8*, i8** %6
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %179)
unreachable
181: ; preds = %168
%182 = load i8*, i8** %6
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i8* %182)
store i32 0, i32* %10
br label %184
184: ; preds = %194, %181
%185 = load i32, i32* %10
%186 = load i32, i32* %8
%187 = sdiv i32 %186, 2
%188 = icmp slt i32 %185, %187
br i1 %188, label %189, label %197
189: ; preds = %184
%190 = load i8*, i8** %7
%191 = load i32, i32* %10
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds i8, i8* %190, i64 %192
store i8 0, i8* %193
br label %194
194: ; preds = %189
%195 = load i32, i32* %10
%196 = add nsw i32 %195, 1
store i32 %196, i32* %10
br label %184
197: ; preds = %184
%198 = load i8*, i8** %6
%199 = call i32 (i8*, ...) bitcast (i32 (...)* @my_open to i32 (i8*, ...)*)(i8* %198)
store i32 %199, i32* %12
%200 = icmp slt i32 %199, 0
br i1 %200, label %201, label %204
201: ; preds = %197
%202 = load i8*, i8** %6
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.13, i64 0, i64 0), i8* %202)
unreachable
204: ; preds = %197
%205 = load i8*, i8** %6
%206 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i8* %205)
%207 = load i32, i32* %12
%208 = load i8*, i8** %7
%209 = load i32, i32* %8
%210 = sdiv i32 %209, 2
%211 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @my_read to i32 (i32, i8*, i32, ...)*)(i32 %207, i8* %208, i32 %210)
%212 = load i32, i32* %8
%213 = sdiv i32 %212, 2
%214 = icmp ne i32 %211, %213
br i1 %214, label %215, label %220
215: ; preds = %204
%216 = load i32, i32* %8
%217 = sdiv i32 %216, 2
%218 = load i8*, i8** %6
%219 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.15, i64 0, i64 0), i32 %217, i8* %218)
unreachable
220: ; preds = %204
%221 = load i32, i32* %8
%222 = sdiv i32 %221, 2
%223 = load i8*, i8** %6
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.16, i64 0, i64 0), i32 %222, i8* %223)
%225 = load i32, i32* %11
%226 = icmp ne i32 %225, 0
br i1 %226, label %227, label %263
227: ; preds = %220
store i32 0, i32* %10
br label %228
228: ; preds = %259, %227
%229 = load i32, i32* %10
%230 = load i32, i32* %8
%231 = icmp slt i32 %229, %230
br i1 %231, label %232, label %262
232: ; preds = %228
%233 = load i8*, i8** %7
%234 = load i32, i32* %10
%235 = sext i32 %234 to i64
%236 = getelementptr inbounds i8, i8* %233, i64 %235
%237 = load i8, i8* %236
%238 = sext i8 %237 to i32
%239 = and i32 %238, 255
%240 = load i32, i32* %10
%241 = srem i32 %240, 128
%242 = and i32 %241, 255
%243 = icmp ne i32 %239, %242
br i1 %243, label %244, label %258
244: ; preds = %232
%245 = load i32, i32* %10
%246 = load i32, i32* %8
%247 = load i8*, i8** %7
%248 = load i32, i32* %10
%249 = sext i32 %248 to i64
%250 = getelementptr inbounds i8, i8* %247, i64 %249
%251 = load i8, i8* %250
%252 = sext i8 %251 to i32
%253 = and i32 %252, 255
%254 = load i32, i32* %10
%255 = srem i32 %254, 128
%256 = and i32 %255, 255
%257 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.17, i64 0, i64 0), i32 %245, i32 %246, i32 %253, i32 %256)
unreachable
258: ; preds = %232
br label %259
259: ; preds = %258
%260 = load i32, i32* %10
%261 = add nsw i32 %260, 1
store i32 %261, i32* %10
br label %228
262: ; preds = %228
br label %271
263: ; preds = %220
%264 = load i8*, i8** %7
%265 = call i32 @strcmp(i8* %264, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0))
%266 = icmp ne i32 %265, 0
br i1 %266, label %267, label %270
267: ; preds = %263
%268 = load i8*, i8** %7
%269 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.19, i64 0, i64 0), i8* %268)
unreachable
270: ; preds = %263
br label %271
271: ; preds = %270, %262
%272 = load i32, i32* %8
%273 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.20, i64 0, i64 0), i32 %272)
%274 = load i32, i32* %12
store i32 %274, i32* %5
br label %275
275: ; preds = %271, %16
%276 = load i32, i32* %5
ret i32 %276
}

LLVM IR (-O2):
@.str = [40 x i8] c"error, unable to recreate %s, aborting\0A\00"
@.str.1 = [30 x i8] c"successfully created file %s\0A\00"
@.str.2 = [49 x i8] c"error, unable to write %d bytes to %s, aborting\0A\00"
@.str.3 = [40 x i8] c"successfully wrote %d bytes to file %s\0A\00"
@.str.4 = [37 x i8] c"error, unable to close %s, aborting\0A\00"
@.str.5 = [29 x i8] c"successfully closed file %s\0A\00"
@.str.6 = [38 x i8] c"error, unable to reopen %s, aborting\0A\00"
@.str.7 = [31 x i8] c"successfully reopened file %s\0A\00"
@.str.8 = [47 x i8] c"error, unable to rewrite part of %s, aborting\0A\00"
@.str.9 = [48 x i8] c"successfully wrote initial %d bytes to file %s\0A\00"
@.str.10 = [37 x i8] c"error, read failed for %s, aborting\0A\00"
@.str.11 = [47 x i8] c"successfully read final %d bytes from file %s\0A\00"
@.str.12 = [43 x i8] c"successfully closed file %s after reading\0A\00"
@.str.13 = [41 x i8] c"error, unable to re-reopen %s, aborting\0A\00"
@.str.14 = [34 x i8] c"successfully re-reopened file %s\0A\00"
@.str.15 = [57 x i8] c"error, read failed for initial %d bytes of %s, aborting\0A\00"
@.str.16 = [49 x i8] c"successfully read initial %d bytes from file %s\0A\00"
@.str.17 = [50 x i8] c"error at index %d (of %d), value %d, expected %d\0A\00"
@.str.18 = [12 x i8] c"hello world\00"
@.str.19 = [59 x i8] c"error, value written was 'hello world', value returned %s\0A\00"
@.str.20 = [50 x i8] c"test completed successfully on a file of size %d\0A\00"
define i32 @test_file(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, %3
br i1 %5, label %180, label %6
6: ; preds = %4
%7 = icmp sgt i32 %2, 20
br i1 %7, label %8, label %75
8: ; preds = %6
%9 = zext i32 %2 to i64
%10 = and i64 %9, 4294967280
%11 = add nsw i64 %10, -16
%12 = lshr exact i64 %11, 4
%13 = add nuw nsw i64 %12, 1
%14 = and i64 %13, 3
%15 = icmp ult i64 %11, 48
br i1 %15, label %44, label %16
16: ; preds = %8
%17 = and i64 %13, 2305843009213693948
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %40, %18 ]
%20 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %16 ], [ %41, %18 ]
%21 = phi i64 [ 0, %16 ], [ %42, %18 ]
%22 = and <16 x i8> %20, <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>
%23 = getelementptr inbounds i8, i8* %1, i64 %19
%24 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> %22, <16 x i8>* %24
%25 = or i64 %19, 16
%26 = add <16 x i8> %20, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%27 = and <16 x i8> %26, <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>
%28 = getelementptr inbounds i8, i8* %1, i64 %25
%29 = bitcast i8* %28 to <16 x i8>*
store <16 x i8> %27, <16 x i8>* %29
%30 = or i64 %19, 32
%31 = add <16 x i8> %20, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%32 = and <16 x i8> %31, <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>
%33 = getelementptr inbounds i8, i8* %1, i64 %30
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> %32, <16 x i8>* %34
%35 = or i64 %19, 48
%36 = add <16 x i8> %20, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%37 = and <16 x i8> %36, <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>
%38 = getelementptr inbounds i8, i8* %1, i64 %35
%39 = bitcast i8* %38 to <16 x i8>*
store <16 x i8> %37, <16 x i8>* %39
%40 = add nuw i64 %19, 64
%41 = add <16 x i8> %20, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
%42 = add i64 %21, 4
%43 = icmp eq i64 %42, %17
br i1 %43, label %44, label %18
44: ; preds = %18, %8
%45 = phi i64 [ 0, %8 ], [ %40, %18 ]
%46 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %8 ], [ %41, %18 ]
%47 = icmp eq i64 %14, 0
br i1 %47, label %59, label %48
48: ; preds = %44, %48
%49 = phi i64 [ %55, %48 ], [ %45, %44 ]
%50 = phi <16 x i8> [ %56, %48 ], [ %46, %44 ]
%51 = phi i64 [ %57, %48 ], [ 0, %44 ]
%52 = and <16 x i8> %50, <i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127, i8 127>
%53 = getelementptr inbounds i8, i8* %1, i64 %49
%54 = bitcast i8* %53 to <16 x i8>*
store <16 x i8> %52, <16 x i8>* %54
%55 = add nuw i64 %49, 16
%56 = add <16 x i8> %50, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%57 = add i64 %51, 1
%58 = icmp eq i64 %57, %14
br i1 %58, label %59, label %48
59: ; preds = %48, %44
%60 = icmp eq i64 %10, %9
br i1 %60, label %68, label %61
61: ; preds = %59, %61
%62 = phi i64 [ %66, %61 ], [ %10, %59 ]
%63 = trunc i64 %62 to i8
%64 = and i8 %63, 127
%65 = getelementptr inbounds i8, i8* %1, i64 %62
store i8 %64, i8* %65
%66 = add nuw nsw i64 %62, 1
%67 = icmp eq i64 %66, %9
br i1 %67, label %68, label %61
68: ; preds = %61, %59
store i8 119, i8* %1
%69 = icmp sgt i32 %2, 2051
br i1 %69, label %70, label %75
70: ; preds = %68
%71 = getelementptr inbounds i8, i8* %1, i64 1025
store i8 -103, i8* %71
%72 = icmp ugt i32 %2, 524331
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = getelementptr inbounds i8, i8* %1, i64 262165
store i8 66, i8* %74
br label %75
75: ; preds = %68, %70, %73, %6
%76 = tail call i32 (i8*, ...) bitcast (i32 (...)* @my_creat to i32 (i8*, ...)*)(i8* %0)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
80: ; preds = %75
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%82 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @my_write to i32 (i32, i8*, i32, ...)*)(i32 %76, i8* %1, i32 %2)
%83 = icmp eq i32 %82, %2
br i1 %83, label %86, label %84
84: ; preds = %80
%85 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %2, i8* %0)
tail call void @exit(i32 1)
unreachable
86: ; preds = %80
%87 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %2, i8* %0)
%88 = tail call i32 (i32, ...) bitcast (i32 (...)* @my_close to i32 (i32, ...)*)(i32 %76)
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %86
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
92: ; preds = %86
%93 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br i1 %7, label %94, label %101
94: ; preds = %92
store i8 0, i8* %1
%95 = icmp ugt i32 %2, 2051
br i1 %95, label %96, label %101
96: ; preds = %94
%97 = getelementptr inbounds i8, i8* %1, i64 1025
store i8 1, i8* %97
%98 = icmp ugt i32 %2, 524331
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = getelementptr inbounds i8, i8* %1, i64 262165
store i8 21, i8* %100
br label %101
101: ; preds = %94, %96, %99, %92
%102 = tail call i32 (i8*, ...) bitcast (i32 (...)* @my_open to i32 (i8*, ...)*)(i8* %0)
%103 = icmp slt i32 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %101
%105 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
106: ; preds = %101
%107 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%108 = sdiv i32 %2, 2
%109 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @my_write to i32 (i32, i8*, i32, ...)*)(i32 %102, i8* %1, i32 %108)
%110 = icmp eq i32 %109, %108
br i1 %110, label %113, label %111
111: ; preds = %106
%112 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
113: ; preds = %106
%114 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i32 %108, i8* %0)
%115 = icmp slt i32 %108, %2
%116 = sext i32 %108 to i64
br i1 %115, label %117, label %123
117: ; preds = %113
%118 = getelementptr i8, i8* %1, i64 %116
%119 = xor i32 %108, -1
%120 = add i32 %119, %2
%121 = zext i32 %120 to i64
%122 = add nuw nsw i64 %121, 1
br label %123
123: ; preds = %113, %117
%124 = getelementptr inbounds i8, i8* %1, i64 %116
%125 = sub nsw i32 %2, %108
%126 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @my_read to i32 (i32, i8*, i32, ...)*)(i32 %102, i8* %124, i32 %125)
%127 = icmp eq i32 %126, %125
br i1 %127, label %130, label %128
128: ; preds = %123
%129 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
130: ; preds = %123
%131 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.11, i64 0, i64 0), i32 %125, i8* %0)
%132 = tail call i32 (i32, ...) bitcast (i32 (...)* @my_close to i32 (i32, ...)*)(i32 %102)
%133 = icmp slt i32 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %130
%135 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
136: ; preds = %130
%137 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i8* %0)
%138 = icmp sgt i32 %2, 1
br i1 %138, label %139, label %143
139: ; preds = %136
%140 = add nsw i32 %108, -1
%141 = zext i32 %140 to i64
%142 = add nuw nsw i64 %141, 1
br label %143
143: ; preds = %139, %136
%144 = tail call i32 (i8*, ...) bitcast (i32 (...)* @my_open to i32 (i8*, ...)*)(i8* %0)
%145 = icmp slt i32 %144, 0
br i1 %145, label %146, label %148
146: ; preds = %143
%147 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.13, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
148: ; preds = %143
%149 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i8* %0)
%150 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @my_read to i32 (i32, i8*, i32, ...)*)(i32 %144, i8* %1, i32 %108)
%151 = icmp eq i32 %150, %108
br i1 %151, label %154, label %152
152: ; preds = %148
%153 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.15, i64 0, i64 0), i32 %108, i8* %0)
tail call void @exit(i32 1)
unreachable
154: ; preds = %148
%155 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.16, i64 0, i64 0), i32 %108, i8* %0)
br i1 %7, label %156, label %173
156: ; preds = %154
%157 = zext i32 %2 to i64
br label %158
158: ; preds = %156, %170
%159 = phi i64 [ 0, %156 ], [ %171, %170 ]
%160 = getelementptr inbounds i8, i8* %1, i64 %159
%161 = load i8, i8* %160
%162 = zext i8 %161 to i32
%163 = trunc i64 %159 to i32
%164 = and i32 %163, 127
%165 = icmp eq i32 %164, %162
br i1 %165, label %170, label %166
166: ; preds = %158
%167 = zext i8 %161 to i32
%168 = trunc i64 %159 to i32
%169 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.17, i64 0, i64 0), i32 %168, i32 %2, i32 %167, i32 %164)
tail call void @exit(i32 1)
unreachable
170: ; preds = %158
%171 = add nuw nsw i64 %159, 1
%172 = icmp eq i64 %171, %157
br i1 %172, label %178, label %158
173: ; preds = %154
%174 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0))
%175 = icmp eq i32 %174, 0
br i1 %175, label %178, label %176
176: ; preds = %173
%177 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.19, i64 0, i64 0), i8* %1)
tail call void @exit(i32 1)
unreachable
178: ; preds = %170, %173
%179 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.20, i64 0, i64 0), i32 %2)
br label %180
180: ; preds = %4, %178
%181 = phi i32 [ %144, %178 ], [ -1, %4 ]
ret i32 %181
}