#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*/ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;
typedef scalar_t__ Bool;

/* Variables and functions */
scalar_t__ glinject_handle_x11_event(int /*<<< orphan*/ *);
scalar_t__ glinject_real_XCheckTypedWindowEvent(int /*<<< orphan*/ *,
                                                int /*<<< orphan*/, int,
                                                int /*<<< orphan*/ *);
Bool XCheckTypedWindowEvent(Display *dpy, Window w, int type, XEvent *event) {
  Bool return_val;
  do {
    return_val = glinject_real_XCheckTypedWindowEvent(dpy, w, type, event);
  } while (return_val && glinject_handle_x11_event(event));
  return return_val;
}


x86 assembly (clang, -O0):
<XCheckTypedWindowEvent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1030 <glinject_real_XCheckTypedWindowEvent@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x21(%rbp)
je     1170 <XCheckTypedWindowEvent+0x50>
mov    -0x18(%rbp),%rdi
call   1040 <glinject_handle_x11_event@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1136 <XCheckTypedWindowEvent+0x16>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XCheckTypedWindowEvent>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
call   1030 <glinject_real_XCheckTypedWindowEvent@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1166 <XCheckTypedWindowEvent+0x46>
mov    %rbx,%rdi
call   1040 <glinject_handle_x11_event@plt>
test   %rax,%rax
jne    1140 <XCheckTypedWindowEvent+0x20>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @XCheckTypedWindowEvent(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i64
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
br label %10
10: ; preds = %23, %4
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = load i32*, i32** %8
%15 = call i64 @glinject_real_XCheckTypedWindowEvent(i32* %11, i32 %12, i32 %13, i32* %14)
store i64 %15, i64* %9
br label %16
16: ; preds = %10
%17 = load i64, i64* %9
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32*, i32** %8
%21 = call i64 @glinject_handle_x11_event(i32* %20)
%22 = icmp ne i64 %21, 0
br label %23
23: ; preds = %19, %16
%24 = phi i1 [ false, %16 ], [ %22, %19 ]
br i1 %24, label %10, label %25
25: ; preds = %23
%26 = load i64, i64* %9
ret i64 %26
}

LLVM IR (-O2):
define i64 @XCheckTypedWindowEvent(i32* %0, i32 %1, i32 %2, i32* %3) {
br label %5
5: ; preds = %8, %4
%6 = tail call i64 @glinject_real_XCheckTypedWindowEvent(i32* %0, i32 %1, i32 %2, i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i64 @glinject_handle_x11_event(i32* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %5
11: ; preds = %5, %8
ret i64 %6
}