#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 */
typedef int /*<<< orphan*/ choice;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ displayTheCredit();
int /*<<< orphan*/ displayTheOption();
int /*<<< orphan*/ displayTheScores();
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ startTheGame();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ system(char *);
int main() {
  char choice[3];
  system("title TIC TAC TOE");
  while (1) {
    system("cls");
    printf("\n            ===============\n");
    printf("            | TIC TAC TOE |\n");
    printf("            ===============\n");
    printf("            |             |\n");
    printf("            |  1. Start   |\n");
    printf("            |  2. Option  |\n");
    printf("            |  3. Scores  |\n");
    printf("            |  4. Credit  |\n");
    printf("            |  5. Exit    |\n");
    printf("            ===============\n\n");
    printf("Enter your choice: ");
    fgets(choice, sizeof(choice), stdin);
    switch (atoi(choice)) {
    case 1:
      startTheGame();
      break;
    case 2:
      displayTheOption();
      break;
    case 3:
      displayTheScores();
      break;
    case 4:
      displayTheCredit();
      break;
    case 5:
      return (0);
    default:
      printf("Invalid choice. Try again...\n\n");
      system("pause");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7e(%rip),%rdi
call   1030 <system@plt>
lea    0xe84(%rip),%rdi
call   1030 <system@plt>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
call   1040 <printf@plt>
lea    0xee8(%rip),%rdi
call   1040 <printf@plt>
lea    0xef9(%rip),%rdi
call   1040 <printf@plt>
lea    0xf0b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edx
lea    -0x7(%rbp),%rdi
mov    %rdi,-0x18(%rbp)
mov    $0x3,%esi
call   1060 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <atoi@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     12ad <main+0x12d>
mov    -0x10(%rbp),%rax
lea    0xd94(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <startTheGame@plt>
jmp    12c5 <main+0x145>
mov    $0x0,%al
call   1070 <displayTheOption@plt>
jmp    12c5 <main+0x145>
mov    $0x0,%al
call   1080 <displayTheScores@plt>
jmp    12c5 <main+0x145>
mov    $0x0,%al
call   1050 <displayTheCredit@plt>
jmp    12c5 <main+0x145>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
call   1030 <system@plt>
jmp    119b <main+0x1b>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe72(%rip),%rdi
call   1040 <system@plt>
lea    0xf5b(%rip),%r13
lea    0xf70(%rip),%rbx
lea    0xe6e(%rip),%rbp
mov    0x2e25(%rip),%r15
lea    0x5(%rsp),%r14
lea    0xe31(%rip),%r12
jmp    11e0 <main+0x50>
xor    %eax,%eax
call   1060 <displayTheCredit@plt>
nopl   0x0(%rax,%rax,1)
lea    0xe3f(%rip),%rdi
call   1040 <system@plt>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    (%r15),%edx
mov    %r14,%rdi
mov    $0x3,%esi
call   1070 <fgets@plt>
mov    %r14,%rdi
call   10b0 <atoi@plt>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1299 <main+0x109>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   10a0 <startTheGame@plt>
jmp    11e0 <main+0x50>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xd92(%rip),%rdi
call   1040 <system@plt>
jmp    11e0 <main+0x50>
xor    %eax,%eax
call   1080 <displayTheOption@plt>
jmp    11e0 <main+0x50>
xor    %eax,%eax
call   1090 <displayTheScores@plt>
jmp    11e0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"title TIC TAC TOE\00"
@.str.1 = [4 x i8] c"cls\00"
@.str.2 = [30 x i8] c"\0A ===============\0A\00"
@.str.3 = [29 x i8] c" | TIC TAC TOE |\0A\00"
@.str.4 = [29 x i8] c" ===============\0A\00"
@.str.5 = [29 x i8] c" | |\0A\00"
@.str.6 = [29 x i8] c" | 1. Start |\0A\00"
@.str.7 = [29 x i8] c" | 2. Option |\0A\00"
@.str.8 = [29 x i8] c" | 3. Scores |\0A\00"
@.str.9 = [29 x i8] c" | 4. Credit |\0A\00"
@.str.10 = [29 x i8] c" | 5. Exit |\0A\00"
@.str.11 = [30 x i8] c" ===============\0A\0A\00"
@.str.12 = [20 x i8] c"Enter your choice: \00"
@stdin = global i32 0
@.str.13 = [31 x i8] c"Invalid choice. Try again...\0A\0A\00"
@.str.14 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
store i32 0, i32* %1
%3 = call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %34
%5 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0))
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %17, i32 3, i32 %18)
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
switch i32 %21, label %31 [
i32 1, label %22
i32 2, label %24
i32 3, label %26
i32 4, label %28
i32 5, label %30
]
22: ; preds = %4
%23 = call i32 (...) @startTheGame()
br label %34
24: ; preds = %4
%25 = call i32 (...) @displayTheOption()
br label %34
26: ; preds = %4
%27 = call i32 (...) @displayTheScores()
br label %34
28: ; preds = %4
%29 = call i32 (...) @displayTheCredit()
br label %34
30: ; preds = %4
ret i32 0
31: ; preds = %4
%32 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
%33 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
br label %34
34: ; preds = %31, %28, %26, %24, %22
br label %4
}

LLVM IR (-O2):
@.str = [18 x i8] c"title TIC TAC TOE\00"
@.str.1 = [4 x i8] c"cls\00"
@.str.12 = [20 x i8] c"Enter your choice: \00"
@stdin = global i32 0
@.str.14 = [6 x i8] c"pause\00"
@str = [29 x i8] c"\0A ===============\00"
@str.15 = [28 x i8] c" | TIC TAC TOE |\00"
@str.16 = [28 x i8] c" ===============\00"
@str.17 = [28 x i8] c" | |\00"
@str.18 = [28 x i8] c" | 1. Start |\00"
@str.19 = [28 x i8] c" | 2. Option |\00"
@str.20 = [28 x i8] c" | 3. Scores |\00"
@str.21 = [28 x i8] c" | 4. Credit |\00"
@str.22 = [28 x i8] c" | 5. Exit |\00"
@str.23 = [29 x i8] c" ===============\0A\00"
@str.24 = [30 x i8] c"Invalid choice. Try again...\0A\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %32, %0
%5 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.15, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.16, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.18, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.19, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.20, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.21, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.22, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.23, i64 0, i64 0))
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %2, i32 3, i32 %17)
%19 = call i32 @atoi(i8* %2)
switch i32 %19, label %29 [
i32 1, label %20
i32 2, label %22
i32 3, label %24
i32 4, label %26
i32 5, label %28
]
20: ; preds = %4
%21 = call i32 (...) @startTheGame()
br label %32
22: ; preds = %4
%23 = call i32 (...) @displayTheOption()
br label %32
24: ; preds = %4
%25 = call i32 (...) @displayTheScores()
br label %32
26: ; preds = %4
%27 = call i32 (...) @displayTheCredit()
br label %32
28: ; preds = %4
ret i32 0
29: ; preds = %4
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.24, i64 0, i64 0))
%31 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
br label %32
32: ; preds = %29, %26, %24, %22, %20
br label %4
}