#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ menu(int);
void keyboard(unsigned char c, int x, int y) {
  switch (c) {
  case 27:
    exit(0);
    break;
  case ' ':
    menu(7);
    break;
  case 'a':
    menu(5);
    break;
  case 'w':
    menu(2);
    break;
  case 'f':
    menu(1);
    break;
  case 't':
    menu(3);
    break;
  case 'n':
    menu(4);
    break;
  }
}


x86 assembly (clang, -O0):
<keyboard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movzbl -0x1(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1b,%eax
je     11af <keyboard+0x8f>
jmp    1149 <keyboard+0x29>
mov    -0x10(%rbp),%eax
sub    $0x20,%eax
je     11b6 <keyboard+0x96>
jmp    115a <keyboard+0x3a>
mov    -0x10(%rbp),%eax
sub    $0x61,%eax
je     11c5 <keyboard+0xa5>
jmp    116b <keyboard+0x4b>
mov    -0x10(%rbp),%eax
sub    $0x66,%eax
je     11e3 <keyboard+0xc3>
jmp    117c <keyboard+0x5c>
mov    -0x10(%rbp),%eax
sub    $0x6e,%eax
je     1201 <keyboard+0xe1>
jmp    118d <keyboard+0x6d>
mov    -0x10(%rbp),%eax
sub    $0x74,%eax
je     11f2 <keyboard+0xd2>
jmp    119e <keyboard+0x7e>
mov    -0x10(%rbp),%eax
sub    $0x77,%eax
je     11d4 <keyboard+0xb4>
jmp    120b <keyboard+0xeb>
xor    %edi,%edi
call   1040 <exit@plt>
mov    $0x7,%edi
call   1030 <menu@plt>
jmp    120b <keyboard+0xeb>
mov    $0x5,%edi
call   1030 <menu@plt>
jmp    120b <keyboard+0xeb>
mov    $0x2,%edi
call   1030 <menu@plt>
jmp    120b <keyboard+0xeb>
mov    $0x1,%edi
call   1030 <menu@plt>
jmp    120b <keyboard+0xeb>
mov    $0x3,%edi
call   1030 <menu@plt>
jmp    120b <keyboard+0xeb>
mov    $0x4,%edi
call   1030 <menu@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keyboard>:
push   %rax
mov    %edi,%eax
lea    -0x61(%rax),%ecx
cmp    $0x16,%cl
ja     1149 <keyboard+0x29>
movzbl %cl,%eax
lea    0xecb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x5,%edi
pop    %rax
jmp    1030 <menu@plt>
mov    $0x7,%edi
cmp    $0x20,%al
je     1168 <keyboard+0x48>
cmp    $0x1b,%al
je     1184 <keyboard+0x64>
pop    %rax
ret
mov    $0x1,%edi
pop    %rax
jmp    1030 <menu@plt>
mov    $0x4,%edi
pop    %rax
jmp    1030 <menu@plt>
mov    $0x3,%edi
pop    %rax
jmp    1030 <menu@plt>
mov    $0x2,%edi
pop    %rax
jmp    1030 <menu@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define void @keyboard(i8 zeroext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8, i8* %4
%8 = zext i8 %7 to i32
switch i32 %8, label %23 [
i32 27, label %9
i32 32, label %11
i32 97, label %13
i32 119, label %15
i32 102, label %17
i32 116, label %19
i32 110, label %21
]
9: ; preds = %3
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %3
%12 = call i32 @menu(i32 7)
br label %23
13: ; preds = %3
%14 = call i32 @menu(i32 5)
br label %23
15: ; preds = %3
%16 = call i32 @menu(i32 2)
br label %23
17: ; preds = %3
%18 = call i32 @menu(i32 1)
br label %23
19: ; preds = %3
%20 = call i32 @menu(i32 3)
br label %23
21: ; preds = %3
%22 = call i32 @menu(i32 4)
br label %23
23: ; preds = %3, %21, %19, %17, %15, %13, %11
ret void
}

LLVM IR (-O2):
define void @keyboard(i8 zeroext %0, i32 %1, i32 %2) {
switch i8 %0, label %14 [
i8 27, label %4
i8 32, label %11
i8 97, label %6
i8 119, label %7
i8 102, label %8
i8 116, label %9
i8 110, label %10
]
4: ; preds = %3
%5 = tail call i32 @exit(i32 0)
unreachable
6: ; preds = %3
br label %11
7: ; preds = %3
br label %11
8: ; preds = %3
br label %11
9: ; preds = %3
br label %11
10: ; preds = %3
br label %11
11: ; preds = %3, %6, %7, %8, %9, %10
%12 = phi i32 [ 4, %10 ], [ 3, %9 ], [ 1, %8 ], [ 2, %7 ], [ 5, %6 ], [ 7, %3 ]
%13 = tail call i32 @menu(i32 %12)
br label %14
14: ; preds = %11, %3
ret void
}