#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 */

/* 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 read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int write(int, char *, int);
int main(int argc, char **argv) {
  int i, c, id;
  char buf[1024];
  if (argc != 3)
    usage();
  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 > 510)
    die("Boot block may not exceed 510 bytes");
  buf[510] = 0x55;
  buf[511] = 0xAA;
  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 '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 %d bytes.\n", i);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     119a <main+0x2a>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x400,%rax
jae    11cb <main+0x5b>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <main+0x31>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    11fb <main+0x8b>
lea    0xe0a(%rip),%rdi
call   1090 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x20,%edx
call   1050 <read@plt>
cmp    $0x20,%eax
je     1224 <main+0xb4>
lea    0xdf7(%rip),%rdi
call   1090 <die@plt>
cmpq   $0x4100301,-0x420(%rbp)
01 03 10 04
je     1241 <main+0xd1>
lea    0xdfa(%rip),%rdi
call   1090 <die@plt>
cmpq   $0x20,-0x418(%rbp)
20
je     125b <main+0xeb>
lea    0xde0(%rip),%rdi
call   1090 <die@plt>
cmpq   $0x0,-0x408(%rbp)
je     1275 <main+0x105>
lea    0xde1(%rip),%rdi
call   1090 <die@plt>
cmpq   $0x0,-0x400(%rbp)
je     128f <main+0x11f>
lea    0xde6(%rip),%rdi
call   1090 <die@plt>
cmpq   $0x0,-0x3f8(%rbp)
je     12a9 <main+0x139>
lea    0xd92(%rip),%rdi
call   1090 <die@plt>
cmpq   $0x0,-0x3e8(%rbp)
je     12c3 <main+0x153>
lea    0xdc8(%rip),%rdi
call   1090 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x14(%rbp)
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xdb8(%rip),%rsi
call   1060 <fprintf@plt>
cmpl   $0x1fe,-0x14(%rbp)
jle    130b <main+0x19b>
lea    0xdb6(%rip),%rdi
call   1090 <die@plt>
movb   $0x55,-0x222(%rbp)
movb   $0xaa,-0x221(%rbp)
lea    -0x420(%rbp),%rsi
mov    $0x1,%edi
mov    $0x200,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
je     134b <main+0x1db>
lea    0xd9a(%rip),%rdi
call   1090 <die@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2c86(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1383 <main+0x213>
lea    0xd74(%rip),%rdi
call   1090 <die@plt>
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
cmp    $0x400,%eax
je     13ae <main+0x23e>
lea    0xd61(%rip),%rdi
call   1090 <die@plt>
cmpq   $0x0,-0x3f8(%rbp)
je     13c8 <main+0x258>
lea    0xd69(%rip),%rdi
call   1090 <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    142b <main+0x2bb>
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    -0x18(%rbp),%eax
je     1418 <main+0x2a8>
lea    0xccd(%rip),%rdi
call   1090 <die@plt>
jmp    141d <main+0x2ad>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    13cf <main+0x25f>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xd01(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
je     11a0 <main+0x20>
xor    %eax,%eax
call   1080 <usage@plt>
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x8(%r14),%rdi
mov    0x2e2e(%rip),%r15
mov    (%r15),%esi
xor    %edx,%edx
call   1090 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11d6 <main+0x56>
lea    0xe2f(%rip),%rdi
call   10a0 <die@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0x20,%edx
call   1060 <read@plt>
cmp    $0x20,%eax
jne    1385 <main+0x205>
cmpq   $0x4100301,(%rsp)
04
jne    139f <main+0x21f>
cmpq   $0x20,0x8(%rsp)
jne    13b7 <main+0x237>
cmpq   $0x0,0x18(%rsp)
je     121c <main+0x9c>
lea    0xe3a(%rip),%rdi
call   10a0 <die@plt>
cmpq   $0x0,0x20(%rsp)
je     1230 <main+0xb0>
lea    0xe45(%rip),%rdi
call   10a0 <die@plt>
cmpq   $0x0,0x28(%rsp)
je     1244 <main+0xc4>
lea    0xdf7(%rip),%rdi
call   10a0 <die@plt>
cmpq   $0x0,0x38(%rsp)
je     1258 <main+0xd8>
lea    0xe33(%rip),%rdi
call   10a0 <die@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,%ebx
mov    0x2d68(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe2a(%rip),%rsi
mov    %eax,%edx
call   1070 <fprintf@plt>
cmp    $0x1ff,%ebx
jl     1296 <main+0x116>
lea    0xe2b(%rip),%rdi
call   10a0 <die@plt>
movw   $0xaa55,0x1fe(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x200,%edx
call   1030 <write@plt>
cmp    $0x200,%eax
je     12c5 <main+0x145>
lea    0xe20(%rip),%rdi
call   10a0 <die@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    0x10(%r14),%rdi
mov    (%r15),%esi
xor    %edx,%edx
call   1090 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    12ed <main+0x16d>
lea    0xe0a(%rip),%rdi
call   10a0 <die@plt>
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1060 <read@plt>
cmp    $0x400,%eax
je     1310 <main+0x190>
lea    0xdff(%rip),%rdi
call   10a0 <die@plt>
cmpq   $0x0,0x28(%rsp)
je     1324 <main+0x1a4>
lea    0xe0d(%rip),%rdi
call   10a0 <die@plt>
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    13d4 <main+0x254>
mov    %eax,%ebx
xor    %ebp,%ebp
mov    %rsp,%r15
lea    0xd96(%rip),%r12
jmp    1368 <main+0x1e8>
nopl   0x0(%rax)
add    %ebx,%ebp
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    13d6 <main+0x256>
mov    $0x1,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    %ebx,%eax
je     1350 <main+0x1d0>
mov    %r12,%rdi
call   10a0 <die@plt>
jmp    1350 <main+0x1d0>
lea    0xc8a(%rip),%rdi
call   10a0 <die@plt>
cmpq   $0x4100301,(%rsp)
04
je     11fc <main+0x7c>
lea    0xc90(%rip),%rdi
call   10a0 <die@plt>
cmpq   $0x20,0x8(%rsp)
je     1208 <main+0x88>
lea    0xc78(%rip),%rdi
call   10a0 <die@plt>
cmpq   $0x0,0x18(%rsp)
jne    1210 <main+0x90>
jmp    121c <main+0x9c>
xor    %ebp,%ebp
mov    %r14d,%edi
call   1050 <close@plt>
mov    0x0(%r13),%edi
lea    0xd5e(%rip),%rsi
mov    %ebp,%edx
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [22 x i8] c"Unable to open 'boot'\00"
@.str.1 = [32 x i8] c"Unable to read header of 'boot'\00"
@.str.2 = [27 x i8] c"Non-Minix header of 'boot'\00"
@.str.3 = [31 x i8] c"Illegal data segment in 'boot'\00"
@.str.4 = [22 x i8] c"Illegal bss in 'boot'\00"
@.str.5 = [31 x i8] c"Illegal symbol table in 'boot'\00"
@stderr = global i32 0
@.str.6 = [23 x i8] c"Boot sector %d bytes.\0A\00"
@.str.7 = [36 x i8] c"Boot block may not exceed 510 bytes\00"
@.str.8 = [18 x i8] c"Write call failed\00"
@.str.9 = [24 x i8] c"Unable to open 'system'\00"
@.str.10 = [34 x i8] c"Unable to read header of 'system'\00"
@.str.11 = [27 x i8] c"Non-GCC header of 'system'\00"
@.str.12 = [18 x i8] c"System %d bytes.\0A\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]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @usage()
br label %14
14: ; preds = %12, %2
store i32 0, i32* %6
br label %15
15: ; preds = %23, %14
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = icmp ult i64 %17, 1024
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %19
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %15
26: ; preds = %15
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = load i32, i32* @O_RDONLY
%31 = call i32 @open(i8* %29, i32 %30, i32 0)
store i32 %31, i32* %8
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %26
%34 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %33, %26
%36 = load i32, i32* %8
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%38 = call i32 @read(i32 %36, i8* %37, i32 32)
%39 = icmp ne i32 %38, 32
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %42
42: ; preds = %40, %35
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%44 = bitcast i8* %43 to i64*
%45 = getelementptr inbounds i64, i64* %44, i64 0
%46 = load i64, i64* %45
%47 = icmp ne i64 %46, 68158209
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48, %42
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%52 = bitcast i8* %51 to i64*
%53 = getelementptr inbounds i64, i64* %52, i64 1
%54 = load i64, i64* %53
%55 = icmp ne i64 %54, 32
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %56, %50
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%60 = bitcast i8* %59 to i64*
%61 = getelementptr inbounds i64, i64* %60, i64 3
%62 = load i64, i64* %61
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %58
%65 = call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %64, %58
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%68 = bitcast i8* %67 to i64*
%69 = getelementptr inbounds i64, i64* %68, i64 4
%70 = load i64, i64* %69
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %74
74: ; preds = %72, %66
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%76 = bitcast i8* %75 to i64*
%77 = getelementptr inbounds i64, i64* %76, i64 5
%78 = load i64, i64* %77
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %74
%81 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %82
82: ; preds = %80, %74
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%84 = bitcast i8* %83 to i64*
%85 = getelementptr inbounds i64, i64* %84, i64 7
%86 = load i64, i64* %85
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %82
%89 = call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %90
90: ; preds = %88, %82
%91 = load i32, i32* %8
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%93 = call i32 @read(i32 %91, i8* %92, i32 1024)
store i32 %93, i32* %6
%94 = load i32, i32* @stderr
%95 = load i32, i32* %6
%96 = call i32 @fprintf(i32 %94, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %95)
%97 = load i32, i32* %6
%98 = icmp sgt i32 %97, 510
br i1 %98, label %99, label %101
99: ; preds = %90
%100 = call i32 @die(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
br label %101
101: ; preds = %99, %90
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 510
store i8 85, i8* %102
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 511
store i8 -86, i8* %103
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%105 = call i32 @write(i32 1, i8* %104, i32 512)
store i32 %105, i32* %6
%106 = load i32, i32* %6
%107 = icmp ne i32 %106, 512
br i1 %107, label %108, label %110
108: ; preds = %101
%109 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %110
110: ; preds = %108, %101
%111 = load i32, i32* %8
%112 = call i32 @close(i32 %111)
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 2
%115 = load i8*, i8** %114
%116 = load i32, i32* @O_RDONLY
%117 = call i32 @open(i8* %115, i32 %116, i32 0)
store i32 %117, i32* %8
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %121
119: ; preds = %110
%120 = call i32 @die(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %121
121: ; preds = %119, %110
%122 = load i32, i32* %8
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%124 = call i32 @read(i32 %122, i8* %123, i32 1024)
%125 = icmp ne i32 %124, 1024
br i1 %125, label %126, label %128
126: ; preds = %121
%127 = call i32 @die(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
br label %128
128: ; preds = %126, %121
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%130 = bitcast i8* %129 to i64*
%131 = getelementptr inbounds i64, i64* %130, i64 5
%132 = load i64, i64* %131
%133 = icmp ne i64 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %128
%135 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
br label %136
136: ; preds = %134, %128
store i32 0, i32* %6
br label %137
137: ; preds = %151, %136
%138 = load i32, i32* %8
%139 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%140 = call i32 @read(i32 %138, i8* %139, i32 1024)
store i32 %140, i32* %7
%141 = icmp sgt i32 %140, 0
br i1 %141, label %142, label %155
142: ; preds = %137
%143 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%144 = load i32, i32* %7
%145 = call i32 @write(i32 1, i8* %143, i32 %144)
%146 = load i32, i32* %7
%147 = icmp ne i32 %145, %146
br i1 %147, label %148, label %150
148: ; preds = %142
%149 = call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %150
150: ; preds = %148, %142
br label %151
151: ; preds = %150
%152 = load i32, i32* %7
%153 = load i32, i32* %6
%154 = add nsw i32 %153, %152
store i32 %154, i32* %6
br label %137
155: ; preds = %137
%156 = load i32, i32* %8
%157 = call i32 @close(i32 %156)
%158 = load i32, i32* @stderr
%159 = load i32, i32* %6
%160 = call i32 @fprintf(i32 %158, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0), i32 %159)
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [22 x i8] c"Unable to open 'boot'\00"
@.str.1 = [32 x i8] c"Unable to read header of 'boot'\00"
@.str.2 = [27 x i8] c"Non-Minix header of 'boot'\00"
@.str.3 = [31 x i8] c"Illegal data segment in 'boot'\00"
@.str.4 = [22 x i8] c"Illegal bss in 'boot'\00"
@.str.5 = [31 x i8] c"Illegal symbol table in 'boot'\00"
@stderr = global i32 0
@.str.6 = [23 x i8] c"Boot sector %d bytes.\0A\00"
@.str.7 = [36 x i8] c"Boot block may not exceed 510 bytes\00"
@.str.8 = [18 x i8] c"Write call failed\00"
@.str.9 = [24 x i8] c"Unable to open 'system'\00"
@.str.10 = [34 x i8] c"Unable to read header of 'system'\00"
@.str.11 = [27 x i8] c"Non-GCC header of 'system'\00"
@.str.12 = [18 x i8] c"System %d bytes.\0A\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 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32 %0, 3
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 (...) @usage()
br label %9
9: ; preds = %7, %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDONLY
%13 = tail call i32 @open(i8* %11, i32 %12, i32 0)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %9
%18 = call i32 @read(i32 %13, i8* %5, i32 32)
%19 = icmp eq i32 %18, 32
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @die(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = bitcast [1024 x i8]* %3 to i64*
%24 = load i64, i64* %23
%25 = icmp eq i64 %24, 68158209
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 8
%30 = bitcast i8* %29 to i64*
%31 = load i64, i64* %30
%32 = icmp eq i64 %31, 32
br i1 %32, label %35, label %33
33: ; preds = %28
%34 = tail call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 24
%37 = bitcast i8* %36 to i64*
%38 = load i64, i64* %37
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %35
%41 = tail call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %35
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 32
%44 = bitcast i8* %43 to i64*
%45 = load i64, i64* %44
%46 = icmp eq i64 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %42
%48 = tail call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %47, %42
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 40
%51 = bitcast i8* %50 to i64*
%52 = load i64, i64* %51
%53 = icmp eq i64 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %49
%55 = tail call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %56
56: ; preds = %54, %49
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 56
%58 = bitcast i8* %57 to i64*
%59 = load i64, i64* %58
%60 = icmp eq i64 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %56
%62 = tail call i32 @die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %63
63: ; preds = %61, %56
%64 = call i32 @read(i32 %13, i8* %5, i32 1024)
%65 = load i32, i32* @stderr
%66 = tail call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %64)
%67 = icmp sgt i32 %64, 510
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = tail call i32 @die(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
br label %70
70: ; preds = %68, %63
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 510
store i8 85, i8* %71
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 511
store i8 -86, i8* %72
%73 = call i32 @write(i32 1, i8* %5, i32 512)
%74 = icmp eq i32 %73, 512
br i1 %74, label %77, label %75
75: ; preds = %70
%76 = tail call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %77
77: ; preds = %75, %70
%78 = tail call i32 @close(i32 %13)
%79 = getelementptr inbounds i8*, i8** %1, i64 2
%80 = load i8*, i8** %79
%81 = load i32, i32* @O_RDONLY
%82 = tail call i32 @open(i8* %80, i32 %81, i32 0)
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %77
%85 = tail call i32 @die(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %86
86: ; preds = %84, %77
%87 = call i32 @read(i32 %82, i8* %5, i32 1024)
%88 = icmp eq i32 %87, 1024
br i1 %88, label %91, label %89
89: ; preds = %86
%90 = tail call i32 @die(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
br label %91
91: ; preds = %89, %86
%92 = load i64, i64* %51
%93 = icmp eq i64 %92, 0
br i1 %93, label %96, label %94
94: ; preds = %91
%95 = tail call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
br label %96
96: ; preds = %94, %91
%97 = call i32 @read(i32 %82, i8* %5, i32 1024)
%98 = icmp sgt i32 %97, 0
br i1 %98, label %99, label %110
99: ; preds = %96, %106
%100 = phi i32 [ %108, %106 ], [ %97, %96 ]
%101 = phi i32 [ %107, %106 ], [ 0, %96 ]
%102 = call i32 @write(i32 1, i8* %5, i32 %100)
%103 = icmp eq i32 %102, %100
br i1 %103, label %106, label %104
104: ; preds = %99
%105 = tail call i32 @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %106
106: ; preds = %99, %104
%107 = add nsw i32 %100, %101
%108 = call i32 @read(i32 %82, i8* %5, i32 1024)
%109 = icmp sgt i32 %108, 0
br i1 %109, label %99, label %110
110: ; preds = %106, %96
%111 = phi i32 [ 0, %96 ], [ %107, %106 ]
%112 = tail call i32 @close(i32 %82)
%113 = load i32, i32* @stderr
%114 = tail call i32 @fprintf(i32 %113, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0), i32 %111)
ret i32 0
}