#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_17__ TYPE_5__;
typedef struct TYPE_16__ TYPE_4__;
typedef struct TYPE_15__ TYPE_3__;
typedef struct TYPE_14__ TYPE_2__;
typedef struct TYPE_13__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ xcb_window_t;
typedef int /*<<< orphan*/ xcb_void_cookie_t;
struct TYPE_13__ {
  int white_pixel;
  int /*<<< orphan*/ root_visual;
  int /*<<< orphan*/ root;
  int /*<<< orphan*/ root_depth;
};
typedef TYPE_1__ xcb_screen_t;
struct TYPE_14__ {
  TYPE_1__ *data;
};
typedef TYPE_2__ xcb_screen_iterator_t;
struct TYPE_15__ {
  int /*<<< orphan*/ detail;
};
typedef TYPE_3__ xcb_key_release_event_t;
struct TYPE_16__ {
  int response_type;
};
typedef TYPE_4__ xcb_generic_event_t;
typedef int /*<<< orphan*/ xcb_connection_t;
struct TYPE_17__ {
  int event_x;
  int event_y;
};
typedef TYPE_5__ xcb_button_press_event_t;
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
#define XCB_BUTTON_PRESS 130
int XCB_CW_BACK_PIXEL;
int XCB_CW_EVENT_MASK;
int XCB_EVENT_MASK_BUTTON_PRESS;
int XCB_EVENT_MASK_EXPOSURE;
int XCB_EVENT_MASK_KEY_RELEASE;
int XCB_EVENT_MASK_POINTER_MOTION;
#define XCB_EXPOSE 129
#define XCB_KEY_RELEASE 128
int /*<<< orphan*/ XCB_WINDOW_CLASS_INPUT_OUTPUT;
int /*<<< orphan*/ drawButton(int /*<<< orphan*/ *, TYPE_1__ *,
                              int /*<<< orphan*/, int, int, char *);
