#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 access(char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int main() {
  int x = 0;
  int i;
  char pass[9];
  for (i = 0; i < 3; i++) {
    printf("PLEASE ENTER PASSWORD: ");
    gets(pass);
    x = access(pass);
    if (x) {
      printf("\nACCESS ACCEPT\n");
      break;
    } else {
      printf("\nACCESS DENIED\n\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11b2 <main+0x82>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x15(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x15(%rbp),%rdi
call   1050 <access@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1193 <main+0x63>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
jmp    11b2 <main+0x82>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    11a4 <main+0x74>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
lea    0x7(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1060 <access@plt>
lea    0xeb7(%rip),%rbx
test   %eax,%eax
jne    11df <main+0x9f>
lea    0xe9c(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
lea    0x7(%rsp),%r15
mov    %r15,%rdi
call   1050 <gets@plt>
mov    %r15,%rdi
call   1060 <access@plt>
test   %eax,%eax
jne    11df <main+0x9f>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
lea    0x7(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1060 <access@plt>
test   %eax,%eax
lea    0xe4d(%rip),%rbx
cmove  %r14,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"PLEASE ENTER PASSWORD: \00"
@.str.1 = [16 x i8] c"\0AACCESS ACCEPT\0A\00"
@.str.2 = [17 x i8] c"\0AACCESS DENIED\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %21, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 3
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%13 = call i32 @access(i8* %12)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %24
18: ; preds = %8
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %5
24: ; preds = %16, %5
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"PLEASE ENTER PASSWORD: \00"
@str = [16 x i8] c"\0AACCESS DENIED\0A\00"
@str.3 = [15 x i8] c"\0AACCESS ACCEPT\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @access(i8* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %20
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @gets(i8* %2)
%11 = call i32 @access(i8* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %7
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @gets(i8* %2)
%17 = call i32 @access(i8* %2)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0)
br label %20
20: ; preds = %13, %0, %7
%21 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0), %0 ], [ %19, %13 ]
%22 = call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}