#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*/ CreateLUT();
int /*<<< orphan*/ PrintAll();
int /*<<< orphan*/ db_check(char *);
int /*<<< orphan*/ db_create(char *);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int file_menu() {
  char filename[64] = {0}, countX = 0, temp, sel;
  printf("* * * * * * * * * * * * * * * * * * *\n");
  printf("*           File Menu               *\n");
  printf("* 1. Create a new database          *\n");
  printf("* 2. Open a CSV database            *\n");
  printf("* * * * * * * * * * * * * * * * * * *\n");
  printf("Please enter your choice:");
  scanf("%d", &sel);
  getchar();
  printf("Please enter the filename of your database.\n");
  while (countX < 64) {
    temp = getchar();
    if (temp != '\n') {
      filename[countX] = temp;
      countX++;
    } else {
      filename[countX] = 0;
      break;
    }
  }
  switch (sel) {
  case 1: {
    db_create(filename);
    db_check(filename);
    break;
  }
  case 2:
    db_check(filename);
    CreateLUT();
    PrintAll();
    break;
  }
}


x86 assembly (clang, -O0):
<file_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movb   $0x0,-0x51(%rbp)
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
lea    0xe2d(%rip),%rdi
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x53(%rbp),%rsi
call   10a0 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x51(%rbp),%eax
cmp    $0x40,%eax
jge    1258 <file_menu+0xd8>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x52(%rbp)
movsbl -0x52(%rbp),%eax
cmp    $0xa,%eax
je     1244 <file_menu+0xc4>
mov    -0x52(%rbp),%cl
movsbq -0x51(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x51(%rbp),%al
add    $0x1,%al
mov    %al,-0x51(%rbp)
jmp    1253 <file_menu+0xd3>
movsbq -0x51(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
jmp    1258 <file_menu+0xd8>
jmp    1207 <file_menu+0x87>
movsbl -0x53(%rbp),%eax
mov    %eax,-0x58(%rbp)
sub    $0x1,%eax
je     127e <file_menu+0xfe>
jmp    126d <file_menu+0xed>
mov    -0x58(%rbp),%eax
sub    $0x2,%eax
je     1295 <file_menu+0x115>
jmp    12ac <file_menu+0x12c>
lea    -0x50(%rbp),%rdi
call   1070 <db_create@plt>
lea    -0x50(%rbp),%rdi
call   1090 <db_check@plt>
jmp    12ac <file_menu+0x12c>
lea    -0x50(%rbp),%rdi
call   1090 <db_check@plt>
mov    $0x0,%al
call   1060 <CreateLUT@plt>
mov    $0x0,%al
call   1080 <PrintAll@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_menu>:
push   %rbx
sub    $0x50,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xeec(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
lea    0xe30(%rip),%rdi
lea    0xf(%rsp),%rsi
call   10a0 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     122b <file_menu+0xab>
mov    %al,0x10(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    1210 <file_menu+0x90>
jmp    1230 <file_menu+0xb0>
movb   $0x0,0x10(%rsp,%rbx,1)
movsbl 0xf(%rsp),%eax
cmp    $0x2,%eax
je     1256 <file_menu+0xd6>
cmp    $0x1,%eax
jne    126e <file_menu+0xee>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <db_create@plt>
mov    %rbx,%rdi
call   1090 <db_check@plt>
jmp    126e <file_menu+0xee>
lea    0x10(%rsp),%rdi
call   1090 <db_check@plt>
xor    %eax,%eax
call   1060 <CreateLUT@plt>
xor    %eax,%eax
call   1080 <PrintAll@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"* * * * * * * * * * * * * * * * * * *\0A\00"
@.str.1 = [39 x i8] c"* File Menu *\0A\00"
@.str.2 = [39 x i8] c"* 1. Create a new database *\0A\00"
@.str.3 = [39 x i8] c"* 2. Open a CSV database *\0A\00"
@.str.4 = [26 x i8] c"Please enter your choice:\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [45 x i8] c"Please enter the filename of your database.\0A\00"
define i32 @file_menu() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = bitcast [64 x i8]* %2 to i8*
store i8 0, i8* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %5)
%14 = call signext i8 (...) @getchar()
%15 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
br label %16
16: ; preds = %36, %0
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp slt i32 %18, 64
br i1 %19, label %20, label %37
20: ; preds = %16
%21 = call signext i8 (...) @getchar()
store i8 %21, i8* %4
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 10
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i8, i8* %4
%27 = load i8, i8* %3
%28 = sext i8 %27 to i64
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %28
store i8 %26, i8* %29
%30 = load i8, i8* %3
%31 = add i8 %30, 1
store i8 %31, i8* %3
br label %36
32: ; preds = %20
%33 = load i8, i8* %3
%34 = sext i8 %33 to i64
%35 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %34
store i8 0, i8* %35
br label %37
36: ; preds = %25
br label %16
37: ; preds = %32, %16
%38 = load i8, i8* %5
%39 = sext i8 %38 to i32
switch i32 %39, label %50 [
i32 1, label %40
i32 2, label %45
]
40: ; preds = %37
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%42 = call i32 @db_create(i8* %41)
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%44 = call i32 @db_check(i8* %43)
br label %50
45: ; preds = %37
%46 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%47 = call i32 @db_check(i8* %46)
%48 = call i32 (...) @CreateLUT()
%49 = call i32 (...) @PrintAll()
br label %50
50: ; preds = %37, %45, %40
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str.4 = [26 x i8] c"Please enter your choice:\00"
@.str.5 = [3 x i8] c"%d\00"
@str.7 = [38 x i8] c"* File Menu *\00"
@str.8 = [38 x i8] c"* 1. Create a new database *\00"
@str.9 = [38 x i8] c"* 2. Open a CSV database *\00"
@str.10 = [38 x i8] c"* * * * * * * * * * * * * * * * * * *\00"
@str.11 = [44 x i8] c"Please enter the filename of your database.\00"
define i32 @file_menu() {
%1 = alloca [64 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.9, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%11 = call signext i8 (...) @getchar()
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.11, i64 0, i64 0))
br label %13
13: ; preds = %0, %17
%14 = phi i64 [ 0, %0 ], [ %19, %17 ]
%15 = call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %14
store i8 %15, i8* %18
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, 64
br i1 %20, label %24, label %13
21: ; preds = %13
%22 = and i64 %14, 255
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %17, %21
%25 = load i8, i8* %2
%26 = sext i8 %25 to i32
switch i32 %26, label %34 [
i32 1, label %27
i32 2, label %30
]
27: ; preds = %24
%28 = call i32 @db_create(i8* %3)
%29 = call i32 @db_check(i8* %3)
br label %34
30: ; preds = %24
%31 = call i32 @db_check(i8* %3)
%32 = call i32 (...) @CreateLUT()
%33 = call i32 (...) @PrintAll()
br label %34
34: ; preds = %24, %30, %27
ret i32 undef
}