#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*/ ABS_CNT;
int /*<<< orphan*/ ABS_MT_POSITION_X;
int /*<<< orphan*/ ABS_MT_POSITION_Y;
int /*<<< orphan*/ ABS_X;
int /*<<< orphan*/ ABS_Y;
int /*<<< orphan*/ BTN_TOUCH;
int /*<<< orphan*/ KEY_CNT;
int bit_check(unsigned long *, int /*<<< orphan*/, int /*<<< orphan*/);
int probably_surface(unsigned long *absbits, unsigned long *keybits) {
  int btn = bit_check(keybits, BTN_TOUCH, KEY_CNT);
  int abs = (bit_check(absbits, ABS_X, ABS_CNT) &&
             bit_check(absbits, ABS_Y, ABS_CNT)) ||
            (bit_check(absbits, ABS_MT_POSITION_X, ABS_CNT) &&
             bit_check(absbits, ABS_MT_POSITION_Y, ABS_CNT));
  if (!btn || !abs) {
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<probably_surface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2ead(%rip),%rax
mov    (%rax),%esi
mov    0x2eac(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
mov    0x2e76(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%eax
je     118d <probably_surface+0x7d>
mov    -0x10(%rbp),%rdi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
mov    0x2e52(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
jne    11e2 <probably_surface+0xd2>
mov    -0x10(%rbp),%rdi
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x22(%rbp)
je     11dc <probably_surface+0xcc>
mov    -0x10(%rbp),%rdi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
mov    0x2dfc(%rip),%rax
mov    (%rax),%edx
call   1030 <bit_check@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1201 <probably_surface+0xf1>
cmpl   $0x0,-0x20(%rbp)
jne    120d <probably_surface+0xfd>
movl   $0x0,-0x4(%rbp)
jmp    1214 <probably_surface+0x104>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<probably_surface>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rax
mov    %rdi,%rbx
mov    0x2eb7(%rip),%rcx
mov    (%rcx),%esi
mov    0x2eb6(%rip),%rcx
mov    (%rcx),%edx
mov    %rax,%rdi
call   1030 <bit_check@plt>
mov    %eax,%r14d
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    0x2e81(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
call   1030 <bit_check@plt>
test   %eax,%eax
je     1170 <probably_surface+0x60>
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
call   1030 <bit_check@plt>
mov    $0x1,%cl
test   %eax,%eax
jne    11a5 <probably_surface+0x95>
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
call   1030 <bit_check@plt>
test   %eax,%eax
je     11a3 <probably_surface+0x93>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
call   1030 <bit_check@plt>
test   %eax,%eax
setne  %cl
jmp    11a5 <probably_surface+0x95>
xor    %ecx,%ecx
test   %r14d,%r14d
setne  %al
and    %cl,%al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@BTN_TOUCH = global i32 0
@KEY_CNT = global i32 0
@ABS_X = global i32 0
@ABS_CNT = global i32 0
@ABS_Y = global i32 0
@ABS_MT_POSITION_X = global i32 0
@ABS_MT_POSITION_Y = global i32 0
define i32 @probably_surface(i64* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i64*
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i32
store i64* %0, i64** %4
store i64* %1, i64** %5
%8 = load i64*, i64** %5
%9 = load i32, i32* @BTN_TOUCH
%10 = load i32, i32* @KEY_CNT
%11 = call i32 @bit_check(i64* %8, i32 %9, i32 %10)
store i32 %11, i32* %6
%12 = load i64*, i64** %4
%13 = load i32, i32* @ABS_X
%14 = load i32, i32* @ABS_CNT
%15 = call i32 @bit_check(i64* %12, i32 %13, i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i64*, i64** %4
%19 = load i32, i32* @ABS_Y
%20 = load i32, i32* @ABS_CNT
%21 = call i32 @bit_check(i64* %18, i32 %19, i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %17, %2
%24 = load i64*, i64** %4
%25 = load i32, i32* @ABS_MT_POSITION_X
%26 = load i32, i32* @ABS_CNT
%27 = call i32 @bit_check(i64* %24, i32 %25, i32 %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load i64*, i64** %4
%31 = load i32, i32* @ABS_MT_POSITION_Y
%32 = load i32, i32* @ABS_CNT
%33 = call i32 @bit_check(i64* %30, i32 %31, i32 %32)
%34 = icmp ne i32 %33, 0
br label %35
35: ; preds = %29, %23
%36 = phi i1 [ false, %23 ], [ %34, %29 ]
br label %37
37: ; preds = %35, %17
%38 = phi i1 [ true, %17 ], [ %36, %35 ]
%39 = zext i1 %38 to i32
store i32 %39, i32* %7
%40 = load i32, i32* %6
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i32, i32* %7
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %42, %37
store i32 0, i32* %3
br label %47
46: ; preds = %42
store i32 1, i32* %3
br label %47
47: ; preds = %46, %45
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@BTN_TOUCH = global i32 0
@KEY_CNT = global i32 0
@ABS_X = global i32 0
@ABS_CNT = global i32 0
@ABS_Y = global i32 0
@ABS_MT_POSITION_X = global i32 0
@ABS_MT_POSITION_Y = global i32 0
define i32 @probably_surface(i64* %0, i64* %1) {
%3 = load i32, i32* @BTN_TOUCH
%4 = load i32, i32* @KEY_CNT
%5 = tail call i32 @bit_check(i64* %1, i32 %3, i32 %4)
%6 = load i32, i32* @ABS_X
%7 = load i32, i32* @ABS_CNT
%8 = tail call i32 @bit_check(i64* %0, i32 %6, i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i32, i32* @ABS_Y
%12 = load i32, i32* @ABS_CNT
%13 = tail call i32 @bit_check(i64* %0, i32 %11, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %10, %2
%16 = load i32, i32* @ABS_MT_POSITION_X
%17 = load i32, i32* @ABS_CNT
%18 = tail call i32 @bit_check(i64* %0, i32 %16, i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %15
%21 = load i32, i32* @ABS_MT_POSITION_Y
%22 = load i32, i32* @ABS_CNT
%23 = tail call i32 @bit_check(i64* %0, i32 %21, i32 %22)
%24 = icmp ne i32 %23, 0
br label %25
25: ; preds = %15, %20, %10
%26 = phi i1 [ true, %10 ], [ false, %15 ], [ %24, %20 ]
%27 = icmp ne i32 %5, 0
%28 = select i1 %27, i1 %26, i1 false
%29 = zext i1 %28 to i32
ret i32 %29
}