#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*/ FALSE;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ cbreak();
int getch();
int /*<<< orphan*/ halfdelay(int);
int /*<<< orphan*/ nocbreak();
int /*<<< orphan*/ nodelay(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdscr;
int WaitForUser(void) {
  int ch;
  nodelay(stdscr, TRUE);
  halfdelay(50);
  ch = getch();
  nodelay(stdscr, FALSE);
  nocbreak();
  cbreak();
  return (ch == '\033') ? ch : 0;
}


x86 assembly (clang, -O0):
<WaitForUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
call   1050 <nodelay@plt>
mov    $0x32,%edi
call   1040 <halfdelay@plt>
mov    $0x0,%al
call   1060 <getch@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
call   1050 <nodelay@plt>
mov    $0x0,%al
call   1070 <nocbreak@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
cmpl   $0x1b,-0x4(%rbp)
jne    11bd <WaitForUser+0x6d>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11c7 <WaitForUser+0x77>
xor    %eax,%eax
mov    %eax,-0x8(%rbp)
jmp    11c7 <WaitForUser+0x77>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WaitForUser>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e8d(%rip),%r14
mov    (%r14),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
call   1050 <nodelay@plt>
mov    $0x32,%edi
call   1040 <halfdelay@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <getch@plt>
mov    %eax,%ebp
mov    (%r14),%edi
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
call   1050 <nodelay@plt>
xor    %eax,%eax
call   1070 <nocbreak@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
cmp    $0x1b,%ebp
cmove  %ebp,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@FALSE = global i32 0
define i32 @WaitForUser() {
%1 = alloca i32
%2 = load i32, i32* @stdscr
%3 = load i32, i32* @TRUE
%4 = call i32 @nodelay(i32 %2, i32 %3)
%5 = call i32 @halfdelay(i32 50)
%6 = call i32 (...) @getch()
store i32 %6, i32* %1
%7 = load i32, i32* @stdscr
%8 = load i32, i32* @FALSE
%9 = call i32 @nodelay(i32 %7, i32 %8)
%10 = call i32 (...) @nocbreak()
%11 = call i32 (...) @cbreak()
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 27
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = load i32, i32* %1
br label %17
16: ; preds = %0
br label %17
17: ; preds = %16, %14
%18 = phi i32 [ %15, %14 ], [ 0, %16 ]
ret i32 %18
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@FALSE = global i32 0
define i32 @WaitForUser() {
%1 = load i32, i32* @stdscr
%2 = load i32, i32* @TRUE
%3 = tail call i32 @nodelay(i32 %1, i32 %2)
%4 = tail call i32 @halfdelay(i32 50)
%5 = tail call i32 (...) @getch()
%6 = load i32, i32* @stdscr
%7 = load i32, i32* @FALSE
%8 = tail call i32 @nodelay(i32 %6, i32 %7)
%9 = tail call i32 (...) @nocbreak()
%10 = tail call i32 (...) @cbreak()
%11 = icmp eq i32 %5, 27
%12 = select i1 %11, i32 27, i32 0
ret i32 %12
}