#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*/ xcb_generic_event_t;
typedef int /*<<< orphan*/ xcb_generic_error_t;
typedef int /*<<< orphan*/ xcb_connection_t;
struct timespec {
  int tv_nsec;
  scalar_t__ tv_sec;
};
struct pollfd {
  scalar_t__ revents;
  int /*<<< orphan*/ events;
  int /*<<< orphan*/ fd;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC_COARSE;
int /*<<< orphan*/ POLLIN;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
scalar_t__ ppoll(struct pollfd *, int, struct timespec *, int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_flush(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_get_file_descriptor(int /*<<< orphan*/ *);
int /*<<< orphan*/ *xcb_poll_for_event(int /*<<< orphan*/ *);
scalar_t__ xcb_poll_for_reply(int /*<<< orphan*/ *, unsigned int, void **,
                              int /*<<< orphan*/ **);
xcb_generic_event_t *__xcb_wait_for_event_timeo(xcb_connection_t *conn,
                                                unsigned int request,
                                                xcb_generic_error_t **e,
                                                int msecs) {
  struct timespec now, delay, deadline;
  struct pollfd pfd;
  xcb_generic_event_t *ev;
  if (!conn)
    return NULL;
  clock_gettime(CLOCK_MONOTONIC_COARSE, &deadline);
  deadline.tv_nsec += msecs * (1000 * 1000);
  if (deadline.tv_nsec >= (1000 * 1000 * 1000)) {
    deadline.tv_sec += 1;
    deadline.tv_nsec -= (1000 * 1000 * 1000);
  }
  if (request)
    xcb_flush(conn);
  while (1) {
    if (request) {
      if (xcb_poll_for_reply(conn, request, (void **)&ev, e))
        return ev;
    } else {
      ev = xcb_poll_for_event(conn);
      if (ev)
        return ev;
    }
    pfd.fd = xcb_get_file_descriptor(conn);
    pfd.events = POLLIN;
    pfd.revents = 0;
    clock_gettime(CLOCK_MONOTONIC_COARSE, &now);
    if (now.tv_sec > deadline.tv_sec)
      return NULL;
    if (now.tv_sec == deadline.tv_sec && now.tv_nsec >= deadline.tv_nsec)
      return NULL;
    delay.tv_sec = deadline.tv_sec - now.tv_sec;
    if (deadline.tv_nsec >= now.tv_nsec)
      delay.tv_nsec = deadline.tv_nsec - now.tv_nsec;
    else {
      delay.tv_sec -= 1;
      delay.tv_nsec = (1000 * 1000 * 1000) + deadline.tv_nsec - now.tv_nsec;
    }
    if (delay.tv_sec == 0 && delay.tv_nsec < (1000 * 1000))
      return NULL;
    if (ppoll(&pfd, 1, &delay, NULL) < 0)
      return NULL;
  }
}


x86 assembly (clang, -O0):
<__xcb_wait_for_event_timeo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118e <__xcb_wait_for_event_timeo+0x2e>
movq   $0x0,-0x8(%rbp)
jmp    1358 <__xcb_wait_for_event_timeo+0x1f8>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    -0x58(%rbp),%rsi
call   1040 <clock_gettime@plt>
imul   $0xf4240,-0x24(%rbp),%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x3b9aca00,-0x58(%rbp)
jl     11d1 <__xcb_wait_for_event_timeo+0x71>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x3b9aca00,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11e4 <__xcb_wait_for_event_timeo+0x84>
mov    -0x10(%rbp),%rdi
call   1050 <xcb_flush@plt>
jmp    11e9 <__xcb_wait_for_event_timeo+0x89>
cmpl   $0x0,-0x14(%rbp)
je     1223 <__xcb_wait_for_event_timeo+0xc3>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x70(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1080 <xcb_poll_for_reply@plt>
cmp    $0x0,%rax
je     121e <__xcb_wait_for_event_timeo+0xbe>
mov    -0x70(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <__xcb_wait_for_event_timeo+0x1f8>
jmp    124d <__xcb_wait_for_event_timeo+0xed>
mov    -0x10(%rbp),%rdi
call   1070 <xcb_poll_for_event@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     1248 <__xcb_wait_for_event_timeo+0xe8>
mov    -0x70(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <__xcb_wait_for_event_timeo+0x1f8>
jmp    124d <__xcb_wait_for_event_timeo+0xed>
mov    -0x10(%rbp),%rdi
call   1030 <xcb_get_file_descriptor@plt>
mov    %eax,-0x5c(%rbp)
mov    0x2d80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x30(%rbp),%rax
cmp    -0x50(%rbp),%rax
jle    129a <__xcb_wait_for_event_timeo+0x13a>
movq   $0x0,-0x8(%rbp)
jmp    1358 <__xcb_wait_for_event_timeo+0x1f8>
mov    -0x30(%rbp),%rax
cmp    -0x50(%rbp),%rax
jne    12c1 <__xcb_wait_for_event_timeo+0x161>
mov    -0x38(%rbp),%eax
cmp    -0x58(%rbp),%eax
jl     12c1 <__xcb_wait_for_event_timeo+0x161>
movq   $0x0,-0x8(%rbp)
jmp    1358 <__xcb_wait_for_event_timeo+0x1f8>
mov    -0x50(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x38(%rbp),%eax
jl     12e7 <__xcb_wait_for_event_timeo+0x187>
mov    -0x58(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x48(%rbp)
jmp    1301 <__xcb_wait_for_event_timeo+0x1a1>
mov    -0x40(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x58(%rbp),%eax
add    $0x3b9aca00,%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1326 <__xcb_wait_for_event_timeo+0x1c6>
cmpl   $0xf4240,-0x48(%rbp)
jge    1326 <__xcb_wait_for_event_timeo+0x1c6>
movq   $0x0,-0x8(%rbp)
jmp    1358 <__xcb_wait_for_event_timeo+0x1f8>
lea    -0x68(%rbp),%rdi
mov    $0x1,%esi
lea    -0x48(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <ppoll@plt>
cmp    $0x0,%rax
jge    1353 <__xcb_wait_for_event_timeo+0x1f3>
movq   $0x0,-0x8(%rbp)
jmp    1358 <__xcb_wait_for_event_timeo+0x1f8>
jmp    11e9 <__xcb_wait_for_event_timeo+0x89>
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__xcb_wait_for_event_timeo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
test   %rdi,%rdi
je     12bd <__xcb_wait_for_event_timeo+0x15d>
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
imul   $0xf4240,%r15d,%eax
add    0x10(%rsp),%eax
mov    %eax,0x10(%rsp)
cmp    $0x3b9aca00,%eax
jl     11ba <__xcb_wait_for_event_timeo+0x5a>
addq   $0x1,0x18(%rsp)
add    $0xc4653600,%eax
mov    %eax,0x10(%rsp)
test   %ebp,%ebp
je     11c6 <__xcb_wait_for_event_timeo+0x66>
mov    %rbx,%rdi
call   1050 <xcb_flush@plt>
mov    0x2e13(%rip),%r13
lea    0x48(%rsp),%r12
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x38(%rsp),%r15
jmp    11fd <__xcb_wait_for_event_timeo+0x9d>
lea    0x28(%rsp),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1060 <ppoll@plt>
test   %rax,%rax
js     12cb <__xcb_wait_for_event_timeo+0x16b>
mov    %rbx,%rdi
test   %ebp,%ebp
je     1220 <__xcb_wait_for_event_timeo+0xc0>
mov    %ebp,%esi
lea    0x20(%rsp),%rdx
mov    %r14,%rcx
call   1080 <xcb_poll_for_reply@plt>
test   %rax,%rax
je     1233 <__xcb_wait_for_event_timeo+0xd3>
jmp    12c1 <__xcb_wait_for_event_timeo+0x161>
nopl   (%rax)
call   1070 <xcb_poll_for_event@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
jne    12c6 <__xcb_wait_for_event_timeo+0x166>
mov    %rbx,%rdi
call   1030 <xcb_get_file_descriptor@plt>
mov    %eax,0x34(%rsp)
mov    0x0(%r13),%eax
mov    %eax,0x30(%rsp)
movq   $0x0,0x28(%rsp)
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
call   1040 <clock_gettime@plt>
mov    0x18(%rsp),%rax
sub    0x50(%rsp),%rax
jl     12cb <__xcb_wait_for_event_timeo+0x16b>
jne    1280 <__xcb_wait_for_event_timeo+0x120>
mov    0x48(%rsp),%edx
mov    0x10(%rsp),%ecx
cmp    %ecx,%edx
jl     1288 <__xcb_wait_for_event_timeo+0x128>
jmp    12cb <__xcb_wait_for_event_timeo+0x16b>
nopl   (%rax)
mov    0x10(%rsp),%ecx
mov    0x48(%rsp),%edx
mov    %rax,0x40(%rsp)
cmp    %edx,%ecx
jge    12a0 <__xcb_wait_for_event_timeo+0x140>
add    $0xffffffffffffffff,%rax
mov    %rax,0x40(%rsp)
add    $0x3b9aca00,%ecx
sub    %edx,%ecx
mov    %ecx,0x38(%rsp)
test   %rax,%rax
jne    11e0 <__xcb_wait_for_event_timeo+0x80>
cmp    $0xf4240,%ecx
jge    11e0 <__xcb_wait_for_event_timeo+0x80>
jmp    12cb <__xcb_wait_for_event_timeo+0x16b>
xor    %eax,%eax
jmp    12c6 <__xcb_wait_for_event_timeo+0x166>
mov    0x20(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
%struct.pollfd = type { i64, i32, i32 }
@CLOCK_MONOTONIC_COARSE = global i32 0
@POLLIN = global i32 0
define i32* @__xcb_wait_for_event_timeo(i32* %0, i32 %1, i32** %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32**
%9 = alloca i32
%10 = alloca %struct.timespec
%11 = alloca %struct.timespec
%12 = alloca %struct.timespec
%13 = alloca %struct.pollfd
%14 = alloca i32*
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32** %2, i32*** %8
store i32 %3, i32* %9
%15 = load i32*, i32** %6
%16 = icmp ne i32* %15, null
br i1 %16, label %18, label %17
17: ; preds = %4
store i32* null, i32** %5
br label %136
18: ; preds = %4
%19 = load i32, i32* @CLOCK_MONOTONIC_COARSE
%20 = call i32 @clock_gettime(i32 %19, %struct.timespec* %12)
%21 = load i32, i32* %9
%22 = mul nsw i32 %21, 1000000
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%24 = load i32, i32* %23
%25 = add nsw i32 %24, %22
store i32 %25, i32* %23
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%27 = load i32, i32* %26
%28 = icmp sge i32 %27, 1000000000
br i1 %28, label %29, label %36
29: ; preds = %18
%30 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
%31 = load i64, i64* %30
%32 = add nsw i64 %31, 1
store i64 %32, i64* %30
%33 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%34 = load i32, i32* %33
%35 = sub nsw i32 %34, 1000000000
store i32 %35, i32* %33
br label %36
36: ; preds = %29, %18
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32*, i32** %6
%41 = call i32 @xcb_flush(i32* %40)
br label %42
42: ; preds = %39, %36
br label %43
43: ; preds = %42, %135
%44 = load i32, i32* %7
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %56
46: ; preds = %43
%47 = load i32*, i32** %6
%48 = load i32, i32* %7
%49 = bitcast i32** %14 to i8**
%50 = load i32**, i32*** %8
%51 = call i64 @xcb_poll_for_reply(i32* %47, i32 %48, i8** %49, i32** %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %46
%54 = load i32*, i32** %14
store i32* %54, i32** %5
br label %136
55: ; preds = %46
br label %64
56: ; preds = %43
%57 = load i32*, i32** %6
%58 = call i32* @xcb_poll_for_event(i32* %57)
store i32* %58, i32** %14
%59 = load i32*, i32** %14
%60 = icmp ne i32* %59, null
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = load i32*, i32** %14
store i32* %62, i32** %5
br label %136
63: ; preds = %56
br label %64
64: ; preds = %63, %55
%65 = load i32*, i32** %6
%66 = call i32 @xcb_get_file_descriptor(i32* %65)
%67 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i32 0, i32 2
store i32 %66, i32* %67
%68 = load i32, i32* @POLLIN
%69 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i32 0, i32 1
store i32 %68, i32* %69
%70 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i32 0, i32 0
store i64 0, i64* %70
%71 = load i32, i32* @CLOCK_MONOTONIC_COARSE
%72 = call i32 @clock_gettime(i32 %71, %struct.timespec* %10)
%73 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%74 = load i64, i64* %73
%75 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
%76 = load i64, i64* %75
%77 = icmp sgt i64 %74, %76
br i1 %77, label %78, label %79
78: ; preds = %64
store i32* null, i32** %5
br label %136
79: ; preds = %64
%80 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%81 = load i64, i64* %80
%82 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
%83 = load i64, i64* %82
%84 = icmp eq i64 %81, %83
br i1 %84, label %85, label %92
85: ; preds = %79
%86 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%87 = load i32, i32* %86
%88 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%89 = load i32, i32* %88
%90 = icmp sge i32 %87, %89
br i1 %90, label %91, label %92
91: ; preds = %85
store i32* null, i32** %5
br label %136
92: ; preds = %85, %79
%93 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
%94 = load i64, i64* %93
%95 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%96 = load i64, i64* %95
%97 = sub nsw i64 %94, %96
%98 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
store i64 %97, i64* %98
%99 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%100 = load i32, i32* %99
%101 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%102 = load i32, i32* %101
%103 = icmp sge i32 %100, %102
br i1 %103, label %104, label %111
104: ; preds = %92
%105 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%106 = load i32, i32* %105
%107 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%108 = load i32, i32* %107
%109 = sub nsw i32 %106, %108
%110 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
store i32 %109, i32* %110
br label %122
111: ; preds = %92
%112 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%113 = load i64, i64* %112
%114 = sub nsw i64 %113, 1
store i64 %114, i64* %112
%115 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%116 = load i32, i32* %115
%117 = add nsw i32 1000000000, %116
%118 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%119 = load i32, i32* %118
%120 = sub nsw i32 %117, %119
%121 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
store i32 %120, i32* %121
br label %122
122: ; preds = %111, %104
%123 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%124 = load i64, i64* %123
%125 = icmp eq i64 %124, 0
br i1 %125, label %126, label %131
126: ; preds = %122
%127 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%128 = load i32, i32* %127
%129 = icmp slt i32 %128, 1000000
br i1 %129, label %130, label %131
130: ; preds = %126
store i32* null, i32** %5
br label %136
131: ; preds = %126, %122
%132 = call i64 @ppoll(%struct.pollfd* %13, i32 1, %struct.timespec* %11, i32* null)
%133 = icmp slt i64 %132, 0
br i1 %133, label %134, label %135
134: ; preds = %131
store i32* null, i32** %5
br label %136
135: ; preds = %131
br label %43
136: ; preds = %134, %130, %91, %78, %61, %53, %17
%137 = load i32*, i32** %5
ret i32* %137
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
%struct.pollfd = type { i64, i32, i32 }
@CLOCK_MONOTONIC_COARSE = global i32 0
@POLLIN = global i32 0
define i32* @__xcb_wait_for_event_timeo(i32* %0, i32 %1, i32** %2, i32 %3) {
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = alloca %struct.pollfd
%9 = alloca i32*
%10 = bitcast %struct.timespec* %5 to i8*
%11 = bitcast %struct.timespec* %6 to i8*
%12 = bitcast %struct.timespec* %7 to i8*
%13 = bitcast %struct.pollfd* %8 to i8*
%14 = bitcast i32** %9 to i8*
%15 = icmp eq i32* %0, null
br i1 %15, label %87, label %16
16: ; preds = %4
%17 = load i32, i32* @CLOCK_MONOTONIC_COARSE
%18 = call i32 @clock_gettime(i32 %17, %struct.timespec* %7)
%19 = mul nsw i32 %3, 1000000
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 0
%21 = load i32, i32* %20
%22 = add nsw i32 %21, %19
store i32 %22, i32* %20
%23 = icmp sgt i32 %22, 999999999
br i1 %23, label %24, label %29
24: ; preds = %16
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 1
%26 = load i64, i64* %25
%27 = add nsw i64 %26, 1
store i64 %27, i64* %25
%28 = add nsw i32 %22, -1000000000
store i32 %28, i32* %20
br label %29
29: ; preds = %24, %16
%30 = icmp eq i32 %1, 0
br i1 %30, label %33, label %31
31: ; preds = %29
%32 = call i32 @xcb_flush(i32* %0)
br label %33
33: ; preds = %31, %29
%34 = bitcast i32** %9 to i8**
%35 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %8, i64 0, i32 2
%36 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %8, i64 0, i32 1
%37 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %8, i64 0, i32 0
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%39 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 1
%40 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 1
%42 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
br label %43
43: ; preds = %84, %33
br i1 %30, label %49, label %44
44: ; preds = %43
%45 = call i64 @xcb_poll_for_reply(i32* %0, i32 %1, i8** %34, i32** %2)
%46 = icmp eq i64 %45, 0
br i1 %46, label %52, label %47
47: ; preds = %44
%48 = load i32*, i32** %9
br label %87
49: ; preds = %43
%50 = call i32* @xcb_poll_for_event(i32* %0)
store i32* %50, i32** %9
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %87
52: ; preds = %49, %44
%53 = call i32 @xcb_get_file_descriptor(i32* %0)
store i32 %53, i32* %35
%54 = load i32, i32* @POLLIN
store i32 %54, i32* %36
store i64 0, i64* %37
%55 = load i32, i32* @CLOCK_MONOTONIC_COARSE
%56 = call i32 @clock_gettime(i32 %55, %struct.timespec* %5)
%57 = load i64, i64* %38
%58 = load i64, i64* %39
%59 = icmp slt i64 %58, %57
br i1 %59, label %87, label %60
60: ; preds = %52
%61 = icmp eq i64 %58, %57
br i1 %61, label %65, label %62
62: ; preds = %60
%63 = load i32, i32* %20
%64 = load i32, i32* %40
br label %69
65: ; preds = %60
%66 = load i32, i32* %40
%67 = load i32, i32* %20
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %87
69: ; preds = %62, %65
%70 = phi i32 [ %64, %62 ], [ %66, %65 ]
%71 = phi i32 [ %63, %62 ], [ %67, %65 ]
%72 = sub nsw i64 %58, %57
store i64 %72, i64* %41
%73 = icmp slt i32 %71, %70
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = add nsw i64 %72, -1
store i64 %75, i64* %41
%76 = add nsw i32 %71, 1000000000
br label %77
77: ; preds = %69, %74
%78 = phi i32 [ %76, %74 ], [ %71, %69 ]
%79 = phi i64 [ %75, %74 ], [ %72, %69 ]
%80 = sub i32 %78, %70
store i32 %80, i32* %42
%81 = icmp eq i64 %79, 0
%82 = icmp slt i32 %80, 1000000
%83 = select i1 %81, i1 %82, i1 false
br i1 %83, label %87, label %84
84: ; preds = %77
%85 = call i64 @ppoll(%struct.pollfd* %8, i32 1, %struct.timespec* %6, i32* null)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %43
87: ; preds = %84, %77, %65, %52, %49, %4, %47
%88 = phi i32* [ %48, %47 ], [ null, %4 ], [ null, %84 ], [ null, %77 ], [ null, %65 ], [ null, %52 ], [ %50, %49 ]
ret i32* %88
}