#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*/ keyboard(unsigned char, int /*<<< orphan*/,
                            int /*<<< orphan*/);
void menu(int val) {
  unsigned char key;
  switch (val) {
  case 1:
    key = 's';
    break;
  case 2:
    key = ' ';
    break;
  case 3:
    key = 't';
    break;
  case 4:
    key = 'o';
    break;
  case 5:
    key = '0';
    break;
  case 6:
    key = '1';
    break;
  case 7:
    key = '+';
    break;
  case 8:
    key = '-';
    break;
  default:
    return;
  }
  keyboard(key, 0, 0);
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x7,%eax
ja     118c <menu+0x7c>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x73,-0x5(%rbp)
jmp    1191 <menu+0x81>
movb   $0x20,-0x5(%rbp)
jmp    1191 <menu+0x81>
movb   $0x74,-0x5(%rbp)
jmp    1191 <menu+0x81>
movb   $0x6f,-0x5(%rbp)
jmp    1191 <menu+0x81>
movb   $0x30,-0x5(%rbp)
jmp    1191 <menu+0x81>
movb   $0x31,-0x5(%rbp)
jmp    1191 <menu+0x81>
movb   $0x2b,-0x5(%rbp)
jmp    1191 <menu+0x81>
movb   $0x2d,-0x5(%rbp)
jmp    1191 <menu+0x81>
jmp    119e <menu+0x8e>
xor    %edx,%edx
movzbl -0x5(%rbp),%edi
mov    %edx,%esi
call   1030 <keyboard@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
add    $0xffffffff,%edi
cmp    $0x7,%edi
ja     1136 <menu+0x26>
shl    $0x3,%edi
movabs $0x2d2b31306f742073,%rax
31 2b 2d
mov    %edi,%ecx
shr    %cl,%rax
movzbl %al,%edi
xor    %esi,%esi
xor    %edx,%edx
jmp    1030 <keyboard@plt>
ret

LLVM IR (-O0):
define void @menu(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %13 [
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
i32 8, label %12
]
5: ; preds = %1
store i8 115, i8* %3
br label %14
6: ; preds = %1
store i8 32, i8* %3
br label %14
7: ; preds = %1
store i8 116, i8* %3
br label %14
8: ; preds = %1
store i8 111, i8* %3
br label %14
9: ; preds = %1
store i8 48, i8* %3
br label %14
10: ; preds = %1
store i8 49, i8* %3
br label %14
11: ; preds = %1
store i8 43, i8* %3
br label %14
12: ; preds = %1
store i8 45, i8* %3
br label %14
13: ; preds = %1
br label %17
14: ; preds = %12, %11, %10, %9, %8, %7, %6, %5
%15 = load i8, i8* %3
%16 = call i32 @keyboard(i8 zeroext %15, i32 0, i32 0)
br label %17
17: ; preds = %14, %13
ret void
}

LLVM IR (-O2):
define void @menu(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 8
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = shl nuw nsw i64 %5, 3
%7 = lshr i64 3254749239803388019, %6
%8 = trunc i64 %7 to i8
%9 = tail call i32 @keyboard(i8 zeroext %8, i32 0, i32 0)
br label %10
10: ; preds = %1, %4
ret void
}