#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getkey();
int /*<<< orphan*/ move(int /*<<< orphan*/);
int /*<<< orphan*/ moveto(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ notifier(char *);
int /*<<< orphan*/ redraw_all();
int /*<<< orphan*/ start_level();
int /*<<< orphan*/ undo();
void key(void) {
  uint8_t c;
  moveto(0, 0);
  switch (c = getkey()) {
  case 'Q':
    if (notifier("quit"))
      exit(0);
    break;
  case 'R' & 31:
    redraw_all();
    break;
  case 'R':
    if (notifier("restart"))
      start_level();
    break;
  case 'U':
    undo();
    break;
  case 'H':
  case 'J':
  case 'K':
  case 'L':
    move(c - 'H');
    break;
  }
}


x86 assembly (clang, -O0):
<key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %esi,%esi
mov    %esi,-0x14(%rbp)
mov    %esi,%edi
call   1070 <moveto@plt>
mov    -0x14(%rbp),%eax
call   1040 <getkey@plt>
mov    %eax,-0x4(%rbp)
add    $0xffffffee,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x43,%eax
ja     122a <key+0xaa>
mov    -0x10(%rbp),%rax
lea    0xe44(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf44(%rip),%rdi
call   1050 <notifier@plt>
cmp    $0x0,%eax
je     11e1 <key+0x61>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    122a <key+0xaa>
mov    $0x0,%al
call   1060 <redraw_all@plt>
jmp    122a <key+0xaa>
lea    0xf1c(%rip),%rdi
call   1050 <notifier@plt>
cmp    $0x0,%eax
je     120e <key+0x8e>
mov    $0x0,%al
call   1090 <start_level@plt>
jmp    122a <key+0xaa>
mov    $0x0,%al
call   1030 <undo@plt>
jmp    122a <key+0xaa>
mov    -0x4(%rbp),%edi
sub    $0x48,%edi
call   10a0 <move@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<key>:
push   %rax
xor    %edi,%edi
xor    %esi,%esi
call   1070 <moveto@plt>
xor    %eax,%eax
call   1040 <getkey@plt>
lea    -0x12(%rax),%ecx
cmp    $0x43,%ecx
ja     11eb <key+0x6b>
lea    0xe60(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
add    $0xffffffb8,%eax
mov    %eax,%edi
pop    %rax
jmp    10a0 <move@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <redraw_all@plt>
lea    0xf4d(%rip),%rdi
call   1050 <notifier@plt>
test   %eax,%eax
je     11eb <key+0x6b>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xf3b(%rip),%rdi
call   1050 <notifier@plt>
test   %eax,%eax
je     11eb <key+0x6b>
xor    %eax,%eax
pop    %rcx
jmp    1090 <start_level@plt>
pop    %rax
ret
xor    %eax,%eax
pop    %rcx
jmp    1030 <undo@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"quit\00"
@.str.1 = [8 x i8] c"restart\00"
define void @key() {
%1 = alloca i32
%2 = call i32 @moveto(i32 0, i32 0)
%3 = call i32 (...) @getkey()
store i32 %3, i32* %1
switch i32 %3, label %24 [
i32 81, label %4
i32 18, label %10
i32 82, label %12
i32 85, label %18
i32 72, label %20
i32 74, label %20
i32 75, label %20
i32 76, label %20
]
4: ; preds = %0
%5 = call i32 @notifier(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = call i32 @exit(i32 0)
unreachable
9: ; preds = %4
br label %24
10: ; preds = %0
%11 = call i32 (...) @redraw_all()
br label %24
12: ; preds = %0
%13 = call i32 @notifier(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (...) @start_level()
br label %17
17: ; preds = %15, %12
br label %24
18: ; preds = %0
%19 = call i32 (...) @undo()
br label %24
20: ; preds = %0, %0, %0, %0
%21 = load i32, i32* %1
%22 = sub nsw i32 %21, 72
%23 = call i32 @move(i32 %22)
br label %24
24: ; preds = %0, %20, %18, %17, %10, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"quit\00"
@.str.1 = [8 x i8] c"restart\00"
define void @key() {
%1 = tail call i32 @moveto(i32 0, i32 0)
%2 = tail call i32 (...) @getkey()
switch i32 %2, label %20 [
i32 81, label %3
i32 18, label %8
i32 82, label %10
i32 85, label %15
i32 72, label %17
i32 74, label %17
i32 75, label %17
i32 76, label %17
]
3: ; preds = %0
%4 = tail call i32 @notifier(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %3
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %0
%9 = tail call i32 (...) @redraw_all()
br label %20
10: ; preds = %0
%11 = tail call i32 @notifier(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = tail call i32 (...) @start_level()
br label %20
15: ; preds = %0
%16 = tail call i32 (...) @undo()
br label %20
17: ; preds = %0, %0, %0, %0
%18 = add nsw i32 %2, -72
%19 = tail call i32 @move(i32 %18)
br label %20
20: ; preds = %10, %13, %3, %0, %17, %15, %8
ret void
}