#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 */
int /*<<< orphan*/ addUserFunction(int /*<<< orphan*/ *);
char charInput();
int /*<<< orphan*/ free(char *);
int inputYOrN(int /*<<< orphan*/);
int /*<<< orphan*/ lineBreak();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ removeUserFunction(int /*<<< orphan*/ *);
scalar_t__ searchForUser(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sleep(int);
char *stringInput(int);
void manageAccounts(sqlite3 *db, char *username, int isAdmin) {
  if (isAdmin) {
    char *password;
    printf("Enter your password: ");
    password = stringInput(1);
    if (searchForUser(db, username, password)) {
      int cont;
      do {
        lineBreak();
        char option;
        int attemptResult = 0;
        do {
          printf("Do you want to Add(A) or Remove(R) accounts? ");
          option = charInput();
          attemptResult = ((option == 'A') || (option == 'a') ||
                           (option == 'R') || (option == 'r'));
          if (attemptResult != 1) {
            printf("\nIncorrect input detected. Please enter 'A' or 'R'.\n");
            lineBreak();
          }
        } while (attemptResult != 1);
        if ((option == 'A') || (option == 'a')) {
          addUserFunction(db);
        } else {
          removeUserFunction(db);
        }
        cont = inputYOrN(0);
      } while (cont);
    } else {
      printf("\nIncorrect password. Exiting program.\n");
    }
    free(password);
  } else {
    printf("You are not an admin.\n");
    puts("Please log out and retry using an admin account.");
  }
  sleep(2);
}


x86 assembly (clang, -O0):
<manageAccounts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1309 <manageAccounts+0x159>
lea    0xe2c(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   1060 <stringInput@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <searchForUser@plt>
cmp    $0x0,%rax
je     12ef <manageAccounts+0x13f>
jmp    1207 <manageAccounts+0x57>
mov    $0x0,%al
call   1090 <lineBreak@plt>
movl   $0x0,-0x2c(%rbp)
lea    0xdfa(%rip),%rdi
call   1080 <printf@plt>
mov    $0x0,%al
call   10b0 <charInput@plt>
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%ecx
mov    $0x1,%al
cmp    $0x41,%ecx
mov    %al,-0x2d(%rbp)
je     126e <manageAccounts+0xbe>
movsbl -0x25(%rbp),%ecx
mov    $0x1,%al
cmp    $0x61,%ecx
mov    %al,-0x2d(%rbp)
je     126e <manageAccounts+0xbe>
movsbl -0x25(%rbp),%ecx
mov    $0x1,%al
cmp    $0x52,%ecx
mov    %al,-0x2d(%rbp)
je     126e <manageAccounts+0xbe>
movsbl -0x25(%rbp),%eax
cmp    $0x72,%eax
sete   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x1,-0x2c(%rbp)
je     1296 <manageAccounts+0xe6>
lea    0xdba(%rip),%rdi
call   1080 <printf@plt>
mov    $0x0,%al
call   1090 <lineBreak@plt>
jmp    129b <manageAccounts+0xeb>
cmpl   $0x1,-0x2c(%rbp)
jne    1215 <manageAccounts+0x65>
movsbl -0x25(%rbp),%eax
cmp    $0x41,%eax
je     12bf <manageAccounts+0x10f>
movsbl -0x25(%rbp),%eax
cmp    $0x61,%eax
jne    12cd <manageAccounts+0x11d>
mov    -0x8(%rbp),%rdi
call   10a0 <addUserFunction@plt>
jmp    12d6 <manageAccounts+0x126>
mov    -0x8(%rbp),%rdi
call   10c0 <removeUserFunction@plt>
xor    %edi,%edi
call   1040 <inputYOrN@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1207 <manageAccounts+0x57>
jmp    12fb <manageAccounts+0x14b>
lea    0xd83(%rip),%rdi
call   1080 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    1321 <manageAccounts+0x171>
lea    0xd90(%rip),%rdi
call   1080 <printf@plt>
lea    0xd9b(%rip),%rdi
call   1050 <puts@plt>
mov    $0x2,%edi
call   10d0 <sleep@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manageAccounts>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
je     127a <manageAccounts+0xca>
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe32(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   1060 <stringInput@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1070 <searchForUser@plt>
test   %rax,%rax
je     1294 <manageAccounts+0xe4>
lea    0xe18(%rip),%r15
lea    0xeac(%rip),%r12
movabs $0x2000100020001,%r13
jmp    1230 <manageAccounts+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   10c0 <removeUserFunction@plt>
xor    %edi,%edi
call   1040 <inputYOrN@plt>
test   %eax,%eax
je     12a0 <manageAccounts+0xf0>
xor    %eax,%eax
call   1090 <lineBreak@plt>
mov    %r15,%rdi
call   1080 <printf@plt>
xor    %eax,%eax
call   10b0 <charInput@plt>
lea    -0x41(%rax),%ecx
cmp    $0x31,%cl
ja     1270 <manageAccounts+0xc0>
movzbl %cl,%ecx
bt     %rcx,%r13
jae    1270 <manageAccounts+0xc0>
and    $0xdf,%al
mov    %rbx,%rdi
cmp    $0x41,%al
jne    1220 <manageAccounts+0x70>
call   10a0 <addUserFunction@plt>
jmp    1225 <manageAccounts+0x75>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <puts@plt>
jmp    1230 <manageAccounts+0x80>
lea    0xdf4(%rip),%rdi
call   1050 <puts@plt>
lea    0xdb7(%rip),%rdi
call   1050 <puts@plt>
jmp    12a8 <manageAccounts+0xf8>
lea    0xdf0(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0x2,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    10d0 <sleep@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Enter your password: \00"
@.str.1 = [46 x i8] c"Do you want to Add(A) or Remove(R) accounts? \00"
@.str.2 = [53 x i8] c"\0AIncorrect input detected. Please enter 'A' or 'R'.\0A\00"
@.str.3 = [39 x i8] c"\0AIncorrect password. Exiting program.\0A\00"
@.str.4 = [23 x i8] c"You are not an admin.\0A\00"
@.str.5 = [49 x i8] c"Please log out and retry using an admin account.\00"
define void @manageAccounts(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %79
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%15 = call i8* @stringInput(i32 1)
store i8* %15, i8** %7
%16 = load i32*, i32** %4
%17 = load i8*, i8** %5
%18 = load i8*, i8** %7
%19 = call i64 @searchForUser(i32* %16, i8* %17, i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %74
21: ; preds = %13
br label %22
22: ; preds = %70, %21
%23 = call i32 (...) @lineBreak()
store i32 0, i32* %10
br label %24
24: ; preds = %51, %22
%25 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%26 = call signext i8 (...) @charInput()
store i8 %26, i8* %9
%27 = load i8, i8* %9
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 65
br i1 %29, label %42, label %30
30: ; preds = %24
%31 = load i8, i8* %9
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 97
br i1 %33, label %42, label %34
34: ; preds = %30
%35 = load i8, i8* %9
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 82
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8, i8* %9
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 114
br label %42
42: ; preds = %38, %34, %30, %24
%43 = phi i1 [ true, %34 ], [ true, %30 ], [ true, %24 ], [ %41, %38 ]
%44 = zext i1 %43 to i32
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = icmp ne i32 %45, 1
br i1 %46, label %47, label %50
47: ; preds = %42
%48 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 (...) @lineBreak()
br label %50
50: ; preds = %47, %42
br label %51
51: ; preds = %50
%52 = load i32, i32* %10
%53 = icmp ne i32 %52, 1
br i1 %53, label %24, label %54
54: ; preds = %51
%55 = load i8, i8* %9
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 65
br i1 %57, label %62, label %58
58: ; preds = %54
%59 = load i8, i8* %9
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 97
br i1 %61, label %62, label %65
62: ; preds = %58, %54
%63 = load i32*, i32** %4
%64 = call i32 @addUserFunction(i32* %63)
br label %68
65: ; preds = %58
%66 = load i32*, i32** %4
%67 = call i32 @removeUserFunction(i32* %66)
br label %68
68: ; preds = %65, %62
%69 = call i32 @inputYOrN(i32 0)
store i32 %69, i32* %8
br label %70
70: ; preds = %68
%71 = load i32, i32* %8
%72 = icmp ne i32 %71, 0
br i1 %72, label %22, label %73
73: ; preds = %70
br label %76
74: ; preds = %13
%75 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %76
76: ; preds = %74, %73
%77 = load i8*, i8** %7
%78 = call i32 @free(i8* %77)
br label %82
79: ; preds = %3
%80 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%81 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %82
82: ; preds = %79, %76
%83 = call i32 @sleep(i32 2)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter your password: \00"
@.str.1 = [46 x i8] c"Do you want to Add(A) or Remove(R) accounts? \00"
@.str.5 = [49 x i8] c"Please log out and retry using an admin account.\00"
@str = [22 x i8] c"You are not an admin.\00"
@str.6 = [38 x i8] c"\0AIncorrect password. Exiting program.\00"
@str.7 = [52 x i8] c"\0AIncorrect input detected. Please enter 'A' or 'R'.\00"
define void @manageAccounts(i32* %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %31, label %5
5: ; preds = %3
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @stringInput(i32 1)
%8 = tail call i64 @searchForUser(i32* %0, i8* %1, i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %27, label %10
10: ; preds = %5, %16
%11 = tail call i32 (...) @lineBreak()
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call signext i8 (...) @charInput()
switch i8 %13, label %14 [
i8 97, label %17
i8 82, label %17
i8 65, label %17
i8 114, label %17
]
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.7, i64 0, i64 0))
br label %16
16: ; preds = %14, %24
br label %10
17: ; preds = %10, %10, %10, %10
%18 = and i8 %13, -33
%19 = icmp eq i8 %18, 65
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @addUserFunction(i32* %0)
br label %24
22: ; preds = %17
%23 = tail call i32 @removeUserFunction(i32* %0)
br label %24
24: ; preds = %22, %20
%25 = tail call i32 @inputYOrN(i32 0)
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %16
27: ; preds = %5
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.6, i64 0, i64 0))
br label %29
29: ; preds = %24, %27
%30 = tail call i32 @free(i8* %7)
br label %34
31: ; preds = %3
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %31, %29
%35 = tail call i32 @sleep(i32 2)
ret void
}