#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_9__ TYPE_5__;
typedef struct TYPE_8__ TYPE_3__;
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int /*<<< orphan*/ height_in_pixels;
  int /*<<< orphan*/ width_in_pixels;
  int /*<<< orphan*/ root;
};
typedef TYPE_1__ xcb_screen_t;
struct TYPE_7__ {
  int response_type;
};
typedef TYPE_2__ xcb_generic_event_t;
typedef int /*<<< orphan*/ xcb_drawable_t;
typedef int /*<<< orphan*/ xcb_connection_t;
struct TYPE_8__ {
  int detail;
  int /*<<< orphan*/ child;
};
typedef TYPE_3__ xcb_button_press_event_t;
typedef int /*<<< orphan*/ uint32_t;
struct TYPE_9__ {
  TYPE_1__ *data;
};

/* Variables and functions */
#define XCB_BUTTON_PRESS 129
#define XCB_BUTTON_RELEASE 128
int XCB_CONFIG_WINDOW_HEIGHT;
int XCB_CONFIG_WINDOW_STACK_MODE;
int XCB_CONFIG_WINDOW_WIDTH;
int /*<<< orphan*/ XCB_CURRENT_TIME;
int XCB_EVENT_MASK_BUTTON_PRESS;
int XCB_EVENT_MASK_BUTTON_RELEASE;
int /*<<< orphan*/ XCB_GRAB_MODE_ASYNC;
int /*<<< orphan*/ XCB_MOD_MASK_CONTROL;
int /*<<< orphan*/ XCB_NONE;
int /*<<< orphan*/ XCB_NO_SYMBOL;
int /*<<< orphan*/ XCB_STACK_MODE_BELOW;
int /*<<< orphan*/ xcb_configure_window(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ *xcb_connect(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ xcb_connection_has_error(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_flush(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_get_setup(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_grab_button(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ xcb_grab_key(int /*<<< orphan*/ *, int, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/);
TYPE_5__ xcb_setup_roots_iterator(int /*<<< orphan*/);
int /*<<< orphan*/ xcb_ungrab_pointer(int /*<<< orphan*/ *, int /*<<< orphan*/);
TYPE_2__ *xcb_wait_for_event(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  uint32_t values[5];
  xcb_connection_t *display;
  xcb_screen_t *screen;
  xcb_drawable_t window;
  xcb_drawable_t root;
  xcb_generic_event_t *event;
  display = xcb_connect(NULL, NULL);
  if (xcb_connection_has_error(display))
    return 1;
  screen = xcb_setup_roots_iterator(xcb_get_setup(display)).data;
  root = screen->root;
  xcb_grab_key(display, 1, root, XCB_MOD_MASK_CONTROL, XCB_NO_SYMBOL,
               XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
  xcb_grab_button(display, 0, root,
                  XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE,
                  XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, root, XCB_NONE, 3,
                  XCB_MOD_MASK_CONTROL);
  xcb_flush(display);
  for (;;) {
    event = xcb_wait_for_event(display);
    switch (event->response_type & ~0x80) {
    case XCB_BUTTON_PRESS: {
      xcb_button_press_event_t *e;
      e = (xcb_button_press_event_t *)event;
      window = e->child;
      if (3 == e->detail) {
        values[0] = XCB_STACK_MODE_BELOW;
        xcb_configure_window(display, window, XCB_CONFIG_WINDOW_STACK_MODE,
                             values);
        values[0] = screen->width_in_pixels;
        values[1] = screen->height_in_pixels;
        xcb_configure_window(display, window,
                             XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
                             values);
      }
      xcb_flush(display);
      break;
    }
    case XCB_BUTTON_RELEASE: {
      xcb_ungrab_pointer(display, XCB_CURRENT_TIME);
      xcb_flush(display);
      break;
    }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   1030 <xcb_connect@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10b0 <xcb_connection_has_error@plt>
cmp    $0x0,%rax
je     11ea <main+0x4a>
mov    $0x1,%eax
add    $0x90,%rsp
pop    %rbp
ret
mov    -0x38(%rbp),%rdi
call   10c0 <xcb_get_setup@plt>
mov    %eax,%edi
call   1070 <xcb_setup_roots_iterator@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%edx
mov    0x2d92(%rip),%rax
mov    (%rax),%ecx
mov    0x2da1(%rip),%rax
mov    (%rax),%r8d
mov    0x2d6f(%rip),%rax
mov    (%rax),%r9d
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    $0x1,%esi
mov    %eax,(%rsp)
call   1090 <xcb_grab_key@plt>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%edx
mov    0x2d40(%rip),%rax
mov    (%rax),%ecx
mov    0x2d27(%rip),%rax
or     (%rax),%ecx
mov    0x2d36(%rip),%rax
mov    (%rax),%r8d
mov    0x2d2c(%rip),%rax
mov    (%rax),%r9d
mov    -0x48(%rbp),%r11d
mov    0x2d76(%rip),%rax
mov    (%rax),%r10d
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
xor    %esi,%esi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
movl   $0x3,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1080 <xcb_grab_button@plt>
mov    -0x38(%rbp),%rdi
call   1040 <xcb_flush@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <xcb_wait_for_event@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
and    $0xffffff7f,%eax
mov    %eax,-0x64(%rbp)
sub    $0x80,%eax
je     137c <main+0x1dc>
jmp    12de <main+0x13e>
mov    -0x64(%rbp),%eax
sub    $0x81,%eax
jne    1397 <main+0x1f7>
jmp    12f1 <main+0x151>
mov    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x60(%rbp),%rcx
mov    $0x3,%eax
cmp    (%rcx),%eax
jne    136e <main+0x1ce>
mov    0x2cbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2c92(%rip),%rax
mov    (%rax),%edx
lea    -0x30(%rbp),%rcx
call   1060 <xcb_configure_window@plt>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2c4e(%rip),%rax
mov    (%rax),%edx
mov    0x2c85(%rip),%rax
or     (%rax),%edx
lea    -0x30(%rbp),%rcx
call   1060 <xcb_configure_window@plt>
mov    -0x38(%rbp),%rdi
call   1040 <xcb_flush@plt>
jmp    1397 <main+0x1f7>
mov    -0x38(%rbp),%rdi
mov    0x2c49(%rip),%rax
mov    (%rax),%esi
call   1050 <xcb_ungrab_pointer@plt>
mov    -0x38(%rbp),%rdi
call   1040 <xcb_flush@plt>
jmp    12b3 <main+0x113>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
xor    %esi,%esi
call   1030 <xcb_connect@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <xcb_connection_has_error@plt>
test   %rax,%rax
je     11b2 <main+0x32>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   10a0 <xcb_get_setup@plt>
mov    %eax,%edi
call   1050 <xcb_setup_roots_iterator@plt>
mov    0x8(%rax),%r14d
mov    0x2e04(%rip),%r15
mov    (%r15),%ecx
mov    0x2e0a(%rip),%rax
mov    (%rax),%r8d
mov    0x2de8(%rip),%r12
mov    (%r12),%r9d
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
push   %r9
call   1070 <xcb_grab_key@plt>
add    $0x10,%rsp
mov    0x2dbb(%rip),%rax
mov    0x2da4(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    (%r12),%r8d
mov    0x2ddd(%rip),%rax
mov    (%rax),%r10d
mov    (%r15),%eax
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14d,%edx
mov    %r8d,%r9d
push   %rax
push   $0x3
push   %r10
push   %r14
call   1060 <xcb_grab_button@plt>
add    $0x20,%rsp
mov    %rbx,%rdi
call   1040 <xcb_flush@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1080 <xcb_wait_for_event@plt>
jmp    1250 <main+0xd0>

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32, i32, i32 }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_9__ = type { %struct.TYPE_6__* }
%struct.TYPE_8__ = type { i32, i32 }
@XCB_MOD_MASK_CONTROL = global i32 0
@XCB_NO_SYMBOL = global i32 0
@XCB_GRAB_MODE_ASYNC = global i32 0
@XCB_EVENT_MASK_BUTTON_PRESS = global i32 0
@XCB_EVENT_MASK_BUTTON_RELEASE = global i32 0
@XCB_NONE = global i32 0
@XCB_STACK_MODE_BELOW = global i32 0
@XCB_CONFIG_WINDOW_STACK_MODE = global i32 0
@XCB_CONFIG_WINDOW_WIDTH = global i32 0
@XCB_CONFIG_WINDOW_HEIGHT = global i32 0
@XCB_CURRENT_TIME = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i32]
%7 = alloca i32*
%8 = alloca %struct.TYPE_6__*
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.TYPE_7__*
%12 = alloca %struct.TYPE_9__
%13 = alloca %struct.TYPE_8__*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32* @xcb_connect(i32* null, i32* null)
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = call i64 @xcb_connection_has_error(i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %2
ret i32 1
19: ; preds = %2
%20 = load i32*, i32** %7
%21 = call i32 @xcb_get_setup(i32* %20)
%22 = call %struct.TYPE_6__* @xcb_setup_roots_iterator(i32 %21)
%23 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %12, i32 0, i32 0
store %struct.TYPE_6__* %22, %struct.TYPE_6__** %23
%24 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %12, i32 0, i32 0
%25 = load %struct.TYPE_6__*, %struct.TYPE_6__** %24
store %struct.TYPE_6__* %25, %struct.TYPE_6__** %8
%26 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%27 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %26, i32 0, i32 2
%28 = load i32, i32* %27
store i32 %28, i32* %10
%29 = load i32*, i32** %7
%30 = load i32, i32* %10
%31 = load i32, i32* @XCB_MOD_MASK_CONTROL
%32 = load i32, i32* @XCB_NO_SYMBOL
%33 = load i32, i32* @XCB_GRAB_MODE_ASYNC
%34 = load i32, i32* @XCB_GRAB_MODE_ASYNC
%35 = call i32 @xcb_grab_key(i32* %29, i32 1, i32 %30, i32 %31, i32 %32, i32 %33, i32 %34)
%36 = load i32*, i32** %7
%37 = load i32, i32* %10
%38 = load i32, i32* @XCB_EVENT_MASK_BUTTON_PRESS
%39 = load i32, i32* @XCB_EVENT_MASK_BUTTON_RELEASE
%40 = or i32 %38, %39
%41 = load i32, i32* @XCB_GRAB_MODE_ASYNC
%42 = load i32, i32* @XCB_GRAB_MODE_ASYNC
%43 = load i32, i32* %10
%44 = load i32, i32* @XCB_NONE
%45 = load i32, i32* @XCB_MOD_MASK_CONTROL
%46 = call i32 @xcb_grab_button(i32* %36, i32 0, i32 %37, i32 %40, i32 %41, i32 %42, i32 %43, i32 %44, i32 3, i32 %45)
%47 = load i32*, i32** %7
%48 = call i32 @xcb_flush(i32* %47)
br label %49
49: ; preds = %98, %19
%50 = load i32*, i32** %7
%51 = call %struct.TYPE_7__* @xcb_wait_for_event(i32* %50)
store %struct.TYPE_7__* %51, %struct.TYPE_7__** %11
%52 = load %struct.TYPE_7__*, %struct.TYPE_7__** %11
%53 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = and i32 %54, -129
switch i32 %55, label %98 [
i32 129, label %56
i32 128, label %92
]
56: ; preds = %49
%57 = load %struct.TYPE_7__*, %struct.TYPE_7__** %11
%58 = bitcast %struct.TYPE_7__* %57 to %struct.TYPE_8__*
store %struct.TYPE_8__* %58, %struct.TYPE_8__** %13
%59 = load %struct.TYPE_8__*, %struct.TYPE_8__** %13
%60 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %59, i32 0, i32 1
%61 = load i32, i32* %60
store i32 %61, i32* %9
%62 = load %struct.TYPE_8__*, %struct.TYPE_8__** %13
%63 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %62, i32 0, i32 0
%64 = load i32, i32* %63
%65 = icmp eq i32 3, %64
br i1 %65, label %66, label %89
66: ; preds = %56
%67 = load i32, i32* @XCB_STACK_MODE_BELOW
%68 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
store i32 %67, i32* %68
%69 = load i32*, i32** %7
%70 = load i32, i32* %9
%71 = load i32, i32* @XCB_CONFIG_WINDOW_STACK_MODE
%72 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%73 = call i32 @xcb_configure_window(i32* %69, i32 %70, i32 %71, i32* %72)
%74 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%75 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %74, i32 0, i32 1
%76 = load i32, i32* %75
%77 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
store i32 %76, i32* %77
%78 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%79 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %78, i32 0, i32 0
%80 = load i32, i32* %79
%81 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 1
store i32 %80, i32* %81
%82 = load i32*, i32** %7
%83 = load i32, i32* %9
%84 = load i32, i32* @XCB_CONFIG_WINDOW_WIDTH
%85 = load i32, i32* @XCB_CONFIG_WINDOW_HEIGHT
%86 = or i32 %84, %85
%87 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%88 = call i32 @xcb_configure_window(i32* %82, i32 %83, i32 %86, i32* %87)
br label %89
89: ; preds = %66, %56
%90 = load i32*, i32** %7
%91 = call i32 @xcb_flush(i32* %90)
br label %98
92: ; preds = %49
%93 = load i32*, i32** %7
%94 = load i32, i32* @XCB_CURRENT_TIME
%95 = call i32 @xcb_ungrab_pointer(i32* %93, i32 %94)
%96 = load i32*, i32** %7
%97 = call i32 @xcb_flush(i32* %96)
br label %98
98: ; preds = %49, %92, %89
br label %49
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32, i32, i32 }
%struct.TYPE_7__ = type { i32 }
@XCB_MOD_MASK_CONTROL = global i32 0
@XCB_NO_SYMBOL = global i32 0
@XCB_GRAB_MODE_ASYNC = global i32 0
@XCB_EVENT_MASK_BUTTON_PRESS = global i32 0
@XCB_EVENT_MASK_BUTTON_RELEASE = global i32 0
@XCB_NONE = global i32 0
@XCB_STACK_MODE_BELOW = global i32 0
@XCB_CONFIG_WINDOW_STACK_MODE = global i32 0
@XCB_CONFIG_WINDOW_WIDTH = global i32 0
@XCB_CONFIG_WINDOW_HEIGHT = global i32 0
@XCB_CURRENT_TIME = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @xcb_connect(i32* null, i32* null)
%4 = tail call i64 @xcb_connection_has_error(i32* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %2
ret i32 1
7: ; preds = %2
%8 = tail call i32 @xcb_get_setup(i32* %3)
%9 = tail call %struct.TYPE_6__* @xcb_setup_roots_iterator(i32 %8)
%10 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %9, i64 0, i32 2
%11 = load i32, i32* %10
%12 = load i32, i32* @XCB_MOD_MASK_CONTROL
%13 = load i32, i32* @XCB_NO_SYMBOL
%14 = load i32, i32* @XCB_GRAB_MODE_ASYNC
%15 = tail call i32 @xcb_grab_key(i32* %3, i32 1, i32 %11, i32 %12, i32 %13, i32 %14, i32 %14)
%16 = load i32, i32* @XCB_EVENT_MASK_BUTTON_PRESS
%17 = load i32, i32* @XCB_EVENT_MASK_BUTTON_RELEASE
%18 = or i32 %17, %16
%19 = load i32, i32* @XCB_GRAB_MODE_ASYNC
%20 = load i32, i32* @XCB_NONE
%21 = load i32, i32* @XCB_MOD_MASK_CONTROL
%22 = tail call i32 @xcb_grab_button(i32* %3, i32 0, i32 %11, i32 %18, i32 %19, i32 %19, i32 %11, i32 %20, i32 3, i32 %21)
%23 = tail call i32 @xcb_flush(i32* %3)
br label %24
24: ; preds = %24, %7
%25 = tail call %struct.TYPE_7__* @xcb_wait_for_event(i32* %3)
br label %24
}