#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*/ create_database();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ system(char *);
int main_menu() {
  int choice = 1;
  system("cd mydb");
  printf("\t\t\t\t\tMain Menu");
  while (choice != 0) {
    printf("1. Create a database\n");
    printf("2. Select from previous databases\n");
    fflush(stdin);
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      create_database();
    }
  }
}


x86 assembly (clang, -O0):
<main_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <system@plt>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11d4 <main_menu+0x84>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xea2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
jne    11cf <main_menu+0x7f>
jmp    11c8 <main_menu+0x78>
mov    $0x0,%al
call   1050 <create_database@plt>
jmp    1177 <main_menu+0x27>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_menu>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
lea    0xe84(%rip),%rdi
call   1040 <system@plt>
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
lea    0xe86(%rip),%r14
lea    0xe94(%rip),%r15
mov    0x2e46(%rip),%r13
lea    0xe6e(%rip),%r12
lea    0xc(%rsp),%rbx
jmp    11b4 <main_menu+0x54>
test   %eax,%eax
je     11ee <main_menu+0x8e>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    0x0(%r13),%edi
call   1070 <fflush@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
jne    11b0 <main_menu+0x50>
xor    %eax,%eax
call   1060 <create_database@plt>
mov    0xc(%rsp),%eax
jmp    11b0 <main_menu+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"cd mydb\00"
@.str.1 = [15 x i8] c"\09\09\09\09\09Main Menu\00"
@.str.2 = [22 x i8] c"1. Create a database\0A\00"
@.str.3 = [35 x i8] c"2. Select from previous databases\0A\00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"%d\00"
define i32 @main_menu() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %2
%3 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %17, %0
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32, i32* @stdin
%12 = call i32 @fflush(i32 %11)
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
switch i32 %14, label %17 [
i32 1, label %15
]
15: ; preds = %8
%16 = call i32 (...) @create_database()
br label %17
17: ; preds = %15, %8
br label %5
18: ; preds = %5
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [8 x i8] c"cd mydb\00"
@.str.1 = [15 x i8] c"\09\09\09\09\09Main Menu\00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@str = [21 x i8] c"1. Create a database\00"
@str.5 = [34 x i8] c"2. Select from previous databases\00"
define i32 @main_menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%3 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %0, %16
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.5, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fflush(i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = call i32 (...) @create_database()
%15 = load i32, i32* %1
br label %16
16: ; preds = %5, %13
%17 = phi i32 [ %11, %5 ], [ %15, %13 ]
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %5
19: ; preds = %16
ret i32 undef
}