#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ in_generate_map();
int /*<<< orphan*/ in_launch_bsq();
int /*<<< orphan*/ printf(char *);
char *s_resp(int /*<<< orphan*/, int);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
void main_menu() {
  printf("-> What do you want to do?\n");
  printf("\t- A: Generate Map\n");
  printf("\t- B: Launch BSQ Algorithm\n");
  printf("\t- X: Exit\n");
  char *response = s_resp(stdin, 1);
  if (!response || strlen(response) <= 0) {
    printf("Invalid value.\n\n");
    free(response);
    main_menu();
  }
  switch (*response) {
  case 'A':
  case 'a':
    free(response);
    in_generate_map();
    break;
  case 'B':
  case 'b':
    free(response);
    in_launch_bsq();
    break;
  default:
    free(response);
    printf("Good bye!\n");
    exit(EXIT_SUCCESS);
    break;
  }
}


x86 assembly (clang, -O0):
<main_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xef9(%rip),%rdi
call   1060 <printf@plt>
lea    0xf09(%rip),%rdi
call   1060 <printf@plt>
lea    0xf11(%rip),%rdi
call   1060 <printf@plt>
lea    0xf21(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1040 <s_resp@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ed <main_menu+0x6d>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jg     1207 <main_menu+0x87>
lea    0xeec(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
call   1080 <main_menu@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x21,%eax
ja     125e <main_menu+0xde>
mov    -0x10(%rbp),%rax
lea    0xdd5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1070 <in_generate_map@plt>
jmp    1281 <main_menu+0x101>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   10a0 <in_launch_bsq@plt>
jmp    1281 <main_menu+0x101>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
lea    0xe83(%rip),%rdi
call   1060 <printf@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_menu>:
push   %rbx
lea    0xf00(%rip),%rdi
call   1040 <puts@plt>
lea    0xf0f(%rip),%rdi
call   1040 <puts@plt>
lea    0xf16(%rip),%rdi
call   1040 <puts@plt>
lea    0xf25(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1050 <s_resp@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d9 <main_menu+0x59>
mov    %rbx,%rdi
call   1060 <strlen@plt>
test   %rax,%rax
jg     11f2 <main_menu+0x72>
lea    0xefc(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
call   1080 <main_menu@plt>
movsbl (%rbx),%eax
add    $0xffffffbf,%eax
cmp    $0x21,%eax
ja     122d <main_menu+0xad>
lea    0xdfc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
jmp    1070 <in_generate_map@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
jmp    10a0 <in_launch_bsq@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"-> What do you want to do?\0A\00"
@.str.1 = [20 x i8] c"\09- A: Generate Map\0A\00"
@.str.2 = [28 x i8] c"\09- B: Launch BSQ Algorithm\0A\00"
@.str.3 = [12 x i8] c"\09- X: Exit\0A\00"
@stdin = global i32 0
@.str.4 = [17 x i8] c"Invalid value.\0A\0A\00"
@.str.5 = [11 x i8] c"Good bye!\0A\00"
@EXIT_SUCCESS = global i32 0
define void @main_menu() {
%1 = alloca i8*
%2 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i8* @s_resp(i32 %6, i32 1)
store i8* %7, i8** %1
%8 = load i8*, i8** %1
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i8*, i8** %1
%12 = call i64 @strlen(i8* %11)
%13 = icmp sle i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10, %0
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%16 = load i8*, i8** %1
%17 = call i32 @free(i8* %16)
br label %18
18: ; preds = %14, %10
%19 = load i8*, i8** %1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %30 [
i32 65, label %22
i32 97, label %22
i32 66, label %26
i32 98, label %26
]
22: ; preds = %18, %18
%23 = load i8*, i8** %1
%24 = call i32 @free(i8* %23)
%25 = call i32 (...) @in_generate_map()
br label %36
26: ; preds = %18, %18
%27 = load i8*, i8** %1
%28 = call i32 @free(i8* %27)
%29 = call i32 (...) @in_launch_bsq()
br label %36
30: ; preds = %18
%31 = load i8*, i8** %1
%32 = call i32 @free(i8* %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%34 = load i32, i32* @EXIT_SUCCESS
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %26, %22
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [27 x i8] c"-> What do you want to do?\00"
@str.6 = [19 x i8] c"\09- A: Generate Map\00"
@str.7 = [27 x i8] c"\09- B: Launch BSQ Algorithm\00"
@str.8 = [11 x i8] c"\09- X: Exit\00"
@str.9 = [16 x i8] c"Invalid value.\0A\00"
@str.10 = [10 x i8] c"Good bye!\00"
define void @main_menu() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = tail call i8* @s_resp(i32 %5, i32 1)
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = tail call i64 @strlen(i8* %6)
%10 = icmp slt i64 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %8, %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.9, i64 0, i64 0))
%13 = tail call i32 @free(i8* %6)
tail call void @main_menu()
br label %14
14: ; preds = %11, %8
%15 = load i8, i8* %6
%16 = sext i8 %15 to i32
switch i32 %16, label %23 [
i32 65, label %17
i32 97, label %17
i32 66, label %20
i32 98, label %20
]
17: ; preds = %14, %14
%18 = tail call i32 @free(i8* %6)
%19 = tail call i32 (...) @in_generate_map()
br label %28
20: ; preds = %14, %14
%21 = tail call i32 @free(i8* %6)
%22 = tail call i32 (...) @in_launch_bsq()
br label %28
23: ; preds = %14
%24 = tail call i32 @free(i8* %6)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%26 = load i32, i32* @EXIT_SUCCESS
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %20, %17
ret void
}