#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_DOWN 133
#define KEY_ENTER 132
#define KEY_POWER 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_ENTER:
    case KEY_POWER:
      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     11a2 <device_handle_key+0xa2>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x80,%eax
je     1185 <device_handle_key+0x85>
jmp    112a <device_handle_key+0x2a>
mov    -0x10(%rbp),%eax
sub    $0x81,%eax
je     1179 <device_handle_key+0x79>
jmp    113d <device_handle_key+0x3d>
mov    -0x10(%rbp),%eax
sub    $0x82,%eax
je     1185 <device_handle_key+0x85>
jmp    1150 <device_handle_key+0x50>
mov    -0x10(%rbp),%eax
add    $0xffffff7d,%eax
sub    $0x2,%eax
jb     1191 <device_handle_key+0x91>
jmp    1166 <device_handle_key+0x66>
mov    -0x10(%rbp),%eax
sub    $0x85,%eax
jne    119d <device_handle_key+0x9d>
jmp    1179 <device_handle_key+0x79>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11a9 <device_handle_key+0xa9>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11a9 <device_handle_key+0xa9>
movl   $0xfffffffc,-0x4(%rbp)
jmp    11a9 <device_handle_key+0xa9>
jmp    11a2 <device_handle_key+0xa2>
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    $0x5,%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 %14
8: ; preds = %2
%9 = load i32, i32* %4
switch i32 %9, label %13 [
i32 133, label %10
i32 129, label %10
i32 130, label %11
i32 128, label %11
i32 132, label %12
i32 131, label %12
]
10: ; preds = %8, %8
store i32 -3, i32* %3
br label %15
11: ; preds = %8, %8
store i32 -2, i32* %3
br label %15
12: ; preds = %8, %8
store i32 -4, i32* %3
br label %15
13: ; preds = %8
br label %14
14: ; preds = %13, %2
store i32 -1, i32* %3
br label %15
15: ; preds = %14, %12, %11, %10
%16 = load i32, i32* %3
ret i32 %16
}

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