#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[1024];
  char major_root, minor_root;
  struct stat sb;
  if ((argc != 4) && (argc != 5))
    usage();
  if (argc == 5) {
    if (strcmp(argv[4], "FLOPPY")) {
      if (stat(argv[4], &sb)) {
        perror(argv[4]);
        die("Couldn't stat root device.");
      }
      major_root = (((unsigned)(sb.st_rdev)) >> 8);
      minor_root = ((sb.st_rdev) & 0xff);
    } else {
      major_root = 0;
      minor_root = 0;
    }
  } else {
    major_root = 3;
    minor_root = 6;
  }
  fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
  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 #");
  }
  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[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, 1024) != 1024)
    die("Unable to read header of 'system'");
  if (((long *)buf)[5] != 0)
    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 > 0x2000 * 16)
    die("System is too big");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11d4 <main+0x34>
cmpl   $0x5,-0x8(%rbp)
je     11d4 <main+0x34>
mov    $0x0,%al
call   1090 <usage@plt>
cmpl   $0x5,-0x8(%rbp)
jne    126b <main+0xcb>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe13(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1258 <main+0xb8>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x428(%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    -0x428(%rbp),%eax
shr    $0x8,%eax
mov    %al,-0x421(%rbp)
mov    -0x428(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x422(%rbp)
jmp    1266 <main+0xc6>
movb   $0x0,-0x421(%rbp)
movb   $0x0,-0x422(%rbp)
jmp    1279 <main+0xd9>
movb   $0x3,-0x421(%rbp)
movb   $0x6,-0x422(%rbp)
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
movsbl -0x421(%rbp),%edx
movsbl -0x422(%rbp),%ecx
lea    0xd8b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movsbl -0x421(%rbp),%eax
cmp    $0x2,%eax
je     12f8 <main+0x158>
movsbl -0x421(%rbp),%eax
cmp    $0x3,%eax
je     12f8 <main+0x158>
movsbl -0x421(%rbp),%eax
cmp    $0x0,%eax
je     12f8 <main+0x158>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
movsbl -0x421(%rbp),%edx
lea    0xd56(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xd6a(%rip),%rdi
call   10b0 <die@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x400,%rax
jae    1329 <main+0x189>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12ff <main+0x15f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2cb0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1359 <main+0x1b9>
lea    0xd25(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x20,%edx
call   1050 <read@plt>
cmp    $0x20,%eax
je     1382 <main+0x1e2>
lea    0xd12(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x4100301,-0x420(%rbp)
01 03 10 04
je     139f <main+0x1ff>
lea    0xd15(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x20,-0x418(%rbp)
20
je     13b9 <main+0x219>
lea    0xcfb(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x408(%rbp)
je     13d3 <main+0x233>
lea    0xcfc(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x400(%rbp)
je     13ed <main+0x24d>
lea    0xd01(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x3f8(%rbp)
je     1407 <main+0x267>
lea    0xcad(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x3e8(%rbp)
je     1421 <main+0x281>
lea    0xce3(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x14(%rbp)
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xcd3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x200,-0x14(%rbp)
je     146b <main+0x2cb>
lea    0xccf(%rip),%rdi
call   10b0 <die@plt>
movzwl -0x222(%rbp),%eax
cmp    $0xaa55,%eax
je     1489 <main+0x2e9>
lea    0xcd6(%rip),%rdi
call   10b0 <die@plt>
mov    -0x422(%rbp),%al
mov    %al,-0x224(%rbp)
mov    -0x421(%rbp),%al
mov    %al,-0x223(%rbp)
lea    -0x420(%rbp),%rsi
mov    $0x1,%edi
mov    $0x200,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
je     14d3 <main+0x333>
lea    0xcb5(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2afe(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    150b <main+0x36b>
lea    0xc8f(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x20,%edx
call   1050 <read@plt>
cmp    $0x20,%eax
je     1534 <main+0x394>
lea    0xc7d(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x4100301,-0x420(%rbp)
01 03 10 04
je     1551 <main+0x3b1>
lea    0xc81(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x20,-0x418(%rbp)
20
je     156b <main+0x3cb>
lea    0xc67(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x408(%rbp)
je     1585 <main+0x3e5>
lea    0xc69(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x400(%rbp)
je     159f <main+0x3ff>
lea    0xc6f(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x3f8(%rbp)
je     15b9 <main+0x419>
lea    0xc19(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x3e8(%rbp)
je     15d3 <main+0x433>
lea    0xc52(%rip),%rdi
call   10b0 <die@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    1636 <main+0x496>
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     1623 <main+0x483>
lea    0xb65(%rip),%rdi
call   10b0 <die@plt>
jmp    1628 <main+0x488>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    15da <main+0x43a>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
cmpl   $0x800,-0x14(%rbp)
jle    1657 <main+0x4b7>
lea    0xbee(%rip),%rdi
call   10b0 <die@plt>
mov    0x297a(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xc13(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x400,%rax
jae    16a2 <main+0x502>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1678 <main+0x4d8>
jmp    16a7 <main+0x507>
cmpl   $0x800,-0x14(%rbp)
jge    170d <main+0x56d>
mov    $0x800,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x400,%rax
jbe    16d6 <main+0x536>
movl   $0x400,-0x18(%rbp)
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     16ff <main+0x55f>
lea    0xa89(%rip),%rdi
call   10b0 <die@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    16a7 <main+0x507>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x28cc(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    173d <main+0x59d>
lea    0xb59(%rip),%rdi
call   10b0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
cmp    $0x400,%eax
je     1768 <main+0x5c8>
lea    0xb46(%rip),%rdi
call   10b0 <die@plt>
cmpq   $0x0,-0x3f8(%rbp)
je     1782 <main+0x5e2>
lea    0xb4e(%rip),%rdi
call   10b0 <die@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    17e5 <main+0x645>
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     17d2 <main+0x632>
lea    0x9b6(%rip),%rdi
call   10b0 <die@plt>
jmp    17d7 <main+0x637>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1789 <main+0x5e9>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    0x27e4(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xae6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x20000,-0x14(%rbp)
jle    1820 <main+0x680>
lea    0xae0(%rip),%rdi
call   10b0 <die@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x4,%eax
je     11d7 <main+0x27>
xor    %eax,%eax
call   10a0 <usage@plt>
cmp    $0x5,%ebx
jne    1266 <main+0xb6>
mov    0x20(%r14),%rdi
lea    0xe15(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     126e <main+0xbe>
mov    0x20(%r14),%rdi
lea    0x8(%rsp),%rsi
call   1090 <stat@plt>
test   %rax,%rax
jne    1750 <main+0x5a0>
mov    0x8(%rsp),%r12d
mov    %r12d,%r15d
shr    $0x8,%r15d
mov    0x2db9(%rip),%rbp
mov    0x0(%rbp),%edi
movsbl %r15b,%ebx
movsbl %r12b,%ecx
lea    0xdf1(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
cmp    $0x3,%bl
ja     1245 <main+0x95>
cmp    $0x1,%r15b
jne    1293 <main+0xe3>
mov    0x0(%rbp),%edi
lea    0xdec(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xdfe(%rip),%rdi
call   10c0 <die@plt>
jmp    1293 <main+0xe3>
mov    $0x6,%r12b
mov    $0x3,%r15b
jmp    1274 <main+0xc4>
xor    %r15d,%r15d
xor    %r12d,%r12d
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
movzbl %r15b,%edx
movzbl %r12b,%ecx
lea    0xd96(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x8(%r14),%rdi
mov    0x2d39(%rip),%r13
mov    0x0(%r13),%esi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    12cc <main+0x11c>
lea    0xdb2(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x20,%edx
call   1060 <read@plt>
cmp    $0x20,%eax
jne    151a <main+0x36a>
cmpq   $0x4100301,0x10(%rsp)
10 04
jne    1535 <main+0x385>
cmpq   $0x20,0x18(%rsp)
jne    154d <main+0x39d>
cmpq   $0x0,0x28(%rsp)
je     1315 <main+0x165>
lea    0xdba(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x30(%rsp)
je     1329 <main+0x179>
lea    0xdc5(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     133d <main+0x18d>
lea    0xd77(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x48(%rsp)
je     1351 <main+0x1a1>
lea    0xdb3(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,%ebx
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
cmp    $0x200,%ebx
je     1391 <main+0x1e1>
lea    0xda9(%rip),%rdi
call   10c0 <die@plt>
movzwl 0x20e(%rsp),%eax
cmp    $0xaa55,%eax
je     13ac <main+0x1fc>
lea    0xdb3(%rip),%rdi
call   10c0 <die@plt>
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     13e3 <main+0x233>
lea    0xda5(%rip),%rdi
call   10c0 <die@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    0x10(%r14),%rdi
mov    0x0(%r13),%esi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    140c <main+0x25c>
lea    0xd8e(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x20,%edx
call   1060 <read@plt>
cmp    $0x20,%eax
jne    156a <main+0x3ba>
cmpq   $0x4100301,0x10(%rsp)
10 04
jne    1585 <main+0x3d5>
cmpq   $0x20,0x18(%rsp)
jne    159d <main+0x3ed>
cmpq   $0x0,0x28(%rsp)
je     1456 <main+0x2a6>
lea    0xd98(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x30(%rsp)
je     146a <main+0x2ba>
lea    0xda4(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     147e <main+0x2ce>
lea    0xd54(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x48(%rsp)
je     1492 <main+0x2e2>
lea    0xd93(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x400,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    15ba <main+0x40a>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0x10(%rsp),%r12
lea    0xcc7(%rip),%r13
jmp    14d8 <main+0x328>
xchg   %ax,%ax
add    %ebp,%ebx
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    14f5 <main+0x345>
mov    $0x1,%edi
mov    %r12,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
cmp    %ebp,%eax
je     14c0 <main+0x310>
mov    %r13,%rdi
call   10c0 <die@plt>
jmp    14c0 <main+0x310>
mov    %r15d,%edi
call   1050 <close@plt>
cmp    $0x801,%ebx
jl     15c4 <main+0x414>
lea    0xd30(%rip),%rdi
call   10c0 <die@plt>
jmp    15c4 <main+0x414>
lea    0xb6e(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x4100301,0x10(%rsp)
10 04
je     12f5 <main+0x145>
lea    0xb73(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x20,0x18(%rsp)
je     1301 <main+0x151>
lea    0xb5b(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x28(%rsp)
jne    1309 <main+0x159>
jmp    1315 <main+0x165>
lea    0xc3b(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x4100301,0x10(%rsp)
10 04
je     1436 <main+0x286>
lea    0xc41(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x20,0x18(%rsp)
je     1442 <main+0x292>
lea    0xc29(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x28(%rsp)
jne    144a <main+0x29a>
jmp    1456 <main+0x2a6>
mov    %r15d,%edi
call   1050 <close@plt>
xor    %ebx,%ebx
mov    0x2a0d(%rip),%rax
mov    (%rax),%edi
lea    0xca9(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
cmp    $0x7ff,%ebx
jg     1648 <main+0x498>
mov    $0x400,%r13d
lea    0x10(%rsp),%r12
lea    0xb7b(%rip),%r15
jmp    161a <main+0x46a>
nopw   0x0(%rax,%rax,1)
add    %ebp,%ebx
cmp    $0x800,%ebx
jge    1648 <main+0x498>
mov    $0x800,%ebp
sub    %ebx,%ebp
cmp    $0x400,%ebp
cmovae %r13d,%ebp
mov    $0x1,%edi
mov    %r12,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
cmp    %ebp,%eax
je     1610 <main+0x460>
mov    %r15,%rdi
call   10c0 <die@plt>
jmp    1610 <main+0x460>
mov    0x18(%r14),%rdi
mov    0x2995(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    166f <main+0x4bf>
lea    0xc27(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1060 <read@plt>
cmp    $0x400,%eax
je     1694 <main+0x4e4>
lea    0xc1a(%rip),%rdi
call   10c0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     16a8 <main+0x4f8>
lea    0xc28(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    1705 <main+0x555>
mov    %eax,%ebx
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
lea    0xab5(%rip),%r12
jmp    16e8 <main+0x538>
add    %ebx,%ebp
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1707 <main+0x557>
mov    $0x1,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    %ebx,%eax
je     16d0 <main+0x520>
mov    %r12,%rdi
call   10c0 <die@plt>
jmp    16d0 <main+0x520>
xor    %ebp,%ebp
mov    %r14d,%edi
call   1050 <close@plt>
mov    0x28c2(%rip),%rax
mov    (%rax),%edi
lea    0xbc7(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
cmp    $0x20001,%ebp
jl     173c <main+0x58c>
lea    0xbc4(%rip),%rdi
call   10c0 <die@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x20(%r14),%rdi
call   10d0 <perror@plt>
lea    0x8a7(%rip),%rdi
call   10c0 <die@plt>
jmp    120c <main+0x5c>

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