#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*/ save_game(int, char, char, char, int, int, int, int, int,
                             int, int, int, char, char, char);
void screen_save_game_menu(int menu_type, int *menu_state, char initial_a,
                           char initial_b, char initial_c, int difficulty,
                           int points, int questions, int question_difficulty,
                           int term1, int term2, int term3, int term4,
                           char operand1, char operand2, char operand3) {
  int option = 0;
  if (menu_type == 0) {
    option = display_standard_menu("Save Game Menu",
                                   "1. Back\n2. Save 1\n3. Save 2\n4. Save 3",
                                   menu_type, 4, 1);
  } else if (menu_type == 1) {
    option = display_standard_menu("Save Game Menu",
                                   "A. Back\nB. Save 1\nC. Save 2\nD. Save 3",
                                   menu_type, 4, 1);
  }
  if (option == 1) {
    *menu_state = 0;
  } else if (option == 2) {
    save_game(1, initial_a, initial_b, initial_c, difficulty, points, questions,
              question_difficulty, term1, term2, term3, term4, operand1,
              operand2, operand3);
    *menu_state = 8;
  } else if (option == 3) {
    save_game(2, initial_a, initial_b, initial_c, difficulty, points, questions,
              question_difficulty, term1, term2, term3, term4, operand1,
              operand2, operand3);
    *menu_state = 9;
  } else {
    save_game(3, initial_a, initial_b, initial_c, difficulty, points, questions,
              question_difficulty, term1, term2, term3, term4, operand1,
              operand2, operand3);
    *menu_state = 10;
  }
}


