#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*/ keyb_in_buff(int, int);
void button_on(char button) {
  switch (button) {
  case 1:
    keyb_in_buff(2, 22);
    break;
  case 2:
    keyb_in_buff(2, 19);
    break;
  case 3:
    keyb_in_buff(2, 21);
    break;
  case 4:
    keyb_in_buff(2, 7);
    break;
  case 5:
    keyb_in_buff(2, 8);
    break;
  case 6:
    keyb_in_buff(2, 4);
    break;
  case 7:
    keyb_in_buff(2, 5);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<button_on>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11d4 <button_on+0xc4>
mov    -0x10(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x2,%edi
mov    $0x16,%esi
call   1030 <keyb_in_buff@plt>
jmp    11d9 <button_on+0xc9>
mov    $0x2,%edi
mov    $0x13,%esi
call   1030 <keyb_in_buff@plt>
jmp    11d9 <button_on+0xc9>
mov    $0x2,%edi
mov    $0x15,%esi
call   1030 <keyb_in_buff@plt>
jmp    11d9 <button_on+0xc9>
mov    $0x2,%edi
mov    $0x7,%esi
call   1030 <keyb_in_buff@plt>
jmp    11d9 <button_on+0xc9>
mov    $0x2,%edi
mov    $0x8,%esi
call   1030 <keyb_in_buff@plt>
jmp    11d9 <button_on+0xc9>
mov    $0x2,%edi
mov    $0x4,%esi
call   1030 <keyb_in_buff@plt>
jmp    11d9 <button_on+0xc9>
mov    $0x2,%edi
mov    $0x5,%esi
call   1030 <keyb_in_buff@plt>
jmp    11d9 <button_on+0xc9>
jmp    11d9 <button_on+0xc9>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<button_on>:
add    $0xffffffff,%edi
cmp    $0x6,%edi
ja     112f <button_on+0x1f>
movslq %edi,%rax
lea    0xede(%rip),%rcx
mov    (%rcx,%rax,4),%esi
mov    $0x2,%edi
jmp    1030 <keyb_in_buff@plt>
ret

LLVM IR (-O0):
define void @button_on(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
switch i32 %4, label %19 [
i32 1, label %5
i32 2, label %7
i32 3, label %9
i32 4, label %11
i32 5, label %13
i32 6, label %15
i32 7, label %17
]
5: ; preds = %1
%6 = call i32 @keyb_in_buff(i32 2, i32 22)
br label %20
7: ; preds = %1
%8 = call i32 @keyb_in_buff(i32 2, i32 19)
br label %20
9: ; preds = %1
%10 = call i32 @keyb_in_buff(i32 2, i32 21)
br label %20
11: ; preds = %1
%12 = call i32 @keyb_in_buff(i32 2, i32 7)
br label %20
13: ; preds = %1
%14 = call i32 @keyb_in_buff(i32 2, i32 8)
br label %20
15: ; preds = %1
%16 = call i32 @keyb_in_buff(i32 2, i32 4)
br label %20
17: ; preds = %1
%18 = call i32 @keyb_in_buff(i32 2, i32 5)
br label %20
19: ; preds = %1
br label %20
20: ; preds = %19, %17, %15, %13, %11, %9, %7, %5
ret void
}

LLVM IR (-O2):
@switch.table.button_on = [7 x i32] [i32 22, i32 19, i32 21, i32 7, i32 8, i32 4, i32 5]
define void @button_on(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -1
%4 = icmp ult i32 %3, 7
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.button_on, i64 0, i64 %6
%8 = load i32, i32* %7
%9 = tail call i32 @keyb_in_buff(i32 2, i32 %8)
br label %10
10: ; preds = %1, %5
ret void
}