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

/* Type definitions */
typedef int /*<<< orphan*/ xcb_window_t;
typedef int /*<<< orphan*/ xcb_void_cookie_t;
struct TYPE_9__ {
  int white_pixel;
  int width_in_pixels;
  int height_in_pixels;
  int /*<<< orphan*/ root_visual;
  int /*<<< orphan*/ root;
  int /*<<< orphan*/ root_depth;
};
typedef TYPE_1__ xcb_screen_t;
struct TYPE_10__ {
  TYPE_1__ *data;
};
typedef TYPE_2__ xcb_screen_iterator_t;
struct TYPE_11__ {
  int /*<<< orphan*/ detail;
};
typedef TYPE_3__ xcb_key_release_event_t;
struct TYPE_12__ {
  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_CONFIG_WINDOW_X;
int XCB_CONFIG_WINDOW_Y;
int /*<<< orphan*/ XCB_CURRENT_TIME;
int XCB_CW_BACK_PIXEL;
int XCB_CW_EVENT_MASK;
#define XCB_ENTER_NOTIFY 131
#define XCB_EVENT_MASK_BUTTON_PRESS 130
int XCB_EVENT_MASK_EXPOSURE;
int XCB_EVENT_MASK_KEY_PRESS;
int XCB_EVENT_MASK_KEY_RELEASE;
int XCB_EVENT_MASK_POINTER_MOTION;
#define XCB_EXPOSE 129
int /*<<< orphan*/ XCB_INPUT_FOCUS_POINTER_ROOT;
#define XCB_KEY_RELEASE 128
int /*<<< orphan*/ XCB_WINDOW_CLASS_INPUT_OUTPUT;
int /*<<< orphan*/ drawText(int /*<<< orphan*/ *, TYPE_1__ *,
                            int /*<<< orphan*/, int /*<<< orphan*/, int,
                            char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(TYPE_4__ *);
int /*<<< orphan*/ setWindowProperties(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                       char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ testCookie(int /*<<< orphan*/, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ xcb_configure_window(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int, int *);
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, 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_set_input_focus_checked(int /*<<< orphan*/ *,
                                               int /*<<< orphan*/,
                                               int /*<<< orphan*/,
                                               int /*<<< orphan*/);
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));
  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_KEY_PRESS |
              XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_EXPOSURE |
              XCB_EVENT_MASK_POINTER_MOTION;
  values[0] = screen->width_in_pixels / 2 - 300 / 2;
  values[1] = screen->height_in_pixels / 2 - 100 / 2;
  xcb_void_cookie_t windowCookie = xcb_create_window_checked(
      connection, screen->root_depth, window, screen->root, values[0],
      values[1], 300, 100, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT,
      screen->root_visual, mask, values);
  testCookie(windowCookie, connection, "can't create window");
  char *title = "BMenu";
  setWindowProperties(connection, window, title);
  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: {
        xcb_void_cookie_t focus_cookie = xcb_set_input_focus_checked(
            connection, XCB_INPUT_FOCUS_POINTER_ROOT, window, XCB_CURRENT_TIME);
        testCookie(focus_cookie, connection, "Failed to grab focus.");
        drawText(connection, screen, window, 300 / 2 - strlen("BMenu"), 100 / 2,
                 "BMenu");
        break;
      }
      case XCB_ENTER_NOTIFY: {
        xcb_void_cookie_t focus_cookie = xcb_set_input_focus_checked(
            connection, XCB_INPUT_FOCUS_POINTER_ROOT, window, XCB_CURRENT_TIME);
        testCookie(focus_cookie, connection, "Failed to grab focus.\n");
      }
      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);
      }
      case XCB_EVENT_MASK_BUTTON_PRESS: {
        xcb_void_cookie_t focus_cookie = xcb_set_input_focus_checked(
            connection, XCB_INPUT_FOCUS_POINTER_ROOT, window, XCB_CURRENT_TIME);
        testCookie(focus_cookie, connection, "Failed to grab focus.\n");
        values[0] = values[0] - 10;
        values[1] = values[1] - 10;
        xcb_configure_window(connection, window,
                             XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
        xcb_void_cookie_t mapCookie =
            xcb_map_window_checked(connection, window);
        testCookie(mapCookie, connection, "Can't move the window, click \n");
        xcb_flush(connection);
        break;
      }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0xc8,%rsp
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
call   1040 <xcb_connect@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1260 <main+0x50>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    15db <main+0x3cb>
mov    -0x18(%rbp),%rdi
call   10f0 <xcb_get_setup@plt>
mov    %eax,%edi
call   1090 <xcb_setup_roots_iterator@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12b1 <main+0xa1>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <xcb_disconnect@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    15db <main+0x3cb>
mov    -0x18(%rbp),%rdi
call   1070 <xcb_generate_id@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2cfc(%rip),%rax
mov    (%rax),%eax
mov    0x2cc3(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2cb6(%rip),%rax
mov    (%rax),%eax
mov    0x2cc5(%rip),%rcx
or     (%rcx),%eax
or     $0x82,%eax
mov    0x2ccf(%rip),%rcx
or     (%rcx),%eax
mov    0x2ce6(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x96,%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x32,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x34(%rbp),%r9d
mov    0x2c89(%rip),%rax
mov    (%rax),%ebx
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%r11d
mov    -0x30(%rbp),%r10d
lea    -0x38(%rbp),%rax
movl   $0x12c,(%rsp)
movl   $0x64,0x8(%rsp)
movl   $0xa,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1110 <xcb_create_window_checked@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    0xcb1(%rip),%rdx
call   10c0 <testCookie@plt>
lea    0xcb9(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x48(%rbp),%rdx
call   1130 <setWindowProperties@plt>
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10b0 <xcb_map_window_checked@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    0xc8e(%rip),%rdx
call   10c0 <testCookie@plt>
mov    -0x18(%rbp),%rdi
call   1060 <xcb_flush@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <xcb_poll_for_event@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     15d6 <main+0x3c6>
mov    -0x58(%rbp),%rax
mov    (%rax),%eax
and    $0xffffff7f,%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x78(%rbp)
sub    $0x3,%eax
ja     15d1 <main+0x3c1>
mov    -0x78(%rbp),%rax
lea    0xbcd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
mov    0x2b59(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edx
mov    0x2b85(%rip),%rax
mov    (%rax),%ecx
call   1100 <xcb_set_input_focus_checked@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    0xc1a(%rip),%rdx
call   10c0 <testCookie@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
lea    0xbdb(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x7c(%rbp),%edx
mov    $0x96,%ecx
sub    %eax,%ecx
mov    $0x32,%r8d
lea    0xbb1(%rip),%r9
call   1120 <drawText@plt>
jmp    15d1 <main+0x3c1>
mov    -0x18(%rbp),%rdi
mov    0x2ace(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edx
mov    0x2afa(%rip),%rax
mov    (%rax),%ecx
call   1100 <xcb_set_input_focus_checked@plt>
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    0xba5(%rip),%rdx
call   10c0 <testCookie@plt>
mov    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    (%rax),%eax
sub    $0x9,%eax
jne    1535 <main+0x325>
jmp    1517 <main+0x307>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <xcb_disconnect@plt>
movl   $0x0,-0xc(%rbp)
jmp    15db <main+0x3cb>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
mov    0x2a57(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edx
mov    0x2a83(%rip),%rax
mov    (%rax),%ecx
call   1100 <xcb_set_input_focus_checked@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    0xb2e(%rip),%rdx
call   10c0 <testCookie@plt>
mov    -0x38(%rbp),%eax
sub    $0xa,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
sub    $0xa,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    0x29f6(%rip),%rax
mov    (%rax),%edx
mov    0x2a35(%rip),%rax
or     (%rax),%edx
lea    -0x38(%rbp),%rcx
call   1080 <xcb_configure_window@plt>
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10b0 <xcb_map_window_checked@plt>
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    0xaef(%rip),%rdx
call   10c0 <testCookie@plt>
mov    -0x18(%rbp),%rdi
call   1060 <xcb_flush@plt>
jmp    15d6 <main+0x3c6>
jmp    13f4 <main+0x1e4>
mov    -0xc(%rbp),%eax
add    $0xc8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rsi
xor    %edi,%edi
call   1030 <xcb_connect@plt>
test   %rax,%rax
je     12da <main+0x11a>
mov    %rax,%rbx
mov    %rax,%rdi
call   10c0 <xcb_get_setup@plt>
mov    %eax,%edi
call   1060 <xcb_setup_roots_iterator@plt>
test   %rax,%rax
je     12f1 <main+0x131>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <xcb_generate_id@plt>
mov    %eax,%r14d
mov    0x2dd3(%rip),%rcx
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x4(%rbp),%ecx
mov    %ecx,%r8d
shr    $0x1f,%r8d
add    %ecx,%r8d
sar    %r8d
add    $0xffffff6a,%r8d
mov    %r8d,0x4(%rsp)
mov    0x8(%rbp),%ecx
mov    %ecx,%r9d
shr    $0x1f,%r9d
add    %ecx,%r9d
sar    %r9d
add    $0xffffffce,%r9d
mov    %r9d,0x8(%rsp)
mov    0x14(%rbp),%esi
mov    0xc(%rbp),%r10d
mov    0x10(%rbp),%ecx
mov    0x2d8a(%rip),%rdx
mov    (%rdx),%ebp
sub    $0x8,%rsp
lea    0xc(%rsp),%r11
mov    %rbx,%rdi
mov    %r14d,%edx
push   %r11
push   %rax
push   %r10
push   %rbp
push   $0xa
push   $0x64
push   $0x12c
call   10d0 <xcb_create_window_checked@plt>
add    $0x40,%rsp
lea    0xdbc(%rip),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
call   1090 <testCookie@plt>
lea    0xdbf(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
call   10e0 <setWindowProperties@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1080 <xcb_map_window_checked@plt>
lea    0xda8(%rip),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
call   1090 <testCookie@plt>
mov    %rbx,%rdi
call   1040 <xcb_flush@plt>
xchg   %ax,%ax
mov    %rbx,%rdi
call   10a0 <xcb_poll_for_event@plt>
jmp    12d0 <main+0x110>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
lea    0xd16(%rip),%rsi
call   1070 <fprintf@plt>
jmp    130e <main+0x14e>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
lea    0xd24(%rip),%rsi
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   10b0 <xcb_disconnect@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.TYPE_9__ = type { i32, i32, i32, i32, i32, 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 = [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_KEY_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 = [6 x i8] c"BMenu\00"
@.str.4 = [17 x i8] c"can't map window\00"
@XCB_INPUT_FOCUS_POINTER_ROOT = global i32 0
@XCB_CURRENT_TIME = global i32 0
@XCB_CONFIG_WINDOW_X = global i32 0
@XCB_CONFIG_WINDOW_Y = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = bitcast i32* %1 to i8*
%4 = call i32* @xcb_connect(i32* null, i32* %1)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %48
9: ; preds = %0
%10 = call i32 @xcb_get_setup(i32* %4)
%11 = call %struct.TYPE_9__* @xcb_setup_roots_iterator(i32 %10)
%12 = icmp eq %struct.TYPE_9__* %11, null
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @xcb_disconnect(i32* %4)
br label %48
17: ; preds = %9
%18 = call i32 @xcb_generate_id(i32* %4)
%19 = load i32, i32* @XCB_CW_BACK_PIXEL
%20 = load i32, i32* @XCB_CW_EVENT_MASK
%21 = or i32 %20, %19
%22 = bitcast [2 x i32]* %2 to i8*
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%25 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %11, i64 0, i32 1
%26 = load i32, i32* %25
%27 = sdiv i32 %26, 2
%28 = add nsw i32 %27, -150
store i32 %28, i32* %23
%29 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %11, i64 0, i32 2
%30 = load i32, i32* %29
%31 = sdiv i32 %30, 2
%32 = add nsw i32 %31, -50
store i32 %32, i32* %24
%33 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %11, i64 0, i32 5
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %11, i64 0, i32 4
%36 = load i32, i32* %35
%37 = load i32, i32* @XCB_WINDOW_CLASS_INPUT_OUTPUT
%38 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %11, i64 0, i32 3
%39 = load i32, i32* %38
%40 = call i32 @xcb_create_window_checked(i32* %4, i32 %34, i32 %18, i32 %36, i32 %28, i32 %32, i32 300, i32 100, i32 10, i32 %37, i32 %39, i32 %21, i32* %23)
%41 = call i32 @testCookie(i32 %40, i32* %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @setWindowProperties(i32* %4, i32 %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @xcb_map_window_checked(i32* %4, i32 %18)
%44 = call i32 @testCookie(i32 %43, i32* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 @xcb_flush(i32* %4)
br label %46
46: ; preds = %46, %17
%47 = call %struct.TYPE_12__* @xcb_poll_for_event(i32* %4)
br label %46
48: ; preds = %13, %6
ret i32 -1
}