#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ hash_pass(char *, char *);
int load_pass(char **);
scalar_t__ login_prompt(int, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int pwsize;
  char *secretpw;
  setvbuf(stdout, NULL, _IONBF, 0);
  pwsize = load_pass(&secretpw);
  pwsize = pwsize > 32 ? 32 : pwsize;
  if (pwsize == 0 || pwsize == -1)
    return EXIT_FAILURE;
  hash_pass(secretpw, "lab6A");
  printf("----------- FALK OS LOGIN PROMPT -----------\n");
  fflush(stdout);
  if (login_prompt(pwsize, secretpw)) {
    printf("+-------------------------------------------------------+\n"
           "|WARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNIN|\n"
           "|GWARNINGWARNI - TOO MANY LOGIN ATTEMPTS - NGWARNINGWARN|\n"
           "|INGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWAR|\n"
           "+-------------------------------------------------------+\n"
           "|       We have logged this session and will be         |\n"
           "|  sending it to the proper CCDC CTF teams to analyze   |\n"
           "|             -----------------------------             |\n"
           "|     The CCDC cyber team dispatched will use their     |\n"
           "|      masterful IT and networking skills to trace      |\n"
           "|       you down and serve swift american justice       |\n"
           "+-------------------------------------------------------+\n");
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
lea    -0x20(%rbp),%rdi
call   1060 <load_pass@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jle    11b6 <main+0x56>
mov    $0x20,%eax
mov    %eax,-0x24(%rbp)
jmp    11bc <main+0x5c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11d6 <main+0x76>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11e7 <main+0x87>
mov    0x2dfb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1250 <main+0xf0>
mov    -0x20(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   1080 <hash_pass@plt>
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <login_prompt@plt>
cmp    $0x0,%rax
je     1244 <main+0xe4>
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1250 <main+0xf0>
mov    0x2d7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e60(%rip),%r15
mov    (%r15),%edi
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
lea    0x8(%rsp),%rdi
call   1060 <load_pass@plt>
cmp    $0x20,%eax
mov    $0x20,%ebx
cmovl  %eax,%ebx
lea    0x1(%rbx),%eax
mov    0x2e34(%rip),%r14
cmp    $0x2,%eax
jb     11f4 <main+0x94>
mov    0x8(%rsp),%rdi
lea    0xe4b(%rip),%rsi
call   1080 <hash_pass@plt>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%edi
call   1050 <fflush@plt>
mov    0x8(%rsp),%rsi
mov    %ebx,%edi
call   1040 <login_prompt@plt>
test   %rax,%rax
je     11ed <main+0x8d>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
jmp    11f4 <main+0x94>
mov    0x2dd4(%rip),%r14
mov    (%r14),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [6 x i8] c"lab6A\00"
@.str.1 = [46 x i8] c"----------- FALK OS LOGIN PROMPT -----------\0A\00"
@.str.2 = [697 x i8] c"+-------------------------------------------------------+\0A|WARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNIN|\0A|GWARNINGWARNI - TOO MANY LOGIN ATTEMPTS - NGWARNINGWARN|\0A|INGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWAR|\0A+-------------------------------------------------------+\0A| We have logged this session and will be |\0A| sending it to the proper CCDC CTF teams to analyze |\0A| ----------------------------- |\0A| The CCDC cyber team dispatched will use their |\0A| masterful IT and networking skills to trace |\0A| you down and serve swift american justice |\0A+-------------------------------------------------------+\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @stdout
%9 = load i32, i32* @_IONBF
%10 = call i32 @setvbuf(i32 %8, i32* null, i32 %9, i32 0)
%11 = call i32 @load_pass(i8** %7)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp sgt i32 %12, 32
br i1 %13, label %14, label %15
14: ; preds = %2
br label %17
15: ; preds = %2
%16 = load i32, i32* %6
br label %17
17: ; preds = %15, %14
%18 = phi i32 [ 32, %14 ], [ %16, %15 ]
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %21, %17
%25 = load i32, i32* @EXIT_FAILURE
store i32 %25, i32* %3
br label %41
26: ; preds = %21
%27 = load i8*, i8** %7
%28 = call i32 @hash_pass(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @stdout
%31 = call i32 @fflush(i32 %30)
%32 = load i32, i32* %6
%33 = load i8*, i8** %7
%34 = call i64 @login_prompt(i32 %32, i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %26
%37 = call i32 @printf(i8* getelementptr inbounds ([697 x i8], [697 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
store i32 %38, i32* %3
br label %41
39: ; preds = %26
%40 = load i32, i32* @EXIT_SUCCESS
store i32 %40, i32* %3
br label %41
41: ; preds = %39, %36, %24
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [6 x i8] c"lab6A\00"
@EXIT_SUCCESS = global i32 0
@str = [45 x i8] c"----------- FALK OS LOGIN PROMPT -----------\00"
@str.3 = [696 x i8] c"+-------------------------------------------------------+\0A|WARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNIN|\0A|GWARNINGWARNI - TOO MANY LOGIN ATTEMPTS - NGWARNINGWARN|\0A|INGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWARNINGWAR|\0A+-------------------------------------------------------+\0A| We have logged this session and will be |\0A| sending it to the proper CCDC CTF teams to analyze |\0A| ----------------------------- |\0A| The CCDC cyber team dispatched will use their |\0A| masterful IT and networking skills to trace |\0A| you down and serve swift american justice |\0A+-------------------------------------------------------+\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i32, i32* @stdout
%6 = load i32, i32* @_IONBF
%7 = tail call i32 @setvbuf(i32 %5, i32* null, i32 %6, i32 0)
%8 = call i32 @load_pass(i8** %3)
%9 = icmp slt i32 %8, 32
%10 = select i1 %9, i32 %8, i32 32
%11 = add nsw i32 %10, 1
%12 = icmp ult i32 %11, 2
br i1 %12, label %24, label %13
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i32 @hash_pass(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
%19 = load i8*, i8** %3
%20 = call i64 @login_prompt(i32 %10, i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %13
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([696 x i8], [696 x i8]* @str.3, i64 0, i64 0))
br label %24
24: ; preds = %13, %2, %22
%25 = phi i32* [ @EXIT_FAILURE, %22 ], [ @EXIT_FAILURE, %2 ], [ @EXIT_SUCCESS, %13 ]
%26 = load i32, i32* %25
ret i32 %26
}