#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 */
char _getch();
int /*<<< orphan*/ printf(char *);
int main() {
  char ch;
  do {
    ch = _getch();
    if (ch == -32)
      ch = _getch();
    if (ch == 75) {
      printf("Left\n");
    }
    if (ch == 77) {
      printf("Right\n");
    }
    if (ch == 72) {
      printf("Up\n");
    }
    if (ch == 80) {
      printf("Down\n");
    }
    if (ch == 13) {
      printf("Enter\n");
    }
    if (ch == 27) {
      printf("Esc\n");
    }
  } while (ch != 27);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <_getch@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xffffffe0,%eax
jne    1150 <main+0x30>
mov    $0x0,%al
call   1040 <_getch@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x4b,%eax
jne    1169 <main+0x49>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x4d,%eax
jne    1182 <main+0x62>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x48,%eax
jne    119b <main+0x7b>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x50,%eax
jne    11b4 <main+0x94>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xd,%eax
jne    11cd <main+0xad>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x1b,%eax
jne    11e6 <main+0xc6>
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
jmp    11eb <main+0xcb>
movsbl -0x5(%rbp),%eax
cmp    $0x1b,%eax
jne    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf0a(%rip),%r15
lea    0xeef(%rip),%r14
lea    0xec0(%rip),%rbx
lea    0xeec(%rip),%r12
lea    0xee8(%rip),%r13
lea    0xed9(%rip),%rbp
jmp    115f <main+0x3f>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <_getch@plt>
cmp    $0xe0,%al
jne    1171 <main+0x51>
xor    %eax,%eax
call   1040 <_getch@plt>
lea    -0x48(%rax),%ecx
cmp    $0x8,%cl
ja     11a0 <main+0x80>
movzbl %cl,%eax
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
mov    %r15,%rdi
jmp    *%rax
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    115f <main+0x3f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0xd,%al
je     1157 <main+0x37>
cmp    $0x1b,%al
jne    115f <main+0x3f>
jmp    11be <main+0x9e>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    115f <main+0x3f>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    115f <main+0x3f>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Left\0A\00"
@.str.1 = [7 x i8] c"Right\0A\00"
@.str.2 = [4 x i8] c"Up\0A\00"
@.str.3 = [6 x i8] c"Down\0A\00"
@.str.4 = [7 x i8] c"Enter\0A\00"
@.str.5 = [5 x i8] c"Esc\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %47, %0
%4 = call signext i8 (...) @_getch()
store i8 %4, i8* %2
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, -32
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = call signext i8 (...) @_getch()
store i8 %9, i8* %2
br label %10
10: ; preds = %8, %3
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 75
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 77
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 72
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = load i8, i8* %2
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 80
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = load i8, i8* %2
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 13
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = load i8, i8* %2
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 27
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
br label %47
47: ; preds = %46
%48 = load i8, i8* %2
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 27
br i1 %50, label %3, label %51
51: ; preds = %47
ret i32 0
}

LLVM IR (-O2):
@str = [4 x i8] c"Esc\00"
@str.6 = [6 x i8] c"Enter\00"
@str.7 = [5 x i8] c"Down\00"
@str.8 = [3 x i8] c"Up\00"
@str.9 = [6 x i8] c"Right\00"
@str.10 = [5 x i8] c"Left\00"
define i32 @main() {
br label %1
1: ; preds = %11, %0
%2 = tail call signext i8 (...) @_getch()
%3 = icmp eq i8 %2, -32
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call signext i8 (...) @_getch()
br label %6
6: ; preds = %4, %1
%7 = phi i8 [ %5, %4 ], [ %2, %1 ]
switch i8 %7, label %11 [
i8 75, label %8
i8 77, label %12
i8 72, label %13
i8 80, label %14
i8 13, label %15
i8 27, label %16
]
8: ; preds = %6, %15, %14, %13, %12
%9 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.9, i64 0, i64 0), %12 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @str.8, i64 0, i64 0), %13 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.7, i64 0, i64 0), %14 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0), %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.10, i64 0, i64 0), %6 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %8, %6
br label %1
12: ; preds = %6
br label %8
13: ; preds = %6
br label %8
14: ; preds = %6
br label %8
15: ; preds = %6
br label %8
16: ; preds = %6
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret i32 0
}