#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 joy(int /*<<< orphan*/);
char wait_for_key() {
  while (1) {
    switch (joy(0)) {
    case 0x14:
      return 0x1;
    case 0x18:
      return 0x2;
    case 0x12:
      return 0x3;
    case 0x11:
      return 0xC;
    case 0x84:
      return 0x4;
    case 0x88:
      return 0x5;
    case 0x82:
      return 0x6;
    case 0x81:
      return 0xD;
    case 0x24:
      return 0x7;
    case 0x28:
      return 0x8;
    case 0x22:
      return 0x9;
    case 0x21:
      return 0xE;
    case 0x44:
      return 0xA;
    case 0x48:
      return 0x0;
    case 0x42:
      return 0xB;
    case 0x41:
      return 0xF;
    }
  }
}


x86 assembly (clang, -O0):
<wait_for_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1030 <joy@plt>
add    $0xffffffef,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x77,%eax
ja     11d5 <wait_for_key+0xc5>
mov    -0x10(%rbp),%rax
lea    0xec4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x1,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x2,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x3,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0xc,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x4,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x5,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x6,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0xd,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x7,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x8,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x9,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0xe,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0xa,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0x0,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0xb,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
movb   $0xf,-0x1(%rbp)
jmp    11da <wait_for_key+0xca>
jmp    1118 <wait_for_key+0x8>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wait_for_key>:
push   %rbx
lea    0xee8(%rip),%rbx
xor    %edi,%edi
call   1030 <joy@plt>
add    $0xffffffef,%eax
cmp    $0x77,%eax
ja     1118 <wait_for_key+0x8>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    $0xc,%al
pop    %rbx
ret
mov    $0x3,%al
pop    %rbx
ret
mov    $0x1,%al
pop    %rbx
ret
mov    $0x2,%al
pop    %rbx
ret
mov    $0xe,%al
pop    %rbx
ret
mov    $0x9,%al
pop    %rbx
ret
mov    $0x7,%al
pop    %rbx
ret
mov    $0x8,%al
pop    %rbx
ret
mov    $0xf,%al
pop    %rbx
ret
mov    $0xb,%al
pop    %rbx
ret
mov    $0xa,%al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0xd,%al
pop    %rbx
ret
mov    $0x6,%al
pop    %rbx
ret
mov    $0x4,%al
pop    %rbx
ret
mov    $0x5,%al
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @wait_for_key() {
%1 = alloca i8
br label %2
2: ; preds = %0, %20
%3 = call i32 @joy(i32 0)
switch i32 %3, label %20 [
i32 20, label %4
i32 24, label %5
i32 18, label %6
i32 17, label %7
i32 132, label %8
i32 136, label %9
i32 130, label %10
i32 129, label %11
i32 36, label %12
i32 40, label %13
i32 34, label %14
i32 33, label %15
i32 68, label %16
i32 72, label %17
i32 66, label %18
i32 65, label %19
]
4: ; preds = %2
store i8 1, i8* %1
br label %21
5: ; preds = %2
store i8 2, i8* %1
br label %21
6: ; preds = %2
store i8 3, i8* %1
br label %21
7: ; preds = %2
store i8 12, i8* %1
br label %21
8: ; preds = %2
store i8 4, i8* %1
br label %21
9: ; preds = %2
store i8 5, i8* %1
br label %21
10: ; preds = %2
store i8 6, i8* %1
br label %21
11: ; preds = %2
store i8 13, i8* %1
br label %21
12: ; preds = %2
store i8 7, i8* %1
br label %21
13: ; preds = %2
store i8 8, i8* %1
br label %21
14: ; preds = %2
store i8 9, i8* %1
br label %21
15: ; preds = %2
store i8 14, i8* %1
br label %21
16: ; preds = %2
store i8 10, i8* %1
br label %21
17: ; preds = %2
store i8 0, i8* %1
br label %21
18: ; preds = %2
store i8 11, i8* %1
br label %21
19: ; preds = %2
store i8 15, i8* %1
br label %21
20: ; preds = %2
br label %2
21: ; preds = %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4
%22 = load i8, i8* %1
ret i8 %22
}

LLVM IR (-O2):
define signext i8 @wait_for_key() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @joy(i32 0)
switch i32 %2, label %1 [
i32 20, label %13
i32 24, label %14
i32 18, label %15
i32 17, label %16
i32 132, label %17
i32 136, label %18
i32 130, label %3
i32 129, label %4
i32 36, label %5
i32 40, label %6
i32 34, label %7
i32 33, label %8
i32 68, label %9
i32 72, label %10
i32 66, label %11
i32 65, label %12
]
3: ; preds = %1
br label %18
4: ; preds = %1
br label %18
5: ; preds = %1
br label %18
6: ; preds = %1
br label %18
7: ; preds = %1
br label %18
8: ; preds = %1
br label %18
9: ; preds = %1
br label %18
10: ; preds = %1
br label %18
11: ; preds = %1
br label %18
12: ; preds = %1
br label %18
13: ; preds = %1
br label %18
14: ; preds = %1
br label %18
15: ; preds = %1
br label %18
16: ; preds = %1
br label %18
17: ; preds = %1
br label %18
18: ; preds = %1, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
%19 = phi i8 [ 15, %12 ], [ 11, %11 ], [ 0, %10 ], [ 10, %9 ], [ 14, %8 ], [ 9, %7 ], [ 8, %6 ], [ 7, %5 ], [ 13, %4 ], [ 6, %3 ], [ 1, %13 ], [ 2, %14 ], [ 3, %15 ], [ 12, %16 ], [ 4, %17 ], [ 5, %1 ]
ret i8 %19
}