#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*/ initialize();
int /*<<< orphan*/ load(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ validate_args(int, char **);
int main(int argc, char *argv[]) {
  (void)initialize();
  (void)validate_args(argc, argv);
  if (!(load(argv[1]))) {
    printf("\nLoader Test Failed\n");
    return 1;
  } else {
    printf("\nLoader Test Passed\n");
    return 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)
mov    $0x0,%al
call   1040 <initialize@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <validate_args@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <load@plt>
cmp    $0x0,%eax
jne    1197 <main+0x57>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11aa <main+0x6a>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <initialize@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <validate_args@plt>
mov    0x8(%rbx),%rdi
call   1060 <load@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
lea    0xe90(%rip),%rax
lea    0xe9d(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0ALoader Test Failed\0A\00"
@.str.1 = [21 x i8] c"\0ALoader Test Passed\0A\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 (...) @initialize()
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @validate_args(i32 %7, i8** %8)
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @load(i8* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %19
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %19
19: ; preds = %17, %15
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@str = [20 x i8] c"\0ALoader Test Failed\00"
@str.2 = [20 x i8] c"\0ALoader Test Passed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 (...) @initialize()
%4 = tail call i32 @validate_args(i32 %0, i8** %1)
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @load(i8* %6)
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.2, i64 0, i64 0)
%10 = zext i1 %8 to i32
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 %10
}