int main(void) {
  char input[128] = {"\0"};
  printf("Please enter a password.\n\nJust kidding,\nfor the purpose of this "
         "program I will force a password to be entered\n\n");
  strcpy(input, "LookMom,I'mAHack");
  printf("Password:\t%s\n", input);
  if (authenticate(input)) {
    printf("\nValid!\nWelcome to my secure files!\n");
  } else
    printf("\nAccess denied!\n");
  printf("\nPress enter to exit\n");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xedf(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x90(%rbp),%rsi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x0,%al
call   1030 <authenticate@plt>
cmp    $0x0,%eax
je     11d5 <main+0x85>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11e3 <main+0x93>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
lea    0xed0(%rip),%rdi
call   1040 <puts@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x11(%rsp)
movups %xmm0,0x21(%rsp)
movups %xmm0,0x31(%rsp)
movups %xmm0,0x41(%rsp)
movups %xmm0,0x51(%rsp)
movups %xmm0,0x61(%rsp)
movups %xmm0,0x70(%rsp)
movups 0xe7f(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xe80(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <authenticate@plt>
test   %eax,%eax
lea    0xedd(%rip),%rax
lea    0xefb(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [112 x i8] c"Please enter a password.\0A\0AJust kidding,\0Afor the purpose of this program I will force a password to be entered\0A\0A\00"
@.str.1 = [17 x i8] c"LookMom,I'mAHack\00"
@.str.2 = [14 x i8] c"Password:\09%s\0A\00"
@.str.3 = [37 x i8] c"\0AValid!\0AWelcome to my secure files!\0A\00"
@.str.4 = [17 x i8] c"\0AAccess denied!\0A\00"
@.str.5 = [22 x i8] c"\0APress enter to exit\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
%3 = bitcast [128 x i8]* %2 to i8*
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = call i8* @strcpy(i8* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @authenticate to i32 (i8*, ...)*)(i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"LookMom,I'mAHack\00"
@.str.2 = [14 x i8] c"Password:\09%s\0A\00"
@str = [111 x i8] c"Please enter a password.\0A\0AJust kidding,\0Afor the purpose of this program I will force a password to be entered\0A\00"
@str.6 = [16 x i8] c"\0AAccess denied!\00"
@str.7 = [21 x i8] c"\0APress enter to exit\00"
@str.8 = [36 x i8] c"\0AValid!\0AWelcome to my secure files!\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([111 x i8], [111 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 17
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @authenticate to i32 (i8*, ...)*)(i8* %2)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.8, i64 0, i64 0)
%9 = call i32 @puts(i8* dereferenceable(1) %8)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%11 = call i32 (...) @getchar()
ret i32 0
}