#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*/ addBook();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ listBooks();
int menu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ system(char *);
int main() {
  for (;;) {
    switch (menu()) {
    case 1:
      system("clear");
      addBook();
      break;
    case 2:
      system("clear");
      listBooks();
      break;
    case 3:
      system("clear");
      printf("\nFim do programa.\n");
      exit(0);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
call   1040 <menu@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
sub    $0x1,%eax
je     11ab <main+0x4b>
jmp    1189 <main+0x29>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     11c3 <main+0x63>
jmp    119a <main+0x3a>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     11db <main+0x7b>
jmp    11fa <main+0x9a>
lea    0xe4e(%rip),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   1030 <addBook@plt>
jmp    11fa <main+0x9a>
lea    0xe36(%rip),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   1050 <listBooks@plt>
jmp    11fa <main+0x9a>
lea    0xe1e(%rip),%rdi
call   1060 <system@plt>
lea    0xe18(%rip),%rdi
call   1070 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    116f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe98(%rip),%rbx
jmp    117f <main+0x1f>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <system@plt>
xor    %eax,%eax
call   1060 <listBooks@plt>
xor    %eax,%eax
call   1050 <menu@plt>
cmp    $0x1,%eax
je     11a0 <main+0x40>
cmp    $0x2,%eax
je     1170 <main+0x10>
cmp    $0x3,%eax
jne    117f <main+0x1f>
jmp    11b1 <main+0x51>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <system@plt>
xor    %eax,%eax
call   1040 <addBook@plt>
jmp    117f <main+0x1f>
lea    0xe48(%rip),%rdi
call   1070 <system@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [19 x i8] c"\0AFim do programa.\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %14, %0
%3 = call i32 (...) @menu()
switch i32 %3, label %14 [
i32 1, label %4
i32 2, label %7
i32 3, label %10
]
4: ; preds = %2
%5 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @addBook()
br label %14
7: ; preds = %2
%8 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @listBooks()
br label %14
10: ; preds = %2
%11 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2, %7, %4
br label %2
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@str = [18 x i8] c"\0AFim do programa.\00"
define i32 @main() {
br label %1
1: ; preds = %3, %0
%2 = tail call i32 (...) @menu()
switch i32 %2, label %3 [
i32 1, label %4
i32 2, label %7
i32 3, label %10
]
3: ; preds = %1, %7, %4
br label %1
4: ; preds = %1
%5 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @addBook()
br label %3
7: ; preds = %1
%8 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 (...) @listBooks()
br label %3
10: ; preds = %1
%11 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 0)
unreachable
}