#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*/ sqlite3;

/* Variables and functions */
char charInput();
int /*<<< orphan*/ clrscr();
int /*<<< orphan*/ lineBreak();
int /*<<< orphan*/ listOptions();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ selection(char, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ sleep(int);
int environment(sqlite3 *db, char *username, int isAdmin) {
  int start_boolean = 0;
  char select;
  do {
    if ((select != '1') && (select != '6'))
      clrscr();
    if (start_boolean) {
      printf("What would you like to do now, %s? ", username);
    } else {
      printf("Hello there, %s.\n\n", username);
      listOptions();
      lineBreak();
      printf("What would you like to do, %s? ", username);
      start_boolean = 1;
    }
    select = charInput();
    if (select != '0')
      clrscr();
    selection(select, db, username, isAdmin);
  } while (select != '0');
  lineBreak();
  printf("Bye, %s!\n", username);
  sleep(2);
  clrscr();
  return 0;
}


x86 assembly (clang, -O0):
<environment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x31,%eax
je     11ab <environment+0x3b>
movsbl -0x19(%rbp),%eax
cmp    $0x36,%eax
je     11ab <environment+0x3b>
mov    $0x0,%al
call   1040 <clrscr@plt>
cmpl   $0x0,-0x18(%rbp)
je     11ca <environment+0x5a>
mov    -0x10(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1060 <printf@plt>
jmp    11ff <environment+0x8f>
mov    -0x10(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <listOptions@plt>
mov    $0x0,%al
call   1070 <lineBreak@plt>
mov    -0x10(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    $0x0,%al
call   1080 <charInput@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x30,%eax
je     121d <environment+0xad>
mov    $0x0,%al
call   1040 <clrscr@plt>
mov    -0x19(%rbp),%al
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
movsbl %al,%edi
call   1030 <selection@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x30,%eax
jne    118a <environment+0x1a>
mov    $0x0,%al
call   1070 <lineBreak@plt>
mov    -0x10(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1060 <printf@plt>
mov    $0x2,%edi
call   1090 <sleep@plt>
mov    $0x0,%al
call   1040 <clrscr@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<environment>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r12
mov    $0x1,%r15b
lea    0xe72(%rip),%r13
cmp    $0x31,%bl
je     11ac <environment+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x36,%bl
je     11ac <environment+0x3c>
xor    %eax,%eax
call   1040 <clrscr@plt>
mov    %r13,%rdi
test   $0x1,%r15b
je     11d9 <environment+0x69>
lea    0xe68(%rip),%rdi
mov    %rbp,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <listOptions@plt>
xor    %eax,%eax
call   1070 <lineBreak@plt>
lea    0xe5e(%rip),%rdi
mov    %rbp,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
call   1080 <charInput@plt>
cmp    $0x30,%al
je     1210 <environment+0xa0>
mov    %eax,%ebx
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <clrscr@plt>
movsbl %bl,%edi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
call   1030 <selection@plt>
cmp    $0x31,%bl
jne    11a0 <environment+0x30>
jmp    11ac <environment+0x3c>
mov    $0x30,%edi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
call   1030 <selection@plt>
xor    %eax,%eax
call   1070 <lineBreak@plt>
lea    0xe26(%rip),%rdi
mov    %rbp,%rsi
call   1060 <printf@plt>
mov    $0x2,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
call   1040 <clrscr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"What would you like to do now, %s? \00"
@.str.1 = [19 x i8] c"Hello there, %s.\0A\0A\00"
@.str.2 = [32 x i8] c"What would you like to do, %s? \00"
@.str.3 = [10 x i8] c"Bye, %s!\0A\00"
define i32 @environment(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %45, %3
%10 = load i8, i8* %8
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 49
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i8, i8* %8
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 54
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (...) @clrscr()
br label %19
19: ; preds = %17, %13, %9
%20 = load i32, i32* %7
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i8*, i8** %5
%24 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %32
25: ; preds = %19
%26 = load i8*, i8** %5
%27 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 (...) @listOptions()
%29 = call i32 (...) @lineBreak()
%30 = load i8*, i8** %5
%31 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %30)
store i32 1, i32* %7
br label %32
32: ; preds = %25, %22
%33 = call signext i8 (...) @charInput()
store i8 %33, i8* %8
%34 = load i8, i8* %8
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 48
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 (...) @clrscr()
br label %39
39: ; preds = %37, %32
%40 = load i8, i8* %8
%41 = load i32*, i32** %4
%42 = load i8*, i8** %5
%43 = load i32, i32* %6
%44 = call i32 @selection(i8 signext %40, i32* %41, i8* %42, i32 %43)
br label %45
45: ; preds = %39
%46 = load i8, i8* %8
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 48
br i1 %48, label %9, label %49
49: ; preds = %45
%50 = call i32 (...) @lineBreak()
%51 = load i8*, i8** %5
%52 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %51)
%53 = call i32 @sleep(i32 2)
%54 = call i32 (...) @clrscr()
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"What would you like to do now, %s? \00"
@.str.1 = [19 x i8] c"Hello there, %s.\0A\0A\00"
@.str.2 = [32 x i8] c"What would you like to do, %s? \00"
@.str.3 = [10 x i8] c"Bye, %s!\0A\00"
define i32 @environment(i32* %0, i8* %1, i32 %2) {
br label %4
4: ; preds = %19, %3
%5 = phi i1 [ false, %19 ], [ true, %3 ]
%6 = phi i8 [ %17, %19 ], [ undef, %3 ]
switch i8 %6, label %7 [
i8 54, label %9
i8 49, label %9
]
7: ; preds = %4
%8 = tail call i32 (...) @clrscr()
br label %9
9: ; preds = %4, %4, %7
br i1 %5, label %10, label %14
10: ; preds = %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%12 = tail call i32 (...) @listOptions()
%13 = tail call i32 (...) @lineBreak()
br label %14
14: ; preds = %9, %10
%15 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), %9 ]
%16 = tail call i32 @printf(i8* %15, i8* %1)
%17 = tail call signext i8 (...) @charInput()
%18 = icmp eq i8 %17, 48
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = tail call i32 (...) @clrscr()
%21 = tail call i32 @selection(i8 signext %17, i32* %0, i8* %1, i32 %2)
br label %4
22: ; preds = %14
%23 = tail call i32 @selection(i8 signext 48, i32* %0, i8* %1, i32 %2)
%24 = tail call i32 (...) @lineBreak()
%25 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%26 = tail call i32 @sleep(i32 2)
%27 = tail call i32 (...) @clrscr()
ret i32 0
}