#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 screen_options_menu(int game_state, int menu_type, int *menu_state) {
  int option = 0;
  if (menu_type == 0) {
    option = display_standard_menu(
        "Options Menu",
        "1. Back\n2. Difficulty\n3. New Initials\n4. Menu Selection Type\n5. "
        "Clear High Scores\n6. Reset Saves\n7. Reset Game Settings",
        menu_type, 7, 1);
  } else if (menu_type == 1) {
    option = display_standard_menu(
        "Options Menu",
        "A. Back\nB. Difficulty\nC. New Initials\nD. Menu Selection Type\nE. "
        "Clear High Scores\nF. Reset Saves\nG. Reset Game Settings",
        menu_type, 7, 1);
  }
  if (option == 1) {
    game_state = 1;
    *menu_state = 0;
  } else if (option == 2) {
    *menu_state = 1;
  } else if (option == 3) {
    *menu_state = 2;
  } else if (option == 4) {
    *menu_state = 3;
  } else if (option == 5) {
    *menu_state = 4;
  } else if (option == 6) {
    *menu_state = 5;
  } else if (option == 7) {
    *menu_state = 6;
  }
  return game_state;
}


x86 assembly (clang, -O0):
<screen_options_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    115c <screen_options_menu+0x4c>
mov    -0x8(%rbp),%edx
lea    0xec3(%rip),%rdi
lea    0xec9(%rip),%rsi
mov    $0x7,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
mov    %eax,-0x14(%rbp)
jmp    118f <screen_options_menu+0x7f>
cmpl   $0x1,-0x8(%rbp)
jne    118a <screen_options_menu+0x7a>
mov    -0x8(%rbp),%edx
lea    0xe90(%rip),%rdi
lea    0xf0e(%rip),%rsi
mov    $0x7,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
mov    %eax,-0x14(%rbp)
jmp    118f <screen_options_menu+0x7f>
cmpl   $0x1,-0x14(%rbp)
jne    11af <screen_options_menu+0x9f>
movl   $0x1,-0x4(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    125e <screen_options_menu+0x14e>
cmpl   $0x2,-0x14(%rbp)
jne    11c8 <screen_options_menu+0xb8>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1259 <screen_options_menu+0x149>
cmpl   $0x3,-0x14(%rbp)
jne    11e1 <screen_options_menu+0xd1>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
jmp    1254 <screen_options_menu+0x144>
cmpl   $0x4,-0x14(%rbp)
jne    11fa <screen_options_menu+0xea>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
jmp    124f <screen_options_menu+0x13f>
cmpl   $0x5,-0x14(%rbp)
jne    1213 <screen_options_menu+0x103>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
jmp    124a <screen_options_menu+0x13a>
cmpl   $0x6,-0x14(%rbp)
jne    122c <screen_options_menu+0x11c>
mov    -0x10(%rbp),%rax
movl   $0x5,(%rax)
jmp    1245 <screen_options_menu+0x135>
cmpl   $0x7,-0x14(%rbp)
jne    1240 <screen_options_menu+0x130>
mov    -0x10(%rbp),%rax
movl   $0x6,(%rax)
jmp    1245 <screen_options_menu+0x135>
jmp    124a <screen_options_menu+0x13a>
jmp    124f <screen_options_menu+0x13f>
jmp    1254 <screen_options_menu+0x144>
jmp    1259 <screen_options_menu+0x149>
jmp    125e <screen_options_menu+0x14e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<screen_options_menu>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %edi,%ebp
cmp    $0x1,%esi
je     1133 <screen_options_menu+0x23>
test   %esi,%esi
jne    119e <screen_options_menu+0x8e>
lea    0xef4(%rip),%rdi
lea    0xefa(%rip),%rsi
xor    %edx,%edx
jmp    1146 <screen_options_menu+0x36>
lea    0xee2(%rip),%rdi
lea    0xf60(%rip),%rsi
mov    $0x1,%edx
mov    $0x7,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
lea    -0x1(%rax),%edx
cmp    $0x6,%edx
ja     119e <screen_options_menu+0x8e>
xor    %ecx,%ecx
lea    0xe99(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
mov    $0x1,%ecx
jmp    1198 <screen_options_menu+0x88>
mov    $0x2,%ecx
jmp    1198 <screen_options_menu+0x88>
mov    $0x3,%ecx
jmp    1198 <screen_options_menu+0x88>
mov    $0x4,%ecx
jmp    1198 <screen_options_menu+0x88>
mov    $0x5,%ecx
jmp    1198 <screen_options_menu+0x88>
mov    $0x6,%ecx
mov    %ebp,%eax
mov    %ecx,(%rbx)
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Options Menu\00"
@.str.1 = [120 x i8] c"1. Back\0A2. Difficulty\0A3. New Initials\0A4. Menu Selection Type\0A5. Clear High Scores\0A6. Reset Saves\0A7. Reset Game Settings\00"
@.str.2 = [120 x i8] c"A. Back\0AB. Difficulty\0AC. New Initials\0AD. Menu Selection Type\0AE. Clear High Scores\0AF. Reset Saves\0AG. Reset Game Settings\00"
define i32 @screen_options_menu(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* %5
%12 = call i32 @display_standard_menu(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 7, i32 1)
store i32 %12, i32* %7
br label %20
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %5
%18 = call i32 @display_standard_menu(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 7, i32 1)
store i32 %18, i32* %7
br label %19
19: ; preds = %16, %13
br label %20
20: ; preds = %19, %10
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %20
store i32 1, i32* %4
%24 = load i32*, i32** %6
store i32 0, i32* %24
br label %61
25: ; preds = %20
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = load i32*, i32** %6
store i32 1, i32* %29
br label %60
30: ; preds = %25
%31 = load i32, i32* %7
%32 = icmp eq i32 %31, 3
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32*, i32** %6
store i32 2, i32* %34
br label %59
35: ; preds = %30
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 4
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i32*, i32** %6
store i32 3, i32* %39
br label %58
40: ; preds = %35
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, 5
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = load i32*, i32** %6
store i32 4, i32* %44
br label %57
45: ; preds = %40
%46 = load i32, i32* %7
%47 = icmp eq i32 %46, 6
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = load i32*, i32** %6
store i32 5, i32* %49
br label %56
50: ; preds = %45
%51 = load i32, i32* %7
%52 = icmp eq i32 %51, 7
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = load i32*, i32** %6
store i32 6, i32* %54
br label %55
55: ; preds = %53, %50
br label %56
56: ; preds = %55, %48
br label %57
57: ; preds = %56, %43
br label %58
58: ; preds = %57, %38
br label %59
59: ; preds = %58, %33
br label %60
60: ; preds = %59, %28
br label %61
61: ; preds = %60, %23
%62 = load i32, i32* %4
ret i32 %62
}

LLVM IR (-O2):
@.str = [13 x i8] c"Options Menu\00"
@.str.1 = [120 x i8] c"1. Back\0A2. Difficulty\0A3. New Initials\0A4. Menu Selection Type\0A5. Clear High Scores\0A6. Reset Saves\0A7. Reset Game Settings\00"
@.str.2 = [120 x i8] c"A. Back\0AB. Difficulty\0AC. New Initials\0AD. Menu Selection Type\0AE. Clear High Scores\0AF. Reset Saves\0AG. Reset Game Settings\00"
define i32 @screen_options_menu(i32 %0, i32 %1, i32* nocapture writeonly %2) {
switch i32 %1, label %19 [
i32 0, label %4
i32 1, label %6
]
4: ; preds = %3
%5 = tail call i32 @display_standard_menu(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 7, i32 1)
br label %8
6: ; preds = %3
%7 = tail call i32 @display_standard_menu(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 7, i32 1)
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ %5, %4 ], [ %7, %6 ]
switch i32 %9, label %19 [
i32 1, label %16
i32 2, label %10
i32 3, label %11
i32 4, label %12
i32 5, label %13
i32 6, label %14
i32 7, label %15
]
10: ; preds = %8
br label %16
11: ; preds = %8
br label %16
12: ; preds = %8
br label %16
13: ; preds = %8
br label %16
14: ; preds = %8
br label %16
15: ; preds = %8
br label %16
16: ; preds = %8, %11, %13, %15, %14, %12, %10
%17 = phi i32 [ 1, %10 ], [ 3, %12 ], [ 5, %14 ], [ 6, %15 ], [ 4, %13 ], [ 2, %11 ], [ 0, %8 ]
%18 = phi i32 [ %0, %10 ], [ %0, %12 ], [ %0, %14 ], [ %0, %15 ], [ %0, %13 ], [ %0, %11 ], [ %9, %8 ]
store i32 %17, i32* %2
br label %19
19: ; preds = %16, %3, %8
%20 = phi i32 [ %0, %8 ], [ %0, %3 ], [ %18, %16 ]
ret i32 %20
}