#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*/ clear();
int game(int, int *, char);
char getch();
int /*<<< orphan*/ is_high_score(int, int, int);
int menu();
int /*<<< orphan*/ printf(char *, ...);
char select_player();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  srand(time(NULL));
  while (true) {
    int difficult = menu();
    int end_level = 1;
    char player_char = select_player();
    int result = game(difficult, &end_level, player_char);
    clear();
    printf("\x1b[31m"
           "\t\t\tGAME OVER!\n"
           "\x1b[0m"
           "\t\t\tScore: %d\n\n",
           result);
    printf("\n\t\t\tpress "
           "\x1b[32m"
           "ENTER"
           "\x1b[0m"
           "\n");
    while ((getch()) != '\n')
      ;
    is_high_score(result, end_level, difficult);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   1040 <menu@plt>
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1030 <select_player@plt>
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
movsbl -0xd(%rbp),%edx
call   1090 <game@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   10b0 <clear@plt>
mov    -0x14(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getch@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     121b <main+0x8b>
jmp    1203 <main+0x73>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   10a0 <is_high_score@plt>
jmp    11af <main+0x1f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0xc(%rsp),%r14
lea    0xe3a(%rip),%r15
lea    0xe59(%rip),%r12
nopl   (%rax)
xor    %eax,%eax
call   1050 <menu@plt>
mov    %eax,%ebp
movl   $0x1,0xc(%rsp)
xor    %eax,%eax
call   1040 <select_player@plt>
movsbl %al,%edx
mov    %ebp,%edi
mov    %r14,%rsi
call   10a0 <game@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10c0 <clear@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <getch@plt>
cmp    $0xa,%al
jne    1220 <main+0x80>
mov    0xc(%rsp),%esi
mov    %ebx,%edi
mov    %ebp,%edx
call   10b0 <is_high_score@plt>
jmp    11d0 <main+0x30>

LLVM IR (-O0):
@.str = [38 x i8] c"\1B[31m\09\09\09GAME OVER!\0A\1B[0m\09\09\09Score: %d\0A\0A\00"
@.str.1 = [26 x i8] c"\0A\09\09\09press \1B[32mENTER\1B[0m\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
br label %8
8: ; preds = %0, %23
%9 = call i32 (...) @menu()
store i32 %9, i32* %2
store i32 1, i32* %3
%10 = call signext i8 (...) @select_player()
store i8 %10, i8* %4
%11 = load i32, i32* %2
%12 = load i8, i8* %4
%13 = call i32 @game(i32 %11, i32* %3, i8 signext %12)
store i32 %13, i32* %5
%14 = call i32 (...) @clear()
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %22, %8
%19 = call signext i8 (...) @getch()
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %18
br label %18
23: ; preds = %18
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = call i32 @is_high_score(i32 %24, i32 %25, i32 %26)
br label %8
}

LLVM IR (-O2):
@.str = [38 x i8] c"\1B[31m\09\09\09GAME OVER!\0A\1B[0m\09\09\09Score: %d\0A\0A\00"
@str = [25 x i8] c"\0A\09\09\09press \1B[32mENTER\1B[0m\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast i32* %1 to i8*
br label %5
5: ; preds = %0, %15
%6 = call i32 (...) @menu()
store i32 1, i32* %1
%7 = call signext i8 (...) @select_player()
%8 = call i32 @game(i32 %6, i32* %1, i8 signext %7)
%9 = call i32 (...) @clear()
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %8)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %12, %5
%13 = call signext i8 (...) @getch()
%14 = icmp eq i8 %13, 10
br i1 %14, label %15, label %12
15: ; preds = %12
%16 = load i32, i32* %1
%17 = call i32 @is_high_score(i32 %8, i32 %16, i32 %6)
br label %5
}