#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*/ TRUE;
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ erase();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
short menu();
int /*<<< orphan*/ nodelay(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ playgame(short);
int /*<<< orphan*/ raw();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  short control = 1;
  initscr();
  curs_set(0);
  noecho();
  keypad(stdscr, TRUE);
  nodelay(stdscr, TRUE);
  raw();
  srand(time(NULL));
  while ((control = menu()) != 4) {
    erase();
    playgame(control);
    erase();
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movw   $0x1,-0x12(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
xor    %edi,%edi
call   10e0 <curs_set@plt>
mov    $0x0,%al
call   10d0 <noecho@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
mov    0x2dc8(%rip),%rax
mov    (%rax),%esi
call   10a0 <nodelay@plt>
mov    $0x0,%al
call   1060 <raw@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
mov    $0x0,%al
call   1030 <menu@plt>
mov    %ax,-0x12(%rbp)
cwtl
cmp    $0x4,%eax
je     1267 <main+0xa7>
mov    $0x0,%al
call   1070 <erase@plt>
movswl -0x12(%rbp),%edi
call   10b0 <playgame@plt>
mov    $0x0,%al
call   1070 <erase@plt>
jmp    1236 <main+0x76>
mov    $0x0,%al
call   10c0 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %edi,%edi
call   10e0 <curs_set@plt>
xor    %eax,%eax
call   10d0 <noecho@plt>
mov    0x2e08(%rip),%r14
mov    (%r14),%edi
mov    0x2df6(%rip),%rbx
mov    (%rbx),%esi
call   1040 <keypad@plt>
mov    (%r14),%edi
mov    (%rbx),%esi
call   10a0 <nodelay@plt>
xor    %eax,%eax
call   1060 <raw@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
xor    %eax,%eax
call   1030 <menu@plt>
cmp    $0x4,%ax
je     1245 <main+0x85>
mov    %eax,%ebx
nop
xor    %eax,%eax
call   1070 <erase@plt>
movswl %bx,%edi
call   10b0 <playgame@plt>
xor    %eax,%eax
call   1070 <erase@plt>
xor    %eax,%eax
call   1030 <menu@plt>
mov    %eax,%ebx
cmp    $0x4,%ax
jne    1220 <main+0x60>
xor    %eax,%eax
call   10c0 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i16 1, i16* %6
%7 = call i32 (...) @initscr()
%8 = call i32 @curs_set(i32 0)
%9 = call i32 (...) @noecho()
%10 = load i32, i32* @stdscr
%11 = load i32, i32* @TRUE
%12 = call i32 @keypad(i32 %10, i32 %11)
%13 = load i32, i32* @stdscr
%14 = load i32, i32* @TRUE
%15 = call i32 @nodelay(i32 %13, i32 %14)
%16 = call i32 (...) @raw()
%17 = call i32 @time(i32* null)
%18 = call i32 @srand(i32 %17)
br label %19
19: ; preds = %23, %2
%20 = call signext i16 (...) @menu()
store i16 %20, i16* %6
%21 = sext i16 %20 to i32
%22 = icmp ne i32 %21, 4
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = call i32 (...) @erase()
%25 = load i16, i16* %6
%26 = call i32 @playgame(i16 signext %25)
%27 = call i32 (...) @erase()
br label %19
28: ; preds = %19
%29 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 @curs_set(i32 0)
%5 = tail call i32 (...) @noecho()
%6 = load i32, i32* @stdscr
%7 = load i32, i32* @TRUE
%8 = tail call i32 @keypad(i32 %6, i32 %7)
%9 = load i32, i32* @stdscr
%10 = load i32, i32* @TRUE
%11 = tail call i32 @nodelay(i32 %9, i32 %10)
%12 = tail call i32 (...) @raw()
%13 = tail call i32 @time(i32* null)
%14 = tail call i32 @srand(i32 %13)
%15 = tail call signext i16 (...) @menu()
%16 = icmp eq i16 %15, 4
br i1 %16, label %24, label %17
17: ; preds = %2, %17
%18 = phi i16 [ %22, %17 ], [ %15, %2 ]
%19 = tail call i32 (...) @erase()
%20 = tail call i32 @playgame(i16 signext %18)
%21 = tail call i32 (...) @erase()
%22 = tail call signext i16 (...) @menu()
%23 = icmp eq i16 %22, 4
br i1 %23, label %24, label %17
24: ; preds = %17, %2
%25 = tail call i32 (...) @endwin()
ret i32 0
}