#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ romcopy(unsigned char *, unsigned char *, unsigned char *,
                           unsigned char *);
int /*<<< orphan*/ showUsage(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ vmlbuild(unsigned char *, unsigned char *);
int /*<<< orphan*/ xberepair(unsigned char *, unsigned char *);
int main(int argc, const char *argv[]) {
  printf("ImageBLD Hasher by XBL Project (c) hamtitampti\n");
  if (argc < 3) {
    showUsage(argv[0]);
    exit(1);
  }
  if (!strcmp(argv[1], "-xbe")) {
    xberepair((unsigned char *)argv[2], (unsigned char *)argv[3]);
  } else if (!strcmp(argv[1], "-vml")) {
    vmlbuild((unsigned char *)argv[2], (unsigned char *)argv[3]);
  } else if (!strcmp(argv[1], "-rom")) {
    if (argc != 6) {
      showUsage(argv[0]);
      exit(1);
    }
    romcopy((unsigned char *)argv[2], (unsigned char *)argv[3],
            (unsigned char *)argv[4], (unsigned char *)argv[5]);
  } else {
    showUsage(argv[0]);
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
jge    11b2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <showUsage@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11e9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1080 <xberepair@plt>
jmp    12a7 <main+0x137>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1220 <main+0xb0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <vmlbuild@plt>
jmp    12a2 <main+0x132>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1287 <main+0x117>
cmpl   $0x6,-0x8(%rbp)
je     125d <main+0xed>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <showUsage@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rcx
call   1090 <romcopy@plt>
jmp    129d <main+0x12d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <showUsage@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    12a2 <main+0x132>
jmp    12a7 <main+0x137>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe8f(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%ebp
jg     119c <main+0x2c>
mov    (%rbx),%rdi
call   1050 <showUsage@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x8(%rbx),%r14
lea    0xe59(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11c7 <main+0x57>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1080 <xberepair@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe37(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11ee <main+0x7e>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1030 <vmlbuild@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe15(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    118a <main+0x1a>
cmp    $0x6,%ebp
jne    118a <main+0x1a>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
mov    0x20(%rbx),%rdx
mov    0x28(%rbx),%rcx
call   1090 <romcopy@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"ImageBLD Hasher by XBL Project (c) hamtitampti\0A\00"
@.str.1 = [5 x i8] c"-xbe\00"
@.str.2 = [5 x i8] c"-vml\00"
@.str.3 = [5 x i8] c"-rom\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @showUsage(i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %15
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i32 @xberepair(i8* %24, i8* %27)
br label %80
29: ; preds = %15
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %43, label %35
35: ; preds = %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i32 @vmlbuild(i8* %38, i8* %41)
br label %79
43: ; preds = %29
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 @strcmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%48 = icmp ne i32 %47, 0
br i1 %48, label %72, label %49
49: ; preds = %43
%50 = load i32, i32* %4
%51 = icmp ne i32 %50, 6
br i1 %51, label %52, label %58
52: ; preds = %49
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i32 @showUsage(i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %49
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 3
%64 = load i8*, i8** %63
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 4
%67 = load i8*, i8** %66
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 5
%70 = load i8*, i8** %69
%71 = call i32 @romcopy(i8* %61, i8* %64, i8* %67, i8* %70)
br label %78
72: ; preds = %43
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 0
%75 = load i8*, i8** %74
%76 = call i32 @showUsage(i8* %75)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %58
br label %79
79: ; preds = %78, %35
br label %80
80: ; preds = %79, %21
%81 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"-xbe\00"
@.str.2 = [5 x i8] c"-vml\00"
@.str.3 = [5 x i8] c"-rom\00"
@str = [47 x i8] c"ImageBLD Hasher by XBL Project (c) hamtitampti\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @showUsage(i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @xberepair(i8* %16, i8* %18)
br label %52
20: ; preds = %9
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8*, i8** %1, i64 3
%27 = load i8*, i8** %26
%28 = tail call i32 @vmlbuild(i8* %25, i8* %27)
br label %52
29: ; preds = %20
%30 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %48
32: ; preds = %29
%33 = icmp eq i32 %0, 6
br i1 %33, label %38, label %34
34: ; preds = %32
%35 = load i8*, i8** %1
%36 = tail call i32 @showUsage(i8* %35)
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %32
%39 = getelementptr inbounds i8*, i8** %1, i64 2
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8*, i8** %1, i64 3
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8*, i8** %1, i64 4
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8*, i8** %1, i64 5
%46 = load i8*, i8** %45
%47 = tail call i32 @romcopy(i8* %40, i8* %42, i8* %44, i8* %46)
br label %52
48: ; preds = %29
%49 = load i8*, i8** %1
%50 = tail call i32 @showUsage(i8* %49)
%51 = tail call i32 @exit(i32 1)
unreachable
52: ; preds = %23, %38, %14
%53 = tail call i32 @exit(i32 0)
unreachable
}