#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_7__ {
  int /*<<< orphan*/ keycode;
};
typedef TYPE_1__ XKeyEvent;
struct TYPE_8__ {
  int foreground;
  int line_width;
  int /*<<< orphan*/ subwindow_mode;
  int /*<<< orphan*/ clip_mask;
  scalar_t__ clip_y_origin;
  scalar_t__ clip_x_origin;
  int /*<<< orphan*/ graphics_exposures;
  int /*<<< orphan*/ fill_rule;
  int /*<<< orphan*/ fill_style;
  int /*<<< orphan*/ join_style;
  int /*<<< orphan*/ cap_style;
  int /*<<< orphan*/ line_style;
  int /*<<< orphan*/ background;
  int /*<<< orphan*/ plane_mask;
  int /*<<< orphan*/ function;
};
typedef TYPE_2__ XGCValues;
struct TYPE_9__ {
  int type;
};
typedef TYPE_3__ XEvent;
struct TYPE_10__ {
  int button;
  int x_root;
  int y_root;
};
typedef TYPE_4__ XButtonEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Screen;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Cursor;

/* Variables and functions */
int /*<<< orphan*/ AllPlanes;
int /*<<< orphan*/ BlackPixel(int /*<<< orphan*/ *, int);
int Button1MotionMask;
int ButtonMotionMask;
#define ButtonPress 131
int ButtonPressMask;
#define ButtonRelease 130
int ButtonReleaseMask;
int /*<<< orphan*/ CapButt;
int /*<<< orphan*/ CurrentTime;
int DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ False;
int /*<<< orphan*/ FillOpaqueStippled;
int GCBackground;
int GCCapStyle;
int GCClipMask;
int GCClipXOrigin;
int GCClipYOrigin;
int GCFillRule;
int GCFillStyle;
int GCForeground;
int GCFunction;
int GCGraphicsExposures;
int GCJoinStyle;
int GCLineStyle;
int GCLineWidth;
int GCPlaneMask;
int GCSubwindowMode;
int /*<<< orphan*/ GXxor;
int /*<<< orphan*/ GrabModeAsync;
int /*<<< orphan*/ GrabModeSync;
int GrabSuccess;
int /*<<< orphan*/ IncludeInferiors;
int /*<<< orphan*/ JoinMiter;
#define KeyPress 129
int KeyPressMask;
int /*<<< orphan*/ LineSolid;
#define MotionNotify 128
int /*<<< orphan*/ None;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ SyncPointer;
int /*<<< orphan*/ WindingRule;
int /*<<< orphan*/ XAllowEvents(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ XC_crosshair;
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCreateFontCursor(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateGC(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                             TYPE_2__ *);
int /*<<< orphan*/ XDrawLine(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int, int, int, int);
int /*<<< orphan*/ XDrawRectangle(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int, int, int, int);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int XGrabKeyboard(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
                  int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int XGrabPointer(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
                 int, int /*<<< orphan*/, int /*<<< orphan*/,
                 int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/);
int /*<<< orphan*/ XScreenNumberOfScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XScreenOfDisplay(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XUngrabServer(int /*<<< orphan*/ *);
int /*<<< orphan*/ XWindowEvent(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                TYPE_3__ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int main() {
  Display *display;
  int screen_num;
  Screen *screen;
  Window root_win;
  XGCValues gc_val;
  XEvent report;
  XButtonEvent *xb = (XButtonEvent *)&report;
  XKeyEvent *xk = (XKeyEvent *)&report;
  int status, x, y, oldx = -1, oldy = -1;
  Cursor cursor;
  display = XOpenDisplay(0);
  if (display == NULL) {
    perror("Cannot connect to X server");
    exit(-1);
  }
  screen_num = DefaultScreen(display);
  screen = XScreenOfDisplay(display, screen_num);
  root_win = RootWindow(display, XScreenNumberOfScreen(screen));
  cursor = XCreateFontCursor(display, XC_crosshair);
  status =
      XGrabPointer(display, root_win, False,
                   ButtonReleaseMask | ButtonPressMask | Button1MotionMask,
                   GrabModeSync, GrabModeAsync, root_win, cursor, CurrentTime);
  if (status != GrabSuccess) {
    perror("Can't grab the mouse");
    exit(-1);
  }
  status = XGrabKeyboard(display, root_win, False, GrabModeSync, GrabModeAsync,
                         CurrentTime);
  if (status != GrabSuccess) {
    perror("Can't grab the keyboard");
    exit(-1);
  }
  gc_val.function = GXxor;
  gc_val.plane_mask = AllPlanes;
  gc_val.foreground = 0x00ff0000L;
  gc_val.background = BlackPixel(display, screen_num);
  gc_val.line_width = 3;
  gc_val.line_style = LineSolid;
  gc_val.cap_style = CapButt;
  gc_val.join_style = JoinMiter;
  gc_val.fill_style = FillOpaqueStippled;
  gc_val.fill_rule = WindingRule;
  gc_val.graphics_exposures = False;
  gc_val.clip_x_origin = 0;
  gc_val.clip_y_origin = 0;
  gc_val.clip_mask = None;
  gc_val.subwindow_mode = IncludeInferiors;
  GC gc_red = XCreateGC(display, root_win,
                        GCFunction | GCPlaneMask | GCForeground | GCBackground |
                            GCLineWidth | GCLineStyle | GCCapStyle |
                            GCJoinStyle | GCFillStyle | GCFillRule |
                            GCGraphicsExposures | GCClipXOrigin |
                            GCClipYOrigin | GCClipMask | GCSubwindowMode,
                        &gc_val);
  gc_val.foreground = 0x0000ff00L;
  GC gc_green = XCreateGC(display, root_win,
                          GCFunction | GCPlaneMask | GCForeground |
                              GCBackground | GCLineWidth | GCLineStyle |
                              GCCapStyle | GCJoinStyle | GCFillStyle |
                              GCFillRule | GCGraphicsExposures | GCClipXOrigin |
                              GCClipYOrigin | GCClipMask | GCSubwindowMode,
                          &gc_val);
  gc_val.foreground = 0x000000ffL;
  GC gc_blue = XCreateGC(display, root_win,
                         GCFunction | GCPlaneMask | GCForeground |
                             GCBackground | GCLineWidth | GCLineStyle |
                             GCCapStyle | GCJoinStyle | GCFillStyle |
                             GCFillRule | GCGraphicsExposures | GCClipXOrigin |
                             GCClipYOrigin | GCClipMask | GCSubwindowMode,
                         &gc_val);
  GC *gc_cur = &gc_red;
  do {
    XAllowEvents(display, SyncPointer, CurrentTime);
    XWindowEvent(display, root_win,
                 ButtonMotionMask | KeyPressMask | ButtonPressMask |
                     ButtonReleaseMask,
                 &report);
    switch (report.type) {
    case KeyPress:
      switch (xk->keycode) {
      case 9:
        goto End;
        break;
      case 27:
        gc_cur = &gc_red;
        break;
      case 42:
        gc_cur = &gc_green;
        break;
      case 56:
        gc_cur = &gc_blue;
        break;
      }
      break;
    case MotionNotify:
      xb->button = 1;
    case ButtonPress:
      x = xb->x_root, y = xb->y_root;
      switch (xb->button) {
      case 1:
        if (oldx > -1 && oldy > -1)
          XDrawLine(display, root_win, *gc_cur, oldx, oldy, x, y);
        oldx = x;
        oldy = y;
        break;
      case 2:
        if (oldx > -1 && oldy > -1) {
          int lx, ly, rx, ry;
          lx = (oldx < x) ? oldx : x;
          ly = (oldy < y) ? oldy : y;
          rx = (oldx > x) ? oldx : x;
          ry = (oldy > y) ? oldy : y;
          XDrawRectangle(display, root_win, *gc_cur, lx, ly, rx - lx, ry - ly);
          oldx = -1;
          oldy = -1;
        } else {
          oldx = x;
          oldy = y;
        }
        break;
      case 3:
        if (oldx > -1 && oldy > -1)
          XDrawLine(display, root_win, *gc_cur, oldx, oldy, x, y);
        oldx = x;
        oldy = y;
        break;
      }
      break;
    case ButtonRelease:
      if (xb->button == 1) {
        oldx = -1;
        oldy = -1;
      }
      break;
    }
  } while (1);
End:
  XFlush(display);
  XUngrabServer(display);
  XCloseDisplay(display);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x78(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x78(%rbp),%rax
mov    %rax,-0x88(%rbp)
movl   $0xffffffff,-0x98(%rbp)
ff ff ff
movl   $0xffffffff,-0x9c(%rbp)
ff ff ff
xor    %edi,%edi
call   2070 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    2295 <main+0x65>
lea    0xd8a(%rip),%rdi
call   20e0 <perror@plt>
mov    $0xffffffff,%edi
call   2100 <exit@plt>
mov    -0x10(%rbp),%rdi
call   2110 <DefaultScreen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   20b0 <XScreenOfDisplay@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x20(%rbp),%rdi
call   2140 <XScreenNumberOfScreen@plt>
mov    -0xd0(%rbp),%rdi
mov    %eax,%esi
call   2090 <RootWindow@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2c9f(%rip),%rax
mov    (%rax),%esi
call   2050 <XCreateFontCursor@plt>
mov    %eax,-0xa0(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2ccc(%rip),%rax
mov    (%rax),%edx
mov    0x2c33(%rip),%rax
mov    (%rax),%ecx
mov    0x2c82(%rip),%rax
or     (%rax),%ecx
mov    0x2c89(%rip),%rax
or     (%rax),%ecx
mov    0x2c78(%rip),%rax
mov    (%rax),%r8d
mov    0x2c1e(%rip),%rax
mov    (%rax),%r9d
mov    -0x24(%rbp),%r11d
mov    -0xa0(%rbp),%r10d
mov    0x2c99(%rip),%rax
mov    (%rax),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   2060 <XGrabPointer@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    0x2b72(%rip),%rcx
cmp    (%rcx),%eax
je     2384 <main+0x154>
lea    0xcb6(%rip),%rdi
call   20e0 <perror@plt>
mov    $0xffffffff,%edi
call   2100 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2c36(%rip),%rax
mov    (%rax),%edx
mov    0x2bfd(%rip),%rax
mov    (%rax),%ecx
mov    0x2ba4(%rip),%rax
mov    (%rax),%r8d
mov    0x2c2a(%rip),%rax
mov    (%rax),%r9d
call   2150 <XGrabKeyboard@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    0x2b0f(%rip),%rcx
cmp    (%rcx),%eax
je     23e7 <main+0x1b7>
lea    0xc68(%rip),%rdi
call   20e0 <perror@plt>
mov    $0xffffffff,%edi
call   2100 <exit@plt>
mov    0x2b2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2b26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
movl   $0xff0000,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   20c0 <BlackPixel@plt>
mov    %eax,-0x38(%rbp)
movl   $0x3,-0x6c(%rbp)
mov    0x2b05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2b81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2a85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2b79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2a9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2b69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
mov    0x2afd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2a49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2a96(%rip),%rax
mov    (%rax),%edx
mov    0x2a5d(%rip),%rax
or     (%rax),%edx
mov    0x2b24(%rip),%rax
or     (%rax),%edx
mov    0x2a53(%rip),%rax
or     (%rax),%edx
mov    0x2a2a(%rip),%rax
or     (%rax),%edx
mov    0x2af1(%rip),%rax
or     (%rax),%edx
mov    0x2b20(%rip),%rax
or     (%rax),%edx
mov    0x2b07(%rip),%rax
or     (%rax),%edx
mov    0x2a6e(%rip),%rax
or     (%rax),%edx
mov    0x2a0d(%rip),%rax
or     (%rax),%edx
mov    0x2a64(%rip),%rax
or     (%rax),%edx
mov    0x29e3(%rip),%rax
or     (%rax),%edx
mov    0x2a3a(%rip),%rax
or     (%rax),%edx
mov    0x2a61(%rip),%rax
or     (%rax),%edx
mov    0x2a50(%rip),%rax
or     (%rax),%edx
lea    -0x70(%rbp),%rcx
call   20a0 <XCreateGC@plt>
mov    %eax,-0xa4(%rbp)
movl   $0xff00,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x29f2(%rip),%rax
mov    (%rax),%edx
mov    0x29b9(%rip),%rax
or     (%rax),%edx
mov    0x2a80(%rip),%rax
or     (%rax),%edx
mov    0x29af(%rip),%rax
or     (%rax),%edx
mov    0x2986(%rip),%rax
or     (%rax),%edx
mov    0x2a4d(%rip),%rax
or     (%rax),%edx
mov    0x2a7c(%rip),%rax
or     (%rax),%edx
mov    0x2a63(%rip),%rax
or     (%rax),%edx
mov    0x29ca(%rip),%rax
or     (%rax),%edx
mov    0x2969(%rip),%rax
or     (%rax),%edx
mov    0x29c0(%rip),%rax
or     (%rax),%edx
mov    0x293f(%rip),%rax
or     (%rax),%edx
mov    0x2996(%rip),%rax
or     (%rax),%edx
mov    0x29bd(%rip),%rax
or     (%rax),%edx
mov    0x29ac(%rip),%rax
or     (%rax),%edx
lea    -0x70(%rbp),%rcx
call   20a0 <XCreateGC@plt>
mov    %eax,-0xa8(%rbp)
movl   $0xff,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x294e(%rip),%rax
mov    (%rax),%edx
mov    0x2915(%rip),%rax
or     (%rax),%edx
mov    0x29dc(%rip),%rax
or     (%rax),%edx
mov    0x290b(%rip),%rax
or     (%rax),%edx
mov    0x28e2(%rip),%rax
or     (%rax),%edx
mov    0x29a9(%rip),%rax
or     (%rax),%edx
mov    0x29d8(%rip),%rax
or     (%rax),%edx
mov    0x29bf(%rip),%rax
or     (%rax),%edx
mov    0x2926(%rip),%rax
or     (%rax),%edx
mov    0x28c5(%rip),%rax
or     (%rax),%edx
mov    0x291c(%rip),%rax
or     (%rax),%edx
mov    0x289b(%rip),%rax
or     (%rax),%edx
mov    0x28f2(%rip),%rax
or     (%rax),%edx
mov    0x2919(%rip),%rax
or     (%rax),%edx
mov    0x2908(%rip),%rax
or     (%rax),%edx
lea    -0x70(%rbp),%rcx
call   20a0 <XCreateGC@plt>
mov    %eax,-0xac(%rbp)
lea    -0xa4(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2886(%rip),%rax
mov    (%rax),%esi
mov    0x2945(%rip),%rax
mov    (%rax),%edx
call   2040 <XAllowEvents@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2900(%rip),%rax
mov    (%rax),%edx
mov    0x28d7(%rip),%rax
mov    (%rax),%eax
or     %eax,%edx
mov    0x28d4(%rip),%rax
mov    (%rax),%eax
or     %eax,%edx
mov    0x2871(%rip),%rax
mov    (%rax),%eax
or     %eax,%edx
lea    -0x78(%rbp),%rcx
call   20f0 <XWindowEvent@plt>
mov    -0x78(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0xd8(%rbp)
sub    $0x3,%eax
ja     2a73 <main+0x843>
mov    -0xd8(%rbp),%rax
lea    0x906(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x88(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xdc(%rbp)
sub    $0x9,%eax
je     275c <main+0x52c>
jmp    2720 <main+0x4f0>
mov    -0xdc(%rbp),%eax
sub    $0x1b,%eax
je     2761 <main+0x531>
jmp    2734 <main+0x504>
mov    -0xdc(%rbp),%eax
sub    $0x2a,%eax
je     2774 <main+0x544>
jmp    2748 <main+0x518>
mov    -0xdc(%rbp),%eax
sub    $0x38,%eax
je     2787 <main+0x557>
jmp    2795 <main+0x565>
jmp    2a8c <main+0x85c>
lea    -0xa4(%rbp),%rax
mov    %rax,-0xb8(%rbp)
jmp    2795 <main+0x565>
lea    -0xa8(%rbp),%rax
mov    %rax,-0xb8(%rbp)
jmp    2795 <main+0x565>
lea    -0xac(%rbp),%rax
mov    %rax,-0xb8(%rbp)
jmp    2a73 <main+0x843>
mov    -0x80(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x80(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x90(%rbp)
mov    -0x80(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x94(%rbp)
mov    -0x80(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xe0(%rbp)
sub    $0x1,%eax
je     2800 <main+0x5d0>
jmp    27d8 <main+0x5a8>
mov    -0xe0(%rbp),%eax
sub    $0x2,%eax
je     2869 <main+0x639>
jmp    27ec <main+0x5bc>
mov    -0xe0(%rbp),%eax
sub    $0x3,%eax
je     29e4 <main+0x7b4>
jmp    2a48 <main+0x818>
cmpl   $0xffffffff,-0x98(%rbp)
jle    284c <main+0x61c>
cmpl   $0xffffffff,-0x9c(%rbp)
jle    284c <main+0x61c>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0xb8(%rbp),%rax
mov    (%rax),%edx
mov    -0x98(%rbp),%ecx
mov    -0x9c(%rbp),%r8d
mov    -0x90(%rbp),%r9d
mov    -0x94(%rbp),%eax
mov    %eax,(%rsp)
call   2130 <XDrawLine@plt>
mov    -0x90(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0x9c(%rbp)
jmp    2a48 <main+0x818>
cmpl   $0xffffffff,-0x98(%rbp)
jle    29c7 <main+0x797>
cmpl   $0xffffffff,-0x9c(%rbp)
jle    29c7 <main+0x797>
mov    -0x98(%rbp),%eax
cmp    -0x90(%rbp),%eax
jge    28a6 <main+0x676>
mov    -0x98(%rbp),%eax
mov    %eax,-0xe4(%rbp)
jmp    28b2 <main+0x682>
mov    -0x90(%rbp),%eax
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    -0x9c(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    28e1 <main+0x6b1>
mov    -0x9c(%rbp),%eax
mov    %eax,-0xe8(%rbp)
jmp    28ed <main+0x6bd>
mov    -0x94(%rbp),%eax
mov    %eax,-0xe8(%rbp)
mov    -0xe8(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0x98(%rbp),%eax
cmp    -0x90(%rbp),%eax
jle    291c <main+0x6ec>
mov    -0x98(%rbp),%eax
mov    %eax,-0xec(%rbp)
jmp    2928 <main+0x6f8>
mov    -0x90(%rbp),%eax
mov    %eax,-0xec(%rbp)
mov    -0xec(%rbp),%eax
mov    %eax,-0xc4(%rbp)
mov    -0x9c(%rbp),%eax
cmp    -0x94(%rbp),%eax
jle    2957 <main+0x727>
mov    -0x9c(%rbp),%eax
mov    %eax,-0xf0(%rbp)
jmp    2963 <main+0x733>
mov    -0x94(%rbp),%eax
mov    %eax,-0xf0(%rbp)
mov    -0xf0(%rbp),%eax
mov    %eax,-0xc8(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0xb8(%rbp),%rax
mov    (%rax),%edx
mov    -0xbc(%rbp),%ecx
mov    -0xc0(%rbp),%r8d
mov    -0xc4(%rbp),%r9d
sub    -0xbc(%rbp),%r9d
mov    -0xc8(%rbp),%eax
sub    -0xc0(%rbp),%eax
mov    %eax,(%rsp)
call   2030 <XDrawRectangle@plt>
movl   $0xffffffff,-0x98(%rbp)
ff ff ff
movl   $0xffffffff,-0x9c(%rbp)
ff ff ff
jmp    29df <main+0x7af>
mov    -0x90(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0x9c(%rbp)
jmp    2a48 <main+0x818>
cmpl   $0xffffffff,-0x98(%rbp)
jle    2a30 <main+0x800>
cmpl   $0xffffffff,-0x9c(%rbp)
jle    2a30 <main+0x800>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0xb8(%rbp),%rax
mov    (%rax),%edx
mov    -0x98(%rbp),%ecx
mov    -0x9c(%rbp),%r8d
mov    -0x90(%rbp),%r9d
mov    -0x94(%rbp),%eax
mov    %eax,(%rsp)
call   2130 <XDrawLine@plt>
mov    -0x90(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0x9c(%rbp)
jmp    2a73 <main+0x843>
mov    -0x80(%rbp),%rax
cmpl   $0x1,(%rax)
jne    2a6e <main+0x83e>
movl   $0xffffffff,-0x98(%rbp)
ff ff ff
movl   $0xffffffff,-0x9c(%rbp)
ff ff ff
jmp    2a73 <main+0x843>
jmp    2a78 <main+0x848>
mov    $0x1,%al
test   $0x1,%al
jne    267f <main+0x44f>
jmp    2a87 <main+0x857>
jmp    2a8c <main+0x85c>
mov    -0x10(%rbp),%rdi
call   20d0 <XFlush@plt>
mov    -0x10(%rbp),%rdi
call   2080 <XUngrabServer@plt>
mov    -0x10(%rbp),%rdi
call   2120 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
xor    %edi,%edi
call   2060 <XOpenDisplay@plt>
test   %rax,%rax
je     263a <main+0x44a>
mov    %rax,%rbx
mov    %rax,%rdi
call   20e0 <DefaultScreen@plt>
mov    %rbx,%rdi
mov    %eax,0x4(%rsp)
mov    %eax,%esi
call   2090 <XScreenOfDisplay@plt>
mov    %rax,%rdi
call   2100 <XScreenNumberOfScreen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   2070 <RootWindow@plt>
mov    %eax,%r14d
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   2040 <XCreateFontCursor@plt>
mov    0x2d74(%rip),%rcx
mov    (%rcx),%edx
mov    0x2cdb(%rip),%rsi
mov    0x2d2c(%rip),%rcx
mov    (%rcx),%ecx
or     (%rsi),%ecx
mov    0x2d31(%rip),%rsi
or     (%rsi),%ecx
mov    0x2d20(%rip),%r12
mov    (%r12),%r8d
mov    0x2cc5(%rip),%r13
mov    0x0(%r13),%r9d
mov    0x2d4a(%rip),%r15
mov    (%r15),%ebp
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %r14d,%esi
push   %rbp
push   %rax
push   %r14
call   2050 <XGrabPointer@plt>
add    $0x20,%rsp
mov    0x2c29(%rip),%rbp
cmp    0x0(%rbp),%eax
jne    2643 <main+0x453>
mov    0x2d09(%rip),%rax
mov    (%rax),%edx
mov    (%r12),%ecx
mov    0x0(%r13),%r8d
mov    (%r15),%r9d
mov    %rbx,%rdi
mov    %r14d,%esi
call   2110 <XGrabKeyboard@plt>
cmp    0x0(%rbp),%eax
jne    264c <main+0x45c>
mov    0x2c31(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x60(%rsp)
mov    0x2c2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x5c(%rsp)
movl   $0xff0000,0x20(%rsp)
mov    %rbx,%rdi
mov    0x4(%rsp),%esi
call   20a0 <BlackPixel@plt>
mov    %eax,0x58(%rsp)
movl   $0x3,0x24(%rsp)
mov    0x2c07(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x54(%rsp)
mov    0x2c82(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rsp)
mov    0x2b85(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4c(%rsp)
mov    0x2c78(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x48(%rsp)
mov    0x2bdb(%rip),%rax
mov    0x2ba4(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2b89(%rip),%rax
mov    0x2c62(%rip),%rcx
or     (%rcx),%edx
mov    (%rax),%eax
mov    0x2b8f(%rip),%rcx
or     (%rcx),%edx
mov    %eax,0x44(%rsp)
mov    0x2b62(%rip),%rax
or     (%rax),%edx
mov    0x2c39(%rip),%rax
mov    (%rax),%eax
mov    0x2c20(%rip),%rcx
or     (%rcx),%edx
mov    %eax,0x40(%rsp)
mov    0x2c4b(%rip),%rax
or     (%rax),%edx
xorps  %xmm0,%xmm0
mov    0x2c2f(%rip),%rax
or     (%rax),%edx
movups %xmm0,0x30(%rsp)
mov    0x2b91(%rip),%rax
or     (%rax),%edx
mov    0x2bb0(%rip),%rax
mov    0x2b29(%rip),%rcx
or     (%rcx),%edx
mov    (%rax),%eax
mov    0x2b7e(%rip),%rcx
or     (%rcx),%edx
mov    %eax,0x2c(%rsp)
mov    0x2af9(%rip),%rax
or     (%rax),%edx
mov    0x2ae0(%rip),%rax
mov    0x2b49(%rip),%r12
or     (%r12),%edx
mov    (%rax),%eax
mov    0x2b6c(%rip),%r13
or     0x0(%r13),%edx
mov    %eax,0x28(%rsp)
mov    0x2b55(%rip),%rbp
or     0x0(%rbp),%edx
lea    0x20(%rsp),%r15
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rcx
call   2080 <XCreateGC@plt>
mov    %eax,0x8(%rsp)
movl   $0xff00,0x20(%rsp)
mov    0x2ac4(%rip),%rax
mov    (%rax),%edx
mov    0x2aeb(%rip),%rax
or     (%rax),%edx
mov    0x2b82(%rip),%rax
or     (%rax),%edx
mov    0x2ab1(%rip),%rax
or     (%rax),%edx
mov    0x2a88(%rip),%rax
or     (%rax),%edx
mov    0x2b4f(%rip),%rax
or     (%rax),%edx
mov    0x2b7e(%rip),%rax
or     (%rax),%edx
mov    0x2b65(%rip),%rax
or     (%rax),%edx
mov    0x2acc(%rip),%rax
or     (%rax),%edx
mov    0x2a6b(%rip),%rax
or     (%rax),%edx
mov    0x2ac2(%rip),%rax
or     (%rax),%edx
mov    0x2a41(%rip),%rax
or     (%rax),%edx
or     (%r12),%edx
or     0x0(%r13),%edx
or     0x0(%rbp),%edx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rcx
call   2080 <XCreateGC@plt>
movl   $0xff,0x20(%rsp)
mov    0x2a37(%rip),%rax
mov    (%rax),%edx
mov    0x2a5e(%rip),%rax
or     (%rax),%edx
mov    0x2af5(%rip),%rax
or     (%rax),%edx
mov    0x2a24(%rip),%rax
or     (%rax),%edx
mov    0x29fb(%rip),%rax
or     (%rax),%edx
mov    0x2ac2(%rip),%rax
or     (%rax),%edx
mov    0x2af1(%rip),%rax
or     (%rax),%edx
mov    0x2ad8(%rip),%rax
or     (%rax),%edx
mov    0x2a3f(%rip),%rax
or     (%rax),%edx
mov    0x29de(%rip),%rax
or     (%rax),%edx
mov    0x2a35(%rip),%rax
or     (%rax),%edx
mov    0x29b4(%rip),%rax
or     (%rax),%edx
or     (%r12),%edx
or     0x0(%r13),%edx
or     0x0(%rbp),%edx
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,0x18(%rsp)
mov    %r14d,%esi
mov    %r15,%rcx
call   2080 <XCreateGC@plt>
mov    $0xffffffff,%ebp
mov    0x29b3(%rip),%rax
mov    $0xffffffff,%r14d
mov    0x18(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14d,0xc(%rsp)
mov    %ebp,%ecx
mov    %ebp,0x4(%rsp)
mov    0x10(%rsp),%rbp
mov    0x2a21(%rip),%r14
mov    0x29fa(%rip),%r12
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rax),%esi
mov    0x2a2f(%rip),%rcx
mov    (%rcx),%edx
mov    %rbp,%rdi
mov    %rax,%rbx
call   2030 <XAllowEvents@plt>
mov    (%r12),%edx
or     (%r14),%edx
mov    0x29cc(%rip),%rax
or     (%rax),%edx
mov    0x296b(%rip),%rax
or     (%rax),%edx
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r13,%rcx
call   20c0 <XWindowEvent@plt>
mov    %rbx,%rax
cmpl   $0x80,(%rsp)
jne    25a0 <main+0x3b0>
movl   $0x1,(%rsp)
mov    0x4(%rsp),%r14d
mov    0x8(%rsp),%ebp
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
mov    0x4(%rsp),%r8d
js     2570 <main+0x380>
test   %r8d,%r8d
js     2570 <main+0x380>
sub    $0x8,%rsp
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rsi
mov    0x10(%rsp),%edx
mov    %r14d,%r9d
push   %rbp
call   20f0 <XDrawLine@plt>
mov    %rbx,%rax
add    $0x10,%rsp
jmp    2570 <main+0x380>
lea    0x9bf(%rip),%rdi
jmp    2653 <main+0x463>
lea    0x9d1(%rip),%rdi
jmp    2653 <main+0x463>
lea    0x9dd(%rip),%rdi
call   20b0 <perror@plt>
mov    $0xffffffff,%edi
call   20d0 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_8__ = type { i32, i32, i32, i32, i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_10__ = type { i32, i32, i32 }
%struct.TYPE_7__ = type { i32 }
@.str = [27 x i8] c"Cannot connect to X server\00"
@XC_crosshair = global i32 0
@False = global i32 0
@ButtonReleaseMask = global i32 0
@ButtonPressMask = global i32 0
@Button1MotionMask = global i32 0
@GrabModeSync = global i32 0
@GrabModeAsync = global i32 0
@CurrentTime = global i32 0
@GrabSuccess = global i32 0
@.str.1 = [21 x i8] c"Can't grab the mouse\00"
@.str.2 = [24 x i8] c"Can't grab the keyboard\00"
@GXxor = global i32 0
@AllPlanes = global i32 0
@LineSolid = global i32 0
@CapButt = global i32 0
@JoinMiter = global i32 0
@FillOpaqueStippled = global i32 0
@WindingRule = global i32 0
@None = global i32 0
@IncludeInferiors = global i32 0
@GCFunction = global i32 0
@GCPlaneMask = global i32 0
@GCForeground = global i32 0
@GCBackground = global i32 0
@GCLineWidth = global i32 0
@GCLineStyle = global i32 0
@GCCapStyle = global i32 0
@GCJoinStyle = global i32 0
@GCFillStyle = global i32 0
@GCFillRule = global i32 0
@GCGraphicsExposures = global i32 0
@GCClipXOrigin = global i32 0
@GCClipYOrigin = global i32 0
@GCClipMask = global i32 0
@GCSubwindowMode = global i32 0
@SyncPointer = global i32 0
@ButtonMotionMask = global i32 0
@KeyPressMask = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca %struct.TYPE_8__
%7 = alloca %struct.TYPE_9__
%8 = alloca %struct.TYPE_10__*
%9 = alloca %struct.TYPE_7__*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i32 0, i32* %1
%24 = bitcast %struct.TYPE_9__* %7 to %struct.TYPE_10__*
store %struct.TYPE_10__* %24, %struct.TYPE_10__** %8
%25 = bitcast %struct.TYPE_9__* %7 to %struct.TYPE_7__*
store %struct.TYPE_7__* %25, %struct.TYPE_7__** %9
store i32 -1, i32* %13
store i32 -1, i32* %14
%26 = call i32* @XOpenDisplay(i32 0)
store i32* %26, i32** %2
%27 = load i32*, i32** %2
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %0
%30 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @exit(i32 -1)
unreachable
32: ; preds = %0
%33 = load i32*, i32** %2
%34 = call i32 @DefaultScreen(i32* %33)
store i32 %34, i32* %3
%35 = load i32*, i32** %2
%36 = load i32, i32* %3
%37 = call i32* @XScreenOfDisplay(i32* %35, i32 %36)
store i32* %37, i32** %4
%38 = load i32*, i32** %2
%39 = load i32*, i32** %4
%40 = call i32 @XScreenNumberOfScreen(i32* %39)
%41 = call i32 @RootWindow(i32* %38, i32 %40)
store i32 %41, i32* %5
%42 = load i32*, i32** %2
%43 = load i32, i32* @XC_crosshair
%44 = call i32 @XCreateFontCursor(i32* %42, i32 %43)
store i32 %44, i32* %15
%45 = load i32*, i32** %2
%46 = load i32, i32* %5
%47 = load i32, i32* @False
%48 = load i32, i32* @ButtonReleaseMask
%49 = load i32, i32* @ButtonPressMask
%50 = or i32 %48, %49
%51 = load i32, i32* @Button1MotionMask
%52 = or i32 %50, %51
%53 = load i32, i32* @GrabModeSync
%54 = load i32, i32* @GrabModeAsync
%55 = load i32, i32* %5
%56 = load i32, i32* %15
%57 = load i32, i32* @CurrentTime
%58 = call i32 @XGrabPointer(i32* %45, i32 %46, i32 %47, i32 %52, i32 %53, i32 %54, i32 %55, i32 %56, i32 %57)
store i32 %58, i32* %10
%59 = load i32, i32* %10
%60 = load i32, i32* @GrabSuccess
%61 = icmp ne i32 %59, %60
br i1 %61, label %62, label %65
62: ; preds = %32
%63 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%64 = call i32 @exit(i32 -1)
unreachable
65: ; preds = %32
%66 = load i32*, i32** %2
%67 = load i32, i32* %5
%68 = load i32, i32* @False
%69 = load i32, i32* @GrabModeSync
%70 = load i32, i32* @GrabModeAsync
%71 = load i32, i32* @CurrentTime
%72 = call i32 @XGrabKeyboard(i32* %66, i32 %67, i32 %68, i32 %69, i32 %70, i32 %71)
store i32 %72, i32* %10
%73 = load i32, i32* %10
%74 = load i32, i32* @GrabSuccess
%75 = icmp ne i32 %73, %74
br i1 %75, label %76, label %79
76: ; preds = %65
%77 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%78 = call i32 @exit(i32 -1)
unreachable
79: ; preds = %65
%80 = load i32, i32* @GXxor
%81 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 14
store i32 %80, i32* %81
%82 = load i32, i32* @AllPlanes
%83 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 13
store i32 %82, i32* %83
%84 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 0
store i32 16711680, i32* %84
%85 = load i32*, i32** %2
%86 = load i32, i32* %3
%87 = call i32 @BlackPixel(i32* %85, i32 %86)
%88 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 12
store i32 %87, i32* %88
%89 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 1
store i32 3, i32* %89
%90 = load i32, i32* @LineSolid
%91 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 11
store i32 %90, i32* %91
%92 = load i32, i32* @CapButt
%93 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 10
store i32 %92, i32* %93
%94 = load i32, i32* @JoinMiter
%95 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 9
store i32 %94, i32* %95
%96 = load i32, i32* @FillOpaqueStippled
%97 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 8
store i32 %96, i32* %97
%98 = load i32, i32* @WindingRule
%99 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 7
store i32 %98, i32* %99
%100 = load i32, i32* @False
%101 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 6
store i32 %100, i32* %101
%102 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 5
store i64 0, i64* %102
%103 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 4
store i64 0, i64* %103
%104 = load i32, i32* @None
%105 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 3
store i32 %104, i32* %105
%106 = load i32, i32* @IncludeInferiors
%107 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 2
store i32 %106, i32* %107
%108 = load i32*, i32** %2
%109 = load i32, i32* %5
%110 = load i32, i32* @GCFunction
%111 = load i32, i32* @GCPlaneMask
%112 = or i32 %110, %111
%113 = load i32, i32* @GCForeground
%114 = or i32 %112, %113
%115 = load i32, i32* @GCBackground
%116 = or i32 %114, %115
%117 = load i32, i32* @GCLineWidth
%118 = or i32 %116, %117
%119 = load i32, i32* @GCLineStyle
%120 = or i32 %118, %119
%121 = load i32, i32* @GCCapStyle
%122 = or i32 %120, %121
%123 = load i32, i32* @GCJoinStyle
%124 = or i32 %122, %123
%125 = load i32, i32* @GCFillStyle
%126 = or i32 %124, %125
%127 = load i32, i32* @GCFillRule
%128 = or i32 %126, %127
%129 = load i32, i32* @GCGraphicsExposures
%130 = or i32 %128, %129
%131 = load i32, i32* @GCClipXOrigin
%132 = or i32 %130, %131
%133 = load i32, i32* @GCClipYOrigin
%134 = or i32 %132, %133
%135 = load i32, i32* @GCClipMask
%136 = or i32 %134, %135
%137 = load i32, i32* @GCSubwindowMode
%138 = or i32 %136, %137
%139 = call i32 @XCreateGC(i32* %108, i32 %109, i32 %138, %struct.TYPE_8__* %6)
store i32 %139, i32* %16
%140 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 0
store i32 65280, i32* %140
%141 = load i32*, i32** %2
%142 = load i32, i32* %5
%143 = load i32, i32* @GCFunction
%144 = load i32, i32* @GCPlaneMask
%145 = or i32 %143, %144
%146 = load i32, i32* @GCForeground
%147 = or i32 %145, %146
%148 = load i32, i32* @GCBackground
%149 = or i32 %147, %148
%150 = load i32, i32* @GCLineWidth
%151 = or i32 %149, %150
%152 = load i32, i32* @GCLineStyle
%153 = or i32 %151, %152
%154 = load i32, i32* @GCCapStyle
%155 = or i32 %153, %154
%156 = load i32, i32* @GCJoinStyle
%157 = or i32 %155, %156
%158 = load i32, i32* @GCFillStyle
%159 = or i32 %157, %158
%160 = load i32, i32* @GCFillRule
%161 = or i32 %159, %160
%162 = load i32, i32* @GCGraphicsExposures
%163 = or i32 %161, %162
%164 = load i32, i32* @GCClipXOrigin
%165 = or i32 %163, %164
%166 = load i32, i32* @GCClipYOrigin
%167 = or i32 %165, %166
%168 = load i32, i32* @GCClipMask
%169 = or i32 %167, %168
%170 = load i32, i32* @GCSubwindowMode
%171 = or i32 %169, %170
%172 = call i32 @XCreateGC(i32* %141, i32 %142, i32 %171, %struct.TYPE_8__* %6)
store i32 %172, i32* %17
%173 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 0
store i32 255, i32* %173
%174 = load i32*, i32** %2
%175 = load i32, i32* %5
%176 = load i32, i32* @GCFunction
%177 = load i32, i32* @GCPlaneMask
%178 = or i32 %176, %177
%179 = load i32, i32* @GCForeground
%180 = or i32 %178, %179
%181 = load i32, i32* @GCBackground
%182 = or i32 %180, %181
%183 = load i32, i32* @GCLineWidth
%184 = or i32 %182, %183
%185 = load i32, i32* @GCLineStyle
%186 = or i32 %184, %185
%187 = load i32, i32* @GCCapStyle
%188 = or i32 %186, %187
%189 = load i32, i32* @GCJoinStyle
%190 = or i32 %188, %189
%191 = load i32, i32* @GCFillStyle
%192 = or i32 %190, %191
%193 = load i32, i32* @GCFillRule
%194 = or i32 %192, %193
%195 = load i32, i32* @GCGraphicsExposures
%196 = or i32 %194, %195
%197 = load i32, i32* @GCClipXOrigin
%198 = or i32 %196, %197
%199 = load i32, i32* @GCClipYOrigin
%200 = or i32 %198, %199
%201 = load i32, i32* @GCClipMask
%202 = or i32 %200, %201
%203 = load i32, i32* @GCSubwindowMode
%204 = or i32 %202, %203
%205 = call i32 @XCreateGC(i32* %174, i32 %175, i32 %204, %struct.TYPE_8__* %6)
store i32 %205, i32* %18
store i32* %16, i32** %19
br label %206
206: ; preds = %352, %79
%207 = load i32*, i32** %2
%208 = load i32, i32* @SyncPointer
%209 = load i32, i32* @CurrentTime
%210 = call i32 @XAllowEvents(i32* %207, i32 %208, i32 %209)
%211 = load i32*, i32** %2
%212 = load i32, i32* %5
%213 = load i32, i32* @ButtonMotionMask
%214 = load i32, i32* @KeyPressMask
%215 = or i32 %213, %214
%216 = load i32, i32* @ButtonPressMask
%217 = or i32 %215, %216
%218 = load i32, i32* @ButtonReleaseMask
%219 = or i32 %217, %218
%220 = call i32 @XWindowEvent(i32* %211, i32 %212, i32 %219, %struct.TYPE_9__* %7)
%221 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %7, i32 0, i32 0
%222 = load i32, i32* %221
switch i32 %222, label %351 [
i32 129, label %223
i32 128, label %232
i32 131, label %235
i32 130, label %344
]
223: ; preds = %206
%224 = load %struct.TYPE_7__*, %struct.TYPE_7__** %9
%225 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %224, i32 0, i32 0
%226 = load i32, i32* %225
switch i32 %226, label %231 [
i32 9, label %227
i32 27, label %228
i32 42, label %229
i32 56, label %230
]
227: ; preds = %223
br label %354
228: ; preds = %223
store i32* %16, i32** %19
br label %231
229: ; preds = %223
store i32* %17, i32** %19
br label %231
230: ; preds = %223
store i32* %18, i32** %19
br label %231
231: ; preds = %223, %230, %229, %228
br label %351
232: ; preds = %206
%233 = load %struct.TYPE_10__*, %struct.TYPE_10__** %8
%234 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %233, i32 0, i32 0
store i32 1, i32* %234
br label %235
235: ; preds = %206, %232
%236 = load %struct.TYPE_10__*, %struct.TYPE_10__** %8
%237 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %236, i32 0, i32 1
%238 = load i32, i32* %237
store i32 %238, i32* %11
%239 = load %struct.TYPE_10__*, %struct.TYPE_10__** %8
%240 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %239, i32 0, i32 2
%241 = load i32, i32* %240
store i32 %241, i32* %12
%242 = load %struct.TYPE_10__*, %struct.TYPE_10__** %8
%243 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %242, i32 0, i32 0
%244 = load i32, i32* %243
switch i32 %244, label %343 [
i32 1, label %245
i32 2, label %264
i32 3, label %324
]
245: ; preds = %235
%246 = load i32, i32* %13
%247 = icmp sgt i32 %246, -1
br i1 %247, label %248, label %261
248: ; preds = %245
%249 = load i32, i32* %14
%250 = icmp sgt i32 %249, -1
br i1 %250, label %251, label %261
251: ; preds = %248
%252 = load i32*, i32** %2
%253 = load i32, i32* %5
%254 = load i32*, i32** %19
%255 = load i32, i32* %254
%256 = load i32, i32* %13
%257 = load i32, i32* %14
%258 = load i32, i32* %11
%259 = load i32, i32* %12
%260 = call i32 @XDrawLine(i32* %252, i32 %253, i32 %255, i32 %256, i32 %257, i32 %258, i32 %259)
br label %261
261: ; preds = %251, %248, %245
%262 = load i32, i32* %11
store i32 %262, i32* %13
%263 = load i32, i32* %12
store i32 %263, i32* %14
br label %343
264: ; preds = %235
%265 = load i32, i32* %13
%266 = icmp sgt i32 %265, -1
br i1 %266, label %267, label %320
267: ; preds = %264
%268 = load i32, i32* %14
%269 = icmp sgt i32 %268, -1
br i1 %269, label %270, label %320
270: ; preds = %267
%271 = load i32, i32* %13
%272 = load i32, i32* %11
%273 = icmp slt i32 %271, %272
br i1 %273, label %274, label %276
274: ; preds = %270
%275 = load i32, i32* %13
br label %278
276: ; preds = %270
%277 = load i32, i32* %11
br label %278
278: ; preds = %276, %274
%279 = phi i32 [ %275, %274 ], [ %277, %276 ]
store i32 %279, i32* %20
%280 = load i32, i32* %14
%281 = load i32, i32* %12
%282 = icmp slt i32 %280, %281
br i1 %282, label %283, label %285
283: ; preds = %278
%284 = load i32, i32* %14
br label %287
285: ; preds = %278
%286 = load i32, i32* %12
br label %287
287: ; preds = %285, %283
%288 = phi i32 [ %284, %283 ], [ %286, %285 ]
store i32 %288, i32* %21
%289 = load i32, i32* %13
%290 = load i32, i32* %11
%291 = icmp sgt i32 %289, %290
br i1 %291, label %292, label %294
292: ; preds = %287
%293 = load i32, i32* %13
br label %296
294: ; preds = %287
%295 = load i32, i32* %11
br label %296
296: ; preds = %294, %292
%297 = phi i32 [ %293, %292 ], [ %295, %294 ]
store i32 %297, i32* %22
%298 = load i32, i32* %14
%299 = load i32, i32* %12
%300 = icmp sgt i32 %298, %299
br i1 %300, label %301, label %303
301: ; preds = %296
%302 = load i32, i32* %14
br label %305
303: ; preds = %296
%304 = load i32, i32* %12
br label %305
305: ; preds = %303, %301
%306 = phi i32 [ %302, %301 ], [ %304, %303 ]
store i32 %306, i32* %23
%307 = load i32*, i32** %2
%308 = load i32, i32* %5
%309 = load i32*, i32** %19
%310 = load i32, i32* %309
%311 = load i32, i32* %20
%312 = load i32, i32* %21
%313 = load i32, i32* %22
%314 = load i32, i32* %20
%315 = sub nsw i32 %313, %314
%316 = load i32, i32* %23
%317 = load i32, i32* %21
%318 = sub nsw i32 %316, %317
%319 = call i32 @XDrawRectangle(i32* %307, i32 %308, i32 %310, i32 %311, i32 %312, i32 %315, i32 %318)
store i32 -1, i32* %13
store i32 -1, i32* %14
br label %323
320: ; preds = %267, %264
%321 = load i32, i32* %11
store i32 %321, i32* %13
%322 = load i32, i32* %12
store i32 %322, i32* %14
br label %323
323: ; preds = %320, %305
br label %343
324: ; preds = %235
%325 = load i32, i32* %13
%326 = icmp sgt i32 %325, -1
br i1 %326, label %327, label %340
327: ; preds = %324
%328 = load i32, i32* %14
%329 = icmp sgt i32 %328, -1
br i1 %329, label %330, label %340
330: ; preds = %327
%331 = load i32*, i32** %2
%332 = load i32, i32* %5
%333 = load i32*, i32** %19
%334 = load i32, i32* %333
%335 = load i32, i32* %13
%336 = load i32, i32* %14
%337 = load i32, i32* %11
%338 = load i32, i32* %12
%339 = call i32 @XDrawLine(i32* %331, i32 %332, i32 %334, i32 %335, i32 %336, i32 %337, i32 %338)
br label %340
340: ; preds = %330, %327, %324
%341 = load i32, i32* %11
store i32 %341, i32* %13
%342 = load i32, i32* %12
store i32 %342, i32* %14
br label %343
343: ; preds = %235, %340, %323, %261
br label %351
344: ; preds = %206
%345 = load %struct.TYPE_10__*, %struct.TYPE_10__** %8
%346 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %345, i32 0, i32 0
%347 = load i32, i32* %346
%348 = icmp eq i32 %347, 1
br i1 %348, label %349, label %350
349: ; preds = %344
store i32 -1, i32* %13
store i32 -1, i32* %14
br label %350
350: ; preds = %349, %344
br label %351
351: ; preds = %206, %350, %343, %231
br label %352
352: ; preds = %351
br i1 true, label %206, label %353
353: ; preds = %352
br label %354
354: ; preds = %353, %227
%355 = load i32*, i32** %2
%356 = call i32 @XFlush(i32* %355)
%357 = load i32*, i32** %2
%358 = call i32 @XUngrabServer(i32* %357)
%359 = load i32*, i32** %2
%360 = call i32 @XCloseDisplay(i32* %359)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i32, i32, i32, i32, i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.TYPE_9__ = type { i32 }
@.str = [27 x i8] c"Cannot connect to X server\00"
@XC_crosshair = global i32 0
@False = global i32 0
@ButtonReleaseMask = global i32 0
@ButtonPressMask = global i32 0
@Button1MotionMask = global i32 0
@GrabModeSync = global i32 0
@GrabModeAsync = global i32 0
@CurrentTime = global i32 0
@GrabSuccess = global i32 0
@.str.1 = [21 x i8] c"Can't grab the mouse\00"
@.str.2 = [24 x i8] c"Can't grab the keyboard\00"
@GXxor = global i32 0
@AllPlanes = global i32 0
@LineSolid = global i32 0
@CapButt = global i32 0
@JoinMiter = global i32 0
@FillOpaqueStippled = global i32 0
@WindingRule = global i32 0
@None = global i32 0
@IncludeInferiors = global i32 0
@GCFunction = global i32 0
@GCPlaneMask = global i32 0
@GCForeground = global i32 0
@GCBackground = global i32 0
@GCLineWidth = global i32 0
@GCLineStyle = global i32 0
@GCCapStyle = global i32 0
@GCJoinStyle = global i32 0
@GCFillStyle = global i32 0
@GCFillRule = global i32 0
@GCGraphicsExposures = global i32 0
@GCClipXOrigin = global i32 0
@GCClipYOrigin = global i32 0
@GCClipMask = global i32 0
@GCSubwindowMode = global i32 0
@SyncPointer = global i32 0
@ButtonMotionMask = global i32 0
@KeyPressMask = global i32 0
define i32 @main() {
%1 = alloca %struct.TYPE_8__
%2 = alloca %struct.TYPE_9__
%3 = bitcast %struct.TYPE_8__* %1 to i8*
%4 = bitcast %struct.TYPE_9__* %2 to i8*
%5 = tail call i32* @XOpenDisplay(i32 0)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %0
%11 = tail call i32 @DefaultScreen(i32* %5)
%12 = tail call i32* @XScreenOfDisplay(i32* %5, i32 %11)
%13 = tail call i32 @XScreenNumberOfScreen(i32* %12)
%14 = tail call i32 @RootWindow(i32* %5, i32 %13)
%15 = load i32, i32* @XC_crosshair
%16 = tail call i32 @XCreateFontCursor(i32* %5, i32 %15)
%17 = load i32, i32* @False
%18 = load i32, i32* @ButtonReleaseMask
%19 = load i32, i32* @ButtonPressMask
%20 = or i32 %19, %18
%21 = load i32, i32* @Button1MotionMask
%22 = or i32 %20, %21
%23 = load i32, i32* @GrabModeSync
%24 = load i32, i32* @GrabModeAsync
%25 = load i32, i32* @CurrentTime
%26 = tail call i32 @XGrabPointer(i32* %5, i32 %14, i32 %17, i32 %22, i32 %23, i32 %24, i32 %14, i32 %16, i32 %25)
%27 = load i32, i32* @GrabSuccess
%28 = icmp eq i32 %26, %27
br i1 %28, label %32, label %29
29: ; preds = %10
%30 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%31 = tail call i32 @exit(i32 -1)
unreachable
32: ; preds = %10
%33 = load i32, i32* @False
%34 = load i32, i32* @GrabModeSync
%35 = load i32, i32* @GrabModeAsync
%36 = load i32, i32* @CurrentTime
%37 = tail call i32 @XGrabKeyboard(i32* %5, i32 %14, i32 %33, i32 %34, i32 %35, i32 %36)
%38 = load i32, i32* @GrabSuccess
%39 = icmp eq i32 %37, %38
br i1 %39, label %43, label %40
40: ; preds = %32
%41 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%42 = tail call i32 @exit(i32 -1)
unreachable
43: ; preds = %32
%44 = load i32, i32* @GXxor
%45 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 14
store i32 %44, i32* %45
%46 = load i32, i32* @AllPlanes
%47 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 13
store i32 %46, i32* %47
%48 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 0
store i32 16711680, i32* %48
%49 = tail call i32 @BlackPixel(i32* %5, i32 %11)
%50 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 12
store i32 %49, i32* %50
%51 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 1
store i32 3, i32* %51
%52 = load i32, i32* @LineSolid
%53 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 11
store i32 %52, i32* %53
%54 = load i32, i32* @CapButt
%55 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 10
store i32 %54, i32* %55
%56 = load i32, i32* @JoinMiter
%57 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 9
store i32 %56, i32* %57
%58 = load i32, i32* @FillOpaqueStippled
%59 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 8
store i32 %58, i32* %59
%60 = load i32, i32* @WindingRule
%61 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 7
store i32 %60, i32* %61
%62 = load i32, i32* @False
%63 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 6
store i32 %62, i32* %63
%64 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 4
%65 = bitcast i64* %64 to i8*
%66 = load i32, i32* @None
%67 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 3
store i32 %66, i32* %67
%68 = load i32, i32* @IncludeInferiors
%69 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 2
store i32 %68, i32* %69
%70 = load i32, i32* @GCFunction
%71 = load i32, i32* @GCPlaneMask
%72 = or i32 %71, %70
%73 = load i32, i32* @GCForeground
%74 = or i32 %72, %73
%75 = load i32, i32* @GCBackground
%76 = or i32 %74, %75
%77 = load i32, i32* @GCLineWidth
%78 = or i32 %76, %77
%79 = load i32, i32* @GCLineStyle
%80 = or i32 %78, %79
%81 = load i32, i32* @GCCapStyle
%82 = or i32 %80, %81
%83 = load i32, i32* @GCJoinStyle
%84 = or i32 %82, %83
%85 = load i32, i32* @GCFillStyle
%86 = or i32 %84, %85
%87 = load i32, i32* @GCFillRule
%88 = or i32 %86, %87
%89 = load i32, i32* @GCGraphicsExposures
%90 = or i32 %88, %89
%91 = load i32, i32* @GCClipXOrigin
%92 = or i32 %90, %91
%93 = load i32, i32* @GCClipYOrigin
%94 = or i32 %92, %93
%95 = load i32, i32* @GCClipMask
%96 = or i32 %94, %95
%97 = load i32, i32* @GCSubwindowMode
%98 = or i32 %96, %97
%99 = call i32 @XCreateGC(i32* %5, i32 %14, i32 %98, %struct.TYPE_8__* %1)
store i32 65280, i32* %48
%100 = load i32, i32* @GCFunction
%101 = load i32, i32* @GCPlaneMask
%102 = or i32 %101, %100
%103 = load i32, i32* @GCForeground
%104 = or i32 %102, %103
%105 = load i32, i32* @GCBackground
%106 = or i32 %104, %105
%107 = load i32, i32* @GCLineWidth
%108 = or i32 %106, %107
%109 = load i32, i32* @GCLineStyle
%110 = or i32 %108, %109
%111 = load i32, i32* @GCCapStyle
%112 = or i32 %110, %111
%113 = load i32, i32* @GCJoinStyle
%114 = or i32 %112, %113
%115 = load i32, i32* @GCFillStyle
%116 = or i32 %114, %115
%117 = load i32, i32* @GCFillRule
%118 = or i32 %116, %117
%119 = load i32, i32* @GCGraphicsExposures
%120 = or i32 %118, %119
%121 = load i32, i32* @GCClipXOrigin
%122 = or i32 %120, %121
%123 = load i32, i32* @GCClipYOrigin
%124 = or i32 %122, %123
%125 = load i32, i32* @GCClipMask
%126 = or i32 %124, %125
%127 = load i32, i32* @GCSubwindowMode
%128 = or i32 %126, %127
%129 = call i32 @XCreateGC(i32* %5, i32 %14, i32 %128, %struct.TYPE_8__* %1)
store i32 255, i32* %48
%130 = load i32, i32* @GCFunction
%131 = load i32, i32* @GCPlaneMask
%132 = or i32 %131, %130
%133 = load i32, i32* @GCForeground
%134 = or i32 %132, %133
%135 = load i32, i32* @GCBackground
%136 = or i32 %134, %135
%137 = load i32, i32* @GCLineWidth
%138 = or i32 %136, %137
%139 = load i32, i32* @GCLineStyle
%140 = or i32 %138, %139
%141 = load i32, i32* @GCCapStyle
%142 = or i32 %140, %141
%143 = load i32, i32* @GCJoinStyle
%144 = or i32 %142, %143
%145 = load i32, i32* @GCFillStyle
%146 = or i32 %144, %145
%147 = load i32, i32* @GCFillRule
%148 = or i32 %146, %147
%149 = load i32, i32* @GCGraphicsExposures
%150 = or i32 %148, %149
%151 = load i32, i32* @GCClipXOrigin
%152 = or i32 %150, %151
%153 = load i32, i32* @GCClipYOrigin
%154 = or i32 %152, %153
%155 = load i32, i32* @GCClipMask
%156 = or i32 %154, %155
%157 = load i32, i32* @GCSubwindowMode
%158 = or i32 %156, %157
%159 = call i32 @XCreateGC(i32* %5, i32 %14, i32 %158, %struct.TYPE_8__* %1)
%160 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %2, i64 0, i32 0
%161 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %2, i64 1, i32 0
%162 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %2, i64 2, i32 0
br label %163
163: ; preds = %188, %43
%164 = phi i32 [ -1, %43 ], [ %182, %188 ]
%165 = phi i32 [ -1, %43 ], [ %181, %188 ]
br label %166
166: ; preds = %163, %166
%167 = load i32, i32* @SyncPointer
%168 = load i32, i32* @CurrentTime
%169 = call i32 @XAllowEvents(i32* %5, i32 %167, i32 %168)
%170 = load i32, i32* @ButtonMotionMask
%171 = load i32, i32* @KeyPressMask
%172 = or i32 %171, %170
%173 = load i32, i32* @ButtonPressMask
%174 = or i32 %172, %173
%175 = load i32, i32* @ButtonReleaseMask
%176 = or i32 %174, %175
%177 = call i32 @XWindowEvent(i32* %5, i32 %14, i32 %176, %struct.TYPE_9__* %2)
%178 = load i32, i32* %160
%179 = icmp eq i32 %178, 128
br i1 %179, label %180, label %166
180: ; preds = %166
store i32 1, i32* %160
%181 = load i32, i32* %161
%182 = load i32, i32* %162
%183 = icmp sgt i32 %165, -1
%184 = icmp sgt i32 %164, -1
%185 = select i1 %183, i1 %184, i1 false
br i1 %185, label %186, label %188
186: ; preds = %180
%187 = call i32 @XDrawLine(i32* %5, i32 %14, i32 %99, i32 %165, i32 %164, i32 %181, i32 %182)
br label %188
188: ; preds = %186, %180
br label %163
}