int /*<<< orphan*/ drawText(int /*<<< orphan*/ *, TYPE_1__ *,
                            int /*<<< orphan*/, int, int, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(TYPE_4__ *);
int /*<<< orphan*/ setCursor(int /*<<< orphan*/ *, TYPE_1__ *,
                             int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ testCookie(int /*<<< orphan*/, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *xcb_connect(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/
xcb_create_window_checked(int /*<<< orphan*/ *, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/, int, int, int,
                          int, int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int, int *);
int /*<<< orphan*/ xcb_disconnect(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_flush(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_generate_id(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_get_setup(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_map_window_checked(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/);
TYPE_4__ *xcb_poll_for_event(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_screen_next(TYPE_2__ *);
TYPE_2__ xcb_setup_roots_iterator(int /*<<< orphan*/);
int main() {
  int screenNum;
  xcb_connection_t *connection = xcb_connect(NULL, &screenNum);
  if (!connection) {
    fprintf(stderr, "ERROR: can't connect to an X server\n");
    return -1;
  }
  xcb_screen_iterator_t iter =
      xcb_setup_roots_iterator(xcb_get_setup(connection));
  for (int i = 0; i < screenNum; i++) {
    xcb_screen_next(&iter);
  }
  xcb_screen_t *screen = iter.data;
  if (!screen) {
    fprintf(stderr, "ERROR: can't get the current screen\n");
    xcb_disconnect(connection);
    return -1;
  }
  xcb_window_t window = xcb_generate_id(connection);
  uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
  uint32_t values[2];
  values[0] = screen->white_pixel;
  values[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_BUTTON_PRESS |
              XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_POINTER_MOTION;
  xcb_void_cookie_t windowCookie = xcb_create_window_checked(
      connection, screen->root_depth, window, screen->root, 20, 200, 300, 150,
      0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, mask, values);
  testCookie(windowCookie, connection, "can't create window");
  xcb_void_cookie_t mapCookie = xcb_map_window_checked(connection, window);
  testCookie(mapCookie, connection, "can't map window");
  setCursor(connection, screen, window, 68);
  xcb_flush(connection);
  uint8_t isHand = 0;
  while (1) {
    xcb_generic_event_t *event = xcb_poll_for_event(connection);
    if (event) {
      switch (event->response_type & ~0x80) {
      case XCB_EXPOSE: {
        char *text = "click here to change cursor";
        drawButton(connection, screen, window, (300 - 7 * strlen(text)) / 2,
                   (300 - 16) / 2, text);
        text = "Press ESC key to exit...";
        drawText(connection, screen, window, 10, 150 - 10, text);
        break;
      }
      case XCB_BUTTON_PRESS: {
        xcb_button_press_event_t *press = (xcb_button_press_event_t *)event;
        int length = strlen("click here to change cursor");
        if ((press->event_x >= (300 - 7 * length) / 2) &&
            (press->event_x <= ((300 - 7 * length) / 2 + 7 * length + 6)) &&
            (press->event_y >= (150 - 16) / 2 - 19) &&
            (press->event_y <= ((150 - 16) / 2))) {
          isHand = 1 - isHand;
        }
        if (isHand) {
          setCursor(connection, screen, window, 58);
        } else {
          setCursor(connection, screen, window, 68);
        }
      }
      case XCB_KEY_RELEASE: {
        xcb_key_release_event_t *kr = (xcb_key_release_event_t *)event;
        switch (kr->detail) {
        case 9:
          free(event);
          xcb_disconnect(connection);
          return 0;
        }
      }
      }
      free(event);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    -0x18(%rbp),%rsi
call   1040 <xcb_connect@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1262 <main+0x52>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xdaf(%rip),%rsi
call   10c0 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1625 <main+0x415>
mov    -0x20(%rbp),%rdi
call   1110 <xcb_get_setup@plt>
mov    %eax,%edi
call   10b0 <xcb_setup_roots_iterator@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12a0 <main+0x90>
lea    -0x28(%rbp),%rdi
call   10a0 <xcb_screen_next@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    127d <main+0x6d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12dd <main+0xcd>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%rsi
call   10c0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1100 <xcb_disconnect@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1625 <main+0x415>
mov    -0x20(%rbp),%rdi
call   1070 <xcb_generate_id@plt>
mov    %eax,-0x3c(%rbp)
mov    0x2ce0(%rip),%rax
mov    (%rax),%eax
mov    0x2cb7(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    0x2c91(%rip),%rcx
or     (%rcx),%eax
mov    0x2cb8(%rip),%rcx
or     (%rcx),%eax
mov    0x2cbf(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%ecx
mov    0x2c96(%rip),%rax
mov    (%rax),%ebx
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%r11d
mov    -0x40(%rbp),%r10d
lea    -0x48(%rbp),%rax
mov    $0x14,%r8d
mov    $0xc8,%r9d
xor    %r14d,%r14d
movl   $0x12c,(%rsp)
movl   $0x96,0x8(%rsp)
movl   $0x0,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1120 <xcb_create_window_checked@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    0xc9f(%rip),%rdx
call   10e0 <testCookie@plt>
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   10d0 <xcb_map_window_checked@plt>
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    0xc91(%rip),%rdx
call   10e0 <testCookie@plt>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    $0x44,%ecx
call   1080 <setCursor@plt>
mov    -0x20(%rbp),%rdi
call   1060 <xcb_flush@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x20(%rbp),%rdi
call   10f0 <xcb_poll_for_event@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     1620 <main+0x410>
mov    -0x60(%rbp),%rax
mov    (%rax),%eax
and    $0xffffff7f,%eax
mov    %eax,-0x84(%rbp)
sub    $0x80,%eax
je     15d8 <main+0x3c8>
jmp    1430 <main+0x220>
mov    -0x84(%rbp),%eax
sub    $0x81,%eax
je     145c <main+0x24c>
jmp    1446 <main+0x236>
mov    -0x84(%rbp),%eax
sub    $0x82,%eax
je     14f5 <main+0x2e5>
jmp    1617 <main+0x407>
lea    0xc0c(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x68(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
imul   $0x7,%eax,%ecx
mov    $0x12c,%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x88(%rbp),%edx
mov    %eax,%ecx
mov    -0x68(%rbp),%r9
mov    $0x8e,%r8d
call   1090 <drawButton@plt>
lea    0xbbe(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x68(%rbp),%r9
mov    $0xa,%ecx
mov    $0x8c,%r8d
call   1130 <drawText@plt>
jmp    1617 <main+0x407>
mov    -0x60(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    0xb6b(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x74(%rbp)
mov    -0x70(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x9c(%rbp)
imul   $0x7,-0x74(%rbp),%ecx
mov    $0x12c,%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
cmp    %ecx,%eax
jl     159a <main+0x38a>
mov    -0x70(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xa0(%rbp)
imul   $0x7,-0x74(%rbp),%ecx
mov    $0x12c,%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xa0(%rbp),%eax
imul   $0x7,-0x74(%rbp),%edx
add    %edx,%ecx
add    $0x6,%ecx
cmp    %ecx,%eax
jg     159a <main+0x38a>
mov    -0x70(%rbp),%rax
cmpl   $0x30,0x4(%rax)
jl     159a <main+0x38a>
mov    -0x70(%rbp),%rax
cmpl   $0x43,0x4(%rax)
jg     159a <main+0x38a>
mov    $0x1,%eax
sub    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     15be <main+0x3ae>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    $0x3a,%ecx
call   1080 <setCursor@plt>
jmp    15d3 <main+0x3c3>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    $0x44,%ecx
call   1080 <setCursor@plt>
jmp    15d8 <main+0x3c8>
mov    -0x60(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    (%rax),%eax
sub    $0x9,%eax
jne    1612 <main+0x402>
jmp    15f4 <main+0x3e4>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1100 <xcb_disconnect@plt>
movl   $0x0,-0x14(%rbp)
jmp    1625 <main+0x415>
jmp    1617 <main+0x407>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
jmp    13f7 <main+0x1e7>
mov    -0x14(%rbp),%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x4(%rsp),%rsi
xor    %edi,%edi
call   1040 <xcb_connect@plt>
test   %rax,%rax
je     1347 <main+0x167>
mov    %rax,%rbx
mov    %rax,%rdi
call   10f0 <xcb_get_setup@plt>
mov    %eax,%edi
call   1090 <xcb_setup_roots_iterator@plt>
mov    %rax,0x8(%rsp)
cmpl   $0x0,0x4(%rsp)
jle    135e <main+0x17e>
xor    %ebp,%ebp
lea    0x8(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1080 <xcb_screen_next@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1230 <main+0x50>
mov    0x8(%rsp),%r14
test   %r14,%r14
je     136a <main+0x18a>
mov    %rbx,%rdi
call   1060 <xcb_generate_id@plt>
mov    0x2d72(%rip),%rcx
mov    0x2d4b(%rip),%rdx
mov    (%rdx),%ebp
or     (%rcx),%ebp
mov    %eax,%r15d
mov    (%r14),%eax
mov    %eax,0x10(%rsp)
mov    0x2d3e(%rip),%rax
mov    0x2d27(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d4c(%rip),%rax
or     (%rax),%ecx
mov    0x2d53(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x14(%rsp)
mov    0xc(%r14),%esi
mov    0x4(%r14),%eax
mov    0x8(%r14),%ecx
mov    0x2d32(%rip),%rdx
mov    (%rdx),%r10d
sub    $0x8,%rsp
lea    0x18(%rsp),%r11
mov    %rbx,%rdi
mov    %r15d,%edx
mov    $0x14,%r8d
mov    $0xc8,%r9d
push   %r11
push   %rbp
push   %rax
push   %r10
push   $0x0
push   $0x96
push   $0x12c
call   1100 <xcb_create_window_checked@plt>
add    $0x40,%rsp
lea    0xd5c(%rip),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
call   10c0 <testCookie@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
call   10b0 <xcb_map_window_checked@plt>
lea    0xd54(%rip),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
call   10c0 <testCookie@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
mov    $0x44,%ecx
call   1070 <setCursor@plt>
mov    %rbx,%rdi
call   1050 <xcb_flush@plt>
nop
mov    %rbx,%rdi
call   10d0 <xcb_poll_for_event@plt>
test   %rax,%rax
je     1330 <main+0x150>
mov    %rax,%rdi
call   1030 <free@plt>
jmp    1330 <main+0x150>
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
lea    0xca9(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    1387 <main+0x1a7>
mov    %rax,%r14
test   %r14,%r14
jne    124f <main+0x6f>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
lea    0xcab(%rip),%rsi
call   10a0 <fprintf@plt>
mov    %rbx,%rdi
call   10e0 <xcb_disconnect@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_14__ = type { %struct.TYPE_13__* }
%struct.TYPE_13__ = type { i32, i32, i32, i32 }
%struct.TYPE_16__ = type { i32 }
%struct.TYPE_17__ = type { i32, i32 }
%struct.TYPE_15__ = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"ERROR: can't connect to an X server\0A\00"
@.str.1 = [37 x i8] c"ERROR: can't get the current screen\0A\00"
@XCB_CW_BACK_PIXEL = global i32 0
@XCB_CW_EVENT_MASK = global i32 0
@XCB_EVENT_MASK_KEY_RELEASE = global i32 0
@XCB_EVENT_MASK_BUTTON_PRESS = global i32 0
@XCB_EVENT_MASK_EXPOSURE = global i32 0
@XCB_EVENT_MASK_POINTER_MOTION = global i32 0
@XCB_WINDOW_CLASS_INPUT_OUTPUT = global i32 0
@.str.2 = [20 x i8] c"can't create window\00"
@.str.3 = [17 x i8] c"can't map window\00"
@.str.4 = [28 x i8] c"click here to change cursor\00"
@.str.5 = [25 x i8] c"Press ESC key to exit...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca %struct.TYPE_14__
%5 = alloca i32
%6 = alloca %struct.TYPE_13__*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.TYPE_16__*
%14 = alloca i8*
%15 = alloca %struct.TYPE_17__*
%16 = alloca i32
%17 = alloca %struct.TYPE_15__*
store i32 0, i32* %1
%18 = call i32* @xcb_connect(i32* null, i32* %2)
store i32* %18, i32** %3
%19 = load i32*, i32** %3
%20 = icmp ne i32* %19, null
br i1 %20, label %24, label %21
21: ; preds = %0
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %190
24: ; preds = %0
%25 = load i32*, i32** %3
%26 = call i32 @xcb_get_setup(i32* %25)
%27 = call %struct.TYPE_13__* @xcb_setup_roots_iterator(i32 %26)
%28 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %4, i32 0, i32 0
store %struct.TYPE_13__* %27, %struct.TYPE_13__** %28
store i32 0, i32* %5
br label %29
29: ; preds = %35, %24
%30 = load i32, i32* %5
%31 = load i32, i32* %2
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = call i32 @xcb_screen_next(%struct.TYPE_14__* %4)
br label %35
35: ; preds = %33
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %29
38: ; preds = %29
%39 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %4, i32 0, i32 0
%40 = load %struct.TYPE_13__*, %struct.TYPE_13__** %39
store %struct.TYPE_13__* %40, %struct.TYPE_13__** %6
%41 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%42 = icmp ne %struct.TYPE_13__* %41, null
br i1 %42, label %48, label %43
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32*, i32** %3
%47 = call i32 @xcb_disconnect(i32* %46)
store i32 -1, i32* %1
br label %190
48: ; preds = %38
%49 = load i32*, i32** %3
%50 = call i32 @xcb_generate_id(i32* %49)
store i32 %50, i32* %7
%51 = load i32, i32* @XCB_CW_BACK_PIXEL
%52 = load i32, i32* @XCB_CW_EVENT_MASK
%53 = or i32 %51, %52
store i32 %53, i32* %8
%54 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%55 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
store i32 %56, i32* %57
%58 = load i32, i32* @XCB_EVENT_MASK_KEY_RELEASE
%59 = load i32, i32* @XCB_EVENT_MASK_BUTTON_PRESS
%60 = or i32 %58, %59
%61 = load i32, i32* @XCB_EVENT_MASK_EXPOSURE
%62 = or i32 %60, %61
%63 = load i32, i32* @XCB_EVENT_MASK_POINTER_MOTION
%64 = or i32 %62, %63
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
store i32 %64, i32* %65
%66 = load i32*, i32** %3
%67 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%68 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %67, i32 0, i32 3
%69 = load i32, i32* %68
%70 = load i32, i32* %7
%71 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%72 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %71, i32 0, i32 2
%73 = load i32, i32* %72
%74 = load i32, i32* @XCB_WINDOW_CLASS_INPUT_OUTPUT
%75 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%76 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %75, i32 0, i32 1
%77 = load i32, i32* %76
%78 = load i32, i32* %8
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%80 = call i32 @xcb_create_window_checked(i32* %66, i32 %69, i32 %70, i32 %73, i32 20, i32 200, i32 300, i32 150, i32 0, i32 %74, i32 %77, i32 %78, i32* %79)
store i32 %80, i32* %10
%81 = load i32, i32* %10
%82 = load i32*, i32** %3
%83 = call i32 @testCookie(i32 %81, i32* %82, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%84 = load i32*, i32** %3
%85 = load i32, i32* %7
%86 = call i32 @xcb_map_window_checked(i32* %84, i32 %85)
store i32 %86, i32* %11
%87 = load i32, i32* %11
%88 = load i32*, i32** %3
%89 = call i32 @testCookie(i32 %87, i32* %88, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%90 = load i32*, i32** %3
%91 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%92 = load i32, i32* %7
%93 = call i32 @setCursor(i32* %90, %struct.TYPE_13__* %91, i32 %92, i32 68)
%94 = load i32*, i32** %3
%95 = call i32 @xcb_flush(i32* %94)
store i32 0, i32* %12
br label %96
96: ; preds = %48, %189
%97 = load i32*, i32** %3
%98 = call %struct.TYPE_16__* @xcb_poll_for_event(i32* %97)
store %struct.TYPE_16__* %98, %struct.TYPE_16__** %13
%99 = load %struct.TYPE_16__*, %struct.TYPE_16__** %13
%100 = icmp ne %struct.TYPE_16__* %99, null
br i1 %100, label %101, label %189
101: ; preds = %96
%102 = load %struct.TYPE_16__*, %struct.TYPE_16__** %13
%103 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %102, i32 0, i32 0
%104 = load i32, i32* %103
%105 = and i32 %104, -129
switch i32 %105, label %186 [
i32 129, label %106
i32 130, label %122
i32 128, label %174
]
106: ; preds = %101
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8** %14
%107 = load i32*, i32** %3
%108 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%109 = load i32, i32* %7
%110 = load i8*, i8** %14
%111 = call i32 @strlen(i8* %110)
%112 = mul nsw i32 7, %111
%113 = sub nsw i32 300, %112
%114 = sdiv i32 %113, 2
%115 = load i8*, i8** %14
%116 = call i32 @drawButton(i32* %107, %struct.TYPE_13__* %108, i32 %109, i32 %114, i32 142, i8* %115)
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8** %14
%117 = load i32*, i32** %3
%118 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%119 = load i32, i32* %7
%120 = load i8*, i8** %14
%121 = call i32 @drawText(i32* %117, %struct.TYPE_13__* %118, i32 %119, i32 10, i32 140, i8* %120)
br label %186
122: ; preds = %101
%123 = load %struct.TYPE_16__*, %struct.TYPE_16__** %13
%124 = bitcast %struct.TYPE_16__* %123 to %struct.TYPE_17__*
store %struct.TYPE_17__* %124, %struct.TYPE_17__** %15
%125 = call i32 @strlen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 %125, i32* %16
%126 = load %struct.TYPE_17__*, %struct.TYPE_17__** %15
%127 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %126, i32 0, i32 0
%128 = load i32, i32* %127
%129 = load i32, i32* %16
%130 = mul nsw i32 7, %129
%131 = sub nsw i32 300, %130
%132 = sdiv i32 %131, 2
%133 = icmp sge i32 %128, %132
br i1 %133, label %134, label %160
134: ; preds = %122
%135 = load %struct.TYPE_17__*, %struct.TYPE_17__** %15
%136 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %135, i32 0, i32 0
%137 = load i32, i32* %136
%138 = load i32, i32* %16
%139 = mul nsw i32 7, %138
%140 = sub nsw i32 300, %139
%141 = sdiv i32 %140, 2
%142 = load i32, i32* %16
%143 = mul nsw i32 7, %142
%144 = add nsw i32 %141, %143
%145 = add nsw i32 %144, 6
%146 = icmp sle i32 %137, %145
br i1 %146, label %147, label %160
147: ; preds = %134
%148 = load %struct.TYPE_17__*, %struct.TYPE_17__** %15
%149 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %148, i32 0, i32 1
%150 = load i32, i32* %149
%151 = icmp sge i32 %150, 48
br i1 %151, label %152, label %160
152: ; preds = %147
%153 = load %struct.TYPE_17__*, %struct.TYPE_17__** %15
%154 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %153, i32 0, i32 1
%155 = load i32, i32* %154
%156 = icmp sle i32 %155, 67
br i1 %156, label %157, label %160
157: ; preds = %152
%158 = load i32, i32* %12
%159 = sub nsw i32 1, %158
store i32 %159, i32* %12
br label %160
160: ; preds = %157, %152, %147, %134, %122
%161 = load i32, i32* %12
%162 = icmp ne i32 %161, 0
br i1 %162, label %163, label %168
163: ; preds = %160
%164 = load i32*, i32** %3
%165 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%166 = load i32, i32* %7
%167 = call i32 @setCursor(i32* %164, %struct.TYPE_13__* %165, i32 %166, i32 58)
br label %173
168: ; preds = %160
%169 = load i32*, i32** %3
%170 = load %struct.TYPE_13__*, %struct.TYPE_13__** %6
%171 = load i32, i32* %7
%172 = call i32 @setCursor(i32* %169, %struct.TYPE_13__* %170, i32 %171, i32 68)
br label %173
173: ; preds = %168, %163
br label %174
174: ; preds = %101, %173
%175 = load %struct.TYPE_16__*, %struct.TYPE_16__** %13
%176 = bitcast %struct.TYPE_16__* %175 to %struct.TYPE_15__*
store %struct.TYPE_15__* %176, %struct.TYPE_15__** %17
%177 = load %struct.TYPE_15__*, %struct.TYPE_15__** %17
%178 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %177, i32 0, i32 0
%179 = load i32, i32* %178
switch i32 %179, label %185 [
i32 9, label %180
]
180: ; preds = %174
%181 = load %struct.TYPE_16__*, %struct.TYPE_16__** %13
%182 = call i32 @free(%struct.TYPE_16__* %181)
%183 = load i32*, i32** %3
%184 = call i32 @xcb_disconnect(i32* %183)
store i32 0, i32* %1
br label %190
185: ; preds = %174
br label %186
186: ; preds = %185, %101, %106
%187 = load %struct.TYPE_16__*, %struct.TYPE_16__** %13
%188 = call i32 @free(%struct.TYPE_16__* %187)
br label %189
189: ; preds = %186, %96
br label %96
190: ; preds = %180, %43, %21
%191 = load i32, i32* %1
ret i32 %191
}

LLVM IR (-O2):
%struct.TYPE_14__ = type { %struct.TYPE_13__* }
%struct.TYPE_13__ = type { i32, i32, i32, i32 }
%struct.TYPE_16__ = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"ERROR: can't connect to an X server\0A\00"
@.str.1 = [37 x i8] c"ERROR: can't get the current screen\0A\00"
@XCB_CW_BACK_PIXEL = global i32 0
@XCB_CW_EVENT_MASK = global i32 0
@XCB_EVENT_MASK_KEY_RELEASE = global i32 0
@XCB_EVENT_MASK_BUTTON_PRESS = global i32 0
@XCB_EVENT_MASK_EXPOSURE = global i32 0
@XCB_EVENT_MASK_POINTER_MOTION = global i32 0
@XCB_WINDOW_CLASS_INPUT_OUTPUT = global i32 0
@.str.2 = [20 x i8] c"can't create window\00"
@.str.3 = [17 x i8] c"can't map window\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.TYPE_14__
%3 = alloca [2 x i32]
%4 = bitcast i32* %1 to i8*
%5 = call i32* @xcb_connect(i32* null, i32* %1)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %68
10: ; preds = %0
%11 = bitcast %struct.TYPE_14__* %2 to i8*
%12 = call i32 @xcb_get_setup(i32* %5)
%13 = call %struct.TYPE_13__* @xcb_setup_roots_iterator(i32 %12)
%14 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %2, i64 0, i32 0
store %struct.TYPE_13__* %13, %struct.TYPE_13__** %14
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %22, label %19
17: ; preds = %22
%18 = load %struct.TYPE_13__*, %struct.TYPE_13__** %14
br label %19
19: ; preds = %17, %10
%20 = phi %struct.TYPE_13__* [ %18, %17 ], [ %13, %10 ]
%21 = icmp eq %struct.TYPE_13__* %20, null
br i1 %21, label %28, label %32
22: ; preds = %10, %22
%23 = phi i32 [ %25, %22 ], [ 0, %10 ]
%24 = call i32 @xcb_screen_next(%struct.TYPE_14__* %2)
%25 = add nuw nsw i32 %23, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %25, %26
br i1 %27, label %22, label %17
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @xcb_disconnect(i32* %5)
br label %68
32: ; preds = %19
%33 = call i32 @xcb_generate_id(i32* %5)
%34 = load i32, i32* @XCB_CW_BACK_PIXEL
%35 = load i32, i32* @XCB_CW_EVENT_MASK
%36 = or i32 %35, %34
%37 = bitcast [2 x i32]* %3 to i8*
%38 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %20, i64 0, i32 0
%39 = load i32, i32* %38
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
store i32 %39, i32* %40
%41 = load i32, i32* @XCB_EVENT_MASK_KEY_RELEASE
%42 = load i32, i32* @XCB_EVENT_MASK_BUTTON_PRESS
%43 = or i32 %42, %41
%44 = load i32, i32* @XCB_EVENT_MASK_EXPOSURE
%45 = or i32 %43, %44
%46 = load i32, i32* @XCB_EVENT_MASK_POINTER_MOTION
%47 = or i32 %45, %46
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
store i32 %47, i32* %48
%49 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %20, i64 0, i32 3
%50 = load i32, i32* %49
%51 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %20, i64 0, i32 2
%52 = load i32, i32* %51
%53 = load i32, i32* @XCB_WINDOW_CLASS_INPUT_OUTPUT
%54 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %20, i64 0, i32 1
%55 = load i32, i32* %54
%56 = call i32 @xcb_create_window_checked(i32* %5, i32 %50, i32 %33, i32 %52, i32 20, i32 200, i32 300, i32 150, i32 0, i32 %53, i32 %55, i32 %36, i32* %40)
%57 = call i32 @testCookie(i32 %56, i32* %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%58 = call i32 @xcb_map_window_checked(i32* %5, i32 %33)
%59 = call i32 @testCookie(i32 %58, i32* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%60 = call i32 @setCursor(i32* %5, %struct.TYPE_13__* %20, i32 %33, i32 68)
%61 = call i32 @xcb_flush(i32* %5)
br label %62
62: ; preds = %67, %32
%63 = call %struct.TYPE_16__* @xcb_poll_for_event(i32* %5)
%64 = icmp eq %struct.TYPE_16__* %63, null
br i1 %64, label %67, label %65
65: ; preds = %62
%66 = call i32 @free(%struct.TYPE_16__* %63)
br label %67
67: ; preds = %65, %62
br label %62
68: ; preds = %28, %7
ret i32 -1
}