#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*/ approve_returns();
int /*<<< orphan*/ change_pass();
int /*<<< orphan*/ flush();
int /*<<< orphan*/ getDB();
int /*<<< orphan*/ manage_stock();
int /*<<< orphan*/ match_pass();
int /*<<< orphan*/ print_issued_books(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ prompt(char *);
int /*<<< orphan*/ scanf(char *, int *);
void admin_panel() {
  int select;
  if (!match_pass())
    return;
  do {
    printf("\033[H\033[J");
    printf("Admin Tools\n"
           "1. See Issued Books\n2. Approve Returns\n"
           "3. Manage Stock\n4. Change Password\n"
           "5. Exit\nPlease select your choice : ");
    scanf("%d", &select);
    flush();
    switch (select) {
    case 1:
      printf("\n\nIssued Books : \n");
      print_issued_books(getDB());
      prompt("\n\n");
      break;
    case 2:
      while (!approve_returns())
        ;
      break;
    case 3:
      while (!manage_stock())
        ;
      break;
    case 4:
      change_pass();
      break;
    case 5:
      break;
    default:
      prompt("Wrong choice entered. Try again.");
      break;
    }
  } while (select != 5);
}


x86 assembly (clang, -O0):
<admin_panel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <match_pass@plt>
cmp    $0x0,%eax
jne    11bd <admin_panel+0x1d>
jmp    12c7 <admin_panel+0x127>
jmp    11c2 <admin_panel+0x22>
lea    0xe4b(%rip),%rdi
call   1090 <printf@plt>
lea    0xe46(%rip),%rdi
call   1090 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   10c0 <scanf@plt>
xor    %eax,%eax
call   1040 <flush@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     12ac <admin_panel+0x10c>
mov    -0x10(%rbp),%rax
lea    0xdef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe78(%rip),%rdi
call   1090 <printf@plt>
mov    $0x0,%al
call   1030 <getDB@plt>
mov    %eax,%edi
call   1060 <print_issued_books@plt>
lea    0xe71(%rip),%rdi
call   1070 <prompt@plt>
jmp    12b8 <admin_panel+0x118>
jmp    124a <admin_panel+0xaa>
mov    $0x0,%al
call   10b0 <approve_returns@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1266 <admin_panel+0xc6>
jmp    126b <admin_panel+0xcb>
jmp    124a <admin_panel+0xaa>
jmp    12b8 <admin_panel+0x118>
jmp    1275 <admin_panel+0xd5>
mov    $0x0,%al
call   10a0 <manage_stock@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1291 <admin_panel+0xf1>
jmp    1296 <admin_panel+0xf6>
jmp    1275 <admin_panel+0xd5>
jmp    12b8 <admin_panel+0x118>
mov    $0x0,%al
call   1080 <change_pass@plt>
jmp    12b8 <admin_panel+0x118>
jmp    12b8 <admin_panel+0x118>
lea    0xdfc(%rip),%rdi
call   1070 <prompt@plt>
jmp    12bd <admin_panel+0x11d>
cmpl   $0x5,-0x4(%rbp)
jne    11c2 <admin_panel+0x22>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<admin_panel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <match_pass@plt>
test   %eax,%eax
je     129c <admin_panel+0xec>
lea    0xe43(%rip),%r14
lea    0xe43(%rip),%r15
lea    0xeb7(%rip),%r12
lea    0x4(%rsp),%rbx
lea    0xe15(%rip),%rbp
lea    0xea7(%rip),%r13
jmp    1217 <admin_panel+0x67>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe95(%rip),%rdi
call   1080 <prompt@plt>
cmpl   $0x5,0x4(%rsp)
je     129c <admin_panel+0xec>
mov    %r14,%rdi
call   10a0 <printf@plt>
mov    %r15,%rdi
call   10a0 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10d0 <scanf@plt>
xor    %eax,%eax
call   1040 <flush@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1200 <admin_panel+0x50>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xe67(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1030 <getDB@plt>
mov    %eax,%edi
call   1070 <print_issued_books@plt>
mov    %r13,%rdi
jmp    1207 <admin_panel+0x57>
xchg   %ax,%ax
xor    %eax,%eax
call   10c0 <approve_returns@plt>
test   %eax,%eax
je     1270 <admin_panel+0xc0>
jmp    120c <admin_panel+0x5c>
nopl   (%rax)
xor    %eax,%eax
call   10b0 <manage_stock@plt>
test   %eax,%eax
je     1280 <admin_panel+0xd0>
jmp    120c <admin_panel+0x5c>
xor    %eax,%eax
call   1090 <change_pass@plt>
jmp    120c <admin_panel+0x5c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\1B[H\1B[J\00"
@.str.1 = [123 x i8] c"Admin Tools\0A1. See Issued Books\0A2. Approve Returns\0A3. Manage Stock\0A4. Change Password\0A5. Exit\0APlease select your choice : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"\0A\0AIssued Books : \0A\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
@.str.5 = [33 x i8] c"Wrong choice entered. Try again.\00"
define void @admin_panel() {
%1 = alloca i32
%2 = call i32 (...) @match_pass()
%3 = icmp ne i32 %2, 0
br i1 %3, label %5, label %4
4: ; preds = %0
br label %40
5: ; preds = %0
br label %6
6: ; preds = %37, %5
%7 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = call i32 (...) @flush()
%11 = load i32, i32* %1
switch i32 %11, label %34 [
i32 1, label %12
i32 2, label %17
i32 3, label %24
i32 4, label %31
i32 5, label %33
]
12: ; preds = %6
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (...) @getDB()
%15 = call i32 @print_issued_books(i32 %14)
%16 = call i32 @prompt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %36
17: ; preds = %6
br label %18
18: ; preds = %22, %17
%19 = call i32 (...) @approve_returns()
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %23
22: ; preds = %18
br label %18
23: ; preds = %18
br label %36
24: ; preds = %6
br label %25
25: ; preds = %29, %24
%26 = call i32 (...) @manage_stock()
%27 = icmp ne i32 %26, 0
%28 = xor i1 %27, true
br i1 %28, label %29, label %30
29: ; preds = %25
br label %25
30: ; preds = %25
br label %36
31: ; preds = %6
%32 = call i32 (...) @change_pass()
br label %36
33: ; preds = %6
br label %36
34: ; preds = %6
%35 = call i32 @prompt(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %33, %31, %30, %23, %12
br label %37
37: ; preds = %36
%38 = load i32, i32* %1
%39 = icmp ne i32 %38, 5
br i1 %39, label %6, label %40
40: ; preds = %4, %37
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"\1B[H\1B[J\00"
@.str.1 = [123 x i8] c"Admin Tools\0A1. See Issued Books\0A2. Approve Returns\0A3. Manage Stock\0A4. Change Password\0A5. Exit\0APlease select your choice : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
@.str.5 = [33 x i8] c"Wrong choice entered. Try again.\00"
@str = [18 x i8] c"\0A\0AIssued Books : \00"
define void @admin_panel() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @match_pass()
%4 = icmp eq i32 %3, 0
br i1 %4, label %29, label %5
5: ; preds = %0, %26
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([123 x i8], [123 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = call i32 (...) @flush()
%10 = load i32, i32* %1
switch i32 %10, label %24 [
i32 1, label %11
i32 2, label %16
i32 3, label %19
i32 4, label %22
i32 5, label %29
]
11: ; preds = %5
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%13 = call i32 (...) @getDB()
%14 = call i32 @print_issued_books(i32 %13)
%15 = call i32 @prompt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %26
16: ; preds = %5, %16
%17 = call i32 (...) @approve_returns()
%18 = icmp eq i32 %17, 0
br i1 %18, label %16, label %26
19: ; preds = %5, %19
%20 = call i32 (...) @manage_stock()
%21 = icmp eq i32 %20, 0
br i1 %21, label %19, label %26
22: ; preds = %5
%23 = call i32 (...) @change_pass()
br label %26
24: ; preds = %5
%25 = call i32 @prompt(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %19, %16, %11, %22, %24
%27 = load i32, i32* %1
%28 = icmp eq i32 %27, 5
br i1 %28, label %29, label %5
29: ; preds = %5, %26, %0
ret void
}