#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*/ printf(char *, int *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int check_authentication(char *password) {
  int auth_flag = 0;
  char password_buffer[16];
  printf("auth_flag : %p\npassword_buffer: %p\n", &auth_flag, password_buffer);
  strcpy(password_buffer, password);
  if (strcmp(password_buffer, "brillig") == 0)
    auth_flag = 1;
  if (strcmp(password_buffer, "outgrabe") == 0)
    auth_flag = 1;
  printf("auth_flag : %p\npassword_buffer: %p\n", &auth_flag, password_buffer);
  return auth_flag;
}


x86 assembly (clang, -O0):
<check_authentication>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x20(%rbp),%rdx
lea    0xeb2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1185 <check_authentication+0x55>
movl   $0x1,-0xc(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a6 <check_authentication+0x76>
movl   $0x1,-0xc(%rbp)
lea    -0x20(%rbp),%rdx
lea    0xe4f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_authentication>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xeb7(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xeb7(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1182 <check_authentication+0x52>
movl   $0x1,0xc(%rsp)
lea    0xea3(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11a0 <check_authentication+0x70>
movl   $0x1,0xc(%rsp)
lea    0xe59(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [36 x i8] c"auth_flag : %p\0Apassword_buffer: %p\0A\00"
@.str.1 = [8 x i8] c"brillig\00"
@.str.2 = [9 x i8] c"outgrabe\00"
define i32 @check_authentication(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [16 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32* %3, i8* %5)
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 1, i32* %3
br label %14
14: ; preds = %13, %1
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %3
br label %19
19: ; preds = %18, %14
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32* %3, i8* %20)
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [36 x i8] c"auth_flag : %p\0Apassword_buffer: %p\0A\00"
@.str.1 = [8 x i8] c"brillig\00"
@.str.2 = [9 x i8] c"outgrabe\00"
define i32 @check_authentication(i8* %0) {
%2 = alloca i32
%3 = alloca [16 x i8]
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32* %2, i8* %5)
%7 = call i32 @strcpy(i8* %5, i8* %0)
%8 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %11
11: ; preds = %10, %1
%12 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %2
br label %15
15: ; preds = %14, %11
%16 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32* %2, i8* %5)
%17 = load i32, i32* %2
ret i32 %17
}