#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct stat {
  unsigned int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
scalar_t__ close(int);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ lseek(int, unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ memcmp(char *, char *, int);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
unsigned int write(int, char *, unsigned int);
int main(int argc, char **argv) {
  char buffer[1024], *q, *r;
  unsigned int i, j, k, start, end, offset;
  FILE *map;
  struct stat s;
  int image, tail;
  if (stat(argv[3], &s) < 0)
    die(argv[3]);
  map = fopen(argv[2], "r");
  if (!map)
    die(argv[2]);
  while (fgets(buffer, 1024, map)) {
    if (!strcmp(buffer + 11, "start\n"))
      start = strtoul(buffer, NULL, 16);
    else if (!strcmp(buffer + 11, "end\n"))
      end = strtoul(buffer, NULL, 16);
  }
  fclose(map);
  if ((image = open(argv[1], O_RDWR)) < 0)
    die(argv[1]);
  if (read(image, buffer, 512) != 512)
    die(argv[1]);
  if (!memcmp(buffer, "\177ELF", 4)) {
    unsigned int *p = (unsigned int *)(buffer + *(unsigned int *)(buffer + 28));
    i = p[1] + *(unsigned int *)(buffer + 24) - p[2];
    if (lseek(image, i, 0) < 0)
      die("lseek");
    if (read(image, buffer, 512) != 512)
      die(argv[1]);
    j = 0;
  } else if (*(unsigned int *)buffer == 0x01030107) {
    i = j = 32;
  } else {
    fprintf(stderr, "Not ELF nor a.out. Don't blame me.\n");
    exit(1);
  }
  k = i;
  i += ((*(unsigned short *)(buffer + j + 2)) << 2) - 512;
  if (lseek(image, i, 0) < 0)
    die("lseek");
  if (read(image, buffer, 1024) != 1024)
    die(argv[1]);
  for (q = buffer, r = q + 512; q < r; q += 4) {
    if (*q == 'H' && q[1] == 'd' && q[2] == 'r' && q[3] == 'S')
      break;
  }
  if (q == r) {
    fprintf(stderr, "Couldn't find headers signature in the kernel.\n");
    exit(1);
  }
  offset = i + (q - buffer) + 10;
  if (lseek(image, offset, 0) < 0)
    die("lseek");
  *(unsigned *)buffer = 0;
  *(unsigned *)(buffer + 4) = 0x01000000;
  *(unsigned *)(buffer + 8) = ((end + 32 + 4095) & ~4095);
  *(unsigned *)(buffer + 12) = s.st_size;
  if (write(image, buffer + 2, 14) != 14)
    die(argv[1]);
  if (lseek(image, k - start + ((end + 32 + 4095) & ~4095), 0) < 0)
    die("lseek");
  if ((tail = open(argv[3], O_RDONLY)) < 0)
    die(argv[3]);
  while ((i = read(tail, buffer, 1024)) > 0)
    if (write(image, buffer, i) != i)
      die(argv[1]);
  if (close(image) < 0)
    die("close");
  if (close(tail) < 0)
    die("close");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x448(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0x0,%rax
jge    1234 <main+0x44>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10f0 <die@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdbd(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    126a <main+0x7a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10f0 <die@plt>
jmp    126f <main+0x7f>
lea    -0x410(%rbp),%rdi
mov    -0x440(%rbp),%rdx
mov    $0x400,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     1316 <main+0x126>
lea    -0x410(%rbp),%rdi
add    $0xb,%rdi
lea    0xd5f(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    12d1 <main+0xe1>
lea    -0x410(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1100 <strtoul@plt>
mov    %eax,-0x430(%rbp)
jmp    1311 <main+0x121>
lea    -0x410(%rbp),%rdi
add    $0xb,%rdi
lea    0xd26(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    130c <main+0x11c>
lea    -0x410(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1100 <strtoul@plt>
mov    %eax,-0x434(%rbp)
jmp    1311 <main+0x121>
jmp    126f <main+0x7f>
mov    -0x440(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2cb7(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x44c(%rbp)
cmp    $0x0,%eax
jge    1354 <main+0x164>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <die@plt>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x200,%edx
call   1070 <read@plt>
cmp    $0x200,%eax
je     1383 <main+0x193>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <die@plt>
lea    -0x410(%rbp),%rdi
lea    0xc7d(%rip),%rsi
mov    $0x4,%edx
call   1080 <memcmp@plt>
cmp    $0x0,%eax
jne    1442 <main+0x252>
lea    -0x410(%rbp),%rax
mov    -0x3f4(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x458(%rbp)
mov    -0x458(%rbp),%rax
mov    0x4(%rax),%eax
add    -0x3f8(%rbp),%eax
mov    -0x458(%rbp),%rcx
sub    0x8(%rcx),%eax
mov    %eax,-0x424(%rbp)
mov    -0x44c(%rbp),%edi
mov    -0x424(%rbp),%esi
xor    %edx,%edx
call   1050 <lseek@plt>
cmp    $0x0,%rax
jge    1404 <main+0x214>
lea    0xc14(%rip),%rdi
call   10f0 <die@plt>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x200,%edx
call   1070 <read@plt>
cmp    $0x200,%eax
je     1433 <main+0x243>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <die@plt>
movl   $0x0,-0x428(%rbp)
jmp    148f <main+0x29f>
cmpl   $0x1030107,-0x410(%rbp)
01 03 01
jne    146b <main+0x27b>
movl   $0x20,-0x428(%rbp)
movl   $0x20,-0x424(%rbp)
jmp    148a <main+0x29a>
mov    0x2b5e(%rip),%rax
mov    (%rax),%edi
lea    0xb9e(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    148f <main+0x29f>
mov    -0x424(%rbp),%eax
mov    %eax,-0x42c(%rbp)
mov    -0x428(%rbp),%eax
movzwl -0x40e(%rbp,%rax,1),%eax
ff
shl    $0x2,%eax
sub    $0x200,%eax
add    -0x424(%rbp),%eax
mov    %eax,-0x424(%rbp)
mov    -0x44c(%rbp),%edi
mov    -0x424(%rbp),%esi
xor    %edx,%edx
call   1050 <lseek@plt>
cmp    $0x0,%rax
jge    14e6 <main+0x2f6>
lea    0xb32(%rip),%rdi
call   10f0 <die@plt>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1070 <read@plt>
cmp    $0x400,%eax
je     1515 <main+0x325>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <die@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
add    $0x200,%rax
mov    %rax,-0x420(%rbp)
mov    -0x418(%rbp),%rax
cmp    -0x420(%rbp),%rax
jae    15bb <main+0x3cb>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x48,%eax
jne    159f <main+0x3af>
mov    -0x418(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
jne    159f <main+0x3af>
mov    -0x418(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x72,%eax
jne    159f <main+0x3af>
mov    -0x418(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x53,%eax
jne    159f <main+0x3af>
jmp    15bb <main+0x3cb>
jmp    15a4 <main+0x3b4>
mov    -0x418(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x418(%rbp)
jmp    1537 <main+0x347>
mov    -0x418(%rbp),%rax
cmp    -0x420(%rbp),%rax
jne    15ee <main+0x3fe>
mov    0x29fa(%rip),%rax
mov    (%rax),%edi
lea    0xa5e(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x424(%rbp),%eax
mov    -0x418(%rbp),%rcx
lea    -0x410(%rbp),%rdx
sub    %rdx,%rcx
add    %rcx,%rax
add    $0xa,%rax
mov    %eax,-0x438(%rbp)
mov    -0x44c(%rbp),%edi
mov    -0x438(%rbp),%esi
xor    %edx,%edx
call   1050 <lseek@plt>
cmp    $0x0,%rax
jge    163b <main+0x44b>
lea    0x9dd(%rip),%rdi
call   10f0 <die@plt>
movl   $0x0,-0x410(%rbp)
movl   $0x1000000,-0x40c(%rbp)
mov    -0x434(%rbp),%eax
add    $0x20,%eax
add    $0xfff,%eax
and    $0xfffff000,%eax
mov    %eax,-0x408(%rbp)
mov    -0x448(%rbp),%eax
mov    %eax,-0x404(%rbp)
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
add    $0x2,%rsi
mov    $0xe,%edx
call   1030 <write@plt>
cmp    $0xe,%eax
je     16a5 <main+0x4b5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <die@plt>
mov    -0x44c(%rbp),%edi
mov    -0x42c(%rbp),%esi
sub    -0x430(%rbp),%esi
mov    -0x434(%rbp),%eax
add    $0x20,%eax
add    $0xfff,%eax
and    $0xfffff000,%eax
add    %eax,%esi
xor    %edx,%edx
call   1050 <lseek@plt>
cmp    $0x0,%rax
jge    16e9 <main+0x4f9>
lea    0x92f(%rip),%rdi
call   10f0 <die@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x28e8(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x450(%rbp)
cmp    $0x0,%eax
jge    171b <main+0x52b>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10f0 <die@plt>
jmp    1720 <main+0x530>
mov    -0x450(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1070 <read@plt>
mov    %eax,-0x424(%rbp)
cmp    $0x0,%eax
jbe    177c <main+0x58c>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x424(%rbp),%edx
call   1030 <write@plt>
cmp    -0x424(%rbp),%eax
je     1777 <main+0x587>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <die@plt>
jmp    1720 <main+0x530>
mov    -0x44c(%rbp),%edi
call   1060 <close@plt>
cmp    $0x0,%rax
jge    179d <main+0x5ad>
lea    0x8d5(%rip),%rdi
call   10f0 <die@plt>
mov    -0x450(%rbp),%edi
call   1060 <close@plt>
cmp    $0x0,%rax
jge    17be <main+0x5ce>
lea    0x8b4(%rip),%rdi
call   10f0 <die@plt>
xor    %eax,%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbx
mov    0x18(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   10b0 <stat@plt>
test   %rax,%rax
jns    1210 <main+0x30>
mov    0x18(%rbx),%rdi
call   10e0 <die@plt>
mov    0x10(%rbx),%rdi
lea    0xde5(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1231 <main+0x51>
mov    0x10(%rbx),%rdi
call   10e0 <die@plt>
mov    %rbx,(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12d4 <main+0xf4>
lea    0x1b(%rsp),%rbx
lea    0xda6(%rip),%r13
lea    0x10(%rsp),%r15
lea    0xda1(%rip),%r14
jmp    1298 <main+0xb8>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10f0 <strtoul@plt>
mov    %eax,0xc(%rsp)
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12d4 <main+0xf4>
mov    $0x7,%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <memcmp@plt>
test   %eax,%eax
je     1270 <main+0x90>
mov    $0x5,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <memcmp@plt>
test   %eax,%eax
jne    1283 <main+0xa3>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10f0 <strtoul@plt>
mov    %eax,%r12d
jmp    1283 <main+0xa3>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    (%rsp),%rbx
mov    0x8(%rbx),%rdi
mov    0x2cfd(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    1302 <main+0x122>
mov    0x8(%rbx),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x200,%edx
call   1070 <read@plt>
cmp    $0x200,%eax
je     1324 <main+0x144>
mov    0x8(%rbx),%rdi
call   10e0 <die@plt>
lea    0xce3(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x4,%edx
call   1080 <memcmp@plt>
test   %eax,%eax
je     1359 <main+0x179>
cmpl   $0x1030107,0x10(%rsp)
01
jne    15aa <main+0x3ca>
mov    $0x20,%r14d
mov    $0x20,%eax
jmp    13ae <main+0x1ce>
mov    0x28(%rsp),%r14d
mov    0x2c(%rsp),%eax
add    0x14(%rsp,%rax,1),%r14d
sub    0x18(%rsp,%rax,1),%r14d
mov    %r15d,%edi
mov    %r14d,%esi
xor    %edx,%edx
call   1050 <lseek@plt>
test   %rax,%rax
jns    138a <main+0x1aa>
lea    0xc8e(%rip),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x200,%edx
call   1070 <read@plt>
cmp    $0x200,%eax
je     13ac <main+0x1cc>
mov    0x8(%rbx),%rdi
call   10e0 <die@plt>
xor    %eax,%eax
movzwl 0x12(%rsp,%rax,1),%eax
lea    (%r14,%rax,4),%r13d
add    $0xfffffe00,%r13d
mov    %r15d,%edi
mov    %r13d,%esi
xor    %edx,%edx
call   1050 <lseek@plt>
test   %rax,%rax
jns    13dc <main+0x1fc>
lea    0xc3c(%rip),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rbx
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1070 <read@plt>
cmp    $0x400,%eax
je     1405 <main+0x225>
mov    (%rsp),%rax
mov    0x8(%rax),%rdi
call   10e0 <die@plt>
lea    0x210(%rsp),%rax
jmp    1419 <main+0x239>
nop
add    $0x4,%rbx
cmp    %rax,%rbx
jae    1430 <main+0x250>
cmpb   $0x48,(%rbx)
jne    1410 <main+0x230>
cmpb   $0x64,0x1(%rbx)
jne    1410 <main+0x230>
cmpb   $0x72,0x2(%rbx)
jne    1410 <main+0x230>
cmpb   $0x53,0x3(%rbx)
jne    1410 <main+0x230>
cmp    %rax,%rbx
je     1598 <main+0x3b8>
lea    0x10(%rsp),%rax
sub    %eax,%ebx
lea    (%rbx,%r13,1),%esi
add    $0xa,%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1050 <lseek@plt>
test   %rax,%rax
jns    1462 <main+0x282>
lea    0xbb6(%rip),%rdi
call   10e0 <die@plt>
movabs $0x100000000000000,%rax
mov    %rax,0x10(%rsp)
add    $0x101f,%r12d
and    $0xfffff000,%r12d
mov    %r12d,0x18(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0x1c(%rsp)
lea    0x12(%rsp),%rsi
mov    %r15d,%edi
mov    $0xe,%edx
call   1030 <write@plt>
cmp    $0xe,%eax
mov    (%rsp),%r13
mov    0xc(%rsp),%ebx
je     14b4 <main+0x2d4>
mov    0x8(%r13),%rdi
call   10e0 <die@plt>
sub    %ebx,%r12d
add    %r14d,%r12d
mov    %r15d,%edi
mov    %r12d,%esi
xor    %edx,%edx
call   1050 <lseek@plt>
test   %rax,%rax
jns    14d8 <main+0x2f8>
lea    0xb40(%rip),%rdi
call   10e0 <die@plt>
mov    0x18(%r13),%rdi
mov    0x2afd(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    14fa <main+0x31a>
mov    0x18(%r13),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1070 <read@plt>
test   %eax,%eax
je     1552 <main+0x372>
mov    %eax,%ebx
lea    0x10(%rsp),%rbp
jmp    1536 <main+0x356>
nopl   0x0(%rax)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1070 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1552 <main+0x372>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    %ebx,%eax
je     1520 <main+0x340>
mov    0x8(%r13),%rdi
call   10e0 <die@plt>
jmp    1520 <main+0x340>
mov    %r15d,%edi
call   1060 <close@plt>
test   %rax,%rax
jns    156b <main+0x38b>
lea    0xb07(%rip),%rdi
call   10e0 <die@plt>
mov    %r14d,%edi
call   1060 <close@plt>
test   %rax,%rax
jns    1584 <main+0x3a4>
lea    0xaee(%rip),%rdi
call   10e0 <die@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a31(%rip),%rax
mov    (%rax),%edi
lea    0xa95(%rip),%rsi
jmp    15ba <main+0x3da>
mov    0x2a1f(%rip),%rax
mov    (%rax),%edi
lea    0xa5f(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"start\0A\00"
@.str.2 = [5 x i8] c"end\0A\00"
@O_RDWR = global i32 0
@.str.3 = [5 x i8] c"\7FELF\00"
@.str.4 = [6 x i8] c"lseek\00"
@stderr = global i32 0
@.str.5 = [36 x i8] c"Not ELF nor a.out. Don't blame me.\0A\00"
@.str.6 = [48 x i8] c"Couldn't find headers signature in the kernel.\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [6 x i8] c"close\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca %struct.stat
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i64 @stat(i8* %22, %struct.stat* %16)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i32 @die(i8* %28)
br label %30
30: ; preds = %25, %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %34, i32** %15
%35 = load i32*, i32** %15
%36 = icmp ne i32* %35, null
br i1 %36, label %42, label %37
37: ; preds = %30
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @die(i8* %40)
br label %42
42: ; preds = %37, %30
br label %43
43: ; preds = %65, %42
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%45 = load i32*, i32** %15
%46 = call i64 @fgets(i8* %44, i32 1024, i32* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %66
48: ; preds = %43
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%50 = getelementptr inbounds i8, i8* %49, i64 11
%51 = call i32 @strcmp(i8* %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %48
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%55 = call i32 @strtoul(i8* %54, i32* null, i32 16)
store i32 %55, i32* %12
br label %65
56: ; preds = %48
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%58 = getelementptr inbounds i8, i8* %57, i64 11
%59 = call i32 @strcmp(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %56
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%63 = call i32 @strtoul(i8* %62, i32* null, i32 16)
store i32 %63, i32* %13
br label %64
64: ; preds = %61, %56
br label %65
65: ; preds = %64, %53
br label %43
66: ; preds = %43
%67 = load i32*, i32** %15
%68 = call i32 @fclose(i32* %67)
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 1
%71 = load i8*, i8** %70
%72 = load i32, i32* @O_RDWR
%73 = call i32 @open(i8* %71, i32 %72)
store i32 %73, i32* %17
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %80
75: ; preds = %66
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 1
%78 = load i8*, i8** %77
%79 = call i32 @die(i8* %78)
br label %80
80: ; preds = %75, %66
%81 = load i32, i32* %17
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%83 = call i32 @read(i32 %81, i8* %82, i32 512)
%84 = icmp ne i32 %83, 512
br i1 %84, label %85, label %90
85: ; preds = %80
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 1
%88 = load i8*, i8** %87
%89 = call i32 @die(i8* %88)
br label %90
90: ; preds = %85, %80
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%92 = call i32 @memcmp(i8* %91, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%93 = icmp ne i32 %92, 0
br i1 %93, label %132, label %94
94: ; preds = %90
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%97 = getelementptr inbounds i8, i8* %96, i64 28
%98 = bitcast i8* %97 to i32*
%99 = load i32, i32* %98
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %95, i64 %100
%102 = bitcast i8* %101 to i32*
store i32* %102, i32** %19
%103 = load i32*, i32** %19
%104 = getelementptr inbounds i32, i32* %103, i64 1
%105 = load i32, i32* %104
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%107 = getelementptr inbounds i8, i8* %106, i64 24
%108 = bitcast i8* %107 to i32*
%109 = load i32, i32* %108
%110 = add i32 %105, %109
%111 = load i32*, i32** %19
%112 = getelementptr inbounds i32, i32* %111, i64 2
%113 = load i32, i32* %112
%114 = sub i32 %110, %113
store i32 %114, i32* %9
%115 = load i32, i32* %17
%116 = load i32, i32* %9
%117 = call i64 @lseek(i32 %115, i32 %116, i32 0)
%118 = icmp slt i64 %117, 0
br i1 %118, label %119, label %121
119: ; preds = %94
%120 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %121
121: ; preds = %119, %94
%122 = load i32, i32* %17
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%124 = call i32 @read(i32 %122, i8* %123, i32 512)
%125 = icmp ne i32 %124, 512
br i1 %125, label %126, label %131
126: ; preds = %121
%127 = load i8**, i8*** %5
%128 = getelementptr inbounds i8*, i8** %127, i64 1
%129 = load i8*, i8** %128
%130 = call i32 @die(i8* %129)
br label %131
131: ; preds = %126, %121
store i32 0, i32* %10
br label %143
132: ; preds = %90
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%134 = bitcast i8* %133 to i32*
%135 = load i32, i32* %134
%136 = icmp eq i32 %135, 16974087
br i1 %136, label %137, label %138
137: ; preds = %132
store i32 32, i32* %10
store i32 32, i32* %9
br label %142
138: ; preds = %132
%139 = load i32, i32* @stderr
%140 = call i32 @fprintf(i32 %139, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%141 = call i32 @exit(i32 1)
unreachable
142: ; preds = %137
br label %143
143: ; preds = %142, %131
%144 = load i32, i32* %9
store i32 %144, i32* %11
%145 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%146 = load i32, i32* %10
%147 = zext i32 %146 to i64
%148 = getelementptr inbounds i8, i8* %145, i64 %147
%149 = getelementptr inbounds i8, i8* %148, i64 2
%150 = bitcast i8* %149 to i16*
%151 = load i16, i16* %150
%152 = zext i16 %151 to i32
%153 = shl i32 %152, 2
%154 = sub nsw i32 %153, 512
%155 = load i32, i32* %9
%156 = add i32 %155, %154
store i32 %156, i32* %9
%157 = load i32, i32* %17
%158 = load i32, i32* %9
%159 = call i64 @lseek(i32 %157, i32 %158, i32 0)
%160 = icmp slt i64 %159, 0
br i1 %160, label %161, label %163
161: ; preds = %143
%162 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %163
163: ; preds = %161, %143
%164 = load i32, i32* %17
%165 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%166 = call i32 @read(i32 %164, i8* %165, i32 1024)
%167 = icmp ne i32 %166, 1024
br i1 %167, label %168, label %173
168: ; preds = %163
%169 = load i8**, i8*** %5
%170 = getelementptr inbounds i8*, i8** %169, i64 1
%171 = load i8*, i8** %170
%172 = call i32 @die(i8* %171)
br label %173
173: ; preds = %168, %163
%174 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
store i8* %174, i8** %7
%175 = load i8*, i8** %7
%176 = getelementptr inbounds i8, i8* %175, i64 512
store i8* %176, i8** %8
br label %177
177: ; preds = %206, %173
%178 = load i8*, i8** %7
%179 = load i8*, i8** %8
%180 = icmp ult i8* %178, %179
br i1 %180, label %181, label %209
181: ; preds = %177
%182 = load i8*, i8** %7
%183 = load i8, i8* %182
%184 = sext i8 %183 to i32
%185 = icmp eq i32 %184, 72
br i1 %185, label %186, label %205
186: ; preds = %181
%187 = load i8*, i8** %7
%188 = getelementptr inbounds i8, i8* %187, i64 1
%189 = load i8, i8* %188
%190 = sext i8 %189 to i32
%191 = icmp eq i32 %190, 100
br i1 %191, label %192, label %205
192: ; preds = %186
%193 = load i8*, i8** %7
%194 = getelementptr inbounds i8, i8* %193, i64 2
%195 = load i8, i8* %194
%196 = sext i8 %195 to i32
%197 = icmp eq i32 %196, 114
br i1 %197, label %198, label %205
198: ; preds = %192
%199 = load i8*, i8** %7
%200 = getelementptr inbounds i8, i8* %199, i64 3
%201 = load i8, i8* %200
%202 = sext i8 %201 to i32
%203 = icmp eq i32 %202, 83
br i1 %203, label %204, label %205
204: ; preds = %198
br label %209
205: ; preds = %198, %192, %186, %181
br label %206
206: ; preds = %205
%207 = load i8*, i8** %7
%208 = getelementptr inbounds i8, i8* %207, i64 4
store i8* %208, i8** %7
br label %177
209: ; preds = %204, %177
%210 = load i8*, i8** %7
%211 = load i8*, i8** %8
%212 = icmp eq i8* %210, %211
br i1 %212, label %213, label %217
213: ; preds = %209
%214 = load i32, i32* @stderr
%215 = call i32 @fprintf(i32 %214, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%216 = call i32 @exit(i32 1)
unreachable
217: ; preds = %209
%218 = load i32, i32* %9
%219 = zext i32 %218 to i64
%220 = load i8*, i8** %7
%221 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%222 = ptrtoint i8* %220 to i64
%223 = ptrtoint i8* %221 to i64
%224 = sub i64 %222, %223
%225 = add nsw i64 %219, %224
%226 = add nsw i64 %225, 10
%227 = trunc i64 %226 to i32
store i32 %227, i32* %14
%228 = load i32, i32* %17
%229 = load i32, i32* %14
%230 = call i64 @lseek(i32 %228, i32 %229, i32 0)
%231 = icmp slt i64 %230, 0
br i1 %231, label %232, label %234
232: ; preds = %217
%233 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %234
234: ; preds = %232, %217
%235 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%236 = bitcast i8* %235 to i32*
store i32 0, i32* %236
%237 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%238 = getelementptr inbounds i8, i8* %237, i64 4
%239 = bitcast i8* %238 to i32*
store i32 16777216, i32* %239
%240 = load i32, i32* %13
%241 = add i32 %240, 32
%242 = add i32 %241, 4095
%243 = and i32 %242, -4096
%244 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%245 = getelementptr inbounds i8, i8* %244, i64 8
%246 = bitcast i8* %245 to i32*
store i32 %243, i32* %246
%247 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%248 = load i32, i32* %247
%249 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%250 = getelementptr inbounds i8, i8* %249, i64 12
%251 = bitcast i8* %250 to i32*
store i32 %248, i32* %251
%252 = load i32, i32* %17
%253 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%254 = getelementptr inbounds i8, i8* %253, i64 2
%255 = call i32 @write(i32 %252, i8* %254, i32 14)
%256 = icmp ne i32 %255, 14
br i1 %256, label %257, label %262
257: ; preds = %234
%258 = load i8**, i8*** %5
%259 = getelementptr inbounds i8*, i8** %258, i64 1
%260 = load i8*, i8** %259
%261 = call i32 @die(i8* %260)
br label %262
262: ; preds = %257, %234
%263 = load i32, i32* %17
%264 = load i32, i32* %11
%265 = load i32, i32* %12
%266 = sub i32 %264, %265
%267 = load i32, i32* %13
%268 = add i32 %267, 32
%269 = add i32 %268, 4095
%270 = and i32 %269, -4096
%271 = add i32 %266, %270
%272 = call i64 @lseek(i32 %263, i32 %271, i32 0)
%273 = icmp slt i64 %272, 0
br i1 %273, label %274, label %276
274: ; preds = %262
%275 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %276
276: ; preds = %274, %262
%277 = load i8**, i8*** %5
%278 = getelementptr inbounds i8*, i8** %277, i64 3
%279 = load i8*, i8** %278
%280 = load i32, i32* @O_RDONLY
%281 = call i32 @open(i8* %279, i32 %280)
store i32 %281, i32* %18
%282 = icmp slt i32 %281, 0
br i1 %282, label %283, label %288
283: ; preds = %276
%284 = load i8**, i8*** %5
%285 = getelementptr inbounds i8*, i8** %284, i64 3
%286 = load i8*, i8** %285
%287 = call i32 @die(i8* %286)
br label %288
288: ; preds = %283, %276
br label %289
289: ; preds = %306, %288
%290 = load i32, i32* %18
%291 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%292 = call i32 @read(i32 %290, i8* %291, i32 1024)
store i32 %292, i32* %9
%293 = icmp ugt i32 %292, 0
br i1 %293, label %294, label %307
294: ; preds = %289
%295 = load i32, i32* %17
%296 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%297 = load i32, i32* %9
%298 = call i32 @write(i32 %295, i8* %296, i32 %297)
%299 = load i32, i32* %9
%300 = icmp ne i32 %298, %299
br i1 %300, label %301, label %306
301: ; preds = %294
%302 = load i8**, i8*** %5
%303 = getelementptr inbounds i8*, i8** %302, i64 1
%304 = load i8*, i8** %303
%305 = call i32 @die(i8* %304)
br label %306
306: ; preds = %301, %294
br label %289
307: ; preds = %289
%308 = load i32, i32* %17
%309 = call i64 @close(i32 %308)
%310 = icmp slt i64 %309, 0
br i1 %310, label %311, label %313
311: ; preds = %307
%312 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %313
313: ; preds = %311, %307
%314 = load i32, i32* %18
%315 = call i64 @close(i32 %314)
%316 = icmp slt i64 %315, 0
br i1 %316, label %317, label %319
317: ; preds = %313
%318 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %319
319: ; preds = %317, %313
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"start\0A\00"
@.str.2 = [5 x i8] c"end\0A\00"
@O_RDWR = global i32 0
@.str.3 = [5 x i8] c"\7FELF\00"
@.str.4 = [6 x i8] c"lseek\00"
@stderr = global i32 0
@.str.5 = [36 x i8] c"Not ELF nor a.out. Don't blame me.\0A\00"
@.str.6 = [48 x i8] c"Couldn't find headers signature in the kernel.\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [6 x i8] c"close\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.stat* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = call i64 @stat(i8* %8, %struct.stat* %4)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %7
%13 = call i32 @die(i8* %12)
br label %14
14: ; preds = %11, %2
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %15
%21 = call i32 @die(i8* %20)
br label %22
22: ; preds = %19, %14
%23 = call i64 @fgets(i8* %5, i32 1024, i32* %17)
%24 = icmp eq i64 %23, 0
br i1 %24, label %44, label %25
25: ; preds = %22
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 11
br label %27
27: ; preds = %25, %39
%28 = phi i32 [ undef, %25 ], [ %41, %39 ]
%29 = phi i32 [ undef, %25 ], [ %40, %39 ]
%30 = call i32 bitcast (i32 (i8*, i8*, i32)* @memcmp to i32 (i8*, i8*, i64)*)(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 7)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 @strtoul(i8* nocapture %5, i32* null, i32 16)
br label %39
34: ; preds = %27
%35 = call i32 bitcast (i32 (i8*, i8*, i32)* @memcmp to i32 (i8*, i8*, i64)*)(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 5)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @strtoul(i8* nocapture %5, i32* null, i32 16)
br label %39
39: ; preds = %34, %37, %32
%40 = phi i32 [ %29, %34 ], [ %38, %37 ], [ %29, %32 ]
%41 = phi i32 [ %28, %34 ], [ %28, %37 ], [ %33, %32 ]
%42 = call i64 @fgets(i8* %5, i32 1024, i32* %17)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %27
44: ; preds = %39, %22
%45 = phi i32 [ undef, %22 ], [ %40, %39 ]
%46 = phi i32 [ undef, %22 ], [ %41, %39 ]
%47 = call i32 @fclose(i32* %17)
%48 = getelementptr inbounds i8*, i8** %1, i64 1
%49 = load i8*, i8** %48
%50 = load i32, i32* @O_RDWR
%51 = call i32 @open(i8* %49, i32 %50)
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %44
%54 = load i8*, i8** %48
%55 = call i32 @die(i8* %54)
br label %56
56: ; preds = %53, %44
%57 = call i32 @read(i32 %51, i8* %5, i32 512)
%58 = icmp eq i32 %57, 512
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = load i8*, i8** %48
%61 = call i32 @die(i8* %60)
br label %62
62: ; preds = %59, %56
%63 = call i32 @memcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %92
65: ; preds = %62
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 28
%67 = bitcast i8* %66 to i32*
%68 = load i32, i32* %67
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %69
%71 = getelementptr inbounds i8, i8* %70, i64 4
%72 = bitcast i8* %71 to i32*
%73 = load i32, i32* %72
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 24
%75 = bitcast i8* %74 to i32*
%76 = load i32, i32* %75
%77 = add i32 %76, %73
%78 = getelementptr inbounds i8, i8* %70, i64 8
%79 = bitcast i8* %78 to i32*
%80 = load i32, i32* %79
%81 = sub i32 %77, %80
%82 = call i64 @lseek(i32 %51, i32 %81, i32 0)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %65
%85 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %86
86: ; preds = %84, %65
%87 = call i32 @read(i32 %51, i8* %5, i32 512)
%88 = icmp eq i32 %87, 512
br i1 %88, label %100, label %89
89: ; preds = %86
%90 = load i8*, i8** %48
%91 = call i32 @die(i8* %90)
br label %100
92: ; preds = %62
%93 = bitcast [1024 x i8]* %3 to i32*
%94 = load i32, i32* %93
%95 = icmp eq i32 %94, 16974087
br i1 %95, label %100, label %96
96: ; preds = %92
%97 = load i32, i32* @stderr
%98 = call i32 @fprintf(i32 %97, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %92, %86, %89
%101 = phi i64 [ 0, %89 ], [ 0, %86 ], [ 32, %92 ]
%102 = phi i32 [ %81, %89 ], [ %81, %86 ], [ 32, %92 ]
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %101
%104 = getelementptr inbounds i8, i8* %103, i64 2
%105 = bitcast i8* %104 to i16*
%106 = load i16, i16* %105
%107 = zext i16 %106 to i32
%108 = shl nuw nsw i32 %107, 2
%109 = add i32 %102, -512
%110 = add i32 %109, %108
%111 = call i64 @lseek(i32 %51, i32 %110, i32 0)
%112 = icmp slt i64 %111, 0
br i1 %112, label %113, label %115
113: ; preds = %100
%114 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %115
115: ; preds = %113, %100
%116 = call i32 @read(i32 %51, i8* %5, i32 1024)
%117 = icmp eq i32 %116, 1024
br i1 %117, label %121, label %118
118: ; preds = %115
%119 = load i8*, i8** %48
%120 = call i32 @die(i8* %119)
br label %121
121: ; preds = %118, %115
%122 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 512
br label %123
123: ; preds = %121, %139
%124 = phi i8* [ %5, %121 ], [ %140, %139 ]
%125 = load i8, i8* %124
%126 = icmp eq i8 %125, 72
br i1 %126, label %127, label %139
127: ; preds = %123
%128 = getelementptr inbounds i8, i8* %124, i64 1
%129 = load i8, i8* %128
%130 = icmp eq i8 %129, 100
br i1 %130, label %131, label %139
131: ; preds = %127
%132 = getelementptr inbounds i8, i8* %124, i64 2
%133 = load i8, i8* %132
%134 = icmp eq i8 %133, 114
br i1 %134, label %135, label %139
135: ; preds = %131
%136 = getelementptr inbounds i8, i8* %124, i64 3
%137 = load i8, i8* %136
%138 = icmp eq i8 %137, 83
br i1 %138, label %142, label %139
139: ; preds = %123, %127, %131, %135
%140 = getelementptr inbounds i8, i8* %124, i64 4
%141 = icmp ult i8* %140, %122
br i1 %141, label %123, label %142
142: ; preds = %135, %139
%143 = phi i8* [ %124, %135 ], [ %140, %139 ]
%144 = icmp eq i8* %143, %122
br i1 %144, label %145, label %149
145: ; preds = %142
%146 = load i32, i32* @stderr
%147 = call i32 @fprintf(i32 %146, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%148 = call i32 @exit(i32 1)
unreachable
149: ; preds = %142
%150 = ptrtoint i8* %143 to i64
%151 = ptrtoint [1024 x i8]* %3 to i64
%152 = sub i64 %150, %151
%153 = trunc i64 %152 to i32
%154 = add i32 %110, 10
%155 = add i32 %154, %153
%156 = call i64 @lseek(i32 %51, i32 %155, i32 0)
%157 = icmp slt i64 %156, 0
br i1 %157, label %158, label %160
158: ; preds = %149
%159 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %160
160: ; preds = %158, %149
%161 = bitcast [1024 x i8]* %3 to i32*
store i32 0, i32* %161
%162 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 4
%163 = bitcast i8* %162 to i32*
store i32 16777216, i32* %163
%164 = add i32 %45, 4127
%165 = and i32 %164, -4096
%166 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 8
%167 = bitcast i8* %166 to i32*
store i32 %165, i32* %167
%168 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%169 = load i32, i32* %168
%170 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 12
%171 = bitcast i8* %170 to i32*
store i32 %169, i32* %171
%172 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 2
%173 = call i32 @write(i32 %51, i8* %172, i32 14)
%174 = icmp eq i32 %173, 14
br i1 %174, label %178, label %175
175: ; preds = %160
%176 = load i8*, i8** %48
%177 = call i32 @die(i8* %176)
br label %178
178: ; preds = %175, %160
%179 = sub i32 %165, %46
%180 = add i32 %179, %102
%181 = call i64 @lseek(i32 %51, i32 %180, i32 0)
%182 = icmp slt i64 %181, 0
br i1 %182, label %183, label %185
183: ; preds = %178
%184 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %185
185: ; preds = %183, %178
%186 = load i8*, i8** %7
%187 = load i32, i32* @O_RDONLY
%188 = call i32 @open(i8* %186, i32 %187)
%189 = icmp slt i32 %188, 0
br i1 %189, label %190, label %193
190: ; preds = %185
%191 = load i8*, i8** %7
%192 = call i32 @die(i8* %191)
br label %193
193: ; preds = %190, %185
%194 = call i32 @read(i32 %188, i8* %5, i32 1024)
%195 = icmp eq i32 %194, 0
br i1 %195, label %206, label %196
196: ; preds = %193, %203
%197 = phi i32 [ %204, %203 ], [ %194, %193 ]
%198 = call i32 @write(i32 %51, i8* %5, i32 %197)
%199 = icmp eq i32 %198, %197
br i1 %199, label %203, label %200
200: ; preds = %196
%201 = load i8*, i8** %48
%202 = call i32 @die(i8* %201)
br label %203
203: ; preds = %200, %196
%204 = call i32 @read(i32 %188, i8* %5, i32 1024)
%205 = icmp eq i32 %204, 0
br i1 %205, label %206, label %196
206: ; preds = %203, %193
%207 = call i64 @close(i32 %51)
%208 = icmp slt i64 %207, 0
br i1 %208, label %209, label %211
209: ; preds = %206
%210 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %211
211: ; preds = %209, %206
%212 = call i64 @close(i32 %188)
%213 = icmp slt i64 %212, 0
br i1 %213, label %214, label %216
214: ; preds = %211
%215 = call i32 @die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %216
216: ; preds = %214, %211
ret i32 0
}