#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(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int ld2(unsigned char *);
int ld4(unsigned char *);
scalar_t__ lseek(int, unsigned int, int /*<<< orphan*/);
scalar_t__ memcmp(unsigned char *, char *, int);
int open(char *, int /*<<< orphan*/);
int read(int, unsigned char *, int);
int /*<<< orphan*/ st4(unsigned char *, unsigned int);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(unsigned char *, char *);
unsigned int strtoul(unsigned char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ usage();
unsigned int write(int, unsigned char *, unsigned int);
int main(int argc, char **argv) {
  static char aout_magic[] = {0x01, 0x03, 0x01, 0x07};
  unsigned char buffer[1024], *q, *r;
  unsigned int i, j, k, start, end, offset;
  FILE *map;
  struct stat s;
  int image, tail;
  if (argc != 4)
    usage();
  start = end = 0;
  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 + 8, " T start\n") || !strcmp(buffer + 16, " T start\n"))
      start = strtoul(buffer, NULL, 16);
    else if (!strcmp(buffer + 8, " A end\n") ||
             !strcmp(buffer + 16, " A end\n"))
      end = strtoul(buffer, NULL, 16);
  }
  fclose(map);
  if (!start || !end) {
    fprintf(stderr, "Could not determine start and end from System.map\n");
    exit(1);
  }
  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) == 0) {
    q = buffer + ld4(buffer + 28);
    i = ld4(q + 4) + ld4(buffer + 24) - ld4(q + 8);
    if (lseek(image, i, 0) < 0)
      die("lseek");
    if (read(image, buffer, 512) != 512)
      die(argv[1]);
    j = 0;
  } else if (memcmp(buffer, aout_magic, 4) == 0) {
    i = j = 32;
  } else {
    fprintf(stderr, "Not ELF nor a.out. Don't blame me.\n");
    exit(1);
  }
  k = i;
  i += (ld2(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");
  st4(buffer, 0);
  st4(buffer + 4, 0x01000000);
  st4(buffer + 8, (end + 32 + 4095) & ~4095);
  st4(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)
cmpl   $0x4,-0x8(%rbp)
je     125a <main+0x2a>
mov    $0x0,%al
call   1100 <usage@plt>
movl   $0x0,-0x434(%rbp)
movl   $0x0,-0x430(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x448(%rbp),%rsi
call   10e0 <stat@plt>
cmp    $0x0,%rax
jge    1299 <main+0x69>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1130 <die@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd58(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    12cf <main+0x9f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1130 <die@plt>
jmp    12d4 <main+0xa4>
lea    -0x410(%rbp),%rdi
mov    -0x440(%rbp),%rdx
mov    $0x400,%esi
call   10b0 <fgets@plt>
cmp    $0x0,%rax
je     13bb <main+0x18b>
lea    -0x410(%rbp),%rdi
add    $0x8,%rdi
lea    0xcfa(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
je     1336 <main+0x106>
lea    -0x410(%rbp),%rdi
add    $0x10,%rdi
lea    0xcda(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
jne    1356 <main+0x126>
lea    -0x410(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1140 <strtoul@plt>
mov    %eax,-0x430(%rbp)
jmp    13b6 <main+0x186>
lea    -0x410(%rbp),%rdi
add    $0x8,%rdi
lea    0xca4(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
je     1396 <main+0x166>
lea    -0x410(%rbp),%rdi
add    $0x10,%rdi
lea    0xc84(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
jne    13b1 <main+0x181>
lea    -0x410(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1140 <strtoul@plt>
mov    %eax,-0x434(%rbp)
jmp    13b6 <main+0x186>
jmp    12d4 <main+0xa4>
mov    -0x440(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x430(%rbp)
je     13e1 <main+0x1b1>
cmpl   $0x0,-0x434(%rbp)
jne    1400 <main+0x1d0>
mov    0x2be8(%rip),%rax
mov    (%rax),%edi
lea    0xc23(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2bd9(%rip),%rax
mov    (%rax),%esi
call   1110 <open@plt>
mov    %eax,-0x44c(%rbp)
cmp    $0x0,%eax
jge    1432 <main+0x202>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <die@plt>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x200,%edx
call   1090 <read@plt>
cmp    $0x200,%eax
je     1461 <main+0x231>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <die@plt>
lea    -0x410(%rbp),%rdi
lea    0xbd8(%rip),%rsi
mov    $0x4,%edx
call   10a0 <memcmp@plt>
cmp    $0x0,%rax
jne    1574 <main+0x344>
lea    -0x410(%rbp),%rax
mov    %rax,-0x460(%rbp)
lea    -0x410(%rbp),%rdi
add    $0x1c,%rdi
call   1070 <ld4@plt>
mov    %eax,%ecx
mov    -0x460(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rdi
add    $0x4,%rdi
call   1070 <ld4@plt>
mov    %eax,-0x458(%rbp)
lea    -0x410(%rbp),%rdi
add    $0x18,%rdi
call   1070 <ld4@plt>
mov    %eax,%ecx
mov    -0x458(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x454(%rbp)
mov    -0x418(%rbp),%rdi
add    $0x8,%rdi
call   1070 <ld4@plt>
mov    %eax,%ecx
mov    -0x454(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x424(%rbp)
mov    -0x44c(%rbp),%edi
mov    -0x424(%rbp),%esi
xor    %edx,%edx
call   1060 <lseek@plt>
cmp    $0x0,%rax
jge    1536 <main+0x306>
lea    0xb1b(%rip),%rdi
call   1130 <die@plt>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x200,%edx
call   1090 <read@plt>
cmp    $0x200,%eax
je     1565 <main+0x335>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <die@plt>
movl   $0x0,-0x428(%rbp)
jmp    15d3 <main+0x3a3>
lea    -0x410(%rbp),%rdi
lea    0x2b36(%rip),%rsi
mov    $0x4,%edx
call   10a0 <memcmp@plt>
cmp    $0x0,%rax
jne    15af <main+0x37f>
movl   $0x20,-0x428(%rbp)
movl   $0x20,-0x424(%rbp)
jmp    15ce <main+0x39e>
mov    0x2a1a(%rip),%rax
mov    (%rax),%edi
lea    0xa93(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
jmp    15d3 <main+0x3a3>
mov    -0x424(%rbp),%eax
mov    %eax,-0x42c(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x428(%rbp),%eax
add    %rax,%rdi
add    $0x2,%rdi
call   1050 <ld2@plt>
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   1060 <lseek@plt>
cmp    $0x0,%rax
jge    1635 <main+0x405>
lea    0xa1c(%rip),%rdi
call   1130 <die@plt>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
cmp    $0x400,%eax
je     1664 <main+0x434>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <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    170a <main+0x4da>
mov    -0x418(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x48,%eax
jne    16ee <main+0x4be>
mov    -0x418(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x64,%eax
jne    16ee <main+0x4be>
mov    -0x418(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x72,%eax
jne    16ee <main+0x4be>
mov    -0x418(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x53,%eax
jne    16ee <main+0x4be>
jmp    170a <main+0x4da>
jmp    16f3 <main+0x4c3>
mov    -0x418(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x418(%rbp)
jmp    1686 <main+0x456>
mov    -0x418(%rbp),%rax
cmp    -0x420(%rbp),%rax
jne    173d <main+0x50d>
mov    0x28ab(%rip),%rax
mov    (%rax),%edi
lea    0x948(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <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   1060 <lseek@plt>
cmp    $0x0,%rax
jge    178a <main+0x55a>
lea    0x8c7(%rip),%rdi
call   1130 <die@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
call   10f0 <st4@plt>
lea    -0x410(%rbp),%rdi
add    $0x4,%rdi
mov    $0x1000000,%esi
call   10f0 <st4@plt>
lea    -0x410(%rbp),%rdi
add    $0x8,%rdi
mov    -0x434(%rbp),%esi
add    $0x20,%esi
add    $0xfff,%esi
and    $0xfffff000,%esi
call   10f0 <st4@plt>
lea    -0x410(%rbp),%rdi
add    $0xc,%rdi
mov    -0x448(%rbp),%esi
call   10f0 <st4@plt>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
add    $0x2,%rsi
mov    $0xe,%edx
call   1030 <write@plt>
cmp    $0xe,%eax
je     1819 <main+0x5e9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <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   1060 <lseek@plt>
cmp    $0x0,%rax
jge    185d <main+0x62d>
lea    0x7f4(%rip),%rdi
call   1130 <die@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2774(%rip),%rax
mov    (%rax),%esi
call   1110 <open@plt>
mov    %eax,-0x450(%rbp)
cmp    $0x0,%eax
jge    188f <main+0x65f>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1130 <die@plt>
jmp    1894 <main+0x664>
mov    -0x450(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,-0x424(%rbp)
cmp    $0x0,%eax
jbe    18f0 <main+0x6c0>
mov    -0x44c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x424(%rbp),%edx
call   1030 <write@plt>
cmp    -0x424(%rbp),%eax
je     18eb <main+0x6bb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <die@plt>
jmp    1894 <main+0x664>
mov    -0x44c(%rbp),%edi
call   1080 <close@plt>
cmp    $0x0,%rax
jge    1911 <main+0x6e1>
lea    0x79a(%rip),%rdi
call   1130 <die@plt>
mov    -0x450(%rbp),%edi
call   1080 <close@plt>
cmp    $0x0,%rax
jge    1932 <main+0x702>
lea    0x779(%rip),%rdi
call   1130 <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    $0x428,%rsp
mov    %rsi,%rbp
cmp    $0x4,%edi
je     1240 <main+0x20>
xor    %eax,%eax
call   10f0 <usage@plt>
mov    0x18(%rbp),%rdi
lea    0x10(%rsp),%rsi
call   10d0 <stat@plt>
test   %rax,%rax
jns    125c <main+0x3c>
mov    0x18(%rbp),%rdi
call   1120 <die@plt>
mov    0x10(%rbp),%rdi
lea    0xd99(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    127d <main+0x5d>
mov    0x10(%rbp),%rdi
call   1120 <die@plt>
mov    %rbp,0x18(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     1368 <main+0x148>
lea    0x28(%rsp),%rbp
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x30(%rsp),%r12
lea    0xd4d(%rip),%r14
lea    0x20(%rsp),%r15
movl   $0x0,0x4(%rsp)
jmp    12f9 <main+0xd9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1130 <strtoul@plt>
mov    %rax,0x8(%rsp)
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     1377 <main+0x157>
mov    $0xa,%edx
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <memcmp@plt>
test   %eax,%eax
je     12d0 <main+0xb0>
mov    $0xa,%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   10a0 <memcmp@plt>
test   %eax,%eax
je     12d0 <main+0xb0>
mov    $0x8,%edx
mov    %rbp,%rdi
lea    0xcdc(%rip),%r13
mov    %r13,%rsi
call   10a0 <memcmp@plt>
test   %eax,%eax
je     1350 <main+0x130>
mov    $0x8,%edx
mov    %r12,%rdi
mov    %r13,%rsi
call   10a0 <memcmp@plt>
test   %eax,%eax
jne    12e4 <main+0xc4>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1130 <strtoul@plt>
mov    %eax,0x4(%rsp)
jmp    12e4 <main+0xc4>
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rax
mov    %rax,%rbp
test   %eax,%eax
mov    0x4(%rsp),%eax
je     16c9 <main+0x4a9>
test   %eax,%eax
je     16c9 <main+0x4a9>
mov    0x18(%rsp),%r12
mov    0x8(%r12),%rdi
mov    0x2c3c(%rip),%rax
mov    (%rax),%esi
call   1100 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    13c4 <main+0x1a4>
mov    0x8(%r12),%rdi
call   1120 <die@plt>
lea    0x20(%rsp),%rsi
mov    %r15d,%edi
mov    $0x200,%edx
call   1090 <read@plt>
cmp    $0x200,%eax
je     13e7 <main+0x1c7>
mov    0x8(%r12),%rdi
call   1120 <die@plt>
lea    0xc59(%rip),%rsi
lea    0x20(%rsp),%rdi
mov    $0x4,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
je     1433 <main+0x213>
lea    0x2ca7(%rip),%rsi
lea    0x20(%rsp),%rdi
mov    $0x4,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
jne    16ed <main+0x4cd>
mov    $0x20,%ebx
mov    $0x20,%eax
mov    %rbp,%r13
jmp    14bb <main+0x29b>
lea    0x3c(%rsp),%rdi
call   1070 <ld4@plt>
movslq %eax,%rbp
lea    (%rsp,%rbp,1),%rdi
add    $0x24,%rdi
call   1070 <ld4@plt>
mov    %eax,%r14d
lea    0x38(%rsp),%rdi
call   1070 <ld4@plt>
mov    %eax,%ebx
add    %r14d,%ebx
lea    (%rsp,%rbp,1),%rdi
add    $0x28,%rdi
call   1070 <ld4@plt>
sub    %eax,%ebx
mov    %r15d,%edi
mov    %rbx,%rbp
mov    %ebx,%esi
xor    %edx,%edx
call   1060 <lseek@plt>
test   %rax,%rax
jns    148e <main+0x26e>
lea    0xbc3(%rip),%rdi
call   1120 <die@plt>
lea    0x20(%rsp),%rsi
mov    %r15d,%edi
mov    $0x200,%edx
call   1090 <read@plt>
cmp    $0x200,%eax
je     14b1 <main+0x291>
mov    0x8(%r12),%rdi
call   1120 <die@plt>
xor    %eax,%eax
mov    0x8(%rsp),%r13
mov    %rbp,%rbx
lea    (%rsp,%rax,1),%rdi
add    $0x22,%rdi
call   1050 <ld2@plt>
lea    (%rbx,%rax,4),%r14d
add    $0xfffffe00,%r14d
mov    %r15d,%edi
mov    %r14d,%esi
xor    %edx,%edx
call   1060 <lseek@plt>
test   %rax,%rax
jns    14f1 <main+0x2d1>
lea    0xb60(%rip),%rdi
call   1120 <die@plt>
lea    0x20(%rsp),%rbp
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
cmp    $0x400,%eax
je     1517 <main+0x2f7>
mov    0x8(%r12),%rdi
call   1120 <die@plt>
lea    0x220(%rsp),%rax
jmp    1539 <main+0x319>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x4,%rbp
cmp    %rax,%rbp
jae    1551 <main+0x331>
cmpb   $0x48,0x0(%rbp)
jne    1530 <main+0x310>
cmpb   $0x64,0x1(%rbp)
jne    1530 <main+0x310>
cmpb   $0x72,0x2(%rbp)
jne    1530 <main+0x310>
cmpb   $0x53,0x3(%rbp)
jne    1530 <main+0x310>
cmp    %rax,%rbp
je     16db <main+0x4bb>
lea    0x20(%rsp),%rax
sub    %eax,%ebp
lea    (%r14,%rbp,1),%esi
add    $0xa,%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1060 <lseek@plt>
test   %rax,%rax
jns    1583 <main+0x363>
lea    0xace(%rip),%rdi
call   1120 <die@plt>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   10e0 <st4@plt>
lea    0x24(%rsp),%rdi
mov    $0x1000000,%esi
call   10e0 <st4@plt>
lea    0x28(%rsp),%rdi
mov    0x4(%rsp),%ebp
add    $0x101f,%ebp
and    $0xfffff000,%ebp
mov    %ebp,%esi
call   10e0 <st4@plt>
lea    0x2c(%rsp),%rdi
mov    0x10(%rsp),%esi
call   10e0 <st4@plt>
lea    0x22(%rsp),%rsi
mov    %r15d,%edi
mov    $0xe,%edx
call   1030 <write@plt>
cmp    $0xe,%eax
je     15e9 <main+0x3c9>
mov    0x8(%r12),%rdi
call   1120 <die@plt>
sub    %r13d,%ebp
add    %ebx,%ebp
mov    %r15d,%edi
mov    %ebp,%esi
xor    %edx,%edx
call   1060 <lseek@plt>
test   %rax,%rax
jns    160b <main+0x3eb>
lea    0xa46(%rip),%rdi
call   1120 <die@plt>
mov    0x18(%r12),%rdi
mov    0x29c9(%rip),%rax
mov    (%rax),%esi
call   1100 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    162f <main+0x40f>
mov    0x18(%r12),%rdi
call   1120 <die@plt>
lea    0x20(%rsp),%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1090 <read@plt>
test   %eax,%eax
je     1683 <main+0x463>
mov    %eax,%ebp
lea    0x20(%rsp),%rbx
jmp    1666 <main+0x446>
xchg   %ax,%ax
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1683 <main+0x463>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
cmp    %ebp,%eax
je     1650 <main+0x430>
mov    0x8(%r12),%rdi
call   1120 <die@plt>
jmp    1650 <main+0x430>
mov    %r15d,%edi
call   1080 <close@plt>
test   %rax,%rax
jns    169c <main+0x47c>
lea    0xa0f(%rip),%rdi
call   1120 <die@plt>
mov    %r14d,%edi
call   1080 <close@plt>
test   %rax,%rax
jns    16b5 <main+0x495>
lea    0x9f6(%rip),%rdi
call   1120 <die@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2900(%rip),%rax
mov    (%rax),%edi
lea    0x93b(%rip),%rsi
jmp    16fd <main+0x4dd>
mov    0x28ee(%rip),%rax
mov    (%rax),%edi
lea    0x98b(%rip),%rsi
jmp    16fd <main+0x4dd>
mov    0x28dc(%rip),%rax
mov    (%rax),%edi
lea    0x955(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>

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

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