#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*/ clear();
char getch();
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ sendHelp();
int /*<<< orphan*/ start_game(int);
void mainMenu(int server_socket) {
  char choice;
  do {
    clear();
    printw("# # # # # # # # # # # # # # #\n");
    printw("#                           #\n");
    printw("# Welcome to PACMAN ! ! !   #\n");
    printw("#                           #\n");
    printw("# Choose an option:         #\n");
    printw("#                           #\n");
    printw("# 1. Start Game             #\n");
    printw("# 2. Help                   #\n");
    printw("# 3. Exit                   #\n");
    printw("#                           #\n");
    printw("# # # # # # # # # # # # # # #\n");
    refresh();
    choice = getch();
    switch (choice) {
    case '1':
      start_game(server_socket);
      break;
    case '2':
      sendHelp();
      break;
    case '3':
      printw("Goodbye.....\n\n");
      refresh();
      break;
    default:
      printw("Wrong option. Try again\n");
      refresh();
      break;
    }
  } while (choice != '3');
}


x86 assembly (clang, -O0):
<mainMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %al,-0xd(%rbp)
call   1080 <clear@plt>
lea    0xe84(%rip),%rdi
mov    %rdi,-0x18(%rbp)
call   1040 <printw@plt>
lea    0xe93(%rip),%rdi
mov    %rdi,-0x20(%rbp)
call   1040 <printw@plt>
lea    0xea2(%rip),%rdi
call   1040 <printw@plt>
mov    -0x20(%rbp),%rdi
call   1040 <printw@plt>
lea    0xeac(%rip),%rdi
call   1040 <printw@plt>
mov    -0x20(%rbp),%rdi
call   1040 <printw@plt>
lea    0xeb6(%rip),%rdi
call   1040 <printw@plt>
lea    0xec9(%rip),%rdi
call   1040 <printw@plt>
lea    0xedc(%rip),%rdi
call   1040 <printw@plt>
mov    -0x20(%rbp),%rdi
call   1040 <printw@plt>
mov    -0x18(%rbp),%rdi
call   1040 <printw@plt>
mov    -0xd(%rbp),%al
call   1050 <refresh@plt>
mov    -0xd(%rbp),%al
call   1060 <getch@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x31,%eax
je     123f <mainMenu+0xdf>
jmp    121d <mainMenu+0xbd>
mov    -0xc(%rbp),%eax
sub    $0x32,%eax
je     124c <mainMenu+0xec>
jmp    122e <mainMenu+0xce>
mov    -0xc(%rbp),%eax
sub    $0x33,%eax
je     1258 <mainMenu+0xf8>
jmp    1270 <mainMenu+0x110>
mov    -0x4(%rbp),%edi
call   1070 <start_game@plt>
jmp    1283 <mainMenu+0x123>
mov    $0x0,%al
call   1030 <sendHelp@plt>
jmp    1283 <mainMenu+0x123>
lea    0xe7a(%rip),%rdi
call   1040 <printw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    1283 <mainMenu+0x123>
lea    0xe71(%rip),%rdi
call   1040 <printw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    1288 <mainMenu+0x128>
movsbl -0x5(%rbp),%eax
cmp    $0x33,%eax
jne    116b <mainMenu+0xb>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mainMenu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,0x4(%rsp)
lea    0xe8a(%rip),%rbx
lea    0xea2(%rip),%rbp
lea    0xef8(%rip),%r13
lea    0xf10(%rip),%r14
lea    0xf28(%rip),%r15
jmp    11bd <mainMenu+0x5d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xf41(%rip),%rdi
call   1040 <printw@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
cmp    $0x33,%r12b
je     127c <mainMenu+0x11c>
xor    %eax,%eax
call   1080 <clear@plt>
mov    %rbx,%rdi
call   1040 <printw@plt>
mov    %rbp,%rdi
call   1040 <printw@plt>
lea    0xe63(%rip),%rdi
call   1040 <printw@plt>
mov    %rbp,%rdi
call   1040 <printw@plt>
lea    0xe6e(%rip),%rdi
call   1040 <printw@plt>
mov    %rbp,%rdi
call   1040 <printw@plt>
mov    %r13,%rdi
call   1040 <printw@plt>
mov    %r14,%rdi
call   1040 <printw@plt>
mov    %r15,%rdi
call   1040 <printw@plt>
mov    %rbp,%rdi
call   1040 <printw@plt>
mov    %rbx,%rdi
call   1040 <printw@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
xor    %eax,%eax
call   1060 <getch@plt>
mov    %eax,%r12d
movsbl %al,%eax
cmp    $0x33,%eax
je     1270 <mainMenu+0x110>
cmp    $0x32,%eax
je     1260 <mainMenu+0x100>
cmp    $0x31,%eax
jne    11a0 <mainMenu+0x40>
mov    0x4(%rsp),%edi
call   1070 <start_game@plt>
jmp    11b3 <mainMenu+0x53>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <sendHelp@plt>
jmp    11b3 <mainMenu+0x53>
nopl   0x0(%rax)
lea    0xe62(%rip),%rdi
jmp    11a7 <mainMenu+0x47>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"# # # # # # # # # # # # # # #\0A\00"
@.str.1 = [31 x i8] c"# #\0A\00"
@.str.2 = [31 x i8] c"# Welcome to PACMAN ! ! ! #\0A\00"
@.str.3 = [31 x i8] c"# Choose an option: #\0A\00"
@.str.4 = [31 x i8] c"# 1. Start Game #\0A\00"
@.str.5 = [31 x i8] c"# 2. Help #\0A\00"
@.str.6 = [31 x i8] c"# 3. Exit #\0A\00"
@.str.7 = [15 x i8] c"Goodbye.....\0A\0A\00"
@.str.8 = [25 x i8] c"Wrong option. Try again\0A\00"
define void @mainMenu(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
br label %4
4: ; preds = %33, %1
%5 = call i32 (...) @clear()
%6 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (...) @refresh()
%18 = call signext i8 (...) @getch()
store i8 %18, i8* %3
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
switch i32 %20, label %29 [
i32 49, label %21
i32 50, label %24
i32 51, label %26
]
21: ; preds = %4
%22 = load i32, i32* %2
%23 = call i32 @start_game(i32 %22)
br label %32
24: ; preds = %4
%25 = call i32 (...) @sendHelp()
br label %32
26: ; preds = %4
%27 = call i32 @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 (...) @refresh()
br label %32
29: ; preds = %4
%30 = call i32 @printw(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%31 = call i32 (...) @refresh()
br label %32
32: ; preds = %29, %26, %24, %21
br label %33
33: ; preds = %32
%34 = load i8, i8* %3
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 51
br i1 %36, label %4, label %37
37: ; preds = %33
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"# # # # # # # # # # # # # # #\0A\00"
@.str.1 = [31 x i8] c"# #\0A\00"
@.str.2 = [31 x i8] c"# Welcome to PACMAN ! ! ! #\0A\00"
@.str.3 = [31 x i8] c"# Choose an option: #\0A\00"
@.str.4 = [31 x i8] c"# 1. Start Game #\0A\00"
@.str.5 = [31 x i8] c"# 2. Help #\0A\00"
@.str.6 = [31 x i8] c"# 3. Exit #\0A\00"
@.str.7 = [15 x i8] c"Goodbye.....\0A\0A\00"
@.str.8 = [25 x i8] c"Wrong option. Try again\0A\00"
define void @mainMenu(i32 %0) {
br label %2
2: ; preds = %28, %1
%3 = tail call i32 (...) @clear()
%4 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%13 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @printw(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 (...) @refresh()
%16 = tail call signext i8 (...) @getch()
%17 = sext i8 %16 to i32
switch i32 %17, label %25 [
i32 49, label %18
i32 50, label %20
i32 51, label %22
]
18: ; preds = %2
%19 = tail call i32 @start_game(i32 %0)
br label %28
20: ; preds = %2
%21 = tail call i32 (...) @sendHelp()
br label %28
22: ; preds = %2
%23 = tail call i32 @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%24 = tail call i32 (...) @refresh()
br label %28
25: ; preds = %2
%26 = tail call i32 @printw(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%27 = tail call i32 (...) @refresh()
br label %28
28: ; preds = %18, %20, %22, %25
%29 = icmp eq i8 %16, 51
br i1 %29, label %30, label %2
30: ; preds = %28
ret void
}