#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 {
  int st_rdev;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int write(int, char *, int);
int main(int argc, char **argv) {
  int i, c, id;
  char buf[4096];
  char major_root, minor_root;
  char major_swap, minor_swap;
  struct stat sb;
  if ((argc < 4) || (argc > 6))
    usage();
  if (argc > 4) {
    if (strcmp(argv[4], "FLOPPY")) {
      if (stat(argv[4], &sb)) {
        perror(argv[4]);
        die("Couldn't stat root device.");
      }
      major_root = (((sb.st_rdev) >> 8) & 0xff);
      minor_root = ((sb.st_rdev) & 0xff);
    } else {
      major_root = 0;
      minor_root = 0;
    }
  } else {
    major_root = 2;
    minor_root = 29;
  }
  if (argc == 6) {
    if (strcmp(argv[5], "NONE")) {
      if (stat(argv[5], &sb)) {
        perror(argv[5]);
        die("Couldn't stat root device.");
      }
      major_swap = (((sb.st_rdev) >> 8) & 0xff);
      minor_swap = ((sb.st_rdev) & 0xff);
    } else {
      major_swap = 0;
      minor_swap = 0;
    }
  } else {
    major_swap = 0;
    minor_swap = 0;
  }
  fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
  fprintf(stderr, "Swap device is (%d, %d)\n", major_swap, minor_swap);
  if ((major_root != 2) && (major_root != 3) && (major_root != 0)) {
    fprintf(stderr, "Illegal root device (major = %d)\n", major_root);
    die("Bad root device --- major #");
  }
  if (major_swap && major_swap != 3) {
    fprintf(stderr, "Illegal swap device (major = %d)\n", major_swap);
    die("Bad root device --- major #");
  }
  for (i = 0; i < sizeof buf; i++)
    buf[i] = 0;
  if ((id = open(argv[1], O_RDONLY, 0)) < 0)
    die("Unable to open 'boot'");
  if (read(id, buf, 32) != 32)
    die("Unable to read header of 'boot'");
  if (((long *)buf)[0] != 0x04100301)
    die("Non-Minix header of 'boot'");
  if (((long *)buf)[1] != 32)
    die("Non-Minix header of 'boot'");
  if (((long *)buf)[3] != 0)
    die("Illegal data segment in 'boot'");
  if (((long *)buf)[4] != 0)
    die("Illegal bss in 'boot'");
  if (((long *)buf)[5] != 0)
    die("Non-Minix header of 'boot'");
  if (((long *)buf)[7] != 0)
    die("Illegal symbol table in 'boot'");
  i = read(id, buf, sizeof buf);
  fprintf(stderr, "Boot sector %d bytes.\n", i);
  if (i != 512)
    die("Boot block must be exactly 512 bytes");
  if ((*(unsigned short *)(buf + 510)) != 0xAA55)
    die("Boot block hasn't got boot flag (0xAA55)");
  buf[506] = (char)minor_swap;
  buf[507] = (char)major_swap;
  buf[508] = (char)minor_root;
  buf[509] = (char)major_root;
  i = write(1, buf, 512);
  if (i != 512)
    die("Write call failed");
  close(id);
  if ((id = open(argv[2], O_RDONLY, 0)) < 0)
    die("Unable to open 'setup'");
  if (read(id, buf, 32) != 32)
    die("Unable to read header of 'setup'");
  if (((long *)buf)[0] != 0x04100301)
    die("Non-Minix header of 'setup'");
  if (((long *)buf)[1] != 32)
    die("Non-Minix header of 'setup'");
  if (((long *)buf)[3] != 0)
    die("Illegal data segment in 'setup'");
  if (((long *)buf)[4] != 0)
    die("Illegal bss in 'setup'");
  if (((long *)buf)[5] != 0)
    die("Non-Minix header of 'setup'");
  if (((long *)buf)[7] != 0)
    die("Illegal symbol table in 'setup'");
  for (i = 0; (c = read(id, buf, sizeof buf)) > 0; i += c)
    if (write(1, buf, c) != c)
      die("Write call failed");
  close(id);
  if (i > 4 * 512)
    die("Setup exceeds "
        "SETUP_SECTS"
        " sectors - rewrite build/boot/setup");
  fprintf(stderr, "Setup is %d bytes.\n", i);
  for (c = 0; c < sizeof(buf); c++)
    buf[c] = '\0';
  while (i < 4 * 512) {
    c = 4 * 512 - i;
    if (c > sizeof(buf))
      c = sizeof(buf);
    if (write(1, buf, c) != c)
      die("Write call failed");
    i += c;
  }
  if ((id = open(argv[3], O_RDONLY, 0)) < 0)
    die("Unable to open 'system'");
  if (read(id, buf, 4096) != 4096)
    die("Unable to read header of 'system'");
  if (((long *)buf)[5] != 1)
    die("Non-GCC header of 'system'");
  for (i = 0; (c = read(id, buf, sizeof buf)) > 0; i += c)
    if (write(1, buf, c) != c)
      die("Write call failed");
  close(id);
  fprintf(stderr, "System is %d bytes.\n", i);
  if (i > 0x3000 * 16)
    die("System is too big");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     11cd <main+0x2d>
cmpl   $0x6,-0x8(%rbp)
jle    11d4 <main+0x34>
mov    $0x0,%al
call   1090 <usage@plt>
cmpl   $0x4,-0x8(%rbp)
jle    1270 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe13(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     125d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x1028(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
je     1233 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <perror@plt>
lea    0xdd9(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1028(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x1021(%rbp)
mov    -0x1028(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x1022(%rbp)
jmp    126b <main+0xcb>
movb   $0x0,-0x1021(%rbp)
movb   $0x0,-0x1022(%rbp)
jmp    127e <main+0xde>
movb   $0x2,-0x1021(%rbp)
movb   $0x1d,-0x1022(%rbp)
cmpl   $0x6,-0x8(%rbp)
jne    131a <main+0x17a>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xd8b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1307 <main+0x167>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    -0x1028(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
je     12dd <main+0x13d>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10c0 <perror@plt>
lea    0xd2f(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1028(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x1023(%rbp)
mov    -0x1028(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x1024(%rbp)
jmp    1315 <main+0x175>
movb   $0x0,-0x1023(%rbp)
movb   $0x0,-0x1024(%rbp)
jmp    1328 <main+0x188>
movb   $0x0,-0x1023(%rbp)
movb   $0x0,-0x1024(%rbp)
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
movsbl -0x1021(%rbp),%edx
movsbl -0x1022(%rbp),%ecx
lea    0xce1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
movsbl -0x1023(%rbp),%edx
movsbl -0x1024(%rbp),%ecx
lea    0xcd5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movsbl -0x1021(%rbp),%eax
cmp    $0x2,%eax
je     13cc <main+0x22c>
movsbl -0x1021(%rbp),%eax
cmp    $0x3,%eax
je     13cc <main+0x22c>
movsbl -0x1021(%rbp),%eax
cmp    $0x0,%eax
je     13cc <main+0x22c>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
movsbl -0x1021(%rbp),%edx
lea    0xca0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xcb4(%rip),%rdi
call   10b0 <die@plt>
movsbl -0x1023(%rbp),%eax
cmp    $0x0,%eax
je     1416 <main+0x276>
movsbl -0x1023(%rbp),%eax
cmp    $0x3,%eax
je     1416 <main+0x276>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
movsbl -0x1023(%rbp),%edx
lea    0xc94(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xc6a(%rip),%rdi
call   10b0 <die@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x1000,%rax
jae    1447 <main+0x2a7>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    141d <main+0x27d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2b92(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1477 <main+0x2d7>
lea    0xc47(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x20,%edx
call   1050 <read@plt>
cmp    $0x20,%eax
je     14a0 <main+0x300>
lea    0xc34(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x4100301,-0x1020(%rbp)
01 03 10 04
je     14bd <main+0x31d>
lea    0xc37(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x20,-0x1018(%rbp)
20
je     14d7 <main+0x337>
lea    0xc1d(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x1008(%rbp)
je     14f1 <main+0x351>
lea    0xc1e(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x1000(%rbp)
je     150b <main+0x36b>
lea    0xc23(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0xff8(%rbp)
je     1525 <main+0x385>
lea    0xbcf(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0xfe8(%rbp)
je     153f <main+0x39f>
lea    0xc05(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
mov    %eax,-0x14(%rbp)
mov    0x2a7b(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xbf5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x200,-0x14(%rbp)
je     1589 <main+0x3e9>
lea    0xbf1(%rip),%rdi
call   10b0 <die@plt>
movzwl -0xe22(%rbp),%eax
cmp    $0xaa55,%eax
je     15a7 <main+0x407>
lea    0xbf8(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1024(%rbp),%al
mov    %al,-0xe26(%rbp)
mov    -0x1023(%rbp),%al
mov    %al,-0xe25(%rbp)
mov    -0x1022(%rbp),%al
mov    %al,-0xe24(%rbp)
mov    -0x1021(%rbp),%al
mov    %al,-0xe23(%rbp)
lea    -0x1020(%rbp),%rsi
mov    $0x1,%edi
mov    $0x200,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
je     1609 <main+0x469>
lea    0xbbf(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x29c8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1641 <main+0x4a1>
lea    0xb99(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x20,%edx
call   1050 <read@plt>
cmp    $0x20,%eax
je     166a <main+0x4ca>
lea    0xb87(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x4100301,-0x1020(%rbp)
01 03 10 04
je     1687 <main+0x4e7>
lea    0xb8b(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x20,-0x1018(%rbp)
20
je     16a1 <main+0x501>
lea    0xb71(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x1008(%rbp)
je     16bb <main+0x51b>
lea    0xb73(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x1000(%rbp)
je     16d5 <main+0x535>
lea    0xb79(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0xff8(%rbp)
je     16ef <main+0x54f>
lea    0xb23(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0xfe8(%rbp)
je     1709 <main+0x569>
lea    0xb5c(%rip),%rdi
call   10b0 <die@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    176c <main+0x5cc>
lea    -0x1020(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     1759 <main+0x5b9>
lea    0xa6f(%rip),%rdi
call   10b0 <die@plt>
jmp    175e <main+0x5be>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1710 <main+0x570>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
cmpl   $0x800,-0x14(%rbp)
jle    178d <main+0x5ed>
lea    0xaf8(%rip),%rdi
call   10b0 <die@plt>
mov    0x2844(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xb1d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x1000,%rax
jae    17d8 <main+0x638>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    17ae <main+0x60e>
jmp    17dd <main+0x63d>
cmpl   $0x800,-0x14(%rbp)
jge    1843 <main+0x6a3>
mov    $0x800,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x1000,%rax
jbe    180c <main+0x66c>
movl   $0x1000,-0x18(%rbp)
lea    -0x1020(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     1835 <main+0x695>
lea    0x993(%rip),%rdi
call   10b0 <die@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    17dd <main+0x63d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2796(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1873 <main+0x6d3>
lea    0xa63(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
cmp    $0x1000,%eax
je     189e <main+0x6fe>
lea    0xa50(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x1,-0xff8(%rbp)
01
je     18b8 <main+0x718>
lea    0xa58(%rip),%rdi
call   10b0 <die@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    191b <main+0x77b>
lea    -0x1020(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     1908 <main+0x768>
lea    0x8c0(%rip),%rdi
call   10b0 <die@plt>
jmp    190d <main+0x76d>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    18bf <main+0x71f>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    0x26ae(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0x9f0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x30000,-0x14(%rbp)
jle    1956 <main+0x7b6>
lea    0x9ea(%rip),%rdi
call   10b0 <die@plt>
xor    %eax,%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    -0x7(%rbx),%eax
cmp    $0xfffffffc,%eax
ja     11d5 <main+0x25>
xor    %eax,%eax
call   10a0 <usage@plt>
cmp    $0x5,%ebx
mov    %rbp,0x8(%rsp)
jl     1222 <main+0x72>
mov    0x20(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     17b0 <main+0x600>
mov    0x20(%rbp),%rdi
mov    %rsp,%rsi
call   1090 <stat@plt>
test   %rax,%rax
jne    17f9 <main+0x649>
mov    (%rsp),%r12d
mov    %r12d,%r15d
shr    $0x8,%r15d
cmp    $0x6,%ebx
jne    1228 <main+0x78>
jmp    17bf <main+0x60f>
mov    $0x2,%r15b
mov    $0x1d,%r12b
xor    %r13d,%r13d
xor    %r14d,%r14d
mov    0x2da3(%rip),%rbx
mov    (%rbx),%edi
movsbl %r15b,%ebp
movsbl %r12b,%ecx
lea    0xde1(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
movsbl %r13b,%ebx
movsbl %r14b,%ecx
lea    0xde0(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
cmp    $0x3,%bpl
ja     127c <main+0xcc>
cmp    $0x1,%r15b
je     127c <main+0xcc>
test   %r13b,%r13b
jne    12a6 <main+0xf6>
jmp    12d1 <main+0x121>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    0xdcd(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xddf(%rip),%rdi
call   10c0 <die@plt>
test   %r13b,%r13b
je     12d1 <main+0x121>
cmp    $0x3,%r13b
je     12d1 <main+0x121>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xdaf(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x8(%rsp),%rax
mov    0x8(%rax),%rdi
mov    0x2cf6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    130d <main+0x15d>
lea    0xdb1(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x20,%edx
call   1060 <read@plt>
cmp    $0x20,%eax
jne    157f <main+0x3cf>
cmpq   $0x4100301,0x10(%rsp)
10 04
jne    159a <main+0x3ea>
cmpq   $0x20,0x18(%rsp)
jne    15b2 <main+0x402>
cmpq   $0x0,0x28(%rsp)
je     1356 <main+0x1a6>
lea    0xdb9(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x30(%rsp)
je     136a <main+0x1ba>
lea    0xdc4(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     137e <main+0x1ce>
lea    0xd76(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x48(%rsp)
je     1392 <main+0x1e2>
lea    0xdb2(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1000,%edx
call   1060 <read@plt>
mov    %eax,%ebx
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
lea    0xda9(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
cmp    $0x200,%ebx
je     13d2 <main+0x222>
lea    0xda8(%rip),%rdi
call   10c0 <die@plt>
movzwl 0x20e(%rsp),%eax
cmp    $0xaa55,%eax
je     13ed <main+0x23d>
lea    0xdb2(%rip),%rdi
call   10c0 <die@plt>
mov    %r14b,0x20a(%rsp)
mov    %r13b,0x20b(%rsp)
mov    %r12b,0x20c(%rsp)
mov    %r15b,0x20d(%rsp)
lea    0x10(%rsp),%rsi
mov    $0x1,%edi
mov    $0x200,%edx
call   1030 <write@plt>
cmp    $0x200,%eax
je     1434 <main+0x284>
lea    0xd94(%rip),%rdi
call   10c0 <die@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    0x8(%rsp),%r13
mov    0x10(%r13),%rdi
mov    0x2b9d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    1467 <main+0x2b7>
lea    0xd73(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x20,%edx
call   1060 <read@plt>
cmp    $0x20,%eax
jne    15cf <main+0x41f>
cmpq   $0x4100301,0x10(%rsp)
10 04
jne    15ea <main+0x43a>
cmpq   $0x20,0x18(%rsp)
jne    1602 <main+0x452>
cmpq   $0x0,0x28(%rsp)
je     14b1 <main+0x301>
lea    0xd7d(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x30(%rsp)
je     14c5 <main+0x315>
lea    0xd89(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     14d9 <main+0x329>
lea    0xd39(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x48(%rsp)
je     14ed <main+0x33d>
lea    0xd78(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1000,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    161f <main+0x46f>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0x10(%rsp),%r12
lea    0xcac(%rip),%r13
jmp    1538 <main+0x388>
nopl   0x0(%rax)
add    %ebp,%ebx
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1555 <main+0x3a5>
mov    $0x1,%edi
mov    %r12,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
cmp    %ebp,%eax
je     1520 <main+0x370>
mov    %r13,%rdi
call   10c0 <die@plt>
jmp    1520 <main+0x370>
mov    %r15d,%edi
call   1050 <close@plt>
cmp    $0x801,%ebx
mov    0x8(%rsp),%r13
jl     1629 <main+0x479>
lea    0xd0b(%rip),%rdi
call   10c0 <die@plt>
jmp    1629 <main+0x479>
lea    0xb49(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x4100301,0x10(%rsp)
10 04
je     1336 <main+0x186>
lea    0xb4e(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x20,0x18(%rsp)
je     1342 <main+0x192>
lea    0xb36(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x28(%rsp)
jne    134a <main+0x19a>
jmp    1356 <main+0x1a6>
lea    0xc16(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x4100301,0x10(%rsp)
10 04
je     1491 <main+0x2e1>
lea    0xc1c(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x20,0x18(%rsp)
je     149d <main+0x2ed>
lea    0xc04(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x28(%rsp)
jne    14a5 <main+0x2f5>
jmp    14b1 <main+0x301>
mov    %r15d,%edi
call   1050 <close@plt>
xor    %ebx,%ebx
mov    0x29a8(%rip),%rax
mov    (%rax),%edi
lea    0xc84(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0x10(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1040 <memset@plt>
cmp    $0x7ff,%ebx
jg     16a8 <main+0x4f8>
mov    $0x1000,%r14d
lea    0x10(%rsp),%r12
lea    0xb56(%rip),%r15
jmp    167a <main+0x4ca>
nop
add    %ebp,%ebx
cmp    $0x800,%ebx
jge    16a8 <main+0x4f8>
mov    $0x800,%ebp
sub    %ebx,%ebp
cmp    $0x1000,%ebp
cmovae %r14d,%ebp
mov    $0x1,%edi
mov    %r12,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
cmp    %ebp,%eax
je     1670 <main+0x4c0>
mov    %r15,%rdi
call   10c0 <die@plt>
jmp    1670 <main+0x4c0>
mov    0x18(%r13),%rdi
mov    0x2935(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    16cf <main+0x51f>
lea    0xc07(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1000,%edx
call   1060 <read@plt>
cmp    $0x1000,%eax
je     16f4 <main+0x544>
lea    0xbfa(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x1,0x38(%rsp)
je     1708 <main+0x558>
lea    0xc08(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1000,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    1765 <main+0x5b5>
mov    %eax,%ebx
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
lea    0xa95(%rip),%r12
jmp    1748 <main+0x598>
add    %ebx,%ebp
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1767 <main+0x5b7>
mov    $0x1,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    %ebx,%eax
je     1730 <main+0x580>
mov    %r12,%rdi
call   10c0 <die@plt>
jmp    1730 <main+0x580>
xor    %ebp,%ebp
mov    %r14d,%edi
call   1050 <close@plt>
mov    0x2862(%rip),%rax
mov    (%rax),%edi
lea    0xba7(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
cmp    $0x30001,%ebp
jl     179c <main+0x5ec>
lea    0xba4(%rip),%rdi
call   10c0 <die@plt>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r15d,%r15d
xor    %r12d,%r12d
cmp    $0x6,%ebx
jne    1228 <main+0x78>
mov    0x28(%rbp),%rdi
lea    0x858(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1228 <main+0x78>
mov    0x28(%rbp),%rdi
mov    %rsp,%rsi
call   1090 <stat@plt>
test   %rax,%rax
jne    1813 <main+0x663>
mov    (%rsp),%r14d
mov    %r14d,%r13d
shr    $0x8,%r13d
jmp    122e <main+0x7e>
mov    0x20(%rbp),%rdi
call   10d0 <perror@plt>
lea    0x7fe(%rip),%rdi
call   10c0 <die@plt>
jmp    120d <main+0x5d>
mov    0x28(%rbp),%rdi
call   10d0 <perror@plt>
lea    0x7e4(%rip),%rdi
call   10c0 <die@plt>
jmp    17e9 <main+0x639>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [7 x i8] c"FLOPPY\00"
@.str.1 = [27 x i8] c"Couldn't stat root device.\00"
@.str.2 = [5 x i8] c"NONE\00"
@stderr = global i32 0
@.str.3 = [25 x i8] c"Root device is (%d, %d)\0A\00"
@.str.4 = [25 x i8] c"Swap device is (%d, %d)\0A\00"
@.str.5 = [34 x i8] c"Illegal root device (major = %d)\0A\00"
@.str.6 = [28 x i8] c"Bad root device --- major #\00"
@.str.7 = [34 x i8] c"Illegal swap device (major = %d)\0A\00"
@O_RDONLY = global i32 0
@.str.8 = [22 x i8] c"Unable to open 'boot'\00"
@.str.9 = [32 x i8] c"Unable to read header of 'boot'\00"
@.str.10 = [27 x i8] c"Non-Minix header of 'boot'\00"
@.str.11 = [31 x i8] c"Illegal data segment in 'boot'\00"
@.str.12 = [22 x i8] c"Illegal bss in 'boot'\00"
@.str.13 = [31 x i8] c"Illegal symbol table in 'boot'\00"
@.str.14 = [23 x i8] c"Boot sector %d bytes.\0A\00"
@.str.15 = [37 x i8] c"Boot block must be exactly 512 bytes\00"
@.str.16 = [41 x i8] c"Boot block hasn't got boot flag (0xAA55)\00"
@.str.17 = [18 x i8] c"Write call failed\00"
@.str.18 = [23 x i8] c"Unable to open 'setup'\00"
@.str.19 = [33 x i8] c"Unable to read header of 'setup'\00"
@.str.20 = [28 x i8] c"Non-Minix header of 'setup'\00"
@.str.21 = [32 x i8] c"Illegal data segment in 'setup'\00"
@.str.22 = [23 x i8] c"Illegal bss in 'setup'\00"
@.str.23 = [32 x i8] c"Illegal symbol table in 'setup'\00"
@.str.24 = [61 x i8] c"Setup exceeds SETUP_SECTS sectors - rewrite build/boot/setup\00"
@.str.25 = [20 x i8] c"Setup is %d bytes.\0A\00"
@.str.26 = [24 x i8] c"Unable to open 'system'\00"
@.str.27 = [34 x i8] c"Unable to read header of 'system'\00"
@.str.28 = [27 x i8] c"Non-GCC header of 'system'\00"
@.str.29 = [21 x i8] c"System is %d bytes.\0A\00"
@.str.30 = [18 x i8] c"System is too big\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4096 x i8]
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
%14 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 4
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 6
br i1 %19, label %20, label %22
20: ; preds = %17, %2
%21 = call i32 (...) @usage()
br label %22
22: ; preds = %20, %17
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 4
br i1 %24, label %25, label %55
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 4
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %53
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 4
%34 = load i8*, i8** %33
%35 = call i64 @stat(i8* %34, %struct.stat* %14)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %31
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 4
%40 = load i8*, i8** %39
%41 = call i32 @perror(i8* %40)
%42 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %37, %31
%44 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%45 = load i32, i32* %44
%46 = ashr i32 %45, 8
%47 = and i32 %46, 255
%48 = trunc i32 %47 to i8
store i8 %48, i8* %10
%49 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%50 = load i32, i32* %49
%51 = and i32 %50, 255
%52 = trunc i32 %51 to i8
store i8 %52, i8* %11
br label %54
53: ; preds = %25
store i8 0, i8* %10
store i8 0, i8* %11
br label %54
54: ; preds = %53, %43
br label %56
55: ; preds = %22
store i8 2, i8* %10
store i8 29, i8* %11
br label %56
56: ; preds = %55, %54
%57 = load i32, i32* %4
%58 = icmp eq i32 %57, 6
br i1 %58, label %59, label %89
59: ; preds = %56
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 5
%62 = load i8*, i8** %61
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %87
65: ; preds = %59
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 5
%68 = load i8*, i8** %67
%69 = call i64 @stat(i8* %68, %struct.stat* %14)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %65
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 5
%74 = load i8*, i8** %73
%75 = call i32 @perror(i8* %74)
%76 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %77
77: ; preds = %71, %65
%78 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%79 = load i32, i32* %78
%80 = ashr i32 %79, 8
%81 = and i32 %80, 255
%82 = trunc i32 %81 to i8
store i8 %82, i8* %12
%83 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%84 = load i32, i32* %83
%85 = and i32 %84, 255
%86 = trunc i32 %85 to i8
store i8 %86, i8* %13
br label %88
87: ; preds = %59
store i8 0, i8* %12
store i8 0, i8* %13
br label %88
88: ; preds = %87, %77
br label %90
89: ; preds = %56
store i8 0, i8* %12
store i8 0, i8* %13
br label %90
90: ; preds = %89, %88
%91 = load i32, i32* @stderr
%92 = load i8, i8* %10
%93 = sext i8 %92 to i32
%94 = load i8, i8* %11
%95 = sext i8 %94 to i32
%96 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %93, i32 %95)
%97 = load i32, i32* @stderr
%98 = load i8, i8* %12
%99 = sext i8 %98 to i32
%100 = load i8, i8* %13
%101 = sext i8 %100 to i32
%102 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %99, i32 %101)
%103 = load i8, i8* %10
%104 = sext i8 %103 to i32
%105 = icmp ne i32 %104, 2
br i1 %105, label %106, label %120
106: ; preds = %90
%107 = load i8, i8* %10
%108 = sext i8 %107 to i32
%109 = icmp ne i32 %108, 3
br i1 %109, label %110, label %120
110: ; preds = %106
%111 = load i8, i8* %10
%112 = sext i8 %111 to i32
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %120
114: ; preds = %110
%115 = load i32, i32* @stderr
%116 = load i8, i8* %10
%117 = sext i8 %116 to i32
%118 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %117)
%119 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %120
120: ; preds = %114, %110, %106, %90
%121 = load i8, i8* %12
%122 = sext i8 %121 to i32
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %134
124: ; preds = %120
%125 = load i8, i8* %12
%126 = sext i8 %125 to i32
%127 = icmp ne i32 %126, 3
br i1 %127, label %128, label %134
128: ; preds = %124
%129 = load i32, i32* @stderr
%130 = load i8, i8* %12
%131 = sext i8 %130 to i32
%132 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %131)
%133 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %134
134: ; preds = %128, %124, %120
store i32 0, i32* %6
br label %135
135: ; preds = %143, %134
%136 = load i32, i32* %6
%137 = sext i32 %136 to i64
%138 = icmp ult i64 %137, 4096
br i1 %138, label %139, label %146
139: ; preds = %135
%140 = load i32, i32* %6
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 %141
store i8 0, i8* %142
br label %143
143: ; preds = %139
%144 = load i32, i32* %6
%145 = add nsw i32 %144, 1
store i32 %145, i32* %6
br label %135
146: ; preds = %135
%147 = load i8**, i8*** %5
%148 = getelementptr inbounds i8*, i8** %147, i64 1
%149 = load i8*, i8** %148
%150 = load i32, i32* @O_RDONLY
%151 = call i32 @open(i8* %149, i32 %150, i32 0)
store i32 %151, i32* %8
%152 = icmp slt i32 %151, 0
br i1 %152, label %153, label %155
153: ; preds = %146
%154 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
br label %155
155: ; preds = %153, %146
%156 = load i32, i32* %8
%157 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%158 = call i32 @read(i32 %156, i8* %157, i32 32)
%159 = icmp ne i32 %158, 32
br i1 %159, label %160, label %162
160: ; preds = %155
%161 = call i32 @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %162
162: ; preds = %160, %155
%163 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%164 = bitcast i8* %163 to i64*
%165 = getelementptr inbounds i64, i64* %164, i64 0
%166 = load i64, i64* %165
%167 = icmp ne i64 %166, 68158209
br i1 %167, label %168, label %170
168: ; preds = %162
%169 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %170
170: ; preds = %168, %162
%171 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%172 = bitcast i8* %171 to i64*
%173 = getelementptr inbounds i64, i64* %172, i64 1
%174 = load i64, i64* %173
%175 = icmp ne i64 %174, 32
br i1 %175, label %176, label %178
176: ; preds = %170
%177 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %178
178: ; preds = %176, %170
%179 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%180 = bitcast i8* %179 to i64*
%181 = getelementptr inbounds i64, i64* %180, i64 3
%182 = load i64, i64* %181
%183 = icmp ne i64 %182, 0
br i1 %183, label %184, label %186
184: ; preds = %178
%185 = call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0))
br label %186
186: ; preds = %184, %178
%187 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%188 = bitcast i8* %187 to i64*
%189 = getelementptr inbounds i64, i64* %188, i64 4
%190 = load i64, i64* %189
%191 = icmp ne i64 %190, 0
br i1 %191, label %192, label %194
192: ; preds = %186
%193 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0))
br label %194
194: ; preds = %192, %186
%195 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%196 = bitcast i8* %195 to i64*
%197 = getelementptr inbounds i64, i64* %196, i64 5
%198 = load i64, i64* %197
%199 = icmp ne i64 %198, 0
br i1 %199, label %200, label %202
200: ; preds = %194
%201 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %202
202: ; preds = %200, %194
%203 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%204 = bitcast i8* %203 to i64*
%205 = getelementptr inbounds i64, i64* %204, i64 7
%206 = load i64, i64* %205
%207 = icmp ne i64 %206, 0
br i1 %207, label %208, label %210
208: ; preds = %202
%209 = call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
br label %210
210: ; preds = %208, %202
%211 = load i32, i32* %8
%212 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%213 = call i32 @read(i32 %211, i8* %212, i32 4096)
store i32 %213, i32* %6
%214 = load i32, i32* @stderr
%215 = load i32, i32* %6
%216 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %214, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i32 %215)
%217 = load i32, i32* %6
%218 = icmp ne i32 %217, 512
br i1 %218, label %219, label %221
219: ; preds = %210
%220 = call i32 @die(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.15, i64 0, i64 0))
br label %221
221: ; preds = %219, %210
%222 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%223 = getelementptr inbounds i8, i8* %222, i64 510
%224 = bitcast i8* %223 to i16*
%225 = load i16, i16* %224
%226 = zext i16 %225 to i32
%227 = icmp ne i32 %226, 43605
br i1 %227, label %228, label %230
228: ; preds = %221
%229 = call i32 @die(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.16, i64 0, i64 0))
br label %230
230: ; preds = %228, %221
%231 = load i8, i8* %13
%232 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 506
store i8 %231, i8* %232
%233 = load i8, i8* %12
%234 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 507
store i8 %233, i8* %234
%235 = load i8, i8* %11
%236 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 508
store i8 %235, i8* %236
%237 = load i8, i8* %10
%238 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 509
store i8 %237, i8* %238
%239 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%240 = call i32 @write(i32 1, i8* %239, i32 512)
store i32 %240, i32* %6
%241 = load i32, i32* %6
%242 = icmp ne i32 %241, 512
br i1 %242, label %243, label %245
243: ; preds = %230
%244 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %245
245: ; preds = %243, %230
%246 = load i32, i32* %8
%247 = call i32 @close(i32 %246)
%248 = load i8**, i8*** %5
%249 = getelementptr inbounds i8*, i8** %248, i64 2
%250 = load i8*, i8** %249
%251 = load i32, i32* @O_RDONLY
%252 = call i32 @open(i8* %250, i32 %251, i32 0)
store i32 %252, i32* %8
%253 = icmp slt i32 %252, 0
br i1 %253, label %254, label %256
254: ; preds = %245
%255 = call i32 @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0))
br label %256
256: ; preds = %254, %245
%257 = load i32, i32* %8
%258 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%259 = call i32 @read(i32 %257, i8* %258, i32 32)
%260 = icmp ne i32 %259, 32
br i1 %260, label %261, label %263
261: ; preds = %256
%262 = call i32 @die(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.19, i64 0, i64 0))
br label %263
263: ; preds = %261, %256
%264 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%265 = bitcast i8* %264 to i64*
%266 = getelementptr inbounds i64, i64* %265, i64 0
%267 = load i64, i64* %266
%268 = icmp ne i64 %267, 68158209
br i1 %268, label %269, label %271
269: ; preds = %263
%270 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %271
271: ; preds = %269, %263
%272 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%273 = bitcast i8* %272 to i64*
%274 = getelementptr inbounds i64, i64* %273, i64 1
%275 = load i64, i64* %274
%276 = icmp ne i64 %275, 32
br i1 %276, label %277, label %279
277: ; preds = %271
%278 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %279
279: ; preds = %277, %271
%280 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%281 = bitcast i8* %280 to i64*
%282 = getelementptr inbounds i64, i64* %281, i64 3
%283 = load i64, i64* %282
%284 = icmp ne i64 %283, 0
br i1 %284, label %285, label %287
285: ; preds = %279
%286 = call i32 @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.21, i64 0, i64 0))
br label %287
287: ; preds = %285, %279
%288 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%289 = bitcast i8* %288 to i64*
%290 = getelementptr inbounds i64, i64* %289, i64 4
%291 = load i64, i64* %290
%292 = icmp ne i64 %291, 0
br i1 %292, label %293, label %295
293: ; preds = %287
%294 = call i32 @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.22, i64 0, i64 0))
br label %295
295: ; preds = %293, %287
%296 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%297 = bitcast i8* %296 to i64*
%298 = getelementptr inbounds i64, i64* %297, i64 5
%299 = load i64, i64* %298
%300 = icmp ne i64 %299, 0
br i1 %300, label %301, label %303
301: ; preds = %295
%302 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %303
303: ; preds = %301, %295
%304 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%305 = bitcast i8* %304 to i64*
%306 = getelementptr inbounds i64, i64* %305, i64 7
%307 = load i64, i64* %306
%308 = icmp ne i64 %307, 0
br i1 %308, label %309, label %311
309: ; preds = %303
%310 = call i32 @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.23, i64 0, i64 0))
br label %311
311: ; preds = %309, %303
store i32 0, i32* %6
br label %312
312: ; preds = %326, %311
%313 = load i32, i32* %8
%314 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%315 = call i32 @read(i32 %313, i8* %314, i32 4096)
store i32 %315, i32* %7
%316 = icmp sgt i32 %315, 0
br i1 %316, label %317, label %330
317: ; preds = %312
%318 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%319 = load i32, i32* %7
%320 = call i32 @write(i32 1, i8* %318, i32 %319)
%321 = load i32, i32* %7
%322 = icmp ne i32 %320, %321
br i1 %322, label %323, label %325
323: ; preds = %317
%324 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %325
325: ; preds = %323, %317
br label %326
326: ; preds = %325
%327 = load i32, i32* %7
%328 = load i32, i32* %6
%329 = add nsw i32 %328, %327
store i32 %329, i32* %6
br label %312
330: ; preds = %312
%331 = load i32, i32* %8
%332 = call i32 @close(i32 %331)
%333 = load i32, i32* %6
%334 = icmp sgt i32 %333, 2048
br i1 %334, label %335, label %337
335: ; preds = %330
%336 = call i32 @die(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.24, i64 0, i64 0))
br label %337
337: ; preds = %335, %330
%338 = load i32, i32* @stderr
%339 = load i32, i32* %6
%340 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %338, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.25, i64 0, i64 0), i32 %339)
store i32 0, i32* %7
br label %341
341: ; preds = %349, %337
%342 = load i32, i32* %7
%343 = sext i32 %342 to i64
%344 = icmp ult i64 %343, 4096
br i1 %344, label %345, label %352
345: ; preds = %341
%346 = load i32, i32* %7
%347 = sext i32 %346 to i64
%348 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 %347
store i8 0, i8* %348
br label %349
349: ; preds = %345
%350 = load i32, i32* %7
%351 = add nsw i32 %350, 1
store i32 %351, i32* %7
br label %341
352: ; preds = %341
br label %353
353: ; preds = %371, %352
%354 = load i32, i32* %6
%355 = icmp slt i32 %354, 2048
br i1 %355, label %356, label %375
356: ; preds = %353
%357 = load i32, i32* %6
%358 = sub nsw i32 2048, %357
store i32 %358, i32* %7
%359 = load i32, i32* %7
%360 = sext i32 %359 to i64
%361 = icmp ugt i64 %360, 4096
br i1 %361, label %362, label %363
362: ; preds = %356
store i32 4096, i32* %7
br label %363
363: ; preds = %362, %356
%364 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%365 = load i32, i32* %7
%366 = call i32 @write(i32 1, i8* %364, i32 %365)
%367 = load i32, i32* %7
%368 = icmp ne i32 %366, %367
br i1 %368, label %369, label %371
369: ; preds = %363
%370 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %371
371: ; preds = %369, %363
%372 = load i32, i32* %7
%373 = load i32, i32* %6
%374 = add nsw i32 %373, %372
store i32 %374, i32* %6
br label %353
375: ; preds = %353
%376 = load i8**, i8*** %5
%377 = getelementptr inbounds i8*, i8** %376, i64 3
%378 = load i8*, i8** %377
%379 = load i32, i32* @O_RDONLY
%380 = call i32 @open(i8* %378, i32 %379, i32 0)
store i32 %380, i32* %8
%381 = icmp slt i32 %380, 0
br i1 %381, label %382, label %384
382: ; preds = %375
%383 = call i32 @die(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.26, i64 0, i64 0))
br label %384
384: ; preds = %382, %375
%385 = load i32, i32* %8
%386 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%387 = call i32 @read(i32 %385, i8* %386, i32 4096)
%388 = icmp ne i32 %387, 4096
br i1 %388, label %389, label %391
389: ; preds = %384
%390 = call i32 @die(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.27, i64 0, i64 0))
br label %391
391: ; preds = %389, %384
%392 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%393 = bitcast i8* %392 to i64*
%394 = getelementptr inbounds i64, i64* %393, i64 5
%395 = load i64, i64* %394
%396 = icmp ne i64 %395, 1
br i1 %396, label %397, label %399
397: ; preds = %391
%398 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.28, i64 0, i64 0))
br label %399
399: ; preds = %397, %391
store i32 0, i32* %6
br label %400
400: ; preds = %414, %399
%401 = load i32, i32* %8
%402 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%403 = call i32 @read(i32 %401, i8* %402, i32 4096)
store i32 %403, i32* %7
%404 = icmp sgt i32 %403, 0
br i1 %404, label %405, label %418
405: ; preds = %400
%406 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%407 = load i32, i32* %7
%408 = call i32 @write(i32 1, i8* %406, i32 %407)
%409 = load i32, i32* %7
%410 = icmp ne i32 %408, %409
br i1 %410, label %411, label %413
411: ; preds = %405
%412 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %413
413: ; preds = %411, %405
br label %414
414: ; preds = %413
%415 = load i32, i32* %7
%416 = load i32, i32* %6
%417 = add nsw i32 %416, %415
store i32 %417, i32* %6
br label %400
418: ; preds = %400
%419 = load i32, i32* %8
%420 = call i32 @close(i32 %419)
%421 = load i32, i32* @stderr
%422 = load i32, i32* %6
%423 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %421, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i32 %422)
%424 = load i32, i32* %6
%425 = icmp sgt i32 %424, 196608
br i1 %425, label %426, label %428
426: ; preds = %418
%427 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.30, i64 0, i64 0))
br label %428
428: ; preds = %426, %418
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [7 x i8] c"FLOPPY\00"
@.str.1 = [27 x i8] c"Couldn't stat root device.\00"
@.str.2 = [5 x i8] c"NONE\00"
@stderr = global i32 0
@.str.3 = [25 x i8] c"Root device is (%d, %d)\0A\00"
@.str.4 = [25 x i8] c"Swap device is (%d, %d)\0A\00"
@.str.5 = [34 x i8] c"Illegal root device (major = %d)\0A\00"
@.str.6 = [28 x i8] c"Bad root device --- major #\00"
@.str.7 = [34 x i8] c"Illegal swap device (major = %d)\0A\00"
@O_RDONLY = global i32 0
@.str.8 = [22 x i8] c"Unable to open 'boot'\00"
@.str.9 = [32 x i8] c"Unable to read header of 'boot'\00"
@.str.10 = [27 x i8] c"Non-Minix header of 'boot'\00"
@.str.11 = [31 x i8] c"Illegal data segment in 'boot'\00"
@.str.12 = [22 x i8] c"Illegal bss in 'boot'\00"
@.str.13 = [31 x i8] c"Illegal symbol table in 'boot'\00"
@.str.14 = [23 x i8] c"Boot sector %d bytes.\0A\00"
@.str.15 = [37 x i8] c"Boot block must be exactly 512 bytes\00"
@.str.16 = [41 x i8] c"Boot block hasn't got boot flag (0xAA55)\00"
@.str.17 = [18 x i8] c"Write call failed\00"
@.str.18 = [23 x i8] c"Unable to open 'setup'\00"
@.str.19 = [33 x i8] c"Unable to read header of 'setup'\00"
@.str.20 = [28 x i8] c"Non-Minix header of 'setup'\00"
@.str.21 = [32 x i8] c"Illegal data segment in 'setup'\00"
@.str.22 = [23 x i8] c"Illegal bss in 'setup'\00"
@.str.23 = [32 x i8] c"Illegal symbol table in 'setup'\00"
@.str.24 = [61 x i8] c"Setup exceeds SETUP_SECTS sectors - rewrite build/boot/setup\00"
@.str.25 = [20 x i8] c"Setup is %d bytes.\0A\00"
@.str.26 = [24 x i8] c"Unable to open 'system'\00"
@.str.27 = [34 x i8] c"Unable to read header of 'system'\00"
@.str.28 = [27 x i8] c"Non-GCC header of 'system'\00"
@.str.29 = [21 x i8] c"System is %d bytes.\0A\00"
@.str.30 = [18 x i8] c"System is too big\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = alloca %struct.stat
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.stat* %5 to i8*
%8 = add i32 %0, -7
%9 = icmp ult i32 %8, -3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (...) @usage()
br label %12
12: ; preds = %2, %10
%13 = icmp sgt i32 %0, 4
br i1 %13, label %14, label %56
14: ; preds = %12
%15 = getelementptr inbounds i8*, i8** %1, i64 4
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %33, label %19
19: ; preds = %14
%20 = load i8*, i8** %15
%21 = call i64 @stat(i8* %20, %struct.stat* %5)
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i8*, i8** %15
%25 = call i32 @perror(i8* %24)
%26 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %23, %19
%28 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%29 = load i32, i32* %28
%30 = lshr i32 %29, 8
%31 = trunc i32 %30 to i8
%32 = trunc i32 %29 to i8
br label %33
33: ; preds = %14, %27
%34 = phi i8 [ %31, %27 ], [ 0, %14 ]
%35 = phi i8 [ %32, %27 ], [ 0, %14 ]
%36 = icmp eq i32 %0, 6
br i1 %36, label %37, label %56
37: ; preds = %33
%38 = getelementptr inbounds i8*, i8** %1, i64 5
%39 = load i8*, i8** %38
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %56, label %42
42: ; preds = %37
%43 = load i8*, i8** %38
%44 = call i64 @stat(i8* %43, %struct.stat* %5)
%45 = icmp eq i64 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %42
%47 = load i8*, i8** %38
%48 = call i32 @perror(i8* %47)
%49 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %46, %42
%51 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%52 = load i32, i32* %51
%53 = lshr i32 %52, 8
%54 = trunc i32 %53 to i8
%55 = trunc i32 %52 to i8
br label %56
56: ; preds = %12, %33, %37, %50
%57 = phi i8 [ %35, %50 ], [ %35, %37 ], [ %35, %33 ], [ 29, %12 ]
%58 = phi i8 [ %34, %50 ], [ %34, %37 ], [ %34, %33 ], [ 2, %12 ]
%59 = phi i8 [ %54, %50 ], [ 0, %37 ], [ 0, %33 ], [ 0, %12 ]
%60 = phi i8 [ %55, %50 ], [ 0, %37 ], [ 0, %33 ], [ 0, %12 ]
%61 = load i32, i32* @stderr
%62 = sext i8 %58 to i32
%63 = sext i8 %57 to i32
%64 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %62, i32 %63)
%65 = load i32, i32* @stderr
%66 = sext i8 %59 to i32
%67 = sext i8 %60 to i32
%68 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %66, i32 %67)
switch i8 %58, label %69 [
i8 3, label %73
i8 2, label %73
i8 0, label %73
]
69: ; preds = %56
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %62)
%72 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %73
73: ; preds = %56, %56, %56, %69
switch i8 %59, label %74 [
i8 3, label %78
i8 0, label %78
]
74: ; preds = %73
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %66)
%77 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %78
78: ; preds = %73, %73, %74
%79 = getelementptr inbounds i8*, i8** %1, i64 1
%80 = load i8*, i8** %79
%81 = load i32, i32* @O_RDONLY
%82 = call i32 @open(i8* %80, i32 %81, i32 0)
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %78
%85 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
br label %86
86: ; preds = %84, %78
%87 = call i32 @read(i32 %82, i8* %6, i32 32)
%88 = icmp eq i32 %87, 32
br i1 %88, label %91, label %89
89: ; preds = %86
%90 = call i32 @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %91
91: ; preds = %89, %86
%92 = bitcast [4096 x i8]* %3 to i64*
%93 = load i64, i64* %92
%94 = icmp eq i64 %93, 68158209
br i1 %94, label %97, label %95
95: ; preds = %91
%96 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %97
97: ; preds = %95, %91
%98 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 8
%99 = bitcast i8* %98 to i64*
%100 = load i64, i64* %99
%101 = icmp eq i64 %100, 32
br i1 %101, label %104, label %102
102: ; preds = %97
%103 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %104
104: ; preds = %102, %97
%105 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 24
%106 = bitcast i8* %105 to i64*
%107 = load i64, i64* %106
%108 = icmp eq i64 %107, 0
br i1 %108, label %111, label %109
109: ; preds = %104
%110 = call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0))
br label %111
111: ; preds = %109, %104
%112 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 32
%113 = bitcast i8* %112 to i64*
%114 = load i64, i64* %113
%115 = icmp eq i64 %114, 0
br i1 %115, label %118, label %116
116: ; preds = %111
%117 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0))
br label %118
118: ; preds = %116, %111
%119 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 40
%120 = bitcast i8* %119 to i64*
%121 = load i64, i64* %120
%122 = icmp eq i64 %121, 0
br i1 %122, label %125, label %123
123: ; preds = %118
%124 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %125
125: ; preds = %123, %118
%126 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 56
%127 = bitcast i8* %126 to i64*
%128 = load i64, i64* %127
%129 = icmp eq i64 %128, 0
br i1 %129, label %132, label %130
130: ; preds = %125
%131 = call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
br label %132
132: ; preds = %130, %125
%133 = call i32 @read(i32 %82, i8* %6, i32 4096)
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i32 %133)
%136 = icmp eq i32 %133, 512
br i1 %136, label %139, label %137
137: ; preds = %132
%138 = call i32 @die(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.15, i64 0, i64 0))
br label %139
139: ; preds = %137, %132
%140 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 510
%141 = bitcast i8* %140 to i16*
%142 = load i16, i16* %141
%143 = icmp eq i16 %142, -21931
br i1 %143, label %146, label %144
144: ; preds = %139
%145 = call i32 @die(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.16, i64 0, i64 0))
br label %146
146: ; preds = %144, %139
%147 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 506
store i8 %60, i8* %147
%148 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 507
store i8 %59, i8* %148
%149 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 508
store i8 %57, i8* %149
%150 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 509
store i8 %58, i8* %150
%151 = call i32 @write(i32 1, i8* %6, i32 512)
%152 = icmp eq i32 %151, 512
br i1 %152, label %155, label %153
153: ; preds = %146
%154 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %155
155: ; preds = %153, %146
%156 = call i32 @close(i32 %82)
%157 = getelementptr inbounds i8*, i8** %1, i64 2
%158 = load i8*, i8** %157
%159 = load i32, i32* @O_RDONLY
%160 = call i32 @open(i8* %158, i32 %159, i32 0)
%161 = icmp slt i32 %160, 0
br i1 %161, label %162, label %164
162: ; preds = %155
%163 = call i32 @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0))
br label %164
164: ; preds = %162, %155
%165 = call i32 @read(i32 %160, i8* %6, i32 32)
%166 = icmp eq i32 %165, 32
br i1 %166, label %169, label %167
167: ; preds = %164
%168 = call i32 @die(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.19, i64 0, i64 0))
br label %169
169: ; preds = %167, %164
%170 = load i64, i64* %92
%171 = icmp eq i64 %170, 68158209
br i1 %171, label %174, label %172
172: ; preds = %169
%173 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %174
174: ; preds = %172, %169
%175 = load i64, i64* %99
%176 = icmp eq i64 %175, 32
br i1 %176, label %179, label %177
177: ; preds = %174
%178 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %179
179: ; preds = %177, %174
%180 = load i64, i64* %106
%181 = icmp eq i64 %180, 0
br i1 %181, label %184, label %182
182: ; preds = %179
%183 = call i32 @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.21, i64 0, i64 0))
br label %184
184: ; preds = %182, %179
%185 = load i64, i64* %113
%186 = icmp eq i64 %185, 0
br i1 %186, label %189, label %187
187: ; preds = %184
%188 = call i32 @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.22, i64 0, i64 0))
br label %189
189: ; preds = %187, %184
%190 = load i64, i64* %120
%191 = icmp eq i64 %190, 0
br i1 %191, label %194, label %192
192: ; preds = %189
%193 = call i32 @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %194
194: ; preds = %192, %189
%195 = load i64, i64* %127
%196 = icmp eq i64 %195, 0
br i1 %196, label %199, label %197
197: ; preds = %194
%198 = call i32 @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.23, i64 0, i64 0))
br label %199
199: ; preds = %197, %194
%200 = call i32 @read(i32 %160, i8* %6, i32 4096)
%201 = icmp sgt i32 %200, 0
br i1 %201, label %204, label %202
202: ; preds = %199
%203 = call i32 @close(i32 %160)
br label %220
204: ; preds = %199, %211
%205 = phi i32 [ %213, %211 ], [ %200, %199 ]
%206 = phi i32 [ %212, %211 ], [ 0, %199 ]
%207 = call i32 @write(i32 1, i8* %6, i32 %205)
%208 = icmp eq i32 %207, %205
br i1 %208, label %211, label %209
209: ; preds = %204
%210 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %211
211: ; preds = %204, %209
%212 = add nsw i32 %205, %206
%213 = call i32 @read(i32 %160, i8* %6, i32 4096)
%214 = icmp sgt i32 %213, 0
br i1 %214, label %204, label %215
215: ; preds = %211
%216 = call i32 @close(i32 %160)
%217 = icmp sgt i32 %212, 2048
br i1 %217, label %218, label %220
218: ; preds = %215
%219 = call i32 @die(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.24, i64 0, i64 0))
br label %220
220: ; preds = %202, %218, %215
%221 = phi i32 [ 0, %202 ], [ %212, %218 ], [ %212, %215 ]
%222 = load i32, i32* @stderr
%223 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %222, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.25, i64 0, i64 0), i32 %221)
%224 = icmp slt i32 %221, 2048
br i1 %224, label %225, label %237
225: ; preds = %220, %234
%226 = phi i32 [ %235, %234 ], [ %221, %220 ]
%227 = sub nsw i32 2048, %226
%228 = icmp ult i32 %227, 4096
%229 = select i1 %228, i32 %227, i32 4096
%230 = call i32 @write(i32 1, i8* %6, i32 %229)
%231 = icmp eq i32 %230, %229
br i1 %231, label %234, label %232
232: ; preds = %225
%233 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %234
234: ; preds = %232, %225
%235 = add nsw i32 %229, %226
%236 = icmp slt i32 %235, 2048
br i1 %236, label %225, label %237
237: ; preds = %234, %220
%238 = getelementptr inbounds i8*, i8** %1, i64 3
%239 = load i8*, i8** %238
%240 = load i32, i32* @O_RDONLY
%241 = call i32 @open(i8* %239, i32 %240, i32 0)
%242 = icmp slt i32 %241, 0
br i1 %242, label %243, label %245
243: ; preds = %237
%244 = call i32 @die(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.26, i64 0, i64 0))
br label %245
245: ; preds = %243, %237
%246 = call i32 @read(i32 %241, i8* %6, i32 4096)
%247 = icmp eq i32 %246, 4096
br i1 %247, label %250, label %248
248: ; preds = %245
%249 = call i32 @die(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.27, i64 0, i64 0))
br label %250
250: ; preds = %248, %245
%251 = load i64, i64* %120
%252 = icmp eq i64 %251, 1
br i1 %252, label %255, label %253
253: ; preds = %250
%254 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.28, i64 0, i64 0))
br label %255
255: ; preds = %253, %250
%256 = call i32 @read(i32 %241, i8* %6, i32 4096)
%257 = icmp sgt i32 %256, 0
br i1 %257, label %258, label %269
258: ; preds = %255, %265
%259 = phi i32 [ %267, %265 ], [ %256, %255 ]
%260 = phi i32 [ %266, %265 ], [ 0, %255 ]
%261 = call i32 @write(i32 1, i8* %6, i32 %259)
%262 = icmp eq i32 %261, %259
br i1 %262, label %265, label %263
263: ; preds = %258
%264 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %265
265: ; preds = %258, %263
%266 = add nsw i32 %259, %260
%267 = call i32 @read(i32 %241, i8* %6, i32 4096)
%268 = icmp sgt i32 %267, 0
br i1 %268, label %258, label %269
269: ; preds = %265, %255
%270 = phi i32 [ 0, %255 ], [ %266, %265 ]
%271 = call i32 @close(i32 %241)
%272 = load i32, i32* @stderr
%273 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %272, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i32 %270)
%274 = icmp sgt i32 %270, 196608
br i1 %274, label %275, label %277
275: ; preds = %269
%276 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.30, i64 0, i64 0))
br label %277
277: ; preds = %275, %269
ret i32 0
}