#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int response_type;
};
typedef TYPE_1__ xcb_generic_event_t;
typedef int /*<<< orphan*/ xcb_connection_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
scalar_t__ XCB_KEYMAP_NOTIFY;
int /*<<< orphan*/ free(TYPE_1__ *);
int /*<<< orphan*/ handle_keymap_notify_event(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
TYPE_1__ *xcb_wait_for_event(int /*<<< orphan*/ *);
void event_loop(xcb_connection_t *connection) {
  xcb_generic_event_t *event = NULL;
  printf("Waiting for events...\n");
  while ((event = xcb_wait_for_event(connection))) {
    uint32_t response_type = event->response_type & ~0x80;
    free(event);
    if (response_type == XCB_KEYMAP_NOTIFY) {
      handle_keymap_notify_event(connection);
    }
  }
}


x86 assembly (clang, -O0):
<event_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <xcb_wait_for_event@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11b3 <event_loop+0x73>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0xffffff7f,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%rax
jne    11ae <event_loop+0x6e>
mov    -0x8(%rbp),%rdi
call   1050 <handle_keymap_notify_event@plt>
jmp    1160 <event_loop+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<event_loop>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1060 <xcb_wait_for_event@plt>
test   %rax,%rax
je     119e <event_loop+0x5e>
mov    0x2e78(%rip),%r14
jmp    117d <event_loop+0x3d>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <xcb_wait_for_event@plt>
test   %rax,%rax
je     119e <event_loop+0x5e>
movslq (%rax),%rbx
and    $0xffffffffffffff7f,%rbx
mov    %rax,%rdi
call   1030 <free@plt>
cmp    %rbx,(%r14)
jne    1170 <event_loop+0x30>
mov    %r15,%rdi
call   1050 <handle_keymap_notify_event@plt>
jmp    1170 <event_loop+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
@.str = [23 x i8] c"Waiting for events...\0A\00"
@XCB_KEYMAP_NOTIFY = global i64 0
define void @event_loop(i32* %0) {
%2 = alloca i32*
%3 = alloca %struct.TYPE_4__*
%4 = alloca i64
store i32* %0, i32** %2
store %struct.TYPE_4__* null, %struct.TYPE_4__** %3
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %24, %1
%7 = load i32*, i32** %2
%8 = call %struct.TYPE_4__* @xcb_wait_for_event(i32* %7)
store %struct.TYPE_4__* %8, %struct.TYPE_4__** %3
%9 = icmp ne %struct.TYPE_4__* %8, null
br i1 %9, label %10, label %25
10: ; preds = %6
%11 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = and i32 %13, -129
%15 = sext i32 %14 to i64
store i64 %15, i64* %4
%16 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%17 = call i32 @free(%struct.TYPE_4__* %16)
%18 = load i64, i64* %4
%19 = load i64, i64* @XCB_KEYMAP_NOTIFY
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %10
%22 = load i32*, i32** %2
%23 = call i32 @handle_keymap_notify_event(i32* %22)
br label %24
24: ; preds = %21, %10
br label %6
25: ; preds = %6
ret void
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32 }
@XCB_KEYMAP_NOTIFY = global i64 0
@str = [22 x i8] c"Waiting for events...\00"
define void @event_loop(i32* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%3 = tail call %struct.TYPE_4__* @xcb_wait_for_event(i32* %0)
%4 = icmp eq %struct.TYPE_4__* %3, null
br i1 %4, label %19, label %5
5: ; preds = %1, %16
%6 = phi %struct.TYPE_4__* [ %17, %16 ], [ %3, %1 ]
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i64 0, i32 0
%8 = load i32, i32* %7
%9 = and i32 %8, -129
%10 = sext i32 %9 to i64
%11 = tail call i32 @free(%struct.TYPE_4__* %6)
%12 = load i64, i64* @XCB_KEYMAP_NOTIFY
%13 = icmp eq i64 %12, %10
br i1 %13, label %14, label %16
14: ; preds = %5
%15 = tail call i32 @handle_keymap_notify_event(i32* %0)
br label %16
16: ; preds = %14, %5
%17 = tail call %struct.TYPE_4__* @xcb_wait_for_event(i32* %0)
%18 = icmp eq %struct.TYPE_4__* %17, null
br i1 %18, label %19, label %5
19: ; preds = %16, %1
ret void
}