#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;
  case 2:
    loadgame();
    break;
  case 3:
    playmultiplayer();
    break;
  case 4:
    printf("Thanks for playing!\n");
    break;
  default:
    printf("Bad input, quitting!\n");
    break;
  }
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1219 <main+0xb9>
mov    -0x10(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <playgame@plt>
jmp    1225 <main+0xc5>
mov    $0x0,%al
call   1080 <loadgame@plt>
jmp    1225 <main+0xc5>
mov    $0x0,%al
call   1050 <playmultiplayer@plt>
jmp    1225 <main+0xc5>
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
jmp    1225 <main+0xc5>
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
lea    0xe68(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11e3 <main+0x73>
lea    0xe2f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1080 <playgame@plt>
jmp    120a <main+0x9a>
lea    0xe7f(%rip),%rdi
jmp    1205 <main+0x95>
xor    %eax,%eax
call   1090 <loadgame@plt>
jmp    120a <main+0x9a>
xor    %eax,%eax
call   1060 <playmultiplayer@plt>
jmp    120a <main+0x9a>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@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 = call i32 (...) @getchar()
%22 = load i32, i32* %1
ret i32 %22
}

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
%21 = call i32 (...) @getchar()
ret i32 0
}