#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*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int login();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
int main() {
  setbuf(stdout, NULL);
  char input[8];
  puts("The authenticity of host 'backend.cia.gov (96.17.215.26)' can't be "
       "established.");
  puts("ECDSA key fingerprint is "
       "SHA256:1loFo62WjwvamuIcfhqo4O2PNdltJgSJ7fB3GpKLm4o.");
  printf("Are you sure you want to continue connecting (yes/no)? ");
  fgets(input, 9, stdin);
  int access = login();
  if (access >= 0xff || access < 0) {
    puts("INVALID ACCOUNT ACCESS LEVEL!");
  } else if (access <= 0x20) {
    puts("SUCCESSFULLY LOGGED IN AS ADMIN!");
    system("/bin/sh");
  } else {
    puts("SUCCESSFULLY LOGGED IN AS USER!");
    puts("ERROR: YOU HAVE BEEN FIRED!");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <setbuf@plt>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    0xeed(%rip),%rdi
call   1060 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    0x2e28(%rip),%rax
mov    (%rax),%edx
mov    $0x9,%esi
call   1070 <fgets@plt>
mov    $0x0,%al
call   1080 <login@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xff,-0x10(%rbp)
jge    11ed <main+0x7d>
cmpl   $0x0,-0x10(%rbp)
jge    11fe <main+0x8e>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
jmp    124c <main+0xdc>
cmpl   $0x20,-0x10(%rbp)
jg     1225 <main+0xb5>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xef9(%rip),%rdi
call   1050 <system@plt>
jmp    1247 <main+0xd7>
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    124c <main+0xdc>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <setbuf@plt>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0xefd(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x9,%esi
call   1070 <fgets@plt>
xor    %eax,%eax
call   1080 <login@plt>
cmp    $0xff,%eax
jb     11d7 <main+0x67>
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
jmp    11f4 <main+0x84>
cmp    $0x20,%eax
ja     11f8 <main+0x88>
lea    0xf10(%rip),%rdi
call   1030 <puts@plt>
lea    0xf25(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xf1d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf31(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [80 x i8] c"The authenticity of host 'backend.cia.gov (96.17.215.26)' can't be established.\00"
@.str.1 = [77 x i8] c"ECDSA key fingerprint is SHA256:1loFo62WjwvamuIcfhqo4O2PNdltJgSJ7fB3GpKLm4o.\00"
@.str.2 = [56 x i8] c"Are you sure you want to continue connecting (yes/no)? \00"
@stdin = global i32 0
@.str.3 = [30 x i8] c"INVALID ACCOUNT ACCESS LEVEL!\00"
@.str.4 = [33 x i8] c"SUCCESSFULLY LOGGED IN AS ADMIN!\00"
@.str.5 = [8 x i8] c"/bin/sh\00"
@.str.6 = [32 x i8] c"SUCCESSFULLY LOGGED IN AS USER!\00"
@.str.7 = [28 x i8] c"ERROR: YOU HAVE BEEN FIRED!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @stdout
%5 = call i32 @setbuf(i32 %4, i32* null)
%6 = call i32 @puts(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 9, i32 %10)
%12 = call i32 (...) @login()
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp sge i32 %13, 255
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15, %0
%19 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %31
20: ; preds = %15
%21 = load i32, i32* %3
%22 = icmp sle i32 %21, 32
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %30
26: ; preds = %20
%27 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%28 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %23
br label %31
31: ; preds = %30, %18
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [80 x i8] c"The authenticity of host 'backend.cia.gov (96.17.215.26)' can't be established.\00"
@.str.1 = [77 x i8] c"ECDSA key fingerprint is SHA256:1loFo62WjwvamuIcfhqo4O2PNdltJgSJ7fB3GpKLm4o.\00"
@.str.2 = [56 x i8] c"Are you sure you want to continue connecting (yes/no)? \00"
@stdin = global i32 0
@.str.3 = [30 x i8] c"INVALID ACCOUNT ACCESS LEVEL!\00"
@.str.4 = [33 x i8] c"SUCCESSFULLY LOGGED IN AS ADMIN!\00"
@.str.5 = [8 x i8] c"/bin/sh\00"
@.str.6 = [32 x i8] c"SUCCESSFULLY LOGGED IN AS USER!\00"
@.str.7 = [28 x i8] c"ERROR: YOU HAVE BEEN FIRED!\00"
define i32 @main() {
%1 = alloca [8 x i8]
%2 = load i32, i32* @stdout
%3 = tail call i32 @setbuf(i32 %2, i32* null)
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %4, i32 9, i32 %8)
%10 = call i32 (...) @login()
%11 = icmp ugt i32 %10, 254
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %23
14: ; preds = %0
%15 = icmp ult i32 %10, 33
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %23
19: ; preds = %14
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %16, %12
ret i32 0
}