#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*/ getchar();
int /*<<< orphan*/ loadgame();
int /*<<< orphan*/ playgame();
int /*<<< orphan*/ playmultiplayer();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int input;
  printf("1. Play game\n");
  printf("2. Load game\n");
  printf("3. Play multiplayer\n");
  printf("4. Exit\n");
  printf("Selection: ");
  scanf("%d", &input);
  switch (input) {
  case 1:
    playgame();
    break;
    getchar();
  case 2:
    loadgame();
    break;
  case 3:
    playmultiplayer();
    break;
  case 4:
    printf("Thanks for playing!\n");
    break;
  default:
    printf("Bad input, quitting!\n");
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1209 <main+0xb9>
mov    -0x10(%rbp),%rax
lea    0xe35(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <playgame@plt>
jmp    1215 <main+0xc5>
mov    $0x0,%al
call   1070 <loadgame@plt>
jmp    1215 <main+0xc5>
mov    $0x0,%al
call   1040 <playmultiplayer@plt>
jmp    1215 <main+0xc5>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    1215 <main+0xc5>
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11d3 <main+0x73>
lea    0xe3f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <playgame@plt>
jmp    11fa <main+0x9a>
lea    0xe8f(%rip),%rdi
jmp    11f5 <main+0x95>
xor    %eax,%eax
call   1080 <loadgame@plt>
jmp    11fa <main+0x9a>
xor    %eax,%eax
call   1050 <playmultiplayer@plt>
jmp    11fa <main+0x9a>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"1. Play game\0A\00"
@.str.1 = [14 x i8] c"2. Load game\0A\00"
@.str.2 = [21 x i8] c"3. Play multiplayer\0A\00"
@.str.3 = [9 x i8] c"4. Exit\0A\00"
@.str.4 = [12 x i8] c"Selection: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [21 x i8] c"Thanks for playing!\0A\00"
@.str.7 = [22 x i8] c"Bad input, quitting!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
switch i32 %9, label %18 [
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
]
10: ; preds = %0
%11 = call i32 (...) @playgame()
br label %20
12: ; preds = %0
%13 = call i32 (...) @loadgame()
br label %20
14: ; preds = %0
%15 = call i32 (...) @playmultiplayer()
br label %20
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %20
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %20
20: ; preds = %18, %16, %14, %12, %10
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str.4 = [12 x i8] c"Selection: \00"
@.str.5 = [3 x i8] c"%d\00"
@str = [13 x i8] c"1. Play game\00"
@str.8 = [13 x i8] c"2. Load game\00"
@str.9 = [20 x i8] c"3. Play multiplayer\00"
@str.10 = [8 x i8] c"4. Exit\00"
@str.11 = [20 x i8] c"Thanks for playing!\00"
@str.12 = [21 x i8] c"Bad input, quitting!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.8, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
switch i32 %9, label %18 [
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
]
10: ; preds = %0
%11 = call i32 (...) @playgame()
br label %20
12: ; preds = %0
%13 = call i32 (...) @loadgame()
br label %20
14: ; preds = %0
%15 = call i32 (...) @playmultiplayer()
br label %20
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
br label %20
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0))
br label %20
20: ; preds = %18, %16, %14, %12, %10
ret i32 0
}