#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 */
#define KEY_LEFT 129
#define KEY_RIGHT 128
int /*<<< orphan*/ draw_msg(char *);
int /*<<< orphan*/ draw_player(char, int const);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ timeout(int);
int toupper(int /*<<< orphan*/);
int game_over(const int player_pos) {
  draw_msg("LOSE");
  draw_player('#', player_pos);
  int key = 0;
  timeout(-1);
  while (1) {
    key = toupper(getch());
    switch (key) {
    case 'Q':
    case 27:
      return 0;
    case 'A':
    case 'D':
    case KEY_LEFT:
    case KEY_RIGHT:
      break;
    default:
      timeout(50);
      return 1;
    }
  }
}


x86 assembly (clang, -O0):
<game_over>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
lea    0xe9e(%rip),%rdi
call   1070 <draw_msg@plt>
mov    -0x8(%rbp),%esi
mov    $0x23,%edi
call   1050 <draw_player@plt>
movl   $0x0,-0xc(%rbp)
mov    $0xffffffff,%edi
call   1040 <timeout@plt>
xor    %eax,%eax
call   1060 <getch@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1b,%eax
je     11f1 <game_over+0xa1>
jmp    11aa <game_over+0x5a>
mov    -0x10(%rbp),%eax
sub    $0x41,%eax
je     11fd <game_over+0xad>
jmp    11bb <game_over+0x6b>
mov    -0x10(%rbp),%eax
sub    $0x44,%eax
je     11fd <game_over+0xad>
jmp    11cc <game_over+0x7c>
mov    -0x10(%rbp),%eax
sub    $0x51,%eax
je     11f1 <game_over+0xa1>
jmp    11dd <game_over+0x8d>
mov    -0x10(%rbp),%eax
add    $0xffffff80,%eax
sub    $0x2,%eax
jb     11fd <game_over+0xad>
jmp    1202 <game_over+0xb2>
movl   $0x0,-0x4(%rbp)
jmp    121d <game_over+0xcd>
jmp    1218 <game_over+0xc8>
mov    $0x32,%edi
call   1040 <timeout@plt>
movl   $0x1,-0x4(%rbp)
jmp    121d <game_over+0xcd>
jmp    1185 <game_over+0x35>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<game_over>:
push   %rbx
mov    %edi,%ebx
lea    0xea6(%rip),%rdi
call   1070 <draw_msg@plt>
mov    $0x23,%edi
mov    %ebx,%esi
call   1050 <draw_player@plt>
mov    $0xffffffff,%edi
call   1040 <timeout@plt>
jmp    1188 <game_over+0x38>
nopw   0x0(%rax,%rax,1)
lea    -0x80(%rax),%ecx
cmp    $0x2,%ecx
jae    11bb <game_over+0x6b>
xor    %eax,%eax
call   1060 <getch@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
cmp    $0x50,%eax
jg     1180 <game_over+0x30>
cmp    $0x41,%eax
je     1188 <game_over+0x38>
cmp    $0x44,%eax
je     1188 <game_over+0x38>
cmp    $0x1b,%eax
je     11c0 <game_over+0x70>
mov    $0x32,%edi
call   1040 <timeout@plt>
mov    $0x1,%eax
pop    %rbx
ret
cmp    $0x51,%eax
jne    11aa <game_over+0x5a>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"LOSE\00"
define i32 @game_over(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = call i32 @draw_msg(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %3
%7 = call i32 @draw_player(i8 signext 35, i32 %6)
store i32 0, i32* %4
%8 = call i32 @timeout(i32 -1)
br label %9
9: ; preds = %1, %17
%10 = call i32 (...) @getch()
%11 = call i32 @toupper(i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
switch i32 %12, label %15 [
i32 81, label %13
i32 27, label %13
i32 65, label %14
i32 68, label %14
i32 129, label %14
i32 128, label %14
]
13: ; preds = %9, %9
store i32 0, i32* %2
br label %18
14: ; preds = %9, %9, %9, %9
br label %17
15: ; preds = %9
%16 = call i32 @timeout(i32 50)
store i32 1, i32* %2
br label %18
17: ; preds = %14
br label %9
18: ; preds = %15, %13
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [5 x i8] c"LOSE\00"
define i32 @game_over(i32 %0) {
%2 = tail call i32 @draw_msg(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @draw_player(i8 signext 35, i32 %0)
%4 = tail call i32 @timeout(i32 -1)
br label %5
5: ; preds = %8, %1
%6 = tail call i32 (...) @getch()
%7 = tail call i32 @toupper(i32 %6)
switch i32 %7, label %9 [
i32 81, label %11
i32 27, label %11
i32 65, label %8
i32 68, label %8
i32 129, label %8
i32 128, label %8
]
8: ; preds = %5, %5, %5, %5
br label %5
9: ; preds = %5
%10 = tail call i32 @timeout(i32 50)
br label %11
11: ; preds = %5, %5, %9
%12 = phi i32 [ 1, %9 ], [ 0, %5 ], [ 0, %5 ]
ret i32 %12
}