#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 */
typedef int /*<<< orphan*/ bits;

/* Variables and functions */
int /*<<< orphan*/ EVIOCGBIT(int /*<<< orphan*/, int);
int /*<<< orphan*/ EV_KEY;
int KEY_MAX;
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, unsigned char **);
int supports_specific_key(int device_fd, unsigned int key) {
  size_t nchar = KEY_MAX / 8 + 1;
  unsigned char bits[nchar];
  ioctl(device_fd, EVIOCGBIT(EV_KEY, sizeof(bits)), &bits);
  return bits[key / 8] & (1 << (key % 8));
}


x86 assembly (clang, -O0):
<supports_specific_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
add    $0x7,%ecx
test   %eax,%eax
cmovs  %ecx,%eax
sar    $0x3,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%ecx
mov    %ecx,-0x2c(%rbp)
mov    0x2e67(%rip),%rcx
mov    (%rcx),%edi
mov    %eax,%esi
call   1030 <EVIOCGBIT@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %eax,%esi
call   1040 <ioctl@plt>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%ecx
shr    $0x3,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%ecx
and    $0x7,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<supports_specific_key>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
lea    0x7(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0x3,%esi
movslq %esi,%rax
add    $0x1,%esi
add    $0x10,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1030 <EVIOCGBIT@plt>
mov    %r14d,%edi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <ioctl@plt>
mov    %r15d,%eax
shr    $0x3,%rax
movzbl (%rax,%rbx,1),%edx
and    $0x7,%r15b
mov    $0x1,%eax
mov    %r15d,%ecx
shl    %cl,%eax
and    %edx,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@KEY_MAX = global i32 0
@EV_KEY = global i32 0
define i32 @supports_specific_key(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* @KEY_MAX
%9 = sdiv i32 %8, 8
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
store i64 %11, i64* %5
%12 = load i64, i64* %5
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = load i32, i32* %3
%16 = load i32, i32* @EV_KEY
%17 = trunc i64 %12 to i32
%18 = call i32 @EVIOCGBIT(i32 %16, i32 %17)
%19 = bitcast i8* %14 to i8**
%20 = call i32 @ioctl(i32 %15, i32 %18, i8** %19)
%21 = load i32, i32* %4
%22 = udiv i32 %21, 8
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %14, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = load i32, i32* %4
%28 = urem i32 %27, 8
%29 = shl i32 1, %28
%30 = and i32 %26, %29
%31 = load i8*, i8** %6
ret i32 %30
}

LLVM IR (-O2):
@KEY_MAX = global i32 0
@EV_KEY = global i32 0
define i32 @supports_specific_key(i32 %0, i32 %1) {
%3 = load i32, i32* @KEY_MAX
%4 = sdiv i32 %3, 8
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = load i32, i32* @EV_KEY
%9 = tail call i32 @EVIOCGBIT(i32 %8, i32 %5)
%10 = bitcast i8* %7 to i8**
%11 = call i32 @ioctl(i32 %0, i32 %9, i8** %10)
%12 = lshr i32 %1, 3
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %7, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %1, 7
%18 = shl nuw nsw i32 1, %17
%19 = and i32 %18, %16
ret i32 %19
}