#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 */
int /*<<< orphan*/ KEY_BACKSPACE;
int /*<<< orphan*/ KEY_CNT;
int /*<<< orphan*/ KEY_ENTER;
int /*<<< orphan*/ KEY_ESC;
int /*<<< orphan*/ KEY_LEFTALT;
int /*<<< orphan*/ KEY_LEFTCTRL;
int /*<<< orphan*/ KEY_RIGHTALT;
int /*<<< orphan*/ KEY_RIGHTCTRL;
int /*<<< orphan*/ KEY_SPACE;
int /*<<< orphan*/ KEY_TAB;
scalar_t__ bit_check(unsigned long *, int /*<<< orphan*/, int /*<<< orphan*/);
int possibly_keyboard(unsigned long *keybits) {
  int ctrl = bit_check(keybits, KEY_LEFTCTRL, KEY_CNT) ||
             bit_check(keybits, KEY_RIGHTCTRL, KEY_CNT);
  int alt = bit_check(keybits, KEY_LEFTALT, KEY_CNT) ||
            bit_check(keybits, KEY_RIGHTALT, KEY_CNT);
  if (!ctrl || !alt || !bit_check(keybits, KEY_SPACE, KEY_CNT) ||
      !bit_check(keybits, KEY_BACKSPACE, KEY_CNT) ||
      !bit_check(keybits, KEY_ENTER, KEY_CNT) ||
      !bit_check(keybits, KEY_TAB, KEY_CNT) ||
      !bit_check(keybits, KEY_ESC, KEY_CNT)) {
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<possibly_keyboard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    0x2ea8(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
jne    116e <possibly_keyboard+0x5e>
mov    -0x10(%rbp),%rdi
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e24(%rip),%rax
mov    (%rax),%esi
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1a(%rbp)
jne    11cb <possibly_keyboard+0xbb>
mov    -0x10(%rbp),%rdi
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12a3 <possibly_keyboard+0x193>
cmpl   $0x0,-0x18(%rbp)
je     12a3 <possibly_keyboard+0x193>
mov    -0x10(%rbp),%rdi
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
mov    0x2dda(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%rax
je     12a3 <possibly_keyboard+0x193>
mov    -0x10(%rbp),%rdi
mov    0x2d96(%rip),%rax
mov    (%rax),%esi
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%rax
je     12a3 <possibly_keyboard+0x193>
mov    -0x10(%rbp),%rdi
mov    0x2d51(%rip),%rax
mov    (%rax),%esi
mov    0x2d90(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%rax
je     12a3 <possibly_keyboard+0x193>
mov    -0x10(%rbp),%rdi
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
mov    0x2d6b(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%rax
je     12a3 <possibly_keyboard+0x193>
mov    -0x10(%rbp),%rdi
mov    0x2d5f(%rip),%rax
mov    (%rax),%esi
mov    0x2d46(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%rax
jne    12af <possibly_keyboard+0x19f>
movl   $0x0,-0x4(%rbp)
jmp    12b6 <possibly_keyboard+0x1a6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<possibly_keyboard>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
mov    0x2e97(%rip),%rax
mov    (%rax),%esi
mov    0x2eae(%rip),%r14
mov    (%r14),%edx
call   1030 <bit_check@plt>
mov    $0x1,%r15b
mov    $0x1,%bl
test   %rax,%rax
jne    1156 <possibly_keyboard+0x46>
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbp,%rdi
call   1030 <bit_check@plt>
test   %rax,%rax
setne  %bl
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbp,%rdi
call   1030 <bit_check@plt>
test   %rax,%rax
jne    118a <possibly_keyboard+0x7a>
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbp,%rdi
call   1030 <bit_check@plt>
test   %rax,%rax
setne  %r15b
and    %r15b,%bl
xor    %r15d,%r15d
cmp    $0x1,%bl
jne    121b <possibly_keyboard+0x10b>
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbp,%rdi
call   1030 <bit_check@plt>
test   %rax,%rax
je     121b <possibly_keyboard+0x10b>
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbp,%rdi
call   1030 <bit_check@plt>
test   %rax,%rax
je     121b <possibly_keyboard+0x10b>
mov    0x2dbe(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbp,%rdi
call   1030 <bit_check@plt>
test   %rax,%rax
je     121b <possibly_keyboard+0x10b>
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbp,%rdi
call   1030 <bit_check@plt>
test   %rax,%rax
je     121b <possibly_keyboard+0x10b>
mov    0x2de4(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbp,%rdi
call   1030 <bit_check@plt>
xor    %r15d,%r15d
test   %rax,%rax
setne  %r15b
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@KEY_LEFTCTRL = global i32 0
@KEY_CNT = global i32 0
@KEY_RIGHTCTRL = global i32 0
@KEY_LEFTALT = global i32 0
@KEY_RIGHTALT = global i32 0
@KEY_SPACE = global i32 0
@KEY_BACKSPACE = global i32 0
@KEY_ENTER = global i32 0
@KEY_TAB = global i32 0
@KEY_ESC = global i32 0
define i32 @possibly_keyboard(i64* %0) {
%2 = alloca i32
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i32
store i64* %0, i64** %3
%6 = load i64*, i64** %3
%7 = load i32, i32* @KEY_LEFTCTRL
%8 = load i32, i32* @KEY_CNT
%9 = call i64 @bit_check(i64* %6, i32 %7, i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %1
%12 = load i64*, i64** %3
%13 = load i32, i32* @KEY_RIGHTCTRL
%14 = load i32, i32* @KEY_CNT
%15 = call i64 @bit_check(i64* %12, i32 %13, i32 %14)
%16 = icmp ne i64 %15, 0
br label %17
17: ; preds = %11, %1
%18 = phi i1 [ true, %1 ], [ %16, %11 ]
%19 = zext i1 %18 to i32
store i32 %19, i32* %4
%20 = load i64*, i64** %3
%21 = load i32, i32* @KEY_LEFTALT
%22 = load i32, i32* @KEY_CNT
%23 = call i64 @bit_check(i64* %20, i32 %21, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %17
%26 = load i64*, i64** %3
%27 = load i32, i32* @KEY_RIGHTALT
%28 = load i32, i32* @KEY_CNT
%29 = call i64 @bit_check(i64* %26, i32 %27, i32 %28)
%30 = icmp ne i64 %29, 0
br label %31
31: ; preds = %25, %17
%32 = phi i1 [ true, %17 ], [ %30, %25 ]
%33 = zext i1 %32 to i32
store i32 %33, i32* %5
%34 = load i32, i32* %4
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %69
36: ; preds = %31
%37 = load i32, i32* %5
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %69
39: ; preds = %36
%40 = load i64*, i64** %3
%41 = load i32, i32* @KEY_SPACE
%42 = load i32, i32* @KEY_CNT
%43 = call i64 @bit_check(i64* %40, i32 %41, i32 %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %69
45: ; preds = %39
%46 = load i64*, i64** %3
%47 = load i32, i32* @KEY_BACKSPACE
%48 = load i32, i32* @KEY_CNT
%49 = call i64 @bit_check(i64* %46, i32 %47, i32 %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %69
51: ; preds = %45
%52 = load i64*, i64** %3
%53 = load i32, i32* @KEY_ENTER
%54 = load i32, i32* @KEY_CNT
%55 = call i64 @bit_check(i64* %52, i32 %53, i32 %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %69
57: ; preds = %51
%58 = load i64*, i64** %3
%59 = load i32, i32* @KEY_TAB
%60 = load i32, i32* @KEY_CNT
%61 = call i64 @bit_check(i64* %58, i32 %59, i32 %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %57
%64 = load i64*, i64** %3
%65 = load i32, i32* @KEY_ESC
%66 = load i32, i32* @KEY_CNT
%67 = call i64 @bit_check(i64* %64, i32 %65, i32 %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %70, label %69
69: ; preds = %63, %57, %51, %45, %39, %36, %31
store i32 0, i32* %2
br label %71
70: ; preds = %63
store i32 1, i32* %2
br label %71
71: ; preds = %70, %69
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
@KEY_LEFTCTRL = global i32 0
@KEY_CNT = global i32 0
@KEY_RIGHTCTRL = global i32 0
@KEY_LEFTALT = global i32 0
@KEY_RIGHTALT = global i32 0
@KEY_SPACE = global i32 0
@KEY_BACKSPACE = global i32 0
@KEY_ENTER = global i32 0
@KEY_TAB = global i32 0
@KEY_ESC = global i32 0
define i32 @possibly_keyboard(i64* %0) {
%2 = load i32, i32* @KEY_LEFTCTRL
%3 = load i32, i32* @KEY_CNT
%4 = tail call i64 @bit_check(i64* %0, i32 %2, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* @KEY_RIGHTCTRL
%8 = load i32, i32* @KEY_CNT
%9 = tail call i64 @bit_check(i64* %0, i32 %7, i32 %8)
%10 = icmp ne i64 %9, 0
br label %11
11: ; preds = %6, %1
%12 = phi i1 [ true, %1 ], [ %10, %6 ]
%13 = load i32, i32* @KEY_LEFTALT
%14 = load i32, i32* @KEY_CNT
%15 = tail call i64 @bit_check(i64* %0, i32 %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load i32, i32* @KEY_RIGHTALT
%19 = load i32, i32* @KEY_CNT
%20 = tail call i64 @bit_check(i64* %0, i32 %18, i32 %19)
%21 = icmp ne i64 %20, 0
br label %22
22: ; preds = %17, %11
%23 = phi i1 [ true, %11 ], [ %21, %17 ]
%24 = select i1 %12, i1 %23, i1 false
br i1 %24, label %25, label %51
25: ; preds = %22
%26 = load i32, i32* @KEY_SPACE
%27 = load i32, i32* @KEY_CNT
%28 = tail call i64 @bit_check(i64* %0, i32 %26, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %51, label %30
30: ; preds = %25
%31 = load i32, i32* @KEY_BACKSPACE
%32 = load i32, i32* @KEY_CNT
%33 = tail call i64 @bit_check(i64* %0, i32 %31, i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %51, label %35
35: ; preds = %30
%36 = load i32, i32* @KEY_ENTER
%37 = load i32, i32* @KEY_CNT
%38 = tail call i64 @bit_check(i64* %0, i32 %36, i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %51, label %40
40: ; preds = %35
%41 = load i32, i32* @KEY_TAB
%42 = load i32, i32* @KEY_CNT
%43 = tail call i64 @bit_check(i64* %0, i32 %41, i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %51, label %45
45: ; preds = %40
%46 = load i32, i32* @KEY_ESC
%47 = load i32, i32* @KEY_CNT
%48 = tail call i64 @bit_check(i64* %0, i32 %46, i32 %47)
%49 = icmp ne i64 %48, 0
%50 = zext i1 %49 to i32
br label %51
51: ; preds = %45, %22, %25, %30, %35, %40
%52 = phi i32 [ 0, %40 ], [ 0, %35 ], [ 0, %30 ], [ 0, %25 ], [ 0, %22 ], [ %50, %45 ]
ret i32 %52
}