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

/* Variables and functions */
char MAJOR(int /*<<< orphan*/);
char MINOR(int /*<<< orphan*/);
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 = MAJOR(sb.st_rdev);
      minor_root = MINOR(sb.st_rdev);
    } 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     11f4 <main+0x34>
cmpl   $0x5,-0x8(%rbp)
je     11f4 <main+0x34>
mov    $0x0,%al
call   10b0 <usage@plt>
cmpl   $0x5,-0x8(%rbp)
jne    128d <main+0xcd>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xdf3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     127a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x428(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0x0,%rax
je     1253 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10e0 <perror@plt>
lea    0xdb9(%rip),%rdi
call   10d0 <die@plt>
mov    -0x428(%rbp),%edi
call   1040 <MAJOR@plt>
mov    %al,-0x421(%rbp)
mov    -0x428(%rbp),%edi
call   1080 <MINOR@plt>
mov    %al,-0x422(%rbp)
jmp    1288 <main+0xc8>
movb   $0x0,-0x421(%rbp)
movb   $0x0,-0x422(%rbp)
jmp    129b <main+0xdb>
movb   $0x3,-0x421(%rbp)
movb   $0x6,-0x422(%rbp)
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
movsbl -0x421(%rbp),%edx
movsbl -0x422(%rbp),%ecx
lea    0xd69(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movsbl -0x421(%rbp),%eax
cmp    $0x2,%eax
je     131a <main+0x15a>
movsbl -0x421(%rbp),%eax
cmp    $0x3,%eax
je     131a <main+0x15a>
movsbl -0x421(%rbp),%eax
cmp    $0x0,%eax
je     131a <main+0x15a>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
movsbl -0x421(%rbp),%edx
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    0xd48(%rip),%rdi
call   10d0 <die@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x400,%rax
jae    134b <main+0x18b>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1321 <main+0x161>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2c8e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    137b <main+0x1bb>
lea    0xd03(%rip),%rdi
call   10d0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x20,%edx
call   1060 <read@plt>
cmp    $0x20,%eax
je     13a4 <main+0x1e4>
lea    0xcf0(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x4100301,-0x420(%rbp)
01 03 10 04
je     13c1 <main+0x201>
lea    0xcf3(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x20,-0x418(%rbp)
20
je     13db <main+0x21b>
lea    0xcd9(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x408(%rbp)
je     13f5 <main+0x235>
lea    0xcda(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x400(%rbp)
je     140f <main+0x24f>
lea    0xcdf(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x3f8(%rbp)
je     1429 <main+0x269>
lea    0xc8b(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x3e8(%rbp)
je     1443 <main+0x283>
lea    0xcc1(%rip),%rdi
call   10d0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,-0x14(%rbp)
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xcb1(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
cmpl   $0x200,-0x14(%rbp)
je     148d <main+0x2cd>
lea    0xcad(%rip),%rdi
call   10d0 <die@plt>
movzwl -0x222(%rbp),%eax
cmp    $0xaa55,%eax
je     14ab <main+0x2eb>
lea    0xcb4(%rip),%rdi
call   10d0 <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     14f5 <main+0x335>
lea    0xc93(%rip),%rdi
call   10d0 <die@plt>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2adc(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    152d <main+0x36d>
lea    0xc6d(%rip),%rdi
call   10d0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x20,%edx
call   1060 <read@plt>
cmp    $0x20,%eax
je     1556 <main+0x396>
lea    0xc5b(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x4100301,-0x420(%rbp)
01 03 10 04
je     1573 <main+0x3b3>
lea    0xc5f(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x20,-0x418(%rbp)
20
je     158d <main+0x3cd>
lea    0xc45(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x408(%rbp)
je     15a7 <main+0x3e7>
lea    0xc47(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x400(%rbp)
je     15c1 <main+0x401>
lea    0xc4d(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x3f8(%rbp)
je     15db <main+0x41b>
lea    0xbf7(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x3e8(%rbp)
je     15f5 <main+0x435>
lea    0xc30(%rip),%rdi
call   10d0 <die@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    1658 <main+0x498>
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     1645 <main+0x485>
lea    0xb43(%rip),%rdi
call   10d0 <die@plt>
jmp    164a <main+0x48a>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    15fc <main+0x43c>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x800,-0x14(%rbp)
jle    1679 <main+0x4b9>
lea    0xbcc(%rip),%rdi
call   10d0 <die@plt>
mov    0x2958(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xbf1(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x400,%rax
jae    16c4 <main+0x504>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    169a <main+0x4da>
jmp    16c9 <main+0x509>
cmpl   $0x800,-0x14(%rbp)
jge    172f <main+0x56f>
mov    $0x800,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x400,%rax
jbe    16f8 <main+0x538>
movl   $0x400,-0x18(%rbp)
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     1721 <main+0x561>
lea    0xa67(%rip),%rdi
call   10d0 <die@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    16c9 <main+0x509>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x28aa(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    175f <main+0x59f>
lea    0xb37(%rip),%rdi
call   10d0 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <read@plt>
cmp    $0x400,%eax
je     178a <main+0x5ca>
lea    0xb24(%rip),%rdi
call   10d0 <die@plt>
cmpq   $0x0,-0x3f8(%rbp)
je     17a4 <main+0x5e4>
lea    0xb2c(%rip),%rdi
call   10d0 <die@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    1807 <main+0x647>
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     17f4 <main+0x634>
lea    0x994(%rip),%rdi
call   10d0 <die@plt>
jmp    17f9 <main+0x639>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    17ab <main+0x5eb>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
mov    0x27c2(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xac4(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
cmpl   $0x20000,-0x14(%rbp)
jle    1842 <main+0x682>
lea    0xabe(%rip),%rdi
call   10d0 <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     11f7 <main+0x27>
xor    %eax,%eax
call   10c0 <usage@plt>
cmp    $0x5,%ebx
jne    1295 <main+0xc5>
mov    0x20(%r14),%rdi
lea    0xdf5(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     129d <main+0xcd>
mov    0x20(%r14),%rdi
lea    0x8(%rsp),%rsi
call   10b0 <stat@plt>
test   %rax,%rax
jne    1780 <main+0x5b0>
mov    0x8(%rsp),%edi
call   1050 <MAJOR@plt>
mov    %eax,%r12d
mov    0x8(%rsp),%edi
call   1090 <MINOR@plt>
mov    %eax,%r15d
mov    0x2d89(%rip),%rbp
mov    0x0(%rbp),%edi
movsbl %r12b,%ebx
movsbl %al,%ecx
lea    0xdc2(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmp    $0x3,%bl
ja     1274 <main+0xa4>
cmp    $0x1,%r12b
jne    12c2 <main+0xf2>
mov    0x0(%rbp),%edi
lea    0xdbd(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xdcf(%rip),%rdi
call   10e0 <die@plt>
jmp    12c2 <main+0xf2>
mov    $0x6,%r15b
mov    $0x3,%r12b
jmp    12a3 <main+0xd3>
xor    %r12d,%r12d
xor    %r15d,%r15d
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
movzbl %r12b,%edx
movzbl %r15b,%ecx
lea    0xd67(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x8(%r14),%rdi
mov    0x2d0a(%rip),%r13
mov    0x0(%r13),%esi
xor    %edx,%edx
call   10d0 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    12fb <main+0x12b>
lea    0xd83(%rip),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x20,%edx
call   1070 <read@plt>
cmp    $0x20,%eax
jne    154a <main+0x37a>
cmpq   $0x4100301,0x10(%rsp)
10 04
jne    1565 <main+0x395>
cmpq   $0x20,0x18(%rsp)
jne    157d <main+0x3ad>
cmpq   $0x0,0x28(%rsp)
je     1344 <main+0x174>
lea    0xd8b(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x30(%rsp)
je     1358 <main+0x188>
lea    0xd96(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     136c <main+0x19c>
lea    0xd48(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x48(%rsp)
je     1380 <main+0x1b0>
lea    0xd84(%rip),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x400,%edx
call   1070 <read@plt>
mov    %eax,%ebp
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
lea    0xd7b(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmp    $0x200,%ebp
je     13c0 <main+0x1f0>
lea    0xd7a(%rip),%rdi
call   10e0 <die@plt>
movzwl 0x20e(%rsp),%eax
cmp    $0xaa55,%eax
je     13db <main+0x20b>
lea    0xd84(%rip),%rdi
call   10e0 <die@plt>
mov    %r15b,0x20c(%rsp)
mov    %r12b,0x20d(%rsp)
lea    0x10(%rsp),%rsi
mov    $0x1,%edi
mov    $0x200,%edx
call   1030 <write@plt>
cmp    $0x200,%eax
je     1412 <main+0x242>
lea    0xd76(%rip),%rdi
call   10e0 <die@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    0x10(%r14),%rdi
mov    0x0(%r13),%esi
xor    %edx,%edx
call   10d0 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    143b <main+0x26b>
lea    0xd5f(%rip),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x20,%edx
call   1070 <read@plt>
cmp    $0x20,%eax
jne    159a <main+0x3ca>
cmpq   $0x4100301,0x10(%rsp)
10 04
jne    15b5 <main+0x3e5>
cmpq   $0x20,0x18(%rsp)
jne    15cd <main+0x3fd>
cmpq   $0x0,0x28(%rsp)
je     1485 <main+0x2b5>
lea    0xd69(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x30(%rsp)
je     1499 <main+0x2c9>
lea    0xd75(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     14ad <main+0x2dd>
lea    0xd25(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x48(%rsp)
je     14c1 <main+0x2f1>
lea    0xd64(%rip),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x400,%edx
call   1070 <read@plt>
test   %eax,%eax
jle    15ea <main+0x41a>
mov    %eax,%ebx
xor    %ebp,%ebp
lea    0x10(%rsp),%r12
lea    0xc98(%rip),%r13
jmp    1508 <main+0x338>
nopl   (%rax)
add    %ebx,%ebp
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x400,%edx
call   1070 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1525 <main+0x355>
mov    $0x1,%edi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    %ebx,%eax
je     14f0 <main+0x320>
mov    %r13,%rdi
call   10e0 <die@plt>
jmp    14f0 <main+0x320>
mov    %r15d,%edi
call   1060 <close@plt>
cmp    $0x801,%ebp
jl     15f4 <main+0x424>
lea    0xd00(%rip),%rdi
call   10e0 <die@plt>
jmp    15f4 <main+0x424>
lea    0xb3e(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x4100301,0x10(%rsp)
10 04
je     1324 <main+0x154>
lea    0xb43(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x20,0x18(%rsp)
je     1330 <main+0x160>
lea    0xb2b(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x28(%rsp)
jne    1338 <main+0x168>
jmp    1344 <main+0x174>
lea    0xc0b(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x4100301,0x10(%rsp)
10 04
je     1465 <main+0x295>
lea    0xc11(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x20,0x18(%rsp)
je     1471 <main+0x2a1>
lea    0xbf9(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x28(%rsp)
jne    1479 <main+0x2a9>
jmp    1485 <main+0x2b5>
mov    %r15d,%edi
call   1060 <close@plt>
xor    %ebp,%ebp
mov    0x29dd(%rip),%rax
mov    (%rax),%edi
lea    0xc79(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
cmp    $0x7ff,%ebp
jg     1678 <main+0x4a8>
mov    $0x400,%r13d
lea    0x10(%rsp),%r12
lea    0xb4b(%rip),%r15
jmp    164a <main+0x47a>
nopw   0x0(%rax,%rax,1)
add    %ebx,%ebp
cmp    $0x800,%ebp
jge    1678 <main+0x4a8>
mov    $0x800,%ebx
sub    %ebp,%ebx
cmp    $0x400,%ebx
cmovae %r13d,%ebx
mov    $0x1,%edi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    %ebx,%eax
je     1640 <main+0x470>
mov    %r15,%rdi
call   10e0 <die@plt>
jmp    1640 <main+0x470>
mov    0x18(%r14),%rdi
mov    0x2965(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    169f <main+0x4cf>
lea    0xbf7(%rip),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1070 <read@plt>
cmp    $0x400,%eax
je     16c4 <main+0x4f4>
lea    0xbea(%rip),%rdi
call   10e0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     16d8 <main+0x508>
lea    0xbf8(%rip),%rdi
call   10e0 <die@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1070 <read@plt>
test   %eax,%eax
jle    1735 <main+0x565>
mov    %eax,%ebx
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
lea    0xa85(%rip),%r12
jmp    1718 <main+0x548>
add    %ebx,%ebp
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1070 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1737 <main+0x567>
mov    $0x1,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    %ebx,%eax
je     1700 <main+0x530>
mov    %r12,%rdi
call   10e0 <die@plt>
jmp    1700 <main+0x530>
xor    %ebp,%ebp
mov    %r14d,%edi
call   1060 <close@plt>
mov    0x2892(%rip),%rax
mov    (%rax),%edi
lea    0xb97(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmp    $0x20001,%ebp
jl     176c <main+0x59c>
lea    0xb94(%rip),%rdi
call   10e0 <die@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x20(%r14),%rdi
call   10f0 <perror@plt>
lea    0x877(%rip),%rdi
call   10e0 <die@plt>
jmp    1230 <main+0x60>

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