#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 */
struct termios {
  int c_lflag;
  int *c_cc;
};

/* Variables and functions */
int ICANON;
int ISIG;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ game_loop();
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
int main() {
  struct termios orig, rawmode;
  setvbuf(stdout, NULL, _IONBF, 0);
  tcgetattr(0, &orig);
  rawmode = orig;
  rawmode.c_lflag &= ~(ISIG | ICANON);
  rawmode.c_cc[VMIN] = 1;
  rawmode.c_cc[VTIME] = 2;
  tcsetattr(0, TCSANOW, &rawmode);
  game_loop();
  tcsetattr(0, TCSANOW, &orig);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    0x2e79(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1040 <setvbuf@plt>
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   1050 <tcgetattr@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    0x2e19(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2e23(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    0x2df6(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x28(%rbp),%rdx
call   1060 <tcsetattr@plt>
mov    $0x0,%al
call   1030 <game_loop@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x18(%rbp),%rdx
call   1060 <tcsetattr@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1040 <setvbuf@plt>
lea    0x18(%rsp),%r14
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <tcgetattr@plt>
movups 0x18(%rsp),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e5f(%rip),%rax
mov    0x2e28(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rsp)
mov    0x8(%rsp),%rax
mov    0x2e33(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2e0a(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x2,(%rax,%rcx,4)
mov    0x2e29(%rip),%rbx
mov    (%rbx),%esi
mov    %rsp,%rdx
xor    %edi,%edi
call   1060 <tcsetattr@plt>
xor    %eax,%eax
call   1030 <game_loop@plt>
mov    (%rbx),%esi
xor    %edi,%edi
mov    %r14,%rdx
call   1060 <tcsetattr@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32* }
@stdout = global i32 0
@_IONBF = global i32 0
@ISIG = global i32 0
@ICANON = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.termios
%3 = alloca %struct.termios
store i32 0, i32* %1
%4 = load i32, i32* @stdout
%5 = load i32, i32* @_IONBF
%6 = call i32 @setvbuf(i32 %4, i32* null, i32 %5, i32 0)
%7 = call i32 @tcgetattr(i32 0, %struct.termios* %2)
%8 = bitcast %struct.termios* %3 to i8*
%9 = bitcast %struct.termios* %2 to i8*
%10 = load i32, i32* @ISIG
%11 = load i32, i32* @ICANON
%12 = or i32 %10, %11
%13 = xor i32 %12, -1
%14 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%15 = load i32, i32* %14
%16 = and i32 %15, %13
store i32 %16, i32* %14
%17 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 1
%18 = load i32*, i32** %17
%19 = load i64, i64* @VMIN
%20 = getelementptr inbounds i32, i32* %18, i64 %19
store i32 1, i32* %20
%21 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 1
%22 = load i32*, i32** %21
%23 = load i64, i64* @VTIME
%24 = getelementptr inbounds i32, i32* %22, i64 %23
store i32 2, i32* %24
%25 = load i32, i32* @TCSANOW
%26 = call i32 @tcsetattr(i32 0, i32 %25, %struct.termios* %3)
%27 = call i32 (...) @game_loop()
%28 = load i32, i32* @TCSANOW
%29 = call i32 @tcsetattr(i32 0, i32 %28, %struct.termios* %2)
ret i32 0
}

LLVM IR (-O2):
%struct.termios = type { i32, i32* }
@stdout = global i32 0
@_IONBF = global i32 0
@ISIG = global i32 0
@ICANON = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
define i32 @main() {
%1 = alloca %struct.termios
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %1 to i8*
%4 = bitcast %struct.termios* %2 to i8*
%5 = load i32, i32* @stdout
%6 = load i32, i32* @_IONBF
%7 = tail call i32 @setvbuf(i32 %5, i32* null, i32 %6, i32 0)
%8 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%9 = load i32, i32* @ISIG
%10 = load i32, i32* @ICANON
%11 = or i32 %10, %9
%12 = xor i32 %11, -1
%13 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%14 = load i32, i32* %13
%15 = and i32 %14, %12
store i32 %15, i32* %13
%16 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 1
%17 = load i32*, i32** %16
%18 = load i64, i64* @VMIN
%19 = getelementptr inbounds i32, i32* %17, i64 %18
store i32 1, i32* %19
%20 = load i64, i64* @VTIME
%21 = getelementptr inbounds i32, i32* %17, i64 %20
store i32 2, i32* %21
%22 = load i32, i32* @TCSANOW
%23 = call i32 @tcsetattr(i32 0, i32 %22, %struct.termios* %2)
%24 = call i32 (...) @game_loop()
%25 = load i32, i32* @TCSANOW
%26 = call i32 @tcsetattr(i32 0, i32 %25, %struct.termios* %1)
ret i32 0
}