#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*/ calc_menu();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ file_menu();
int /*<<< orphan*/ mod_menu();
int /*<<< orphan*/ output_menu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ query_menu();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sort_menu();
int mainmenu() {
  char sel;
  printf("* * * * * * * * * * * * * * * * * * *\n");
  printf("*           Main Menu               *\n");
  printf("* 1. File                           *\n");
  printf("* 2. Modify                         *\n");
  printf("* 3. Calculate                      *\n");
  printf("* 4. Sort                           *\n");
  printf("* 5. Query                          *\n");
  printf("* 6. Output                         *\n");
  printf("* 0. Exit                           *\n");
  printf("* * * * * * * * * * * * * * * * * * *\n");
  printf("Please enter your choice:");
  scanf("%d", &sel);
  switch (sel) {
  case 1:
    file_menu();
    break;
  case 2:
    mod_menu();
    break;
  case 3:
    calc_menu();
    break;
  case 4:
    sort_menu();
    break;
  case 5:
    query_menu();
    break;
  case 6:
    output_menu();
    break;
  case 0:
    exit(0);
    break;
  }
}


x86 assembly (clang, -O0):
<mainmenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe7d(%rip),%rdi
mov    %rdi,-0x18(%rbp)
call   1070 <printf@plt>
lea    0xe94(%rip),%rdi
call   1070 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1070 <printf@plt>
lea    0xeca(%rip),%rdi
call   1070 <printf@plt>
lea    0xee5(%rip),%rdi
call   1070 <printf@plt>
lea    0xf00(%rip),%rdi
call   1070 <printf@plt>
lea    0xf1b(%rip),%rdi
call   1070 <printf@plt>
lea    0xf36(%rip),%rdi
call   1070 <printf@plt>
lea    0xf51(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <printf@plt>
lea    0xf63(%rip),%rdi
call   1070 <printf@plt>
lea    0xf71(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   10a0 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     12a3 <mainmenu+0x113>
mov    -0x10(%rbp),%rax
lea    0xdb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1050 <file_menu@plt>
jmp    12a3 <mainmenu+0x113>
mov    $0x0,%al
call   1080 <mod_menu@plt>
jmp    12a3 <mainmenu+0x113>
mov    $0x0,%al
call   1090 <calc_menu@plt>
jmp    12a3 <mainmenu+0x113>
mov    $0x0,%al
call   1060 <sort_menu@plt>
jmp    12a3 <mainmenu+0x113>
mov    $0x0,%al
call   1030 <query_menu@plt>
jmp    12a3 <mainmenu+0x113>
mov    $0x0,%al
call   1040 <output_menu@plt>
jmp    12a3 <mainmenu+0x113>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mainmenu>:
push   %rbx
sub    $0x10,%rsp
lea    0xfbd(%rip),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xe7e(%rip),%rdi
call   1050 <puts@plt>
lea    0xe98(%rip),%rdi
call   1050 <puts@plt>
lea    0xeb2(%rip),%rdi
call   1050 <puts@plt>
lea    0xecc(%rip),%rdi
call   1050 <puts@plt>
lea    0xee6(%rip),%rdi
call   1050 <puts@plt>
lea    0xf00(%rip),%rdi
call   1050 <puts@plt>
lea    0xf1a(%rip),%rdi
call   1050 <puts@plt>
lea    0xf34(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xdf9(%rip),%rdi
call   1080 <printf@plt>
lea    0xe07(%rip),%rdi
lea    0xf(%rsp),%rsi
call   10b0 <scanf@plt>
movsbl 0xf(%rsp),%eax
cmp    $0x6,%eax
ja     1287 <mainmenu+0xe7>
lea    0xdb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <file_menu@plt>
jmp    1287 <mainmenu+0xe7>
xor    %eax,%eax
call   1090 <mod_menu@plt>
jmp    1287 <mainmenu+0xe7>
xor    %eax,%eax
call   10a0 <calc_menu@plt>
jmp    1287 <mainmenu+0xe7>
xor    %eax,%eax
call   1070 <sort_menu@plt>
jmp    1287 <mainmenu+0xe7>
xor    %eax,%eax
call   1030 <query_menu@plt>
jmp    1287 <mainmenu+0xe7>
xor    %eax,%eax
call   1040 <output_menu@plt>
add    $0x10,%rsp
pop    %rbx
ret
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"* * * * * * * * * * * * * * * * * * *\0A\00"
@.str.1 = [39 x i8] c"* Main Menu *\0A\00"
@.str.2 = [39 x i8] c"* 1. File *\0A\00"
@.str.3 = [39 x i8] c"* 2. Modify *\0A\00"
@.str.4 = [39 x i8] c"* 3. Calculate *\0A\00"
@.str.5 = [39 x i8] c"* 4. Sort *\0A\00"
@.str.6 = [39 x i8] c"* 5. Query *\0A\00"
@.str.7 = [39 x i8] c"* 6. Output *\0A\00"
@.str.8 = [39 x i8] c"* 0. Exit *\0A\00"
@.str.9 = [26 x i8] c"Please enter your choice:\00"
@.str.10 = [3 x i8] c"%d\00"
define i32 @mainmenu() {
%1 = alloca i32
%2 = alloca i8
%3 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %2)
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
switch i32 %16, label %31 [
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 0, label %29
]
17: ; preds = %0
%18 = call i32 (...) @file_menu()
br label %31
19: ; preds = %0
%20 = call i32 (...) @mod_menu()
br label %31
21: ; preds = %0
%22 = call i32 (...) @calc_menu()
br label %31
23: ; preds = %0
%24 = call i32 (...) @sort_menu()
br label %31
25: ; preds = %0
%26 = call i32 (...) @query_menu()
br label %31
27: ; preds = %0
%28 = call i32 (...) @output_menu()
br label %31
29: ; preds = %0
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %0, %27, %25, %23, %21, %19, %17
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str.9 = [26 x i8] c"Please enter your choice:\00"
@.str.10 = [3 x i8] c"%d\00"
@str.11 = [38 x i8] c"* Main Menu *\00"
@str.12 = [38 x i8] c"* 1. File *\00"
@str.13 = [38 x i8] c"* 2. Modify *\00"
@str.14 = [38 x i8] c"* 3. Calculate *\00"
@str.15 = [38 x i8] c"* 4. Sort *\00"
@str.16 = [38 x i8] c"* 5. Query *\00"
@str.17 = [38 x i8] c"* 6. Output *\00"
@str.18 = [38 x i8] c"* 0. Exit *\00"
@str.19 = [38 x i8] c"* * * * * * * * * * * * * * * * * * *\00"
define i32 @mainmenu() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.19, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.11, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.12, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.14, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.15, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.16, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.17, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.18, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.19, i64 0, i64 0))
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %1)
%14 = load i8, i8* %1
%15 = sext i8 %14 to i32
switch i32 %15, label %30 [
i32 1, label %16
i32 2, label %18
i32 3, label %20
i32 4, label %22
i32 5, label %24
i32 6, label %26
i32 0, label %28
]
16: ; preds = %0
%17 = call i32 (...) @file_menu()
br label %30
18: ; preds = %0
%19 = call i32 (...) @mod_menu()
br label %30
20: ; preds = %0
%21 = call i32 (...) @calc_menu()
br label %30
22: ; preds = %0
%23 = call i32 (...) @sort_menu()
br label %30
24: ; preds = %0
%25 = call i32 (...) @query_menu()
br label %30
26: ; preds = %0
%27 = call i32 (...) @output_menu()
br label %30
28: ; preds = %0
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %0, %26, %24, %22, %20, %18, %16
ret i32 undef
}