x86 assembly (clang, -O0):
<screen_save_game_menu>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8b,%al
mov    0x58(%rbp),%r8b
mov    0x50(%rbp),%r8b
mov    0x48(%rbp),%r8b
mov    0x40(%rbp),%r8d
mov    0x38(%rbp),%r8d
mov    0x30(%rbp),%r8d
mov    0x28(%rbp),%r8d
mov    0x20(%rbp),%r8d
mov    0x18(%rbp),%r8d
mov    0x10(%rbp),%r8d
mov    %edi,-0x2c(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %dl,-0x39(%rbp)
mov    %cl,-0x3a(%rbp)
mov    %al,-0x3b(%rbp)
mov    %r9d,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11aa <screen_save_game_menu+0x8a>
mov    -0x2c(%rbp),%edx
lea    0xe75(%rip),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x4,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
mov    %eax,-0x44(%rbp)
jmp    11dd <screen_save_game_menu+0xbd>
cmpl   $0x1,-0x2c(%rbp)
jne    11d8 <screen_save_game_menu+0xb8>
mov    -0x2c(%rbp),%edx
lea    0xe42(%rip),%rdi
lea    0xe70(%rip),%rsi
mov    $0x4,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
mov    %eax,-0x44(%rbp)
jmp    11dd <screen_save_game_menu+0xbd>
cmpl   $0x1,-0x44(%rbp)
jne    11f6 <screen_save_game_menu+0xd6>
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
jmp    13a4 <screen_save_game_menu+0x284>
cmpl   $0x2,-0x44(%rbp)
jne    1287 <screen_save_game_menu+0x167>
mov    -0x39(%rbp),%sil
mov    -0x3a(%rbp),%dl
mov    -0x3b(%rbp),%cl
mov    -0x40(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%r13d
mov    0x20(%rbp),%r12d
mov    0x28(%rbp),%r15d
mov    0x30(%rbp),%r14d
mov    0x38(%rbp),%ebx
mov    0x40(%rbp),%r11d
mov    0x48(%rbp),%r10b
mov    0x50(%rbp),%al
mov    $0x1,%edi
movsbl %sil,%esi
movsbl %dl,%edx
movsbl %cl,%ecx
mov    %r13d,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14d,0x18(%rsp)
mov    %ebx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
movsbl %r10b,%r10d
mov    %r10d,0x30(%rsp)
movsbl %al,%eax
mov    %eax,0x38(%rsp)
movsbl 0x58(%rbp),%eax
mov    %eax,0x40(%rsp)
call   1040 <save_game@plt>
mov    -0x38(%rbp),%rax
movl   $0x8,(%rax)
jmp    139f <screen_save_game_menu+0x27f>
cmpl   $0x3,-0x44(%rbp)
jne    1318 <screen_save_game_menu+0x1f8>
mov    -0x39(%rbp),%sil
mov    -0x3a(%rbp),%dl
mov    -0x3b(%rbp),%cl
mov    -0x40(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%r13d
mov    0x20(%rbp),%r12d
mov    0x28(%rbp),%r15d
mov    0x30(%rbp),%r14d
mov    0x38(%rbp),%ebx
mov    0x40(%rbp),%r11d
mov    0x48(%rbp),%r10b
mov    0x50(%rbp),%al
mov    $0x2,%edi
movsbl %sil,%esi
movsbl %dl,%edx
movsbl %cl,%ecx
mov    %r13d,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14d,0x18(%rsp)
mov    %ebx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
movsbl %r10b,%r10d
mov    %r10d,0x30(%rsp)
movsbl %al,%eax
mov    %eax,0x38(%rsp)
movsbl 0x58(%rbp),%eax
mov    %eax,0x40(%rsp)
call   1040 <save_game@plt>
mov    -0x38(%rbp),%rax
movl   $0x9,(%rax)
jmp    139a <screen_save_game_menu+0x27a>
mov    -0x39(%rbp),%sil
mov    -0x3a(%rbp),%dl
mov    -0x3b(%rbp),%cl
mov    -0x40(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%r13d
mov    0x20(%rbp),%r12d
mov    0x28(%rbp),%r15d
mov    0x30(%rbp),%r14d
mov    0x38(%rbp),%ebx
mov    0x40(%rbp),%r11d
mov    0x48(%rbp),%r10b
mov    0x50(%rbp),%al
mov    $0x3,%edi
movsbl %sil,%esi
movsbl %dl,%edx
movsbl %cl,%ecx
mov    %r13d,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14d,0x18(%rsp)
mov    %ebx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
movsbl %r10b,%r10d
mov    %r10d,0x30(%rsp)
movsbl %al,%eax
mov    %eax,0x38(%rsp)
movsbl 0x58(%rbp),%eax
mov    %eax,0x40(%rsp)
call   1040 <save_game@plt>
mov    -0x38(%rbp),%rax
movl   $0xa,(%rax)
jmp    139f <screen_save_game_menu+0x27f>
jmp    13a4 <screen_save_game_menu+0x284>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<screen_save_game_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebp
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %rsi,%rbx
cmp    $0x1,%edi
je     1155 <screen_save_game_menu+0x35>
test   %edi,%edi
jne    1196 <screen_save_game_menu+0x76>
lea    0xeb6(%rip),%rdi
lea    0xebe(%rip),%rsi
xor    %edx,%edx
jmp    1168 <screen_save_game_menu+0x48>
lea    0xea4(%rip),%rdi
lea    0xed2(%rip),%rsi
mov    $0x1,%edx
mov    $0x4,%ecx
mov    $0x1,%r8d
call   1030 <display_standard_menu@plt>
cmp    $0x1,%eax
je     11a5 <screen_save_game_menu+0x85>
cmp    $0x2,%eax
je     11a9 <screen_save_game_menu+0x89>
cmp    $0x3,%eax
jne    1196 <screen_save_game_menu+0x76>
mov    %ebp,%r8d
mov    $0x9,%ebp
mov    $0x2,%edi
jmp    11b6 <screen_save_game_menu+0x96>
mov    %ebp,%r8d
mov    $0xa,%ebp
mov    $0x3,%edi
jmp    11b6 <screen_save_game_menu+0x96>
xor    %ebp,%ebp
jmp    1223 <screen_save_game_menu+0x103>
mov    %ebp,%r8d
mov    $0x8,%ebp
mov    $0x1,%edi
mov    0x80(%rsp),%cl
mov    0x78(%rsp),%dl
mov    0x70(%rsp),%r11d
mov    0x40(%rsp),%r9d
sub    $0x8,%rsp
movsbl 0x90(%rsp),%eax
movsbl %cl,%r14d
movsbl %dl,%r10d
movsbl %r15b,%esi
movsbl %r13b,%edx
movsbl %r12b,%ecx
push   %rax
push   %r14
push   %r10
push   %r11
mov    0x90(%rsp),%eax
push   %rax
mov    0x90(%rsp),%eax
push   %rax
mov    0x90(%rsp),%eax
push   %rax
mov    0x90(%rsp),%eax
push   %rax
mov    0x90(%rsp),%eax
push   %rax
call   1040 <save_game@plt>
add    $0x50,%rsp
mov    %ebp,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Save Game Menu\00"
@.str.1 = [38 x i8] c"1. Back\0A2. Save 1\0A3. Save 2\0A4. Save 3\00"
@.str.2 = [38 x i8] c"A. Back\0AB. Save 1\0AC. Save 2\0AD. Save 3\00"
define void @screen_save_game_menu(i32 %0, i32* %1, i8 signext %2, i8 signext %3, i8 signext %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12, i8 signext %13, i8 signext %14, i8 signext %15) {
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i8
%20 = alloca i8
%21 = alloca i8
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i8
%31 = alloca i8
%32 = alloca i8
%33 = alloca i32
store i32 %0, i32* %17
store i32* %1, i32** %18
store i8 %2, i8* %19
store i8 %3, i8* %20
store i8 %4, i8* %21
store i32 %5, i32* %22
store i32 %6, i32* %23
store i32 %7, i32* %24
store i32 %8, i32* %25
store i32 %9, i32* %26
store i32 %10, i32* %27
store i32 %11, i32* %28
store i32 %12, i32* %29
store i8 %13, i8* %30
store i8 %14, i8* %31
store i8 %15, i8* %32
store i32 0, i32* %33
%34 = load i32, i32* %17
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %16
%37 = load i32, i32* %17
%38 = call i32 @display_standard_menu(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 4, i32 1)
store i32 %38, i32* %33
br label %46
39: ; preds = %16
%40 = load i32, i32* %17
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %17
%44 = call i32 @display_standard_menu(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 4, i32 1)
store i32 %44, i32* %33
br label %45
45: ; preds = %42, %39
br label %46
46: ; preds = %45, %36
%47 = load i32, i32* %33
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = load i32*, i32** %18
store i32 0, i32* %50
br label %110
51: ; preds = %46
%52 = load i32, i32* %33
%53 = icmp eq i32 %52, 2
br i1 %53, label %54, label %71
54: ; preds = %51
%55 = load i8, i8* %19
%56 = load i8, i8* %20
%57 = load i8, i8* %21
%58 = load i32, i32* %22
%59 = load i32, i32* %23
%60 = load i32, i32* %24
%61 = load i32, i32* %25
%62 = load i32, i32* %26
%63 = load i32, i32* %27
%64 = load i32, i32* %28
%65 = load i32, i32* %29
%66 = load i8, i8* %30
%67 = load i8, i8* %31
%68 = load i8, i8* %32
%69 = call i32 @save_game(i32 1, i8 signext %55, i8 signext %56, i8 signext %57, i32 %58, i32 %59, i32 %60, i32 %61, i32 %62, i32 %63, i32 %64, i32 %65, i8 signext %66, i8 signext %67, i8 signext %68)
%70 = load i32*, i32** %18
store i32 8, i32* %70
br label %109
71: ; preds = %51
%72 = load i32, i32* %33
%73 = icmp eq i32 %72, 3
br i1 %73, label %74, label %91
74: ; preds = %71
%75 = load i8, i8* %19
%76 = load i8, i8* %20
%77 = load i8, i8* %21
%78 = load i32, i32* %22
%79 = load i32, i32* %23
%80 = load i32, i32* %24
%81 = load i32, i32* %25
%82 = load i32, i32* %26
%83 = load i32, i32* %27
%84 = load i32, i32* %28
%85 = load i32, i32* %29
%86 = load i8, i8* %30
%87 = load i8, i8* %31
%88 = load i8, i8* %32
%89 = call i32 @save_game(i32 2, i8 signext %75, i8 signext %76, i8 signext %77, i32 %78, i32 %79, i32 %80, i32 %81, i32 %82, i32 %83, i32 %84, i32 %85, i8 signext %86, i8 signext %87, i8 signext %88)
%90 = load i32*, i32** %18
store i32 9, i32* %90
br label %108
91: ; preds = %71
%92 = load i8, i8* %19
%93 = load i8, i8* %20
%94 = load i8, i8* %21
%95 = load i32, i32* %22
%96 = load i32, i32* %23
%97 = load i32, i32* %24
%98 = load i32, i32* %25
%99 = load i32, i32* %26
%100 = load i32, i32* %27
%101 = load i32, i32* %28
%102 = load i32, i32* %29
%103 = load i8, i8* %30
%104 = load i8, i8* %31
%105 = load i8, i8* %32
%106 = call i32 @save_game(i32 3, i8 signext %92, i8 signext %93, i8 signext %94, i32 %95, i32 %96, i32 %97, i32 %98, i32 %99, i32 %100, i32 %101, i32 %102, i8 signext %103, i8 signext %104, i8 signext %105)
%107 = load i32*, i32** %18
store i32 10, i32* %107
br label %108
108: ; preds = %91, %74
br label %109
109: ; preds = %108, %54
br label %110
110: ; preds = %109, %49
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Save Game Menu\00"
@.str.1 = [38 x i8] c"1. Back\0A2. Save 1\0A3. Save 2\0A4. Save 3\00"
@.str.2 = [38 x i8] c"A. Back\0AB. Save 1\0AC. Save 2\0AD. Save 3\00"
define void @screen_save_game_menu(i32 %0, i32* nocapture writeonly %1, i8 signext %2, i8 signext %3, i8 signext %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12, i8 signext %13, i8 signext %14, i8 signext %15) {
switch i32 %0, label %24 [
i32 0, label %17
i32 1, label %19
]
17: ; preds = %16
%18 = tail call i32 @display_standard_menu(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 4, i32 1)
br label %21
19: ; preds = %16
%20 = tail call i32 @display_standard_menu(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 4, i32 1)
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ]
switch i32 %22, label %24 [
i32 1, label %29
i32 2, label %25
i32 3, label %23
]
23: ; preds = %21
br label %25
24: ; preds = %16, %21
br label %25
25: ; preds = %21, %23, %24
%26 = phi i32 [ 3, %24 ], [ 2, %23 ], [ 1, %21 ]
%27 = phi i32 [ 10, %24 ], [ 9, %23 ], [ 8, %21 ]
%28 = tail call i32 @save_game(i32 %26, i8 signext %2, i8 signext %3, i8 signext %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12, i8 signext %13, i8 signext %14, i8 signext %15)
br label %29
29: ; preds = %25, %21
%30 = phi i32 [ 0, %21 ], [ %27, %25 ]
store i32 %30, i32* %1
ret void
}