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

/* Type definitions */
struct sigaction {
  int /*<<< orphan*/ sa_handler;
};
struct TYPE_6__ {
  int button;
  int /*<<< orphan*/ y_root;
  int /*<<< orphan*/ x_root;
};
struct TYPE_7__ {
  scalar_t__ type;
  TYPE_1__ xbutton;
};
typedef TYPE_2__ XEvent;
struct TYPE_8__ {
  int red;
  int green;
  int blue;
  int /*<<< orphan*/ pixel;
};
typedef TYPE_3__ XColor;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Cursor;

/* Variables and functions */
int /*<<< orphan*/ AllPlanes;
int Button1MotionMask;
scalar_t__ ButtonPress;
int ButtonPressMask;
scalar_t__ ButtonRelease;
int ButtonReleaseMask;
int /*<<< orphan*/ CurrentTime;
int /*<<< orphan*/ DefaultColormap(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ False;
int /*<<< orphan*/ GrabModeAsync;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ XC_crosshair;
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCreateFontCursor(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XFreeCursor(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XGetImage(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/, int, int,
                             int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XGetPixel(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/);
scalar_t__ XGrabPointer(int /*<<< orphan*/ *, int /*<<< orphan*/,
                        int /*<<< orphan*/, int, int /*<<< orphan*/,
                        int /*<<< orphan*/, int /*<<< orphan*/,
                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_2__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XQueryColor(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               TYPE_3__ *);
int /*<<< orphan*/ XUngrabPointer(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ ZPixmap;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int rv = 0;
  Display *dpy = XOpenDisplay(NULL);
  if (!dpy) {
    fprintf(stderr, "could not open display\n");
    return 1;
  }
  Window root = DefaultRootWindow(dpy);
  Cursor cross = XCreateFontCursor(dpy, XC_crosshair);
  if (XGrabPointer(dpy, root, False,
                   ButtonPressMask | Button1MotionMask | ButtonReleaseMask,
                   GrabModeAsync, GrabModeAsync, root, cross, CurrentTime)) {
    fprintf(stderr, "could not grab pointer\n");
    rv = 1;
    goto out_free;
  }
  XEvent ev;
  do {
    XNextEvent(dpy, &ev);
  } while (ev.type != ButtonPress);
  if (ev.xbutton.button != 1) {
    int b = ev.xbutton.button;
    do {
      XNextEvent(dpy, &ev);
    } while (ev.type != ButtonRelease || ev.xbutton.button != b);
    rv = 2;
    goto out_ungrab;
  }
  struct sigaction sa_ign = {.sa_handler = SIG_IGN};
  sigaction(SIGPIPE, &sa_ign, NULL);
  while (ev.type != ButtonRelease || ev.xbutton.button != 1) {
    XColor c;
    c.pixel = XGetPixel(XGetImage(dpy, root, ev.xbutton.x_root,
                                  ev.xbutton.y_root, 1, 1, AllPlanes, ZPixmap),
                        0, 0);
    XQueryColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), &c);
    printf("%d %d %d\n", c.red >> 8, c.green >> 8, c.blue >> 8);
    fflush(stdout);
    XNextEvent(dpy, &ev);
  }
out_ungrab:
  XUngrabPointer(dpy, CurrentTime);
out_free:
  XFreeCursor(dpy, cross);
  XCloseDisplay(dpy);
  return rv;
}


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)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <XOpenDisplay@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1269 <main+0x59>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d2 <main+0x2c2>
mov    -0x20(%rbp),%rdi
call   1060 <DefaultRootWindow@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
call   1040 <XCreateFontCursor@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2d48(%rip),%rax
mov    (%rax),%edx
mov    0x2d2f(%rip),%rax
mov    (%rax),%ecx
mov    0x2d2e(%rip),%rax
or     (%rax),%ecx
mov    0x2ce5(%rip),%rax
or     (%rax),%ecx
mov    0x2cec(%rip),%rax
mov    (%rax),%r8d
mov    0x2ce2(%rip),%rax
mov    (%rax),%r9d
mov    -0x24(%rbp),%r11d
mov    -0x28(%rbp),%r10d
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1080 <XGrabPointer@plt>
cmp    $0x0,%rax
je     1317 <main+0x107>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
lea    0xd12(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
jmp    14b7 <main+0x2a7>
jmp    131c <main+0x10c>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10c0 <XNextEvent@plt>
mov    -0x40(%rbp),%rax
mov    0x2c5c(%rip),%rcx
cmp    (%rcx),%rax
jne    131c <main+0x10c>
cmpl   $0x1,-0x38(%rbp)
je     1396 <main+0x186>
mov    -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10c0 <XNextEvent@plt>
mov    -0x40(%rbp),%rcx
mov    $0x1,%al
mov    0x2c01(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x59(%rbp)
jne    137f <main+0x16f>
mov    -0x38(%rbp),%eax
cmp    -0x44(%rbp),%eax
setne  %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    134d <main+0x13d>
movl   $0x2,-0x14(%rbp)
jmp    14a5 <main+0x295>
mov    0x2c1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
lea    -0x48(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    -0x40(%rbp),%rcx
mov    $0x1,%al
mov    0x2ba3(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x5a(%rbp)
jne    13db <main+0x1cb>
cmpl   $0x1,-0x38(%rbp)
setne  %al
mov    %al,-0x5a(%rbp)
mov    -0x5a(%rbp),%al
test   $0x1,%al
jne    13eb <main+0x1db>
jmp    14a0 <main+0x290>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    0x2b89(%rip),%rax
mov    (%rax),%r10d
mov    0x2bb7(%rip),%rax
mov    (%rax),%eax
mov    $0x1,%r9d
mov    %r9d,%r8d
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1130 <XGetImage@plt>
mov    %eax,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <XGetPixel@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%rdi
call   1110 <DefaultScreen@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%esi
call   10e0 <DefaultColormap@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
lea    -0x58(%rbp),%rdx
call   10f0 <XQueryColor@plt>
mov    -0x58(%rbp),%esi
sar    $0x8,%esi
mov    -0x54(%rbp),%edx
sar    $0x8,%edx
mov    -0x50(%rbp),%ecx
sar    $0x8,%ecx
lea    0xbb5(%rip),%rdi
call   1070 <printf@plt>
mov    0x2af1(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10c0 <XNextEvent@plt>
jmp    13b8 <main+0x1a8>
jmp    14a5 <main+0x295>
mov    -0x20(%rbp),%rdi
mov    0x2b38(%rip),%rax
mov    (%rax),%esi
call   10b0 <XUngrabPointer@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1100 <XFreeCursor@plt>
mov    -0x20(%rbp),%rdi
call   1120 <XCloseDisplay@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %edi,%edi
call   1090 <XOpenDisplay@plt>
test   %rax,%rax
je     12c7 <main+0xb7>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <DefaultRootWindow@plt>
mov    %eax,%r15d
mov    0x2d85(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1040 <XCreateFontCursor@plt>
mov    %eax,%r14d
mov    0x2d89(%rip),%rax
mov    0x2d72(%rip),%rdx
mov    0x2d73(%rip),%rcx
mov    (%rcx),%ecx
or     (%rdx),%ecx
mov    (%rax),%edx
mov    0x2d26(%rip),%rax
or     (%rax),%ecx
mov    0x2d2d(%rip),%rax
mov    (%rax),%r8d
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r8d,%r9d
push   %rax
push   %r14
push   %r15
call   1080 <XGrabPointer@plt>
add    $0x20,%rsp
test   %rax,%rax
je     12e7 <main+0xd7>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
lea    0xd61(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%r12d
jmp    1476 <main+0x266>
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
lea    0xd29(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%r12d
jmp    1489 <main+0x279>
mov    %rsp,%rbp
mov    0x2c9f(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbp,%rsi
call   10c0 <XNextEvent@plt>
mov    (%rsp),%rax
cmp    (%rbx),%rax
jne    1300 <main+0xf0>
mov    0x8(%rsp),%ebp
cmp    $0x1,%ebp
mov    %r14,0x30(%rsp)
jne    1431 <main+0x221>
mov    0x2c8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
xor    %r12d,%r12d
lea    0x18(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    (%rsp),%rax
mov    0x2c12(%rip),%rcx
cmp    (%rcx),%rax
jne    1366 <main+0x156>
cmpl   $0x1,0x8(%rsp)
je     1460 <main+0x250>
lea    0xcc3(%rip),%rbp
mov    %rsp,%r14
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%edx
mov    0x2c09(%rip),%rax
mov    (%rax),%eax
mov    0x2c38(%rip),%rsi
mov    (%rsi),%ebx
mov    %r13,%rdi
mov    %r15d,%esi
mov    $0x1,%r8d
mov    $0x1,%r9d
push   %rbx
push   %rax
call   1130 <XGetImage@plt>
add    $0x10,%rsp
xor    %r12d,%r12d
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <XGetPixel@plt>
mov    %eax,0x2c(%rsp)
mov    %r13,%rdi
call   1110 <DefaultScreen@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   10e0 <DefaultColormap@plt>
mov    %r13,%rdi
mov    %eax,%esi
lea    0x20(%rsp),%rdx
call   10f0 <XQueryColor@plt>
mov    0x20(%rsp),%esi
mov    0x24(%rsp),%edx
sar    $0x8,%esi
sar    $0x8,%edx
mov    0x28(%rsp),%ecx
sar    $0x8,%ecx
mov    %rbp,%rdi
call   1070 <printf@plt>
mov    0x2b7a(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   10c0 <XNextEvent@plt>
mov    (%rsp),%rax
mov    0x2b4d(%rip),%rcx
cmp    (%rcx),%rax
jne    1370 <main+0x160>
cmpl   $0x1,0x8(%rsp)
jne    1370 <main+0x160>
jmp    1460 <main+0x250>
mov    %rsp,%r14
mov    0x2b2d(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
call   10c0 <XNextEvent@plt>
mov    (%rsp),%rax
cmp    (%r15),%rax
jne    1440 <main+0x230>
cmp    %ebp,0x8(%rsp)
jne    1440 <main+0x230>
mov    $0x2,%r12d
mov    0x2b81(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   10b0 <XUngrabPointer@plt>
mov    0x30(%rsp),%r14
mov    %r13,%rdi
mov    %r14d,%esi
call   1100 <XFreeCursor@plt>
mov    %r13,%rdi
call   1120 <XCloseDisplay@plt>
mov    %r12d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i64, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32, i32, i32 }
%struct.sigaction = type { i32 }
%struct.TYPE_8__ = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"could not open display\0A\00"
@XC_crosshair = global i32 0
@False = global i32 0
@ButtonPressMask = global i32 0
@Button1MotionMask = global i32 0
@ButtonReleaseMask = global i32 0
@GrabModeAsync = global i32 0
@CurrentTime = global i32 0
@.str.1 = [24 x i8] c"could not grab pointer\0A\00"
@ButtonPress = global i64 0
@ButtonRelease = global i64 0
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@AllPlanes = global i32 0
@ZPixmap = global i32 0
@.str.2 = [10 x i8] c"%d %d %d\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.TYPE_7__
%11 = alloca i32
%12 = alloca %struct.sigaction
%13 = alloca %struct.TYPE_8__
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%14 = call i32* @XOpenDisplay(i32* null)
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp ne i32* %15, null
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %142
20: ; preds = %2
%21 = load i32*, i32** %7
%22 = call i32 @DefaultRootWindow(i32* %21)
store i32 %22, i32* %8
%23 = load i32*, i32** %7
%24 = load i32, i32* @XC_crosshair
%25 = call i32 @XCreateFontCursor(i32* %23, i32 %24)
store i32 %25, i32* %9
%26 = load i32*, i32** %7
%27 = load i32, i32* %8
%28 = load i32, i32* @False
%29 = load i32, i32* @ButtonPressMask
%30 = load i32, i32* @Button1MotionMask
%31 = or i32 %29, %30
%32 = load i32, i32* @ButtonReleaseMask
%33 = or i32 %31, %32
%34 = load i32, i32* @GrabModeAsync
%35 = load i32, i32* @GrabModeAsync
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = load i32, i32* @CurrentTime
%39 = call i64 @XGrabPointer(i32* %26, i32 %27, i32 %28, i32 %33, i32 %34, i32 %35, i32 %36, i32 %37, i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %20
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %135
44: ; preds = %20
br label %45
45: ; preds = %48, %44
%46 = load i32*, i32** %7
%47 = call i32 @XNextEvent(i32* %46, %struct.TYPE_7__* %10)
br label %48
48: ; preds = %45
%49 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 0
%50 = load i64, i64* %49
%51 = load i64, i64* @ButtonPress
%52 = icmp ne i64 %50, %51
br i1 %52, label %45, label %53
53: ; preds = %48
%54 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 1
%55 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = icmp ne i32 %56, 1
br i1 %57, label %58, label %79
58: ; preds = %53
%59 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 1
%60 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %59, i32 0, i32 0
%61 = load i32, i32* %60
store i32 %61, i32* %11
br label %62
62: ; preds = %76, %58
%63 = load i32*, i32** %7
%64 = call i32 @XNextEvent(i32* %63, %struct.TYPE_7__* %10)
br label %65
65: ; preds = %62
%66 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 0
%67 = load i64, i64* %66
%68 = load i64, i64* @ButtonRelease
%69 = icmp ne i64 %67, %68
br i1 %69, label %76, label %70
70: ; preds = %65
%71 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 1
%72 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %71, i32 0, i32 0
%73 = load i32, i32* %72
%74 = load i32, i32* %11
%75 = icmp ne i32 %73, %74
br label %76
76: ; preds = %70, %65
%77 = phi i1 [ true, %65 ], [ %75, %70 ]
br i1 %77, label %62, label %78
78: ; preds = %76
store i32 2, i32* %6
br label %131
79: ; preds = %53
%80 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %12, i32 0, i32 0
%81 = load i32, i32* @SIG_IGN
store i32 %81, i32* %80
%82 = load i32, i32* @SIGPIPE
%83 = call i32 @sigaction(i32 %82, %struct.sigaction* %12, i32* null)
br label %84
84: ; preds = %96, %79
%85 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 0
%86 = load i64, i64* %85
%87 = load i64, i64* @ButtonRelease
%88 = icmp ne i64 %86, %87
br i1 %88, label %94, label %89
89: ; preds = %84
%90 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 1
%91 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %90, i32 0, i32 0
%92 = load i32, i32* %91
%93 = icmp ne i32 %92, 1
br label %94
94: ; preds = %89, %84
%95 = phi i1 [ true, %84 ], [ %93, %89 ]
br i1 %95, label %96, label %130
96: ; preds = %94
%97 = load i32*, i32** %7
%98 = load i32, i32* %8
%99 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 1
%100 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %99, i32 0, i32 2
%101 = load i32, i32* %100
%102 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 1
%103 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %102, i32 0, i32 1
%104 = load i32, i32* %103
%105 = load i32, i32* @AllPlanes
%106 = load i32, i32* @ZPixmap
%107 = call i32 @XGetImage(i32* %97, i32 %98, i32 %101, i32 %104, i32 1, i32 1, i32 %105, i32 %106)
%108 = call i32 @XGetPixel(i32 %107, i32 0, i32 0)
%109 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %13, i32 0, i32 3
store i32 %108, i32* %109
%110 = load i32*, i32** %7
%111 = load i32*, i32** %7
%112 = load i32*, i32** %7
%113 = call i32 @DefaultScreen(i32* %112)
%114 = call i32 @DefaultColormap(i32* %111, i32 %113)
%115 = call i32 @XQueryColor(i32* %110, i32 %114, %struct.TYPE_8__* %13)
%116 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %13, i32 0, i32 0
%117 = load i32, i32* %116
%118 = ashr i32 %117, 8
%119 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %13, i32 0, i32 1
%120 = load i32, i32* %119
%121 = ashr i32 %120, 8
%122 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %13, i32 0, i32 2
%123 = load i32, i32* %122
%124 = ashr i32 %123, 8
%125 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %118, i32 %121, i32 %124)
%126 = load i32, i32* @stdout
%127 = call i32 @fflush(i32 %126)
%128 = load i32*, i32** %7
%129 = call i32 @XNextEvent(i32* %128, %struct.TYPE_7__* %10)
br label %84
130: ; preds = %94
br label %131
131: ; preds = %130, %78
%132 = load i32*, i32** %7
%133 = load i32, i32* @CurrentTime
%134 = call i32 @XUngrabPointer(i32* %132, i32 %133)
br label %135
135: ; preds = %131, %41
%136 = load i32*, i32** %7
%137 = load i32, i32* %9
%138 = call i32 @XFreeCursor(i32* %136, i32 %137)
%139 = load i32*, i32** %7
%140 = call i32 @XCloseDisplay(i32* %139)
%141 = load i32, i32* %6
store i32 %141, i32* %3
br label %142
142: ; preds = %135, %17
%143 = load i32, i32* %3
ret i32 %143
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i64, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32, i32, i32 }
%struct.sigaction = type { i32 }
%struct.TYPE_8__ = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"could not open display\0A\00"
@XC_crosshair = global i32 0
@False = global i32 0
@ButtonPressMask = global i32 0
@Button1MotionMask = global i32 0
@ButtonReleaseMask = global i32 0
@GrabModeAsync = global i32 0
@CurrentTime = global i32 0
@.str.1 = [24 x i8] c"could not grab pointer\0A\00"
@ButtonPress = global i64 0
@ButtonRelease = global i64 0
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@AllPlanes = global i32 0
@ZPixmap = global i32 0
@.str.2 = [10 x i8] c"%d %d %d\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.TYPE_7__
%4 = alloca %struct.sigaction
%5 = alloca %struct.TYPE_8__
%6 = tail call i32* @XOpenDisplay(i32* null)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %100
11: ; preds = %2
%12 = tail call i32 @DefaultRootWindow(i32* %6)
%13 = load i32, i32* @XC_crosshair
%14 = tail call i32 @XCreateFontCursor(i32* %6, i32 %13)
%15 = load i32, i32* @False
%16 = load i32, i32* @ButtonPressMask
%17 = load i32, i32* @Button1MotionMask
%18 = or i32 %17, %16
%19 = load i32, i32* @ButtonReleaseMask
%20 = or i32 %18, %19
%21 = load i32, i32* @GrabModeAsync
%22 = load i32, i32* @CurrentTime
%23 = tail call i64 @XGrabPointer(i32* %6, i32 %12, i32 %15, i32 %20, i32 %21, i32 %21, i32 %12, i32 %14, i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %11
%26 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 0
br label %30
27: ; preds = %11
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %96
30: ; preds = %25, %30
%31 = call i32 @XNextEvent(i32* %6, %struct.TYPE_7__* %3)
%32 = load i64, i64* %26
%33 = load i64, i64* @ButtonPress
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %30
35: ; preds = %30
%36 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 1, i32 0
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 1
br i1 %38, label %47, label %39
39: ; preds = %35, %39
%40 = call i32 @XNextEvent(i32* %6, %struct.TYPE_7__* %3)
%41 = load i64, i64* %26
%42 = load i64, i64* @ButtonRelease
%43 = icmp ne i64 %41, %42
%44 = load i32, i32* %36
%45 = icmp ne i32 %44, %37
%46 = select i1 %43, i1 true, i1 %45
br i1 %46, label %39, label %92
47: ; preds = %35
%48 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i64 0, i32 0
%49 = load i32, i32* @SIG_IGN
store i32 %49, i32* %48
%50 = load i32, i32* @SIGPIPE
%51 = call i32 @sigaction(i32 %50, %struct.sigaction* %4, i32* null)
%52 = load i64, i64* %26
%53 = load i64, i64* @ButtonRelease
%54 = icmp ne i64 %52, %53
%55 = load i32, i32* %36
%56 = icmp ne i32 %55, 1
%57 = select i1 %54, i1 true, i1 %56
br i1 %57, label %58, label %92
58: ; preds = %47
%59 = bitcast %struct.TYPE_8__* %5 to i8*
%60 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 1, i32 2
%61 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 1, i32 1
%62 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %5, i64 0, i32 3
%63 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %5, i64 0, i32 0
%64 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %5, i64 0, i32 1
%65 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %5, i64 0, i32 2
br label %66
66: ; preds = %58, %66
%67 = load i32, i32* %60
%68 = load i32, i32* %61
%69 = load i32, i32* @AllPlanes
%70 = load i32, i32* @ZPixmap
%71 = call i32 @XGetImage(i32* %6, i32 %12, i32 %67, i32 %68, i32 1, i32 1, i32 %69, i32 %70)
%72 = call i32 @XGetPixel(i32 %71, i32 0, i32 0)
store i32 %72, i32* %62
%73 = call i32 @DefaultScreen(i32* %6)
%74 = call i32 @DefaultColormap(i32* %6, i32 %73)
%75 = call i32 @XQueryColor(i32* %6, i32 %74, %struct.TYPE_8__* %5)
%76 = load i32, i32* %63
%77 = ashr i32 %76, 8
%78 = load i32, i32* %64
%79 = ashr i32 %78, 8
%80 = load i32, i32* %65
%81 = ashr i32 %80, 8
%82 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %77, i32 %79, i32 %81)
%83 = load i32, i32* @stdout
%84 = call i32 @fflush(i32 %83)
%85 = call i32 @XNextEvent(i32* %6, %struct.TYPE_7__* %3)
%86 = load i64, i64* %26
%87 = load i64, i64* @ButtonRelease
%88 = icmp ne i64 %86, %87
%89 = load i32, i32* %36
%90 = icmp ne i32 %89, 1
%91 = select i1 %88, i1 true, i1 %90
br i1 %91, label %66, label %92
92: ; preds = %39, %66, %47
%93 = phi i32 [ 0, %47 ], [ 0, %66 ], [ 2, %39 ]
%94 = load i32, i32* @CurrentTime
%95 = call i32 @XUngrabPointer(i32* %6, i32 %94)
br label %96
96: ; preds = %92, %27
%97 = phi i32 [ 1, %27 ], [ %93, %92 ]
%98 = call i32 @XFreeCursor(i32* %6, i32 %14)
%99 = call i32 @XCloseDisplay(i32* %6)
br label %100
100: ; preds = %96, %8
%101 = phi i32 [ %97, %96 ], [ 1, %8 ]
ret i32 %101
}