#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 mkboot(char *, char *, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  char *infile, *bootfile, *outfile;
  int origin = 0x1f0000;
  if (argc < 3) {
    usage();
  }
  if (!strcmp(argv[1], "-h300")) {
    infile = argv[2];
    bootfile = argv[3];
    outfile = argv[4];
    origin = 0x3f0000;
  } else {
    infile = argv[1];
    bootfile = argv[2];
    outfile = argv[3];
  }
  return mkboot(infile, bootfile, outfile, origin);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1f0000,-0x2c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    115e <main+0x2e>
mov    $0x0,%al
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11ab <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x3f0000,-0x2c(%rbp)
jmp    11cf <main+0x9f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1040 <mkboot@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     1143 <main+0x13>
xor    %eax,%eax
call   1050 <usage@plt>
mov    0x8(%rbx),%r14
lea    0xeb2(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     116a <main+0x3a>
lea    0x10(%rbx),%rax
mov    $0x1f0000,%ecx
mov    $0x3,%edx
jmp    117c <main+0x4c>
mov    0x10(%rbx),%r14
lea    0x18(%rbx),%rax
mov    $0x3f0000,%ecx
mov    $0x4,%edx
mov    (%rbx,%rdx,8),%rdx
mov    (%rax),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mkboot@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"-h300\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2031616, i32* %9
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @usage()
br label %14
14: ; preds = %12, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %30, label %20
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
store i8* %26, i8** %7
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 4
%29 = load i8*, i8** %28
store i8* %29, i8** %8
store i32 4128768, i32* %9
br label %40
30: ; preds = %14
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
store i8* %33, i8** %6
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
store i8* %36, i8** %7
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
store i8* %39, i8** %8
br label %40
40: ; preds = %30, %20
%41 = load i8*, i8** %6
%42 = load i8*, i8** %7
%43 = load i8*, i8** %8
%44 = load i32, i32* %9
%45 = call i32 @mkboot(i8* %41, i8* %42, i8* %43, i32 %44)
ret i32 %45
}

LLVM IR (-O2):
@.str = [6 x i8] c"-h300\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
%11 = getelementptr inbounds i8*, i8** %1, i64 2
br i1 %10, label %12, label %15
12: ; preds = %6
%13 = load i8*, i8** %11
%14 = getelementptr inbounds i8*, i8** %1, i64 3
br label %15
15: ; preds = %6, %12
%16 = phi i64 [ 4, %12 ], [ 3, %6 ]
%17 = phi i8* [ %13, %12 ], [ %8, %6 ]
%18 = phi i8** [ %14, %12 ], [ %11, %6 ]
%19 = phi i32 [ 4128768, %12 ], [ 2031616, %6 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 %16
%21 = load i8*, i8** %20
%22 = load i8*, i8** %18
%23 = tail call i32 @mkboot(i8* %17, i8* %22, i8* %21, i32 %19)
ret i32 %23
}