#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*/ admin_panel();
int /*<<< orphan*/ construct();
int /*<<< orphan*/ flush();
int /*<<< orphan*/ issue();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ prompt(char *);
int /*<<< orphan*/ request_return();
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int select;
  if (!construct())
    return !prompt("");
  do {
    printf("\033[H\033[J");
    printf("Welcome to Library Management System\n\nMain Menu:\n"
           "1. Issue a Book\n2. Return a Book\n"
           "3. Admin Panel\n4. Exit\n"
           "Please select your choice : ");
    scanf("%d", &select);
    flush();
    switch (select) {
    case 1:
      while (!issue())
        ;
      break;
    case 2:
      while (!request_return())
        ;
      break;
    case 3:
      admin_panel();
      break;
    case 4:
      break;
    default:
      prompt("Please enter correct choice.");
      break;
    }
  } while (select != 4);
  prompt("\nProgram exiting...\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <construct@plt>
cmp    $0x0,%eax
jne    11c0 <main+0x40>
lea    0xf2b(%rip),%rdi
call   1050 <prompt@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12b2 <main+0x132>
jmp    11c5 <main+0x45>
lea    0xe44(%rip),%rdi
call   1060 <printf@plt>
lea    0xe3f(%rip),%rdi
call   1060 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1030 <flush@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1284 <main+0x104>
mov    -0x10(%rbp),%rax
lea    0xdec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1222 <main+0xa2>
mov    $0x0,%al
call   1070 <issue@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    123e <main+0xbe>
jmp    1243 <main+0xc3>
jmp    1222 <main+0xa2>
jmp    1290 <main+0x110>
jmp    124d <main+0xcd>
mov    $0x0,%al
call   1040 <request_return@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1269 <main+0xe9>
jmp    126e <main+0xee>
jmp    124d <main+0xcd>
jmp    1290 <main+0x110>
mov    $0x0,%al
call   1080 <admin_panel@plt>
jmp    1290 <main+0x110>
jmp    1290 <main+0x110>
lea    0xe15(%rip),%rdi
call   1050 <prompt@plt>
jmp    1295 <main+0x115>
cmpl   $0x4,-0x8(%rbp)
jne    11c5 <main+0x45>
lea    0xe17(%rip),%rdi
call   1050 <prompt@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   10a0 <construct@plt>
test   %eax,%eax
je     1259 <main+0xd9>
lea    0xe6f(%rip),%r14
lea    0xe6f(%rip),%r15
lea    0xeee(%rip),%r12
lea    0x4(%rsp),%rbx
lea    0xee5(%rip),%r13
lea    0xe3e(%rip),%rbp
jmp    11df <main+0x5f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
call   1050 <prompt@plt>
cmpl   $0x4,0x4(%rsp)
je     1249 <main+0xc9>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1030 <flush@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11d0 <main+0x50>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <issue@plt>
test   %eax,%eax
je     1220 <main+0xa0>
jmp    11d8 <main+0x58>
nopl   (%rax)
xor    %eax,%eax
call   1040 <request_return@plt>
test   %eax,%eax
je     1230 <main+0xb0>
jmp    11d8 <main+0x58>
nopl   (%rax)
xor    %eax,%eax
call   1080 <admin_panel@plt>
jmp    11d8 <main+0x58>
lea    0xe6d(%rip),%rdi
call   1050 <prompt@plt>
xor    %eax,%eax
jmp    126e <main+0xee>
lea    0xe71(%rip),%rdi
call   1050 <prompt@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"\1B[H\1B[J\00"
@.str.2 = [134 x i8] c"Welcome to Library Management System\0A\0AMain Menu:\0A1. Issue a Book\0A2. Return a Book\0A3. Admin Panel\0A4. Exit\0APlease select your choice : \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [29 x i8] c"Please enter correct choice.\00"
@.str.5 = [21 x i8] c"\0AProgram exiting...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @construct()
%4 = icmp ne i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = call i32 @prompt(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
%9 = zext i1 %8 to i32
store i32 %9, i32* %1
br label %42
10: ; preds = %0
br label %11
11: ; preds = %37, %10
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%15 = call i32 (...) @flush()
%16 = load i32, i32* %2
switch i32 %16, label %34 [
i32 1, label %17
i32 2, label %24
i32 3, label %31
i32 4, label %33
]
17: ; preds = %11
br label %18
18: ; preds = %22, %17
%19 = call i32 (...) @issue()
%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 = %11
br label %25
25: ; preds = %29, %24
%26 = call i32 (...) @request_return()
%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 = %11
%32 = call i32 (...) @admin_panel()
br label %36
33: ; preds = %11
br label %36
34: ; preds = %11
%35 = call i32 @prompt(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %33, %31, %30, %23
br label %37
37: ; preds = %36
%38 = load i32, i32* %2
%39 = icmp ne i32 %38, 4
br i1 %39, label %11, label %40
40: ; preds = %37
%41 = call i32 @prompt(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %42
42: ; preds = %40, %5
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"\1B[H\1B[J\00"
@.str.2 = [134 x i8] c"Welcome to Library Management System\0A\0AMain Menu:\0A1. Issue a Book\0A2. Return a Book\0A3. Admin Panel\0A4. Exit\0APlease select your choice : \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [29 x i8] c"Please enter correct choice.\00"
@.str.5 = [21 x i8] c"\0AProgram exiting...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @construct()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = tail call i32 @prompt(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
br label %30
9: ; preds = %0, %25
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([134 x i8], [134 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%13 = call i32 (...) @flush()
%14 = load i32, i32* %1
switch i32 %14, label %23 [
i32 1, label %15
i32 2, label %18
i32 3, label %21
i32 4, label %28
]
15: ; preds = %9, %15
%16 = call i32 (...) @issue()
%17 = icmp eq i32 %16, 0
br i1 %17, label %15, label %25
18: ; preds = %9, %18
%19 = call i32 (...) @request_return()
%20 = icmp eq i32 %19, 0
br i1 %20, label %18, label %25
21: ; preds = %9
%22 = call i32 (...) @admin_panel()
br label %25
23: ; preds = %9
%24 = call i32 @prompt(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %18, %15, %21, %23
%26 = load i32, i32* %1
%27 = icmp eq i32 %26, 4
br i1 %27, label %28, label %9
28: ; preds = %9, %25
%29 = call i32 @prompt(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28, %5
%31 = phi i32 [ 0, %28 ], [ %8, %5 ]
ret i32 %31
}