#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 O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ copy_blocks(int, int, unsigned long *, unsigned long *);
int /*<<< orphan*/ die(char *, char *, ...);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, char *);
int sprintf(char *, char *, unsigned long, unsigned long);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  char *kernel, *loader, *rdimage = NULL;
  unsigned long ld_off, kern_off, rd_off;
  unsigned long ld_size, kern_size, rd_size;
  int fd, ofd, len;
  char buffer[500];
  if (argc < 5 && !strcmp(argv[argc - 2], "-o"))
    usage();
  if (argc > 5)
    rdimage = argv[3];
  kernel = argv[2];
  loader = argv[1];
  ofd = open(argv[argc - 1], (O_RDWR | O_CREAT), 0755);
  if (ofd < 0) {
    die("can't open %s: %s", argv[5], strerror(errno));
  }
  ld_off = kern_off = rd_off = 0;
  ld_size = kern_size = rd_size = 0;
  memset(buffer, 0, 500);
  len = 0;
  fd = open(loader, O_RDONLY);
  if (fd < 0)
    die("can't open loader: %s", strerror(errno));
  copy_blocks(fd, ofd, &ld_off, &ld_size);
  len = sprintf(buffer, "bootloader: %lx %lx\n", ld_off, ld_size);
  close(fd);
  fd = open(kernel, O_RDONLY);
  if (fd < 0)
    die("can't open kernel: %s", strerror(errno));
  copy_blocks(fd, ofd, &kern_off, &kern_size);
  len += sprintf(buffer + len, "zimage: %lx %lx\n", kern_off, kern_size);
  close(fd);
  if (rdimage) {
    fd = open(rdimage, O_RDONLY);
    if (fd < 0)
      die("can't get ramdisk: %s", strerror(errno));
    copy_blocks(fd, ofd, &rd_off, &rd_size);
    close(fd);
  }
  len += sprintf(buffer + len, "initrd: %lx %lx", rd_off, rd_size);
  close(ofd);
  printf("%s\n", buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11f8 <main+0x58>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe1d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11f8 <main+0x58>
mov    $0x0,%al
call   1080 <usage@plt>
cmpl   $0x5,-0x8(%rbp)
jle    120e <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
mov    0x2db1(%rip),%rax
or     (%rax),%esi
mov    $0x1ed,%edx
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
jge    1296 <main+0xf6>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x268(%rbp)
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x268(%rbp),%rsi
mov    %eax,%edx
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   10a0 <die@plt>
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
lea    -0x260(%rbp),%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1040 <memset@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    1320 <main+0x180>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
movslq %eax,%rsi
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   10a0 <die@plt>
mov    -0x5c(%rbp),%edi
mov    -0x60(%rbp),%esi
lea    -0x30(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1070 <copy_blocks@plt>
lea    -0x260(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x48(%rbp),%rcx
lea    0xce2(%rip),%rsi
call   10b0 <sprintf@plt>
mov    %eax,-0x64(%rbp)
mov    -0x5c(%rbp),%edi
call   1050 <close@plt>
mov    -0x18(%rbp),%rdi
mov    0x2c74(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    1399 <main+0x1f9>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
movslq %eax,%rsi
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   10a0 <die@plt>
mov    -0x5c(%rbp),%edi
mov    -0x60(%rbp),%esi
lea    -0x38(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   1070 <copy_blocks@plt>
lea    -0x260(%rbp),%rdi
movslq -0x64(%rbp),%rax
add    %rax,%rdi
mov    -0x38(%rbp),%rdx
mov    -0x50(%rbp),%rcx
lea    0xc8d(%rip),%rsi
call   10b0 <sprintf@plt>
add    -0x64(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x5c(%rbp),%edi
call   1050 <close@plt>
cmpq   $0x0,-0x28(%rbp)
je     1442 <main+0x2a2>
mov    -0x28(%rbp),%rdi
mov    0x2be6(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    1427 <main+0x287>
mov    0x2bb9(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
movslq %eax,%rsi
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   10a0 <die@plt>
mov    -0x5c(%rbp),%edi
mov    -0x60(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1070 <copy_blocks@plt>
mov    -0x5c(%rbp),%edi
call   1050 <close@plt>
lea    -0x260(%rbp),%rdi
movslq -0x64(%rbp),%rax
add    %rax,%rdi
mov    -0x40(%rbp),%rdx
mov    -0x58(%rbp),%rcx
lea    0xc1e(%rip),%rsi
call   10b0 <sprintf@plt>
add    -0x64(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x60(%rbp),%edi
call   1050 <close@plt>
lea    -0x260(%rbp),%rsi
lea    0xc0d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rsi,%rbp
movslq %edi,%rbx
cmp    $0x4,%edi
jg     11e1 <main+0x41>
mov    -0x10(%rbp,%rbx,8),%rdi
lea    0xe38(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11e6 <main+0x46>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1080 <usage@plt>
jmp    11f3 <main+0x53>
cmp    $0x5,%edi
jne    11ea <main+0x4a>
xor    %eax,%eax
jmp    11ee <main+0x4e>
mov    0x18(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    0x8(%rbp),%r12
mov    0x10(%rbp),%r15
mov    -0x8(%rbp,%rbx,8),%rdi
mov    0x2dd9(%rip),%rax
mov    0x2dea(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    $0x1ed,%edx
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%r13d
test   %eax,%eax
jns    124a <main+0xaa>
mov    0x28(%rbp),%rbp
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xdc5(%rip),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <die@plt>
movq   $0x0,0x28(%rsp)
movq   $0x0,0x30(%rsp)
movq   $0x0,0x38(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x40(%rsp),%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1040 <memset@plt>
mov    0x2d40(%rip),%r14
mov    (%r14),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    12ca <main+0x12a>
mov    0x2d16(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
movslq %eax,%rsi
lea    0xd52(%rip),%rdi
xor    %eax,%eax
call   10a0 <die@plt>
lea    0x38(%rsp),%rdx
lea    0x20(%rsp),%rcx
mov    %ebx,%edi
mov    %r13d,%esi
call   1070 <copy_blocks@plt>
mov    0x38(%rsp),%rdx
mov    0x20(%rsp),%rcx
lea    0xd3c(%rip),%rsi
lea    0x40(%rsp),%rdi
call   10b0 <sprintf@plt>
mov    %eax,%r12d
mov    %ebx,%edi
call   1050 <close@plt>
mov    (%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1335 <main+0x195>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
movslq %eax,%rsi
lea    0xd12(%rip),%rdi
xor    %eax,%eax
call   10a0 <die@plt>
lea    0x30(%rsp),%rdx
lea    0x18(%rsp),%rcx
mov    %ebx,%edi
mov    %r13d,%esi
call   1070 <copy_blocks@plt>
movslq %r12d,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x40,%rdi
mov    0x30(%rsp),%rdx
mov    0x18(%rsp),%rcx
lea    0xcf1(%rip),%rsi
call   10b0 <sprintf@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     13d3 <main+0x233>
mov    (%r14),%esi
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    13ac <main+0x20c>
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
movslq %eax,%rsi
lea    0xcc2(%rip),%rdi
xor    %eax,%eax
call   10a0 <die@plt>
lea    0x28(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %r13d,%esi
call   1070 <copy_blocks@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x28(%rsp),%rdx
mov    0x10(%rsp),%rcx
jmp    13d7 <main+0x237>
xor    %ecx,%ecx
xor    %edx,%edx
add    %r12d,%ebp
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x40,%rdi
lea    0xc91(%rip),%rsi
call   10b0 <sprintf@plt>
mov    %r13d,%edi
call   1050 <close@plt>
lea    0xc8d(%rip),%rdi
lea    0x40(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-o\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@.str.1 = [18 x i8] c"can't open %s: %s\00"
@errno = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [22 x i8] c"can't open loader: %s\00"
@.str.3 = [21 x i8] c"bootloader: %lx %lx\0A\00"
@.str.4 = [22 x i8] c"can't open kernel: %s\00"
@.str.5 = [17 x i8] c"zimage: %lx %lx\0A\00"
@.str.6 = [22 x i8] c"can't get ramdisk: %s\00"
@.str.7 = [16 x i8] c"initrd: %lx %lx\00"
@.str.8 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [500 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %8
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 5
br i1 %20, label %21, label %32
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %22, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %21
%31 = call i32 (...) @usage()
br label %32
32: ; preds = %30, %21, %2
%33 = load i32, i32* %4
%34 = icmp sgt i32 %33, 5
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
store i8* %38, i8** %8
br label %39
39: ; preds = %35, %32
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
store i8* %42, i8** %6
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
store i8* %45, i8** %7
%46 = load i8**, i8*** %5
%47 = load i32, i32* %4
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %46, i64 %49
%51 = load i8*, i8** %50
%52 = load i32, i32* @O_RDWR
%53 = load i32, i32* @O_CREAT
%54 = or i32 %52, %53
%55 = call i32 (i8*, i32, ...) @open(i8* %51, i32 %54, i32 493)
store i32 %55, i32* %16
%56 = load i32, i32* %16
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %39
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 5
%61 = load i8*, i8** %60
%62 = load i32, i32* @errno
%63 = call i32 @strerror(i32 %62)
%64 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %61, i32 %63)
br label %65
65: ; preds = %58, %39
store i64 0, i64* %11
store i64 0, i64* %10
store i64 0, i64* %9
store i64 0, i64* %14
store i64 0, i64* %13
store i64 0, i64* %12
%66 = getelementptr inbounds [500 x i8], [500 x i8]* %18, i64 0, i64 0
%67 = call i32 @memset(i8* %66, i32 0, i32 500)
store i32 0, i32* %17
%68 = load i8*, i8** %7
%69 = load i32, i32* @O_RDONLY
%70 = call i32 (i8*, i32, ...) @open(i8* %68, i32 %69)
store i32 %70, i32* %15
%71 = load i32, i32* %15
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %65
%74 = load i32, i32* @errno
%75 = call i32 @strerror(i32 %74)
%76 = sext i32 %75 to i64
%77 = inttoptr i64 %76 to i8*
%78 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %77)
br label %79
79: ; preds = %73, %65
%80 = load i32, i32* %15
%81 = load i32, i32* %16
%82 = call i32 @copy_blocks(i32 %80, i32 %81, i64* %9, i64* %12)
%83 = getelementptr inbounds [500 x i8], [500 x i8]* %18, i64 0, i64 0
%84 = load i64, i64* %9
%85 = load i64, i64* %12
%86 = call i32 @sprintf(i8* %83, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %84, i64 %85)
store i32 %86, i32* %17
%87 = load i32, i32* %15
%88 = call i32 @close(i32 %87)
%89 = load i8*, i8** %6
%90 = load i32, i32* @O_RDONLY
%91 = call i32 (i8*, i32, ...) @open(i8* %89, i32 %90)
store i32 %91, i32* %15
%92 = load i32, i32* %15
%93 = icmp slt i32 %92, 0
br i1 %93, label %94, label %100
94: ; preds = %79
%95 = load i32, i32* @errno
%96 = call i32 @strerror(i32 %95)
%97 = sext i32 %96 to i64
%98 = inttoptr i64 %97 to i8*
%99 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %98)
br label %100
100: ; preds = %94, %79
%101 = load i32, i32* %15
%102 = load i32, i32* %16
%103 = call i32 @copy_blocks(i32 %101, i32 %102, i64* %10, i64* %13)
%104 = getelementptr inbounds [500 x i8], [500 x i8]* %18, i64 0, i64 0
%105 = load i32, i32* %17
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %104, i64 %106
%108 = load i64, i64* %10
%109 = load i64, i64* %13
%110 = call i32 @sprintf(i8* %107, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i64 %108, i64 %109)
%111 = load i32, i32* %17
%112 = add nsw i32 %111, %110
store i32 %112, i32* %17
%113 = load i32, i32* %15
%114 = call i32 @close(i32 %113)
%115 = load i8*, i8** %8
%116 = icmp ne i8* %115, null
br i1 %116, label %117, label %135
117: ; preds = %100
%118 = load i8*, i8** %8
%119 = load i32, i32* @O_RDONLY
%120 = call i32 (i8*, i32, ...) @open(i8* %118, i32 %119)
store i32 %120, i32* %15
%121 = load i32, i32* %15
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %129
123: ; preds = %117
%124 = load i32, i32* @errno
%125 = call i32 @strerror(i32 %124)
%126 = sext i32 %125 to i64
%127 = inttoptr i64 %126 to i8*
%128 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %127)
br label %129
129: ; preds = %123, %117
%130 = load i32, i32* %15
%131 = load i32, i32* %16
%132 = call i32 @copy_blocks(i32 %130, i32 %131, i64* %11, i64* %14)
%133 = load i32, i32* %15
%134 = call i32 @close(i32 %133)
br label %135
135: ; preds = %129, %100
%136 = getelementptr inbounds [500 x i8], [500 x i8]* %18, i64 0, i64 0
%137 = load i32, i32* %17
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds i8, i8* %136, i64 %138
%140 = load i64, i64* %11
%141 = load i64, i64* %14
%142 = call i32 @sprintf(i8* %139, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i64 %140, i64 %141)
%143 = load i32, i32* %17
%144 = add nsw i32 %143, %142
store i32 %144, i32* %17
%145 = load i32, i32* %16
%146 = call i32 @close(i32 %145)
%147 = getelementptr inbounds [500 x i8], [500 x i8]* %18, i64 0, i64 0
%148 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %147)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-o\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@.str.1 = [18 x i8] c"can't open %s: %s\00"
@errno = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [22 x i8] c"can't open loader: %s\00"
@.str.3 = [21 x i8] c"bootloader: %lx %lx\0A\00"
@.str.4 = [22 x i8] c"can't open kernel: %s\00"
@.str.5 = [17 x i8] c"zimage: %lx %lx\0A\00"
@.str.6 = [22 x i8] c"can't get ramdisk: %s\00"
@.str.7 = [16 x i8] c"initrd: %lx %lx\00"
@.str.8 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca [500 x i8]
%10 = bitcast i64* %3 to i8*
%11 = bitcast i64* %4 to i8*
%12 = bitcast i64* %5 to i8*
%13 = bitcast i64* %6 to i8*
%14 = bitcast i64* %7 to i8*
%15 = bitcast i64* %8 to i8*
%16 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%17 = icmp slt i32 %0, 5
br i1 %17, label %18, label %27
18: ; preds = %2
%19 = add nsw i32 %0, -2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %22, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %18
%26 = tail call i32 (...) @usage()
br label %32
27: ; preds = %2
%28 = icmp eq i32 %0, 5
br i1 %28, label %32, label %29
29: ; preds = %27
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
br label %32
32: ; preds = %18, %25, %29, %27
%33 = phi i8* [ %31, %29 ], [ null, %27 ], [ null, %25 ], [ null, %18 ]
%34 = getelementptr inbounds i8*, i8** %1, i64 2
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8*, i8** %1, i64 1
%37 = load i8*, i8** %36
%38 = add nsw i32 %0, -1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %1, i64 %39
%41 = load i8*, i8** %40
%42 = load i32, i32* @O_RDWR
%43 = load i32, i32* @O_CREAT
%44 = or i32 %43, %42
%45 = tail call i32 (i8*, i32, ...) @open(i8* %41, i32 %44, i32 493)
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %32
%48 = getelementptr inbounds i8*, i8** %1, i64 5
%49 = load i8*, i8** %48
%50 = load i32, i32* @errno
%51 = tail call i32 @strerror(i32 %50)
%52 = tail call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %49, i32 %51)
br label %53
53: ; preds = %47, %32
store i64 0, i64* %5
store i64 0, i64* %4
store i64 0, i64* %3
store i64 0, i64* %8
store i64 0, i64* %7
store i64 0, i64* %6
%54 = call i32 @memset(i8* %16, i32 0, i32 500)
%55 = load i32, i32* @O_RDONLY
%56 = call i32 (i8*, i32, ...) @open(i8* %37, i32 %55)
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %53
%59 = load i32, i32* @errno
%60 = call i32 @strerror(i32 %59)
%61 = sext i32 %60 to i64
%62 = inttoptr i64 %61 to i8*
%63 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %58, %53
%65 = call i32 @copy_blocks(i32 %56, i32 %45, i64* %3, i64* %6)
%66 = load i64, i64* %3
%67 = load i64, i64* %6
%68 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %66, i64 %67)
%69 = call i32 @close(i32 %56)
%70 = load i32, i32* @O_RDONLY
%71 = call i32 (i8*, i32, ...) @open(i8* %35, i32 %70)
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %64
%74 = load i32, i32* @errno
%75 = call i32 @strerror(i32 %74)
%76 = sext i32 %75 to i64
%77 = inttoptr i64 %76 to i8*
%78 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %77)
br label %79
79: ; preds = %73, %64
%80 = call i32 @copy_blocks(i32 %71, i32 %45, i64* %4, i64* %7)
%81 = sext i32 %68 to i64
%82 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 %81
%83 = load i64, i64* %4
%84 = load i64, i64* %7
%85 = call i32 @sprintf(i8* %82, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i64 %83, i64 %84)
%86 = call i32 @close(i32 %71)
%87 = icmp eq i8* %33, null
br i1 %87, label %103, label %88
88: ; preds = %79
%89 = load i32, i32* @O_RDONLY
%90 = call i32 (i8*, i32, ...) @open(i8* %33, i32 %89)
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %98
92: ; preds = %88
%93 = load i32, i32* @errno
%94 = call i32 @strerror(i32 %93)
%95 = sext i32 %94 to i64
%96 = inttoptr i64 %95 to i8*
%97 = call i32 (i8*, i8*, ...) @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %96)
br label %98
98: ; preds = %92, %88
%99 = call i32 @copy_blocks(i32 %90, i32 %45, i64* %5, i64* %8)
%100 = call i32 @close(i32 %90)
%101 = load i64, i64* %5
%102 = load i64, i64* %8
br label %103
103: ; preds = %98, %79
%104 = phi i64 [ %102, %98 ], [ 0, %79 ]
%105 = phi i64 [ %101, %98 ], [ 0, %79 ]
%106 = add nsw i32 %85, %68
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 %107
%109 = call i32 @sprintf(i8* %108, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i64 %105, i64 %104)
%110 = call i32 @close(i32 %45)
%111 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %16)
ret i32 0
}