#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_game_menu(int, int, int, int, int, char, char, char, char *, int,
                      int, int);
int screen_game_menu(int game_state, int menu_type, int *menu_state,
                     int questions, int term1, int term2, int term3, int term4,
                     char operand1, char operand2, char operand3) {
  int option = 0;
  if (menu_type == 0) {
    option = display_game_menu(
        questions, term1, term2, term3, term4, operand1, operand2, operand3,
        "1. Enter Answer\n2. Show Points\n3. Help\n4. Save Game\n5. Exit Game",
        menu_type, 5, 1);
  } else if (menu_type == 1) {
    option = display_game_menu(
        questions, term1, term2, term3, term4, operand1, operand2, operand3,
        "A. Enter Answer\nB. Show Points\nC. Help\nD. Save Game\nE. Exit Game",
        menu_type, 5, 1);
  }
  if (option == 1) {
    *menu_state = 1;
  } else if (option == 2) {
    *menu_state = 2;
  } else if (option == 3) {
    *menu_state = 3;
  } else if (option == 4) {
    *menu_state = 4;
  } else if (option == 5) {
    *menu_state = 6;
  }
  return game_state;
}


x86 assembly (clang, -O0):
<screen_game_menu>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    0x30(%rbp),%al
mov    0x28(%rbp),%al
mov    0x20(%rbp),%al
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11ac <screen_game_menu+0x9c>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
mov    0x20(%rbp),%r9b
mov    0x28(%rbp),%bl
mov    0x30(%rbp),%r11b
mov    -0x10(%rbp),%eax
lea    0xe8d(%rip),%r10
movsbl %r9b,%r9d
movsbl %bl,%ebx
mov    %ebx,(%rsp)
movsbl %r11b,%r11d
mov    %r11d,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x5,0x20(%rsp)
movl   $0x1,0x28(%rsp)
call   1030 <display_game_menu@plt>
mov    %eax,-0x28(%rbp)
jmp    1214 <screen_game_menu+0x104>
cmpl   $0x1,-0x10(%rbp)
jne    120f <screen_game_menu+0xff>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
mov    0x20(%rbp),%r9b
mov    0x28(%rbp),%bl
mov    0x30(%rbp),%r11b
mov    -0x10(%rbp),%eax
lea    0xe66(%rip),%r10
movsbl %r9b,%r9d
movsbl %bl,%ebx
mov    %ebx,(%rsp)
movsbl %r11b,%r11d
mov    %r11d,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x5,0x20(%rsp)
movl   $0x1,0x28(%rsp)
call   1030 <display_game_menu@plt>
mov    %eax,-0x28(%rbp)
jmp    1214 <screen_game_menu+0x104>
cmpl   $0x1,-0x28(%rbp)
jne    122d <screen_game_menu+0x11d>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    12a0 <screen_game_menu+0x190>
cmpl   $0x2,-0x28(%rbp)
jne    1246 <screen_game_menu+0x136>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    129b <screen_game_menu+0x18b>
cmpl   $0x3,-0x28(%rbp)
jne    125f <screen_game_menu+0x14f>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
jmp    1296 <screen_game_menu+0x186>
cmpl   $0x4,-0x28(%rbp)
jne    1278 <screen_game_menu+0x168>
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
jmp    1291 <screen_game_menu+0x181>
cmpl   $0x5,-0x28(%rbp)
jne    128c <screen_game_menu+0x17c>
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
jmp    1291 <screen_game_menu+0x181>
jmp    1296 <screen_game_menu+0x186>
jmp    129b <screen_game_menu+0x18b>
jmp    12a0 <screen_game_menu+0x190>
mov    -0xc(%rbp),%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<screen_game_menu>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %edi,%ebp
mov    0x50(%rsp),%bl
mov    0x48(%rsp),%dl
mov    0x40(%rsp),%al
mov    0x38(%rsp),%r10d
mov    0x30(%rsp),%r11d
cmp    $0x1,%esi
je     1166 <screen_game_menu+0x56>
test   %esi,%esi
jne    11b3 <screen_game_menu+0xa3>
lea    0xebd(%rip),%r15
movsbl %bl,%ebx
movsbl %dl,%r12d
movsbl %al,%eax
mov    %ecx,%edi
mov    %r8d,%esi
mov    %r9d,%edx
mov    %r11d,%ecx
mov    %r10d,%r8d
mov    %eax,%r9d
push   $0x1
push   $0x5
push   $0x0
jmp    118e <screen_game_menu+0x7e>
lea    0xed4(%rip),%r15
movsbl %bl,%ebx
movsbl %dl,%r12d
movsbl %al,%eax
mov    %ecx,%edi
mov    %r8d,%esi
mov    %r9d,%edx
mov    %r11d,%ecx
mov    %r10d,%r8d
mov    %eax,%r9d
push   $0x1
push   $0x5
push   $0x1
push   %r15
push   %rbx
push   %r12
call   1030 <display_game_menu@plt>
add    $0x30,%rsp
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11b3 <screen_game_menu+0xa3>
cltq
lea    0xed7(%rip),%rcx
mov    (%rcx,%rax,4),%eax
mov    %eax,(%r14)
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"1. Enter Answer\0A2. Show Points\0A3. Help\0A4. Save Game\0A5. Exit Game\00"
@.str.1 = [65 x i8] c"A. Enter Answer\0AB. Show Points\0AC. Help\0AD. Save Game\0AE. Exit Game\00"
define i32 @screen_game_menu(i32 %0, i32 %1, i32* %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i8 signext %8, i8 signext %9, i8 signext %10) {
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i8
%21 = alloca i8
%22 = alloca i8
%23 = alloca i32
store i32 %0, i32* %12
store i32 %1, i32* %13
store i32* %2, i32** %14
store i32 %3, i32* %15
store i32 %4, i32* %16
store i32 %5, i32* %17
store i32 %6, i32* %18
store i32 %7, i32* %19
store i8 %8, i8* %20
store i8 %9, i8* %21
store i8 %10, i8* %22
store i32 0, i32* %23
%24 = load i32, i32* %13
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %11
%27 = load i32, i32* %15
%28 = load i32, i32* %16
%29 = load i32, i32* %17
%30 = load i32, i32* %18
%31 = load i32, i32* %19
%32 = load i8, i8* %20
%33 = load i8, i8* %21
%34 = load i8, i8* %22
%35 = load i32, i32* %13
%36 = call i32 @display_game_menu(i32 %27, i32 %28, i32 %29, i32 %30, i32 %31, i8 signext %32, i8 signext %33, i8 signext %34, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %35, i32 5, i32 1)
store i32 %36, i32* %23
br label %52
37: ; preds = %11
%38 = load i32, i32* %13
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %51
40: ; preds = %37
%41 = load i32, i32* %15
%42 = load i32, i32* %16
%43 = load i32, i32* %17
%44 = load i32, i32* %18
%45 = load i32, i32* %19
%46 = load i8, i8* %20
%47 = load i8, i8* %21
%48 = load i8, i8* %22
%49 = load i32, i32* %13
%50 = call i32 @display_game_menu(i32 %41, i32 %42, i32 %43, i32 %44, i32 %45, i8 signext %46, i8 signext %47, i8 signext %48, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 5, i32 1)
store i32 %50, i32* %23
br label %51
51: ; preds = %40, %37
br label %52
52: ; preds = %51, %26
%53 = load i32, i32* %23
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = load i32*, i32** %14
store i32 1, i32* %56
br label %81
57: ; preds = %52
%58 = load i32, i32* %23
%59 = icmp eq i32 %58, 2
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = load i32*, i32** %14
store i32 2, i32* %61
br label %80
62: ; preds = %57
%63 = load i32, i32* %23
%64 = icmp eq i32 %63, 3
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = load i32*, i32** %14
store i32 3, i32* %66
br label %79
67: ; preds = %62
%68 = load i32, i32* %23
%69 = icmp eq i32 %68, 4
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = load i32*, i32** %14
store i32 4, i32* %71
br label %78
72: ; preds = %67
%73 = load i32, i32* %23
%74 = icmp eq i32 %73, 5
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = load i32*, i32** %14
store i32 6, i32* %76
br label %77
77: ; preds = %75, %72
br label %78
78: ; preds = %77, %70
br label %79
79: ; preds = %78, %65
br label %80
80: ; preds = %79, %60
br label %81
81: ; preds = %80, %55
%82 = load i32, i32* %12
ret i32 %82
}

