#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_10__ TYPE_4__;
typedef struct TYPE_9__ TYPE_3__;
typedef struct TYPE_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
struct TYPE_9__ {
  int event_mask;
  scalar_t__ override_redirect;
  int /*<<< orphan*/ background_pixel;
  int /*<<< orphan*/ border_pixel;
};
typedef TYPE_3__ XSetWindowAttributes;
struct TYPE_8__ {
  int x;
  int y;
  int state;
  int /*<<< orphan*/ button;
};
struct TYPE_7__ {
  int x;
  int y;
  int width;
  int height;
};
struct TYPE_10__ {
  int type;
  TYPE_2__ xbutton;
  int /*<<< orphan*/ xkey;
  TYPE_1__ xexpose;
};
typedef TYPE_4__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Atom;

/* Variables and functions */
int /*<<< orphan*/ BlackPixel(int /*<<< orphan*/ *, int);
#define Button1 138
#define Button2 137
#define Button3 136
#define Button4 135
#define Button5 134
#define ButtonPress 133
int ButtonPressMask;
int CWBackPixel;
int CWBorderPixel;
#define ClientMessage 132
#define ConfigureNotify 131
int ControlMask;
int /*<<< orphan*/ CopyFromParent;
int /*<<< orphan*/ DefaultDepth(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ DefaultGC(int /*<<< orphan*/ *, int);
int DefaultScreen(int /*<<< orphan*/ *);
#define Expose 130
int ExposureMask;
int /*<<< orphan*/ False;
int /*<<< orphan*/ InputOutput;
#define KeyPress 129
int KeyPressMask;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int);
int StructureNotifyMask;
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int, int, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/, int,
                                 TYPE_3__ *);
