#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 */
#define KEY_BACK 137
#define KEY_DOWN 136
#define KEY_ENTER 135
#define KEY_HOME 134
#define KEY_MENU 133
#define KEY_POWER 132
#define KEY_SEARCH 131
#define KEY_UP 130
#define KEY_VOLUMEDOWN 129
#define KEY_VOLUMEUP 128
int device_handle_key(int key_code, int visible) {
  if (visible) {
    switch (key_code) {
    case KEY_DOWN:
    case KEY_VOLUMEDOWN:
      return -3;
    case KEY_UP:
    case KEY_VOLUMEUP:
      return -2;
    case KEY_POWER:
    case KEY_ENTER:
      return -4;
    case KEY_HOME:
      return -6;
    case KEY_MENU:
      return -7;
    case KEY_BACK:
      return -5;
    case KEY_SEARCH:
      return -4;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<device_handle_key>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1196 <device_handle_key+0x96>
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     1191 <device_handle_key+0x91>
mov    -0x18(%rbp),%rax
lea    0xecc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xfffffffd,-0x4(%rbp)
jmp    119d <device_handle_key+0x9d>
movl   $0xfffffffe,-0x4(%rbp)
jmp    119d <device_handle_key+0x9d>
movl   $0xfffffffc,-0x4(%rbp)
jmp    119d <device_handle_key+0x9d>
movl   $0xfffffffa,-0x4(%rbp)
jmp    119d <device_handle_key+0x9d>
movl   $0xfffffff9,-0x4(%rbp)
jmp    119d <device_handle_key+0x9d>
movl   $0xfffffffb,-0x4(%rbp)
jmp    119d <device_handle_key+0x9d>
movl   $0xfffffffc,-0x4(%rbp)
jmp    119d <device_handle_key+0x9d>
jmp    1196 <device_handle_key+0x96>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<device_handle_key>:
mov    $0xffffffff,%eax
test   %esi,%esi
je     111e <device_handle_key+0x1e>
add    $0xffffff80,%edi
cmp    $0x9,%edi
ja     111e <device_handle_key+0x1e>
movslq %edi,%rax
lea    0xee5(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @device_handle_key(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = load i32, i32* %4
switch i32 %9, label %17 [
i32 136, label %10
i32 129, label %10
i32 130, label %11
i32 128, label %11
i32 132, label %12
i32 135, label %12
i32 134, label %13
i32 133, label %14
i32 137, label %15
i32 131, label %16
]
10: ; preds = %8, %8
store i32 -3, i32* %3
br label %19
11: ; preds = %8, %8
store i32 -2, i32* %3
br label %19
12: ; preds = %8, %8
store i32 -4, i32* %3
br label %19
13: ; preds = %8
store i32 -6, i32* %3
br label %19
14: ; preds = %8
store i32 -7, i32* %3
br label %19
15: ; preds = %8
store i32 -5, i32* %3
br label %19
16: ; preds = %8
store i32 -4, i32* %3
br label %19
17: ; preds = %8
br label %18
18: ; preds = %17, %2
store i32 -1, i32* %3
br label %19
19: ; preds = %18, %16, %15, %14, %13, %12, %11, %10
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@switch.table.device_handle_key = [10 x i32] [i32 -2, i32 -3, i32 -2, i32 -4, i32 -4, i32 -7, i32 -6, i32 -4, i32 -3, i32 -5]
define i32 @device_handle_key(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = add i32 %0, -128
%6 = icmp ult i32 %5, 10
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds [10 x i32], [10 x i32]* @switch.table.device_handle_key, i64 0, i64 %8
%10 = load i32, i32* %9
br label %11
11: ; preds = %2, %4, %7
%12 = phi i32 [ %10, %7 ], [ -1, %4 ], [ -1, %2 ]
ret i32 %12
}