#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_13__ TYPE_4__;
typedef struct TYPE_12__ TYPE_3__;
typedef struct TYPE_11__ TYPE_2__;
typedef struct TYPE_10__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ xcb_window_t;
typedef int /*<<< orphan*/ xcb_void_cookie_t;
struct TYPE_10__ {
  int white_pixel;
  int /*<<< orphan*/ root_visual;
  int /*<<< orphan*/ root;
  int /*<<< orphan*/ root_depth;
};
typedef TYPE_1__ xcb_screen_t;
struct TYPE_11__ {
  TYPE_1__ *data;
};
typedef TYPE_2__ xcb_screen_iterator_t;
struct TYPE_12__ {
  int /*<<< orphan*/ detail;
};
typedef TYPE_3__ xcb_key_release_event_t;
struct TYPE_13__ {
  int response_type;
};
typedef TYPE_4__ xcb_generic_event_t;
typedef int /*<<< orphan*/ xcb_connection_t;
typedef int uint32_t;

/* Variables and functions */
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*/ drawText(int /*<<< orphan*/ *, TYPE_1__ *,
                            int /*<<< orphan*/, int, int, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(TYPE_4__ *);
int /*<<< orphan*/ stderr;
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 screens\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, 100,
      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");
  xcb_flush(connection);
  xcb_generic_event_t *event;
  while (1) {
    if ((event = xcb_poll_for_event(connection))) {
      switch (event->response_type & ~0x80) {
      case XCB_EXPOSE: {
        drawText(connection, screen, window, 10, 100 - 10,
                 "press ESC key to exit...");
        break;
      }
      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    $0x90,%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    1232 <main+0x52>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xddf(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1467 <main+0x287>
mov    -0x20(%rbp),%rdi
call   10e0 <xcb_get_setup@plt>
mov    %eax,%edi
call   1080 <xcb_setup_roots_iterator@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1270 <main+0x90>
lea    -0x28(%rbp),%rdi
call   1070 <xcb_screen_next@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    124d <main+0x6d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12ad <main+0xcd>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xd92(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   10d0 <xcb_disconnect@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1467 <main+0x287>
mov    -0x20(%rbp),%rdi
call   1060 <xcb_generate_id@plt>
mov    %eax,-0x3c(%rbp)
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
mov    0x2ce7(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2cda(%rip),%rax
mov    (%rax),%eax
mov    0x2cc1(%rip),%rcx
or     (%rcx),%eax
mov    0x2ce8(%rip),%rcx
or     (%rcx),%eax
mov    0x2cef(%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    0x2cc6(%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   $0x64,0x8(%rsp)
movl   $0x0,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   10f0 <xcb_create_window_checked@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    0xcd0(%rip),%rdx
call   10b0 <testCookie@plt>
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   10a0 <xcb_map_window_checked@plt>
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    0xcc2(%rip),%rdx
call   10b0 <testCookie@plt>
mov    -0x20(%rbp),%rdi
call   1050 <xcb_flush@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <xcb_poll_for_event@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     1462 <main+0x282>
mov    -0x58(%rbp),%rax
mov    (%rax),%eax
and    $0xffffff7f,%eax
mov    %eax,-0x64(%rbp)
sub    $0x80,%eax
je     141a <main+0x23a>
jmp    13e0 <main+0x200>
mov    -0x64(%rbp),%eax
sub    $0x81,%eax
jne    145d <main+0x27d>
jmp    13f3 <main+0x213>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    $0xa,%ecx
mov    $0x5a,%r8d
lea    0xc60(%rip),%r9
call   1100 <drawText@plt>
jmp    145d <main+0x27d>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    (%rax),%eax
sub    $0x9,%eax
jne    1454 <main+0x274>
jmp    1436 <main+0x256>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   10d0 <xcb_disconnect@plt>
movl   $0x0,-0x14(%rbp)
jmp    1467 <main+0x287>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
jmp    1462 <main+0x282>
jmp    13ab <main+0x1cb>
mov    -0x14(%rbp),%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xc(%rsp),%rsi
xor    %edi,%edi
call   1030 <xcb_connect@plt>
test   %rax,%rax
je     130a <main+0x14a>
mov    %rax,%rbx
mov    %rax,%rdi
call   10d0 <xcb_get_setup@plt>
mov    %eax,%edi
call   1070 <xcb_setup_roots_iterator@plt>
mov    %rax,0x10(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    1321 <main+0x161>
xor    %ebp,%ebp
lea    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <xcb_screen_next@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1210 <main+0x50>
mov    0x10(%rsp),%rbp
test   %rbp,%rbp
je     132d <main+0x16d>
mov    %rbx,%rdi
call   1050 <xcb_generate_id@plt>
mov    0x2d92(%rip),%rcx
mov    0x2d6b(%rip),%rdx
mov    (%rdx),%r10d
or     (%rcx),%r10d
mov    %eax,%r14d
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    0x2d5c(%rip),%rax
mov    0x2d45(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d6a(%rip),%rax
or     (%rax),%ecx
mov    0x2d71(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x1c(%rsp)
mov    0xc(%rbp),%esi
mov    0x4(%rbp),%eax
mov    0x8(%rbp),%ecx
mov    0x2d53(%rip),%rdx
mov    (%rdx),%ebp
sub    $0x8,%rsp
lea    0x20(%rsp),%r11
mov    %rbx,%rdi
mov    %r14d,%edx
mov    $0x14,%r8d
mov    $0xc8,%r9d
push   %r11
push   %r10
push   %rax
push   %rbp
push   $0x0
push   $0x64
push   $0x12c
call   10e0 <xcb_create_window_checked@plt>
add    $0x40,%rsp
lea    0xd82(%rip),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
call   10a0 <testCookie@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1090 <xcb_map_window_checked@plt>
lea    0xd7a(%rip),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
call   10a0 <testCookie@plt>
mov    %rbx,%rdi
call   1040 <xcb_flush@plt>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10b0 <xcb_poll_for_event@plt>
jmp    1300 <main+0x140>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
lea    0xce6(%rip),%rsi
call   1080 <fprintf@plt>
jmp    134a <main+0x18a>
mov    %rax,%rbp
test   %rbp,%rbp
jne    122f <main+0x6f>
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   10c0 <xcb_disconnect@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_11__ = type { %struct.TYPE_10__* }
%struct.TYPE_10__ = type { i32, i32, i32, i32 }
%struct.TYPE_13__ = type { i32 }
%struct.TYPE_12__ = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"ERROR: can't connect to an X server\0A\00"
@.str.1 = [38 x i8] c"ERROR: can't get the current screens\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 = [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_11__
%5 = alloca i32
%6 = alloca %struct.TYPE_10__*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.TYPE_13__*
%13 = alloca %struct.TYPE_12__*
store i32 0, i32* %1
%14 = call i32* @xcb_connect(i32* null, i32* %2)
store i32* %14, i32** %3
%15 = load i32*, i32** %3
%16 = icmp ne i32* %15, null
br i1 %16, label %20, label %17
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %118
20: ; preds = %0
%21 = load i32*, i32** %3
%22 = call i32 @xcb_get_setup(i32* %21)
%23 = call %struct.TYPE_10__* @xcb_setup_roots_iterator(i32 %22)
%24 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %4, i32 0, i32 0
store %struct.TYPE_10__* %23, %struct.TYPE_10__** %24
store i32 0, i32* %5
br label %25
25: ; preds = %31, %20
%26 = load i32, i32* %5
%27 = load i32, i32* %2
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = call i32 @xcb_screen_next(%struct.TYPE_11__* %4)
br label %31
31: ; preds = %29
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %25
34: ; preds = %25
%35 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %4, i32 0, i32 0
%36 = load %struct.TYPE_10__*, %struct.TYPE_10__** %35
store %struct.TYPE_10__* %36, %struct.TYPE_10__** %6
%37 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%38 = icmp ne %struct.TYPE_10__* %37, null
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%42 = load i32*, i32** %3
%43 = call i32 @xcb_disconnect(i32* %42)
store i32 -1, i32* %1
br label %118
44: ; preds = %34
%45 = load i32*, i32** %3
%46 = call i32 @xcb_generate_id(i32* %45)
store i32 %46, i32* %7
%47 = load i32, i32* @XCB_CW_BACK_PIXEL
%48 = load i32, i32* @XCB_CW_EVENT_MASK
%49 = or i32 %47, %48
store i32 %49, i32* %8
%50 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%51 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %50, i32 0, i32 0
%52 = load i32, i32* %51
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
store i32 %52, i32* %53
%54 = load i32, i32* @XCB_EVENT_MASK_KEY_RELEASE
%55 = load i32, i32* @XCB_EVENT_MASK_BUTTON_PRESS
%56 = or i32 %54, %55
%57 = load i32, i32* @XCB_EVENT_MASK_EXPOSURE
%58 = or i32 %56, %57
%59 = load i32, i32* @XCB_EVENT_MASK_POINTER_MOTION
%60 = or i32 %58, %59
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
store i32 %60, i32* %61
%62 = load i32*, i32** %3
%63 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%64 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %63, i32 0, i32 3
%65 = load i32, i32* %64
%66 = load i32, i32* %7
%67 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%68 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %67, i32 0, i32 2
%69 = load i32, i32* %68
%70 = load i32, i32* @XCB_WINDOW_CLASS_INPUT_OUTPUT
%71 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%72 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %71, i32 0, i32 1
%73 = load i32, i32* %72
%74 = load i32, i32* %8
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%76 = call i32 @xcb_create_window_checked(i32* %62, i32 %65, i32 %66, i32 %69, i32 20, i32 200, i32 300, i32 100, i32 0, i32 %70, i32 %73, i32 %74, i32* %75)
store i32 %76, i32* %10
%77 = load i32, i32* %10
%78 = load i32*, i32** %3
%79 = call i32 @testCookie(i32 %77, i32* %78, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%80 = load i32*, i32** %3
%81 = load i32, i32* %7
%82 = call i32 @xcb_map_window_checked(i32* %80, i32 %81)
store i32 %82, i32* %11
%83 = load i32, i32* %11
%84 = load i32*, i32** %3
%85 = call i32 @testCookie(i32 %83, i32* %84, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%86 = load i32*, i32** %3
%87 = call i32 @xcb_flush(i32* %86)
br label %88
88: ; preds = %44, %117
%89 = load i32*, i32** %3
%90 = call %struct.TYPE_13__* @xcb_poll_for_event(i32* %89)
store %struct.TYPE_13__* %90, %struct.TYPE_13__** %12
%91 = icmp ne %struct.TYPE_13__* %90, null
br i1 %91, label %92, label %117
92: ; preds = %88
%93 = load %struct.TYPE_13__*, %struct.TYPE_13__** %12
%94 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %93, i32 0, i32 0
%95 = load i32, i32* %94
%96 = and i32 %95, -129
switch i32 %96, label %116 [
i32 129, label %97
i32 128, label %102
]
97: ; preds = %92
%98 = load i32*, i32** %3
%99 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%100 = load i32, i32* %7
%101 = call i32 @drawText(i32* %98, %struct.TYPE_10__* %99, i32 %100, i32 10, i32 90, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %116
102: ; preds = %92
%103 = load %struct.TYPE_13__*, %struct.TYPE_13__** %12
%104 = bitcast %struct.TYPE_13__* %103 to %struct.TYPE_12__*
store %struct.TYPE_12__* %104, %struct.TYPE_12__** %13
%105 = load %struct.TYPE_12__*, %struct.TYPE_12__** %13
%106 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %105, i32 0, i32 0
%107 = load i32, i32* %106
switch i32 %107, label %113 [
i32 9, label %108
]
108: ; preds = %102
%109 = load %struct.TYPE_13__*, %struct.TYPE_13__** %12
%110 = call i32 @free(%struct.TYPE_13__* %109)
%111 = load i32*, i32** %3
%112 = call i32 @xcb_disconnect(i32* %111)
store i32 0, i32* %1
br label %118
113: ; preds = %102
%114 = load %struct.TYPE_13__*, %struct.TYPE_13__** %12
%115 = call i32 @free(%struct.TYPE_13__* %114)
br label %116
116: ; preds = %113, %92, %97
br label %117
117: ; preds = %116, %88
br label %88
118: ; preds = %108, %39, %17
%119 = load i32, i32* %1
ret i32 %119
}

LLVM IR (-O2):
%struct.TYPE_11__ = type { %struct.TYPE_10__* }
%struct.TYPE_10__ = type { i32, i32, i32, i32 }
%struct.TYPE_13__ = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"ERROR: can't connect to an X server\0A\00"
@.str.1 = [38 x i8] c"ERROR: can't get the current screens\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_11__
%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 %63
10: ; preds = %0
%11 = bitcast %struct.TYPE_11__* %2 to i8*
%12 = call i32 @xcb_get_setup(i32* %5)
%13 = call %struct.TYPE_10__* @xcb_setup_roots_iterator(i32 %12)
%14 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %2, i64 0, i32 0
store %struct.TYPE_10__* %13, %struct.TYPE_10__** %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_10__*, %struct.TYPE_10__** %14
br label %19
19: ; preds = %17, %10
%20 = phi %struct.TYPE_10__* [ %18, %17 ], [ %13, %10 ]
%21 = icmp eq %struct.TYPE_10__* %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_11__* %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 ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @xcb_disconnect(i32* %5)
br label %63
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_10__, %struct.TYPE_10__* %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_10__, %struct.TYPE_10__* %20, i64 0, i32 3
%50 = load i32, i32* %49
%51 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %20, i64 0, i32 2
%52 = load i32, i32* %51
%53 = load i32, i32* @XCB_WINDOW_CLASS_INPUT_OUTPUT
%54 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %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 100, 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 @xcb_flush(i32* %5)
br label %61
61: ; preds = %61, %32
%62 = call %struct.TYPE_13__* @xcb_poll_for_event(i32* %5)
br label %61
63: ; preds = %28, %7
ret i32 -1
}