#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 display_standard_menu(char *, char *, int, int, int);
int /*<<< orphan*/ screen_display_highscores();
int /*<<< orphan*/ screen_how_to_play();
int screen_main_menu(int game_state, int menu_type) {
  int option = 0;
  if (menu_type == 0) {
    option = display_standard_menu(
        "Main Menu",
        "1. Play Game\n2. How to Play\n3. High Scores\n4. Options\n5. Quit",
        menu_type, 5, 1);
  } else if (menu_type == 1) {
    option = display_standard_menu(
        "Main Menu",
        "A. Play Game\nB. How to Play\nC. High Scores\nD. Options\nE. Quit",
        menu_type, 5, 1);
  }
  if (option == 1) {
    game_state = 3;
  } else if (option == 2) {
    screen_how_to_play();
  } else if (option == 3) {
    screen_display_highscores();
  } else if (option == 4) {
    game_state = 2;
  } else if (option == 5) {
    game_state = -1;
  }
  return game_state;
}


x86 assembly (clang, -O0):
<screen_main_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1178 <screen_main_menu+0x48>
mov    -0x8(%rbp),%edx
lea    0xea7(%rip),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x5,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
mov    %eax,-0xc(%rbp)
jmp    11ab <screen_main_menu+0x7b>
cmpl   $0x1,-0x8(%rbp)
jne    11a6 <screen_main_menu+0x76>
mov    -0x8(%rbp),%edx
lea    0xe74(%rip),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x5,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
mov    %eax,-0xc(%rbp)
jmp    11ab <screen_main_menu+0x7b>
cmpl   $0x1,-0xc(%rbp)
jne    11c1 <screen_main_menu+0x91>
movl   $0x3,-0x4(%rbp)
jmp    1228 <screen_main_menu+0xf8>
cmpl   $0x2,-0xc(%rbp)
jne    11d7 <screen_main_menu+0xa7>
mov    $0x0,%al
call   1040 <screen_how_to_play@plt>
jmp    1223 <screen_main_menu+0xf3>
cmpl   $0x3,-0xc(%rbp)
jne    11ed <screen_main_menu+0xbd>
mov    $0x0,%al
call   1050 <screen_display_highscores@plt>
jmp    121e <screen_main_menu+0xee>
cmpl   $0x4,-0xc(%rbp)
jne    1203 <screen_main_menu+0xd3>
movl   $0x2,-0x4(%rbp)
jmp    1219 <screen_main_menu+0xe9>
cmpl   $0x5,-0xc(%rbp)
jne    1214 <screen_main_menu+0xe4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1219 <screen_main_menu+0xe9>
jmp    121e <screen_main_menu+0xee>
jmp    1223 <screen_main_menu+0xf3>
jmp    1228 <screen_main_menu+0xf8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<screen_main_menu>:
push   %rbx
mov    %edi,%ebx
cmp    $0x1,%esi
je     114e <screen_main_menu+0x1e>
test   %esi,%esi
jne    11a0 <screen_main_menu+0x70>
lea    0xed1(%rip),%rdi
lea    0xed4(%rip),%rsi
xor    %edx,%edx
jmp    1161 <screen_main_menu+0x31>
lea    0xebf(%rip),%rdi
lea    0xf00(%rip),%rsi
mov    $0x1,%edx
mov    $0x5,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
cmp    $0x4,%ecx
ja     11a0 <screen_main_menu+0x70>
mov    $0x3,%eax
lea    0xe79(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1040 <screen_how_to_play@plt>
jmp    11a0 <screen_main_menu+0x70>
xor    %eax,%eax
call   1050 <screen_display_highscores@plt>
mov    %ebx,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Main Menu\00"
@.str.1 = [62 x i8] c"1. Play Game\0A2. How to Play\0A3. High Scores\0A4. Options\0A5. Quit\00"
@.str.2 = [62 x i8] c"A. Play Game\0AB. How to Play\0AC. High Scores\0AD. Options\0AE. Quit\00"
define i32 @screen_main_menu(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @display_standard_menu(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 5, i32 1)
store i32 %10, i32* %5
br label %18
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %4
%16 = call i32 @display_standard_menu(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 5, i32 1)
store i32 %16, i32* %5
br label %17
17: ; preds = %14, %11
br label %18
18: ; preds = %17, %8
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 3, i32* %3
br label %44
22: ; preds = %18
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (...) @screen_how_to_play()
br label %43
27: ; preds = %22
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (...) @screen_display_highscores()
br label %42
32: ; preds = %27
%33 = load i32, i32* %5
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 2, i32* %3
br label %41
36: ; preds = %32
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 5
br i1 %38, label %39, label %40
39: ; preds = %36
store i32 -1, i32* %3
br label %40
40: ; preds = %39, %36
br label %41
41: ; preds = %40, %35
br label %42
42: ; preds = %41, %30
br label %43
43: ; preds = %42, %25
br label %44
44: ; preds = %43, %21
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [10 x i8] c"Main Menu\00"
@.str.1 = [62 x i8] c"1. Play Game\0A2. How to Play\0A3. High Scores\0A4. Options\0A5. Quit\00"
@.str.2 = [62 x i8] c"A. Play Game\0AB. How to Play\0AC. High Scores\0AD. Options\0AE. Quit\00"
define i32 @screen_main_menu(i32 %0, i32 %1) {
switch i32 %1, label %15 [
i32 0, label %3
i32 1, label %5
]
3: ; preds = %2
%4 = tail call i32 @display_standard_menu(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 5, i32 1)
br label %7
5: ; preds = %2
%6 = tail call i32 @display_standard_menu(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 5, i32 1)
br label %7
7: ; preds = %5, %3
%8 = phi i32 [ %4, %3 ], [ %6, %5 ]
switch i32 %8, label %15 [
i32 1, label %16
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %14
]
9: ; preds = %7
%10 = tail call i32 (...) @screen_how_to_play()
br label %16
11: ; preds = %7
%12 = tail call i32 (...) @screen_display_highscores()
br label %16
13: ; preds = %7
br label %16
14: ; preds = %7
br label %16
15: ; preds = %2, %7
br label %16
16: ; preds = %7, %15, %9, %13, %14, %11
%17 = phi i32 [ %0, %9 ], [ %0, %11 ], [ 2, %13 ], [ -1, %14 ], [ 3, %7 ], [ %0, %15 ]
ret i32 %17
}