#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 132
#define KEY_HOME 131
#define KEY_POWER 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_VOLUMEUP:
      return -2;
    case KEY_VOLUMEDOWN:
      return -3;
    case KEY_HOME:
    case KEY_POWER:
      return -4;
    case KEY_BACK:
      return -5;
    }
  }
  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     1172 <device_handle_key+0x72>
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     116d <device_handle_key+0x6d>
mov    -0x18(%rbp),%rax
lea    0xecc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xfffffffe,-0x4(%rbp)
jmp    1179 <device_handle_key+0x79>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1179 <device_handle_key+0x79>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1179 <device_handle_key+0x79>
movl   $0xfffffffb,-0x4(%rbp)
jmp    1179 <device_handle_key+0x79>
jmp    1172 <device_handle_key+0x72>
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    $0x4,%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 %15
8: ; preds = %2
%9 = load i32, i32* %4
switch i32 %9, label %14 [
i32 128, label %10
i32 129, label %11
i32 131, label %12
i32 130, label %12
i32 132, label %13
]
10: ; preds = %8
store i32 -2, i32* %3
br label %16
11: ; preds = %8
store i32 -3, i32* %3
br label %16
12: ; preds = %8, %8
store i32 -4, i32* %3
br label %16
13: ; preds = %8
store i32 -5, i32* %3
br label %16
14: ; preds = %8
br label %15
15: ; preds = %14, %2
store i32 -1, i32* %3
br label %16
16: ; preds = %15, %13, %12, %11, %10
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@switch.table.device_handle_key = [5 x i32] [i32 -2, i32 -3, i32 -4, i32 -4, 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, 5
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds [5 x i32], [5 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
}