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

/* Variables and functions */
int /*<<< orphan*/ createList();
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
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+");
  char lineInsert[256];
  time_t rawtime;
  time(&rawtime);
  snprintf(lineInsert, sizeof(lineInsert), "%s%s %s\n", ctime(&rawtime),
           username, password);
  fprintf(file, "%s", lineInsert);
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe37(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <createList@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x3,-0x84(%rbp)
jge    1281 <main+0xd1>
lea    0xe2e(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   10c0 <scanf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
lea    0xe19(%rip),%rdi
call   1050 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe06(%rip),%rdi
call   10c0 <scanf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10b0 <valid@plt>
cmp    $0x0,%rax
je     1261 <main+0xb1>
lea    0xdea(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    131d <main+0x16d>
lea    0xdf4(%rip),%rdi
call   1050 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11df <main+0x2f>
lea    0xdee(%rip),%rdi
call   1050 <printf@plt>
lea    0xdf7(%rip),%rdi
lea    0xe00(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x90(%rbp)
lea    -0x194(%rbp),%rdi
call   1090 <time@plt>
lea    -0x190(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
lea    -0x194(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x1a0(%rbp),%rdi
mov    %rax,%rcx
lea    -0x40(%rbp),%r8
lea    -0x80(%rbp),%r9
mov    $0x100,%esi
lea    0xdb3(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x90(%rbp),%rdi
lea    -0x190(%rbp),%rdx
lea    0xd27(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x90(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x190,%rsp
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10b0 <createList@plt>
lea    0xe1a(%rip),%rdi
call   1060 <printf@plt>
lea    0xe19(%rip),%r15
lea    0x50(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   10d0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
lea    0xdfe(%rip),%rdi
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10d0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10c0 <valid@plt>
test   %rax,%rax
jne    1312 <main+0x152>
lea    0xe22(%rip),%rdi
call   1030 <puts@plt>
lea    0xdad(%rip),%rdi
call   1060 <printf@plt>
lea    0xdac(%rip),%r15
lea    0x50(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   10d0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
lea    0xd91(%rip),%rdi
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10d0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10c0 <valid@plt>
test   %rax,%rax
jne    1312 <main+0x152>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xd44(%rip),%rdi
call   1060 <printf@plt>
lea    0xd43(%rip),%r15
lea    0x50(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   10d0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
lea    0xd28(%rip),%rdi
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10d0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10c0 <valid@plt>
test   %rax,%rax
je     132d <main+0x16d>
lea    0xd69(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd35(%rip),%rdi
call   1030 <puts@plt>
lea    0xd15(%rip),%rdi
call   1030 <puts@plt>
lea    0xccd(%rip),%rdi
lea    0xcd6(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   10a0 <time@plt>
mov    %r14,%rdi
call   1050 <ctime@plt>
lea    0xcb5(%rip),%rdx
lea    0x90(%rsp),%r14
lea    0x50(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rax,%rcx
call   1070 <snprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <fputs@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    131e <main+0x15e>

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"
@.str.9 = [9 x i8] c"%s%s %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [256 x i8]
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @createList()
store i32 0, i32* %4
br label %10
10: ; preds = %30, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = call i32 (...) @getchar()
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call i32 (...) @getchar()
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%24 = call i64 @valid(i8* %22, i8* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %13
%27 = 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 %47
28: ; preds = %13
%29 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %10
33: ; preds = %10
%34 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%35 = 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* %35, i32** %5
%36 = call i32 @time(i32* %7)
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%38 = call i8* @ctime(i32* %7)
%39 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%41 = call i32 @snprintf(i8* %37, i32 256, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %38, i8* %39, i8* %40)
%42 = load i32*, i32** %5
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%44 = call i32 @fprintf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = load i32*, i32** %5
%46 = call i32 @fclose(i32* %45)
store i32 0, i32* %1
br label %47
47: ; preds = %33, %26
%48 = load i32, i32* %1
ret i32 %48
}

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.9 = [9 x i8] c"%s%s %s\0A\00"
@str = [32 x i8] c"Welcome to Michael's login page\00"
@str.10 = [20 x i8] c"Calling the police!\00"
@str.11 = [25 x i8] c"Sorry, please try again.\00"
@str.12 = [33 x i8] c"Congratulations, you've made it!\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (...) @createList()
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%11 = call i32 (...) @getchar()
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%14 = call i32 (...) @getchar()
%15 = call i64 @valid(i8* %7, i8* %8)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %29, %19, %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.12, i64 0, i64 0))
br label %50
19: ; preds = %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%23 = call i32 (...) @getchar()
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%26 = call i32 (...) @getchar()
%27 = call i64 @valid(i8* %7, i8* %8)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %17
29: ; preds = %19
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%33 = call i32 (...) @getchar()
%34 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%36 = call i32 (...) @getchar()
%37 = call i64 @valid(i8* %7, i8* %8)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %17
39: ; preds = %29
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%42 = 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))
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%44 = bitcast i32* %4 to i8*
%45 = call i32 @time(i32* %4)
%46 = call i8* @ctime(i32* %4)
%47 = call i32 @snprintf(i8* %43, i32 256, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %46, i8* %7, i8* %8)
%48 = call i32 @fputs(i8* %43, i32* %42)
%49 = call i32 @fclose(i32* %42)
br label %50
50: ; preds = %39, %17
ret i32 0
}