int /*<<< orphan*/ XFillRectangle(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int, int, int, int);
int /*<<< orphan*/ XInternAtom(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
#define XK_q 128
int /*<<< orphan*/ XLookupKeysym(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XLookupString(int /*<<< orphan*/ *, char *, int,
                                 int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_4__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSelectInput(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ XSetWMProtocols(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/ *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char buf[100];
  int i = 0;
  int x = 0;
  int r = 0;
  Display *d;
  Window w;
  XEvent e;
  XSetWindowAttributes wa;
  char *msg = "Hello, World!";
  int s;
  d = XOpenDisplay(NULL);
  if (d == NULL) {
    fprintf(stderr, "Cannot open display\n");
    exit(1);
  } else
    fprintf(stderr, "display sucessfully opened\n");
  s = DefaultScreen(d);
  wa.border_pixel = BlackPixel(d, s);
  wa.background_pixel = WhitePixel(d, s);
  wa.override_redirect = 0;
  wa.event_mask = ExposureMask | KeyPressMask;
  w = XCreateWindow(d, RootWindow(d, s), 10, 10, 300, 300, 1,
                    DefaultDepth(d, s), InputOutput, CopyFromParent,
                    CWBackPixel | CWBorderPixel, &wa);
  XSelectInput(d, w,
               ExposureMask | KeyPressMask | ButtonPressMask |
                   StructureNotifyMask);
  XMapWindow(d, w);
  Atom WM_DELETE_WINDOW = XInternAtom(d, "WM_DELETE_WINDOW", False);
  XSetWMProtocols(d, w, &WM_DELETE_WINDOW, 1);
  while (1) {
    XNextEvent(d, &e);
    switch (e.type) {
    case ConfigureNotify:
      break;
    case Expose:
      printf("expose %d %d %d %d %d\n", i++, e.xexpose.x, e.xexpose.y,
             e.xexpose.width, e.xexpose.height);
      XFillRectangle(d, w, DefaultGC(d, s), 75, 75, 150, 150);
      break;
    case KeyPress:
      XLookupString(&e.xkey, buf, 100, NULL, NULL);
      printf("keypress %s\n", buf);
      switch (XLookupKeysym(&e.xkey, 0)) {
      case XK_q:
        XCloseDisplay(d);
        exit(0);
        break;
      }
      break;
    case ClientMessage:
      XCloseDisplay(d);
      exit(0);
      break;
    case ButtonPress:
      printf("buttonpress %d %d\n", e.xbutton.x, e.xbutton.y);
      switch (e.xbutton.button) {
      case Button1:
        break;
      case Button2:
        break;
      case Button3:
        break;
      case Button4:
        printf("wheel up\n");
        break;
      case Button5:
        if (e.xbutton.state & ControlMask)
          printf("wheel down\n");
        break;
      }
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x170,%rsp
movl   $0x0,-0x14(%rbp)
mov    %edi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
lea    0xda7(%rip),%rax
mov    %rax,-0xf8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jne    12c5 <main+0x85>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xd80(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
call   1150 <DefaultScreen@plt>
mov    %eax,-0xfc(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0xfc(%rbp),%esi
call   1120 <BlackPixel@plt>
mov    %eax,-0xdc(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0xfc(%rbp),%esi
call   1070 <WhitePixel@plt>
mov    %eax,-0xe0(%rbp)
movq   $0x0,-0xe8(%rbp)
mov    0x2c6a(%rip),%rax
mov    (%rax),%eax
mov    0x2c89(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0xf0(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0xfc(%rbp),%esi
call   10f0 <RootWindow@plt>
mov    %eax,-0x104(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0xfc(%rbp),%esi
call   1110 <DefaultDepth@plt>
mov    -0x110(%rbp),%rdi
mov    -0x104(%rbp),%esi
mov    %eax,%r14d
mov    0x2c12(%rip),%rax
mov    (%rax),%ebx
mov    0x2bf9(%rip),%rax
mov    (%rax),%r11d
mov    0x2c3f(%rip),%rax
mov    (%rax),%r10d
mov    0x2c45(%rip),%rax
or     (%rax),%r10d
mov    $0xa,%ecx
mov    $0x12c,%r9d
lea    -0xf0(%rbp),%rax
mov    %ecx,%edx
mov    %r9d,%r8d
movl   $0x1,(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebx,0x10(%rsp)
mov    %r11d,0x18(%rsp)
mov    %r10d,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   10e0 <XCreateWindow@plt>
mov    %eax,-0xac(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0xac(%rbp),%esi
mov    0x2b95(%rip),%rax
mov    (%rax),%edx
mov    0x2bb4(%rip),%rax
or     (%rax),%edx
mov    0x2bb3(%rip),%rax
or     (%rax),%edx
mov    0x2b92(%rip),%rax
or     (%rax),%edx
call   1100 <XSelectInput@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xac(%rbp),%esi
call   1130 <XMapWindow@plt>
mov    -0xa8(%rbp),%rdi
mov    0x2b8b(%rip),%rax
mov    (%rax),%edx
lea    0xc19(%rip),%rsi
call   10c0 <XInternAtom@plt>
mov    %eax,-0x100(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0xac(%rbp),%esi
lea    -0x100(%rbp),%rdx
mov    $0x1,%ecx
call   10a0 <XSetWMProtocols@plt>
mov    -0xa8(%rbp),%rdi
lea    -0xd8(%rbp),%rsi
call   10b0 <XNextEvent@plt>
mov    -0xd8(%rbp),%eax
add    $0xffffff7f,%eax
mov    %eax,%ecx
mov    %rcx,-0x118(%rbp)
sub    $0x4,%eax
ja     1691 <main+0x451>
mov    -0x118(%rbp),%rax
lea    0xb4b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1691 <main+0x451>
mov    -0x94(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
mov    -0xc0(%rbp),%edx
mov    -0xbc(%rbp),%ecx
mov    -0xb8(%rbp),%r8d
mov    -0xb4(%rbp),%r9d
lea    0xb83(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xa8(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0xac(%rbp),%eax
mov    %eax,-0x11c(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0xfc(%rbp),%esi
call   1040 <DefaultGC@plt>
mov    -0x128(%rbp),%rdi
mov    -0x11c(%rbp),%esi
mov    %eax,%edx
mov    $0x4b,%r8d
mov    $0x96,%r9d
mov    %r8d,%ecx
movl   $0x96,(%rsp)
call   1050 <XFillRectangle@plt>
jmp    1691 <main+0x451>
lea    -0xc4(%rbp),%rdi
mov    %rdi,-0x138(%rbp)
xor    %eax,%eax
mov    %eax,-0x12c(%rbp)
mov    %eax,%r8d
lea    -0x90(%rbp),%rsi
mov    %rsi,-0x140(%rbp)
mov    $0x64,%edx
mov    %r8,%rcx
call   1030 <XLookupString@plt>
mov    -0x140(%rbp),%rsi
mov    -0x12c(%rbp),%eax
lea    0xaf0(%rip),%rdi
call   1060 <printf@plt>
mov    -0x138(%rbp),%rdi
mov    -0x12c(%rbp),%esi
call   10d0 <XLookupKeysym@plt>
sub    $0x80,%eax
jne    15d9 <main+0x399>
jmp    15c6 <main+0x386>
mov    -0xa8(%rbp),%rdi
call   1160 <XCloseDisplay@plt>
xor    %edi,%edi
call   1140 <exit@plt>
jmp    1691 <main+0x451>
mov    -0xa8(%rbp),%rdi
call   1160 <XCloseDisplay@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    -0xd4(%rbp),%esi
mov    -0xd0(%rbp),%edx
lea    0xa98(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0xc8(%rbp),%eax
add    $0xffffff7a,%eax
mov    %eax,%ecx
mov    %rcx,-0x148(%rbp)
sub    $0x4,%eax
ja     168c <main+0x44c>
mov    -0x148(%rbp),%rax
lea    0x9de(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    168c <main+0x44c>
jmp    168c <main+0x44c>
jmp    168c <main+0x44c>
lea    0xa5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    168c <main+0x44c>
mov    -0xcc(%rbp),%eax
mov    0x296a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1687 <main+0x447>
lea    0xa39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    168c <main+0x44c>
jmp    1691 <main+0x451>
jmp    1477 <main+0x237>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
xor    %edi,%edi
call   1090 <XOpenDisplay@plt>
mov    %rax,%rbx
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
test   %rbx,%rbx
je     14f9 <main+0x2a9>
lea    0xda5(%rip),%rsi
call   10a0 <fprintf@plt>
mov    %rbx,%rdi
call   1160 <DefaultScreen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1130 <BlackPixel@plt>
mov    %eax,0x5c(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <WhitePixel@plt>
mov    %eax,0x58(%rsp)
movq   $0x0,0x50(%rsp)
mov    0x2cd9(%rip),%r14
mov    0x2cfa(%rip),%r15
mov    (%r15),%eax
or     (%r14),%eax
mov    %eax,0x48(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1100 <RootWindow@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %ebp,0xc(%rsp)
mov    %ebp,%esi
call   1120 <DefaultDepth@plt>
mov    0x2cae(%rip),%rcx
mov    (%rcx),%r10d
mov    0x2c94(%rip),%rcx
mov    (%rcx),%r11d
mov    0x2cda(%rip),%rcx
mov    0x2ce3(%rip),%rdx
mov    (%rdx),%ebp
or     (%rcx),%ebp
lea    0x48(%rsp),%r13
mov    %rbx,%rdi
mov    %r12d,%esi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0x12c,%r8d
mov    $0x12c,%r9d
push   %r13
push   %rbp
push   %r11
push   %r10
push   %rax
push   $0x1
call   10f0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    (%r15),%edx
or     (%r14),%edx
mov    0x2c76(%rip),%rcx
or     (%rcx),%edx
mov    %eax,%ebp
mov    0x2c53(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1110 <XSelectInput@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1140 <XMapWindow@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edx
lea    0xcc2(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <XInternAtom@plt>
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdx
mov    %rbx,%rdi
mov    %ebp,0x8(%rsp)
mov    %ebp,%esi
mov    $0x1,%ecx
call   10b0 <XSetWMProtocols@plt>
lea    0x34(%rsp),%r12
lea    0x20(%rsp),%rbp
mov    $0xffffff7f,%r14d
lea    0xc42(%rip),%r15
lea    0x60(%rsp),%r13
xor    %eax,%eax
jmp    1438 <main+0x1e8>
nopw   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rsi
lea    0x1(%rsi),%eax
mov    %eax,0x10(%rsp)
mov    0x38(%rsp),%edx
mov    0x3c(%rsp),%ecx
mov    0x40(%rsp),%r8d
mov    0x44(%rsp),%r9d
lea    0xc61(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    0xc(%rsp),%esi
call   1050 <DefaultGC@plt>
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    0x10(%rsp),%esi
mov    %eax,%edx
mov    $0x4b,%ecx
mov    $0x4b,%r8d
mov    $0x96,%r9d
push   $0x96
call   1060 <XFillRectangle@plt>
add    $0x10,%rsp
mov    0x10(%rsp),%eax
mov    %rax,0x18(%rsp)
jmp    1477 <main+0x227>
nop
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <XLookupString@plt>
lea    0xc11(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
xor    %esi,%esi
call   10e0 <XLookupKeysym@plt>
cmp    $0x80,%eax
je     14ea <main+0x29a>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10c0 <XNextEvent@plt>
mov    0x20(%rsp),%eax
add    %r14d,%eax
cmp    $0x4,%eax
ja     1477 <main+0x227>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    0x24(%rsp),%esi
mov    0x28(%rsp),%edx
lea    0xbd4(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x30(%rsp),%eax
cmp    $0x86,%eax
je     14cd <main+0x27d>
cmp    $0x87,%eax
jne    1477 <main+0x227>
lea    0xbc7(%rip),%rdi
call   1040 <puts@plt>
jmp    1477 <main+0x227>
mov    0x2b04(%rip),%rax
mov    (%rax),%eax
test   %eax,0x2c(%rsp)
je     1477 <main+0x227>
lea    0xbb3(%rip),%rdi
call   1040 <puts@plt>
jmp    1477 <main+0x227>
mov    %rbx,%rdi
call   1170 <XCloseDisplay@plt>
xor    %edi,%edi
call   1150 <exit@plt>
lea    0xb14(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_10__ = type { i32, %struct.TYPE_8__, i32, %struct.TYPE_7__ }
%struct.TYPE_8__ = type { i32, i32, i32, i32 }
%struct.TYPE_7__ = type { i32, i32, i32, i32 }
%struct.TYPE_9__ = type { i32, i64, i32, i32 }
@.str = [14 x i8] c"Hello, World!\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"Cannot open display\0A\00"
@.str.2 = [28 x i8] c"display sucessfully opened\0A\00"
@ExposureMask = global i32 0
@KeyPressMask = global i32 0
@InputOutput = global i32 0
@CopyFromParent = global i32 0
@CWBackPixel = global i32 0
@CWBorderPixel = global i32 0
@ButtonPressMask = global i32 0
@StructureNotifyMask = global i32 0
@.str.3 = [17 x i8] c"WM_DELETE_WINDOW\00"
@False = global i32 0
@.str.4 = [23 x i8] c"expose %d %d %d %d %d\0A\00"
@.str.5 = [13 x i8] c"keypress %s\0A\00"
@.str.6 = [19 x i8] c"buttonpress %d %d\0A\00"
@.str.7 = [10 x i8] c"wheel up\0A\00"
@ControlMask = global i32 0
@.str.8 = [12 x i8] c"wheel down\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca %struct.TYPE_10__
%13 = alloca %struct.TYPE_9__
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %14
%17 = call i32* @XOpenDisplay(i32* null)
store i32* %17, i32** %10
%18 = load i32*, i32** %10
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %24
%28 = load i32*, i32** %10
%29 = call i32 @DefaultScreen(i32* %28)
store i32 %29, i32* %15
%30 = load i32*, i32** %10
%31 = load i32, i32* %15
%32 = call i32 @BlackPixel(i32* %30, i32 %31)
%33 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %13, i32 0, i32 3
store i32 %32, i32* %33
%34 = load i32*, i32** %10
%35 = load i32, i32* %15
%36 = call i32 @WhitePixel(i32* %34, i32 %35)
%37 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %13, i32 0, i32 2
store i32 %36, i32* %37
%38 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %13, i32 0, i32 1
store i64 0, i64* %38
%39 = load i32, i32* @ExposureMask
%40 = load i32, i32* @KeyPressMask
%41 = or i32 %39, %40
%42 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %13, i32 0, i32 0
store i32 %41, i32* %42
%43 = load i32*, i32** %10
%44 = load i32*, i32** %10
%45 = load i32, i32* %15
%46 = call i32 @RootWindow(i32* %44, i32 %45)
%47 = load i32*, i32** %10
%48 = load i32, i32* %15
%49 = call i32 @DefaultDepth(i32* %47, i32 %48)
%50 = load i32, i32* @InputOutput
%51 = load i32, i32* @CopyFromParent
%52 = load i32, i32* @CWBackPixel
%53 = load i32, i32* @CWBorderPixel
%54 = or i32 %52, %53
%55 = call i32 @XCreateWindow(i32* %43, i32 %46, i32 10, i32 10, i32 300, i32 300, i32 1, i32 %49, i32 %50, i32 %51, i32 %54, %struct.TYPE_9__* %13)
store i32 %55, i32* %11
%56 = load i32*, i32** %10
%57 = load i32, i32* %11
%58 = load i32, i32* @ExposureMask
%59 = load i32, i32* @KeyPressMask
%60 = or i32 %58, %59
%61 = load i32, i32* @ButtonPressMask
%62 = or i32 %60, %61
%63 = load i32, i32* @StructureNotifyMask
%64 = or i32 %62, %63
%65 = call i32 @XSelectInput(i32* %56, i32 %57, i32 %64)
%66 = load i32*, i32** %10
%67 = load i32, i32* %11
%68 = call i32 @XMapWindow(i32* %66, i32 %67)
%69 = load i32*, i32** %10
%70 = load i32, i32* @False
%71 = call i32 @XInternAtom(i32* %69, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %70)
store i32 %71, i32* %16
%72 = load i32*, i32** %10
%73 = load i32, i32* %11
%74 = call i32 @XSetWMProtocols(i32* %72, i32 %73, i32* %16, i32 1)
br label %75
75: ; preds = %27, %147
%76 = load i32*, i32** %10
%77 = call i32 @XNextEvent(i32* %76, %struct.TYPE_10__* %12)
%78 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 0
%79 = load i32, i32* %78
switch i32 %79, label %147 [
i32 131, label %80
i32 130, label %81
i32 129, label %103
i32 132, label %116
i32 133, label %120
]
80: ; preds = %75
br label %147
81: ; preds = %75
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
%84 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 3
%85 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %84, i32 0, i32 0
%86 = load i32, i32* %85
%87 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 3
%88 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %87, i32 0, i32 1
%89 = load i32, i32* %88
%90 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 3
%91 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %90, i32 0, i32 2
%92 = load i32, i32* %91
%93 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 3
%94 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %93, i32 0, i32 3
%95 = load i32, i32* %94
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %82, i32 %86, i32 %89, i32 %92, i32 %95)
%97 = load i32*, i32** %10
%98 = load i32, i32* %11
%99 = load i32*, i32** %10
%100 = load i32, i32* %15
%101 = call i32 @DefaultGC(i32* %99, i32 %100)
%102 = call i32 @XFillRectangle(i32* %97, i32 %98, i32 %101, i32 75, i32 75, i32 150, i32 150)
br label %147
103: ; preds = %75
%104 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 2
%105 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%106 = call i32 @XLookupString(i32* %104, i8* %105, i32 100, i32* null, i32* null)
%107 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %107)
%109 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 2
%110 = call i32 @XLookupKeysym(i32* %109, i32 0)
switch i32 %110, label %115 [
i32 128, label %111
]
111: ; preds = %103
%112 = load i32*, i32** %10
%113 = call i32 @XCloseDisplay(i32* %112)
%114 = call i32 @exit(i32 0)
unreachable
115: ; preds = %103
br label %147
116: ; preds = %75
%117 = load i32*, i32** %10
%118 = call i32 @XCloseDisplay(i32* %117)
%119 = call i32 @exit(i32 0)
unreachable
120: ; preds = %75
%121 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 1
%122 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %121, i32 0, i32 0
%123 = load i32, i32* %122
%124 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 1
%125 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %124, i32 0, i32 1
%126 = load i32, i32* %125
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %123, i32 %126)
%128 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 1
%129 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %128, i32 0, i32 3
%130 = load i32, i32* %129
switch i32 %130, label %146 [
i32 138, label %131
i32 137, label %132
i32 136, label %133
i32 135, label %134
i32 134, label %136
]
131: ; preds = %120
br label %146
132: ; preds = %120
br label %146
133: ; preds = %120
br label %146
134: ; preds = %120
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %146
136: ; preds = %120
%137 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i32 0, i32 1
%138 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %137, i32 0, i32 2
%139 = load i32, i32* %138
%140 = load i32, i32* @ControlMask
%141 = and i32 %139, %140
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %145
143: ; preds = %136
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
br label %145
145: ; preds = %143, %136
br label %146
146: ; preds = %120, %145, %134, %133, %132, %131
br label %147
147: ; preds = %75, %146, %115, %81, %80
br label %75
}

LLVM IR (-O2):
%struct.TYPE_10__ = type { i32, %struct.TYPE_8__, i32, %struct.TYPE_7__ }
%struct.TYPE_8__ = type { i32, i32, i32, i32 }
%struct.TYPE_7__ = type { i32, i32, i32, i32 }
%struct.TYPE_9__ = type { i32, i64, i32, i32 }
@stderr = global i32 0
@.str.1 = [21 x i8] c"Cannot open display\0A\00"
@.str.2 = [28 x i8] c"display sucessfully opened\0A\00"
@ExposureMask = global i32 0
@KeyPressMask = global i32 0
@InputOutput = global i32 0
@CopyFromParent = global i32 0
@CWBackPixel = global i32 0
@CWBorderPixel = global i32 0
@ButtonPressMask = global i32 0
@StructureNotifyMask = global i32 0
@.str.3 = [17 x i8] c"WM_DELETE_WINDOW\00"
@False = global i32 0
@.str.4 = [23 x i8] c"expose %d %d %d %d %d\0A\00"
@.str.5 = [13 x i8] c"keypress %s\0A\00"
@.str.6 = [19 x i8] c"buttonpress %d %d\0A\00"
@ControlMask = global i32 0
@str = [9 x i8] c"wheel up\00"
@str.9 = [11 x i8] c"wheel down\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca %struct.TYPE_10__
%5 = alloca %struct.TYPE_9__
%6 = alloca i32
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.TYPE_10__* %4 to i8*
%9 = bitcast %struct.TYPE_9__* %5 to i8*
%10 = tail call i32* @XOpenDisplay(i32* null)
%11 = icmp eq i32* %10, null
%12 = load i32, i32* @stderr
br i1 %11, label %13, label %16
13: ; preds = %2
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @DefaultScreen(i32* %10)
%19 = tail call i32 @BlackPixel(i32* %10, i32 %18)
%20 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %5, i64 0, i32 3
store i32 %19, i32* %20
%21 = tail call i32 @WhitePixel(i32* %10, i32 %18)
%22 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %5, i64 0, i32 2
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %5, i64 0, i32 1
store i64 0, i64* %23
%24 = load i32, i32* @ExposureMask
%25 = load i32, i32* @KeyPressMask
%26 = or i32 %25, %24
%27 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %5, i64 0, i32 0
store i32 %26, i32* %27
%28 = tail call i32 @RootWindow(i32* %10, i32 %18)
%29 = tail call i32 @DefaultDepth(i32* %10, i32 %18)
%30 = load i32, i32* @InputOutput
%31 = load i32, i32* @CopyFromParent
%32 = load i32, i32* @CWBackPixel
%33 = load i32, i32* @CWBorderPixel
%34 = or i32 %33, %32
%35 = call i32 @XCreateWindow(i32* %10, i32 %28, i32 10, i32 10, i32 300, i32 300, i32 1, i32 %29, i32 %30, i32 %31, i32 %34, %struct.TYPE_9__* %5)
%36 = load i32, i32* @ExposureMask
%37 = load i32, i32* @KeyPressMask
%38 = or i32 %37, %36
%39 = load i32, i32* @ButtonPressMask
%40 = or i32 %38, %39
%41 = load i32, i32* @StructureNotifyMask
%42 = or i32 %40, %41
%43 = call i32 @XSelectInput(i32* %10, i32 %35, i32 %42)
%44 = call i32 @XMapWindow(i32* %10, i32 %35)
%45 = bitcast i32* %6 to i8*
%46 = load i32, i32* @False
%47 = call i32 @XInternAtom(i32* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %46)
store i32 %47, i32* %6
%48 = call i32 @XSetWMProtocols(i32* %10, i32 %35, i32* %6, i32 1)
%49 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 0
%50 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 2
%51 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 3, i32 0
%52 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 3, i32 1
%53 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 3, i32 2
%54 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 3, i32 3
%55 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 1, i32 0
%56 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 1, i32 1
%57 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 1, i32 3
%58 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i64 0, i32 1, i32 2
br label %59
59: ; preds = %64, %16
%60 = phi i32 [ %65, %64 ], [ 0, %16 ]
br label %61
61: ; preds = %91, %59
%62 = call i32 @XNextEvent(i32* %10, %struct.TYPE_10__* %4)
%63 = load i32, i32* %49
switch i32 %63, label %91 [
i32 133, label %84
i32 130, label %64
i32 129, label %73
i32 132, label %81
]
64: ; preds = %61
%65 = add nuw nsw i32 %60, 1
%66 = load i32, i32* %51
%67 = load i32, i32* %52
%68 = load i32, i32* %53
%69 = load i32, i32* %54
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %60, i32 %66, i32 %67, i32 %68, i32 %69)
%71 = call i32 @DefaultGC(i32* %10, i32 %18)
%72 = call i32 @XFillRectangle(i32* %10, i32 %35, i32 %71, i32 75, i32 75, i32 150, i32 150)
br label %59
73: ; preds = %61
%74 = call i32 @XLookupString(i32* %50, i8* %7, i32 100, i32* null, i32* null)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%76 = call i32 @XLookupKeysym(i32* %50, i32 0)
%77 = icmp eq i32 %76, 128
br i1 %77, label %78, label %91
78: ; preds = %73
%79 = call i32 @XCloseDisplay(i32* %10)
%80 = call i32 @exit(i32 0)
unreachable
81: ; preds = %61
%82 = call i32 @XCloseDisplay(i32* %10)
%83 = call i32 @exit(i32 0)
unreachable
84: ; preds = %61
%85 = load i32, i32* %55
%86 = load i32, i32* %56
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %85, i32 %86)
%88 = load i32, i32* %57
switch i32 %88, label %91 [
i32 134, label %92
i32 135, label %89
]
89: ; preds = %84
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %91
91: ; preds = %89, %84, %97, %92, %73, %61
br label %61
92: ; preds = %84
%93 = load i32, i32* %58
%94 = load i32, i32* @ControlMask
%95 = and i32 %94, %93
%96 = icmp eq i32 %95, 0
br i1 %96, label %91, label %97
97: ; preds = %92
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0))
br label %91
}