#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ createList();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ valid(char *, char *);
int main(void) {
  printf("Welcome to Michael's login page\n");
  createList();
  char username[50];
  char password[50];
  int numberTries = 0;
  while (numberTries < 3) {
    printf("Username: ");
    scanf("%s", username);
    getchar();
    printf("Password: ");
    scanf("%s", password);
    getchar();
    if (valid(username, password)) {
      printf("Congratulations, you've made it!\n");
      return 0;
    } else {
      printf("Sorry, please try again.\n");
    }
    numberTries++;
  }
  printf("Calling the police!\n");
  FILE *file = fopen("LoginErrors.txt", "a+");
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <createList@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x3,-0x84(%rbp)
jge    1241 <main+0xd1>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1070 <valid@plt>
cmp    $0x0,%rax
je     1221 <main+0xb1>
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127a <main+0x10a>
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    119f <main+0x2f>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
lea    0xe40(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <createList@plt>
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe59(%rip),%r15
lea    0x40(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xe3e(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <valid@plt>
test   %rax,%rax
jne    12cc <main+0x14c>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
lea    0xdef(%rip),%rdi
call   1050 <printf@plt>
lea    0xdee(%rip),%r15
lea    0x40(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xdd3(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <valid@plt>
test   %rax,%rax
jne    12cc <main+0x14c>
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
lea    0xd88(%rip),%rdi
call   1050 <printf@plt>
lea    0xd87(%rip),%r15
lea    0x40(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xd6c(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <valid@plt>
test   %rax,%rax
je     12e7 <main+0x167>
lea    0xda6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd72(%rip),%rdi
call   1030 <puts@plt>
lea    0xd52(%rip),%rdi
call   1030 <puts@plt>
lea    0xd13(%rip),%rdi
lea    0xd1c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rdi
call   1040 <fclose@plt>
jmp    12d8 <main+0x158>

LLVM IR (-O0):
@.str = [33 x i8] c"Welcome to Michael's login page\0A\00"
@.str.1 = [11 x i8] c"Username: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [11 x i8] c"Password: \00"
@.str.4 = [34 x i8] c"Congratulations, you've made it!\0A\00"
@.str.5 = [26 x i8] c"Sorry, please try again.\0A\00"
@.str.6 = [21 x i8] c"Calling the police!\0A\00"
@.str.7 = [16 x i8] c"LoginErrors.txt\00"
@.str.8 = [3 x i8] c"a+\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @createList()
store i32 0, i32* %4
br label %8
8: ; preds = %28, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %31
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = call i32 (...) @getchar()
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = call i32 (...) @getchar()
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%22 = call i64 @valid(i8* %20, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %11
%25 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %36
26: ; preds = %11
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %28
28: ; preds = %26
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %8
31: ; preds = %8
%32 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%33 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %33, i32** %5
%34 = load i32*, i32** %5
%35 = call i32 @fclose(i32* %34)
store i32 0, i32* %1
br label %36
36: ; preds = %31, %24
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"Username: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [11 x i8] c"Password: \00"
@.str.7 = [16 x i8] c"LoginErrors.txt\00"
@.str.8 = [3 x i8] c"a+\00"
@str = [32 x i8] c"Welcome to Michael's login page\00"
@str.9 = [20 x i8] c"Calling the police!\00"
@str.10 = [25 x i8] c"Sorry, please try again.\00"
@str.11 = [33 x i8] c"Congratulations, you've made it!\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @createList()
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%9 = call i32 (...) @getchar()
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%12 = call i32 (...) @getchar()
%13 = call i64 @valid(i8* %5, i8* %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %27, %17, %0
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0))
br label %42
17: ; preds = %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%21 = call i32 (...) @getchar()
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%24 = call i32 (...) @getchar()
%25 = call i64 @valid(i8* %5, i8* %6)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %15
27: ; preds = %17
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%31 = call i32 (...) @getchar()
%32 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%34 = call i32 (...) @getchar()
%35 = call i64 @valid(i8* %5, i8* %6)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %15
37: ; preds = %27
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%40 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %37, %15
ret i32 0
}