LLVM IR (-O2):
@.str = [65 x i8] c"1. Enter Answer\0A2. Show Points\0A3. Help\0A4. Save Game\0A5. Exit Game\00"
@.str.1 = [65 x i8] c"A. Enter Answer\0AB. Show Points\0AC. Help\0AD. Save Game\0AE. Exit Game\00"
@switch.table.screen_game_menu = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 6]
define i32 @screen_game_menu(i32 returned %0, i32 %1, i32* nocapture writeonly %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i8 signext %8, i8 signext %9, i8 signext %10) {
switch i32 %1, label %24 [
i32 0, label %12
i32 1, label %14
]
12: ; preds = %11
%13 = tail call i32 @display_game_menu(i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i8 signext %8, i8 signext %9, i8 signext %10, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 0, i32 5, i32 1)
br label %16
14: ; preds = %11
%15 = tail call i32 @display_game_menu(i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i8 signext %8, i8 signext %9, i8 signext %10, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 5, i32 1)
br label %16
16: ; preds = %14, %12
%17 = phi i32 [ %13, %12 ], [ %15, %14 ]
%18 = add i32 %17, -1
%19 = icmp ult i32 %18, 5
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.screen_game_menu, i64 0, i64 %21
%23 = load i32, i32* %22
store i32 %23, i32* %2
br label %24
24: ; preds = %16, %20, %11
ret i32 %0
}