#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*/ uint64_t;
typedef scalar_t__ int32_t;

/* Variables and functions */
int /*<<< orphan*/ EVIOCGBIT(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ EV_KEY;
int /*<<< orphan*/ KEY_MAX;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ ioctl(scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void get_key_evt_codes(int32_t fd, uint64_t *p_bitsring) {
  int32_t ret = ioctl(fd, EVIOCGBIT(EV_KEY, KEY_MAX), p_bitsring);
  if (ret < 0) {
    fprintf(stderr, "EVIOCGBIT ioctl() failed: %s\n", strerror(errno));
  }
}


x86 assembly (clang, -O0):
<get_key_evt_codes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
call   1030 <EVIOCGBIT@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    11b9 <get_key_evt_codes+0x79>
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe4c(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_key_evt_codes>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
call   1030 <EVIOCGBIT@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   1040 <ioctl@plt>
test   %rax,%rax
js     117b <get_key_evt_codes+0x3b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e56(%rip),%rax
mov    (%rax),%ebx
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe67(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@EV_KEY = global i32 0
@KEY_MAX = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"EVIOCGBIT ioctl() failed: %s\0A\00"
@errno = global i32 0
define void @get_key_evt_codes(i64 %0, i32* %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i64
store i64 %0, i64* %3
store i32* %1, i32** %4
%6 = load i64, i64* %3
%7 = load i32, i32* @EV_KEY
%8 = load i32, i32* @KEY_MAX
%9 = call i32 @EVIOCGBIT(i32 %7, i32 %8)
%10 = load i32*, i32** %4
%11 = call i64 @ioctl(i64 %6, i32 %9, i32* %10)
store i64 %11, i64* %5
%12 = load i64, i64* %5
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %14, %2
ret void
}

LLVM IR (-O2):
@EV_KEY = global i32 0
@KEY_MAX = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"EVIOCGBIT ioctl() failed: %s\0A\00"
@errno = global i32 0
define void @get_key_evt_codes(i64 %0, i32* %1) {
%3 = load i32, i32* @EV_KEY
%4 = load i32, i32* @KEY_MAX
%5 = tail call i32 @EVIOCGBIT(i32 %3, i32 %4)
%6 = tail call i64 @ioctl(i64 %0, i32 %5, i32* %1)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = tail call i8* @strerror(i32 %10)
%12 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %8, %2
ret void
}