#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*/ call();
int /*<<< orphan*/ dump(char);
scalar_t__ import();
scalar_t__ load(char *);
int print(char *, ...);
scalar_t__ read();
scalar_t__ reloc();
int main2(int argc, char **argv) {
  if (argc != 2)
    return print("usage: %s arm_pe_file\n", argv[0]), 1;
  if (load(argv[1]))
    return 2;
  if (read())
    return 3;
  dump('0');
  if (import())
    return 4;
  dump('1');
  if (reloc())
    return 5;
  dump('2');
  call();
  print("ok.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11aa <main2+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <print@plt>
movl   $0x1,-0x4(%rbp)
jmp    125e <main2+0xee>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <load@plt>
cmp    $0x0,%rax
je     11cd <main2+0x5d>
movl   $0x2,-0x4(%rbp)
jmp    125e <main2+0xee>
mov    $0x0,%al
call   1060 <read@plt>
cmp    $0x0,%rax
je     11ea <main2+0x7a>
movl   $0x3,-0x4(%rbp)
jmp    125e <main2+0xee>
mov    $0x30,%edi
call   1040 <dump@plt>
mov    $0x0,%al
call   1070 <import@plt>
cmp    $0x0,%rax
je     1211 <main2+0xa1>
movl   $0x4,-0x4(%rbp)
jmp    125e <main2+0xee>
mov    $0x31,%edi
call   1040 <dump@plt>
mov    $0x0,%al
call   1030 <reloc@plt>
cmp    $0x0,%rax
je     1238 <main2+0xc8>
movl   $0x5,-0x4(%rbp)
jmp    125e <main2+0xee>
mov    $0x32,%edi
call   1040 <dump@plt>
mov    $0x0,%al
call   1090 <call@plt>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1050 <print@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main2>:
push   %rax
cmp    $0x2,%edi
jne    118e <main2+0x1e>
mov    0x8(%rsi),%rdi
call   1080 <load@plt>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
je     11a6 <main2+0x36>
pop    %rcx
ret
mov    (%rsi),%rsi
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1050 <print@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1060 <read@plt>
mov    %rax,%rcx
mov    $0x3,%eax
test   %rcx,%rcx
jne    118c <main2+0x1c>
mov    $0x30,%edi
call   1040 <dump@plt>
xor    %eax,%eax
call   1070 <import@plt>
mov    %rax,%rcx
mov    $0x4,%eax
test   %rcx,%rcx
jne    118c <main2+0x1c>
mov    $0x31,%edi
call   1040 <dump@plt>
xor    %eax,%eax
call   1030 <reloc@plt>
mov    %rax,%rcx
mov    $0x5,%eax
test   %rcx,%rcx
jne    118c <main2+0x1c>
mov    $0x32,%edi
call   1040 <dump@plt>
xor    %eax,%eax
call   1090 <call@plt>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1050 <print@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"usage: %s arm_pe_file\0A\00"
@.str.1 = [5 x i8] c"ok.\0A\00"
define i32 @main2(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 1, i32* %3
br label %38
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @load(i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 2, i32* %3
br label %38
20: ; preds = %13
%21 = call i64 (...) @read()
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 3, i32* %3
br label %38
24: ; preds = %20
%25 = call i32 @dump(i8 signext 48)
%26 = call i64 (...) @import()
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 4, i32* %3
br label %38
29: ; preds = %24
%30 = call i32 @dump(i8 signext 49)
%31 = call i64 (...) @reloc()
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 5, i32* %3
br label %38
34: ; preds = %29
%35 = call i32 @dump(i8 signext 50)
%36 = call i32 (...) @call()
%37 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %38
38: ; preds = %34, %33, %28, %23, %19, %8
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [23 x i8] c"usage: %s arm_pe_file\0A\00"
@.str.1 = [5 x i8] c"ok.\0A\00"
define i32 @main2(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %27
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @load(i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %7
%13 = tail call i64 (...) @read()
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = tail call i32 @dump(i8 signext 48)
%17 = tail call i64 (...) @import()
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = tail call i32 @dump(i8 signext 49)
%21 = tail call i64 (...) @reloc()
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = tail call i32 @dump(i8 signext 50)
%25 = tail call i32 (...) @call()
%26 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %19, %15, %12, %7, %23, %4
%28 = phi i32 [ 1, %4 ], [ 0, %23 ], [ 2, %7 ], [ 3, %12 ], [ 4, %15 ], [ 5, %19 ]
ret i32 %28
}