#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*/ exit(int);
int /*<<< orphan*/ goToHelp();
int /*<<< orphan*/ goToSettings();
int /*<<< orphan*/ printMainMenu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ startNewGame();
int /*<<< orphan*/ system(char *);
void main(void) {
  int gameMode;
  system("cls");
  printf("Welcome to BATTLESHIP - The CMD Edition!\nPress 'Maximize' for "
         "better Experience\n");
  printMainMenu();
  scanf("%d", &gameMode);
  switch (gameMode) {
  case 0:
    exit(1);
  case 1:
    startNewGame();
    break;
  case 2:
    goToSettings();
    break;
  case 3:
    goToHelp();
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
call   1050 <system@plt>
lea    0xe79(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1030 <printMainMenu@plt>
lea    0xeb7(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     1205 <main+0x85>
mov    -0x10(%rbp),%rax
lea    0xe2d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1070 <startNewGame@plt>
jmp    1205 <main+0x85>
mov    $0x0,%al
call   1040 <goToSettings@plt>
jmp    1205 <main+0x85>
mov    $0x0,%al
call   1080 <goToHelp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe88(%rip),%rdi
call   1060 <system@plt>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <printMainMenu@plt>
lea    0xe6d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     11e4 <main+0x64>
lea    0xe3e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <startNewGame@plt>
pop    %rax
ret
xor    %eax,%eax
call   1050 <goToSettings@plt>
pop    %rax
ret
xor    %eax,%eax
call   1080 <goToHelp@plt>
pop    %rax
ret
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [81 x i8] c"Welcome to BATTLESHIP - The CMD Edition!\0APress 'Maximize' for better Experience\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define void @main() {
%1 = alloca i32
%2 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (...) @printMainMenu()
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
switch i32 %6, label %15 [
i32 0, label %7
i32 1, label %9
i32 2, label %11
i32 3, label %13
]
7: ; preds = %0
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i32 (...) @startNewGame()
br label %15
11: ; preds = %0
%12 = call i32 (...) @goToSettings()
br label %15
13: ; preds = %0
%14 = call i32 (...) @goToHelp()
br label %15
15: ; preds = %0, %13, %11, %9
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [80 x i8] c"Welcome to BATTLESHIP - The CMD Edition!\0APress 'Maximize' for better Experience\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (...) @printMainMenu()
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
switch i32 %7, label %16 [
i32 0, label %8
i32 1, label %10
i32 2, label %12
i32 3, label %14
]
8: ; preds = %0
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = call i32 (...) @startNewGame()
br label %16
12: ; preds = %0
%13 = call i32 (...) @goToSettings()
br label %16
14: ; preds = %0
%15 = call i32 (...) @goToHelp()
br label %16
16: ; preds = %0, %14, %12, %10
ret void
}