#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 /*<<< orphan*/ scanf(char *, char *);
int verify_password(char *);
int main() {
  int valid_flag = 0;
  char password[1024];
  while (1) {
    printf("please input password:");
    scanf("%s", password);
    valid_flag = verify_password(password);
    if (valid_flag) {
      printf("incorrect password!\n\n");
    } else {
      printf("Congratulation! You have passed the verification!\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xeb4(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x410(%rbp),%rdi
call   1030 <verify_password@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1192 <main+0x62>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
jmp    11a3 <main+0x73>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
jmp    11a8 <main+0x78>
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xeab(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <verify_password@plt>
test   %eax,%eax
je     11b7 <main+0x77>
lea    0xecd(%rip),%r14
lea    0xe7a(%rip),%r15
lea    0xe8a(%rip),%r12
mov    %rsp,%rbx
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <verify_password@plt>
test   %eax,%eax
jne    1190 <main+0x50>
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"please input password:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c"incorrect password!\0A\0A\00"
@.str.3 = [51 x i8] c"Congratulation! You have passed the verification!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %0, %16
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = call i32 @verify_password(i8* %8)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %4
%15 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
br label %17
16: ; preds = %12
br label %4
17: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"please input password:\00"
@.str.1 = [3 x i8] c"%s\00"
@str = [50 x i8] c"Congratulation! You have passed the verification!\00"
@str.4 = [21 x i8] c"incorrect password!\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @verify_password(i8* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%11 = call i32 @verify_password(i8* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %7, %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
ret i32 0
}