#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char real_password[8] = "monkey1\0";
  char password[8];
  printf("Enter the 7 character password:");
  gets(password);
  password[7] = '\0';
  if (!strcmp(password, real_password)) {
    printf("Success\n%s\n%s\n", real_password, password);
  } else {
    printf("Wrong password!\n%s\n%s\n", real_password, password);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <gets@plt>
movb   $0x0,-0x19(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    119d <main+0x6d>
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b3 <main+0x83>
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x3179656b6e6f6d,%rax
mov    %rax,0x8(%rsp)
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
movb   $0x0,0x17(%rsp)
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
lea    0xea1(%rip),%rax
lea    0xea9(%rip),%rdi
cmove  %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.real_password = [8 x i8] c"monkey1\00"
@.str = [32 x i8] c"Enter the 7 character password:\00"
@.str.1 = [15 x i8] c"Success\0A%s\0A%s\0A\00"
@.str.2 = [23 x i8] c"Wrong password!\0A%s\0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i8]
%7 = alloca [8 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [8 x i8]* %6 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 7
store i8 0, i8* %12
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%15 = call i32 @strcmp(i8* %13, i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %2
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19)
br label %25
21: ; preds = %2
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %23)
br label %25
25: ; preds = %21, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter the 7 character password:\00"
@.str.1 = [15 x i8] c"Success\0A%s\0A%s\0A\00"
@.str.2 = [23 x i8] c"Wrong password!\0A%s\0A%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca [8 x i8]
%5 = bitcast i64* %3 to i8*
store i64 13925750359879533, i64* %3
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %6)
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 7
store i8 0, i8* %9
%10 = call i32 @strcmp(i8* %6, i8* %5)
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %12, i64* %3, i8* %6)
ret i32 0
}