#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 keydown();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int c;
  printf("press 'q' or 'Esc' to quit.\n");
  while (1) {
    printf("%d\n", c = keydown());
    if (c == 'q' || c == '')
      break;
  }
  printf("down.\n");
  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)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <keydown@plt>
mov    %eax,%esi
mov    %esi,-0x14(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x71,-0x14(%rbp)
je     1172 <main+0x52>
cmpl   $0x1b,-0x14(%rbp)
jne    1177 <main+0x57>
jmp    117c <main+0x5c>
jmp    1144 <main+0x24>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <keydown@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x71,%ebp
je     116f <main+0x3f>
cmp    $0x1b,%ebp
jne    1150 <main+0x20>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"press 'q' or 'Esc' to quit.\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [7 x i8] c"down.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %2, %17
%9 = call i32 (...) @keydown()
store i32 %9, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 113
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 27
br i1 %15, label %16, label %17
16: ; preds = %13, %8
br label %18
17: ; preds = %13
br label %8
18: ; preds = %16
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [28 x i8] c"press 'q' or 'Esc' to quit.\00"
@str.3 = [6 x i8] c"down.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %4, %2
%5 = tail call i32 (...) @keydown()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
switch i32 %5, label %4 [
i32 113, label %7
i32 27, label %7
]
7: ; preds = %4, %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0))
ret i32 0
}