#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*/ AddEntry();
int /*<<< orphan*/ BackupDatabase();
int /*<<< orphan*/ ChangeEntry();
int /*<<< orphan*/ CloseDatabase();
int /*<<< orphan*/ DeleteEntry();
int EXIT_FAILURE;
int /*<<< orphan*/ ErrorMessage();
int MainMenu();
int /*<<< orphan*/ NewDatabase();
int /*<<< orphan*/ OpenDatabase();
int /*<<< orphan*/ PrintDatabase();
int /*<<< orphan*/ PrintValues();
int /*<<< orphan*/ ReloadDatabase();
int /*<<< orphan*/ UpdateDatabase();
int eXdbmInit();
int /*<<< orphan*/ printf(char *);
int main(void) {
  int choice;
  int ret;
  ret = eXdbmInit();
  if (ret == -1) {
    ErrorMessage();
    return (EXIT_FAILURE);
  }
  choice = -1;
  while (choice != 12) {
    choice = MainMenu();
    switch (choice) {
    case 1:
      OpenDatabase();
      break;
    case 2:
      NewDatabase();
      break;
    case 3:
      CloseDatabase();
      break;
    case 4:
      UpdateDatabase();
      break;
    case 5:
      BackupDatabase();
      break;
    case 6:
      ReloadDatabase();
      break;
    case 7:
      PrintDatabase();
      break;
    case 8:
      PrintValues();
      break;
    case 9:
      AddEntry();
      break;
    case 10:
      ChangeEntry();
      break;
    case 11:
      DeleteEntry();
      break;
    }
  }
  printf("\n\nBye bye ...\n");
  return (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1110 <eXdbmInit@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    122b <main+0x3b>
mov    $0x0,%al
call   1050 <ErrorMessage@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1306 <main+0x116>
movl   $0xffffffff,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
je     12f3 <main+0x103>
xor    %eax,%eax
call   1100 <MainMenu@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xa,%eax
ja     12ee <main+0xfe>
mov    -0x18(%rbp),%rax
lea    0xd9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <OpenDatabase@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   10e0 <NewDatabase@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   10b0 <CloseDatabase@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   1040 <UpdateDatabase@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   1090 <BackupDatabase@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   1060 <ReloadDatabase@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   10a0 <PrintDatabase@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   10c0 <PrintValues@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   10f0 <AddEntry@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   1030 <ChangeEntry@plt>
jmp    12ee <main+0xfe>
mov    $0x0,%al
call   10d0 <DeleteEntry@plt>
jmp    1232 <main+0x42>
lea    0xd32(%rip),%rdi
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1110 <eXdbmInit@plt>
cmp    $0xffffffff,%eax
je     12a5 <main+0xb5>
lea    0xdf8(%rip),%rbx
jmp    1220 <main+0x30>
xor    %eax,%eax
call   10d0 <DeleteEntry@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1100 <MainMenu@plt>
add    $0xffffffff,%eax
cmp    $0xb,%eax
ja     1220 <main+0x30>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1080 <OpenDatabase@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   10e0 <NewDatabase@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   10b0 <CloseDatabase@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   1040 <UpdateDatabase@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   1090 <BackupDatabase@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   1070 <ReloadDatabase@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   10a0 <PrintDatabase@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   10c0 <PrintValues@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   10f0 <AddEntry@plt>
jmp    1220 <main+0x30>
xor    %eax,%eax
call   1030 <ChangeEntry@plt>
jmp    1220 <main+0x30>
lea    0xd97(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1050 <ErrorMessage@plt>
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [15 x i8] c"\0A\0ABye bye ...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @eXdbmInit()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 (...) @ErrorMessage()
%9 = load i32, i32* @EXIT_FAILURE
store i32 %9, i32* %1
br label %42
10: ; preds = %0
store i32 -1, i32* %2
br label %11
11: ; preds = %39, %10
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 12
br i1 %13, label %14, label %40
14: ; preds = %11
%15 = call i32 (...) @MainMenu()
store i32 %15, i32* %2
%16 = load i32, i32* %2
switch i32 %16, label %39 [
i32 1, label %17
i32 2, label %19
i32 3, label %21
i32 4, label %23
i32 5, label %25
i32 6, label %27
i32 7, label %29
i32 8, label %31
i32 9, label %33
i32 10, label %35
i32 11, label %37
]
17: ; preds = %14
%18 = call i32 (...) @OpenDatabase()
br label %39
19: ; preds = %14
%20 = call i32 (...) @NewDatabase()
br label %39
21: ; preds = %14
%22 = call i32 (...) @CloseDatabase()
br label %39
23: ; preds = %14
%24 = call i32 (...) @UpdateDatabase()
br label %39
25: ; preds = %14
%26 = call i32 (...) @BackupDatabase()
br label %39
27: ; preds = %14
%28 = call i32 (...) @ReloadDatabase()
br label %39
29: ; preds = %14
%30 = call i32 (...) @PrintDatabase()
br label %39
31: ; preds = %14
%32 = call i32 (...) @PrintValues()
br label %39
33: ; preds = %14
%34 = call i32 (...) @AddEntry()
br label %39
35: ; preds = %14
%36 = call i32 (...) @ChangeEntry()
br label %39
37: ; preds = %14
%38 = call i32 (...) @DeleteEntry()
br label %39
39: ; preds = %14, %37, %35, %33, %31, %29, %27, %25, %23, %21, %19, %17
br label %11
40: ; preds = %11
%41 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %42
42: ; preds = %40, %7
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@str = [14 x i8] c"\0A\0ABye bye ...\00"
define i32 @main() {
%1 = tail call i32 (...) @eXdbmInit()
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 (...) @ErrorMessage()
%5 = load i32, i32* @EXIT_FAILURE
br label %33
6: ; preds = %0, %10
%7 = tail call i32 (...) @MainMenu()
switch i32 %7, label %10 [
i32 1, label %8
i32 2, label %11
i32 3, label %13
i32 4, label %15
i32 5, label %17
i32 6, label %19
i32 7, label %21
i32 8, label %23
i32 9, label %25
i32 10, label %27
i32 11, label %29
i32 12, label %31
]
8: ; preds = %6
%9 = tail call i32 (...) @OpenDatabase()
br label %10
10: ; preds = %8, %11, %13, %15, %17, %19, %21, %23, %25, %27, %29, %6
br label %6
11: ; preds = %6
%12 = tail call i32 (...) @NewDatabase()
br label %10
13: ; preds = %6
%14 = tail call i32 (...) @CloseDatabase()
br label %10
15: ; preds = %6
%16 = tail call i32 (...) @UpdateDatabase()
br label %10
17: ; preds = %6
%18 = tail call i32 (...) @BackupDatabase()
br label %10
19: ; preds = %6
%20 = tail call i32 (...) @ReloadDatabase()
br label %10
21: ; preds = %6
%22 = tail call i32 (...) @PrintDatabase()
br label %10
23: ; preds = %6
%24 = tail call i32 (...) @PrintValues()
br label %10
25: ; preds = %6
%26 = tail call i32 (...) @AddEntry()
br label %10
27: ; preds = %6
%28 = tail call i32 (...) @ChangeEntry()
br label %10
29: ; preds = %6
%30 = tail call i32 (...) @DeleteEntry()
br label %10
31: ; preds = %6
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %33
33: ; preds = %31, %3
%34 = phi i32 [ %5, %3 ], [ 1, %31 ]
ret i32 %34
}