#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_9__ TYPE_4__;
typedef struct TYPE_8__ TYPE_3__;
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct TYPE_7__ {
  long *l;
};
struct TYPE_8__ {
  int format;
  TYPE_2__ data;
  scalar_t__ message_type;
};
struct TYPE_6__ {
  int width;
  int height;
};
struct TYPE_9__ {
  int type;
  int /*<<< orphan*/ xkey;
  TYPE_3__ xclient;
  TYPE_1__ xconfigure;
};
typedef TYPE_4__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;
typedef scalar_t__ Atom;

/* Variables and functions */
int BlackPixel(int /*<<< orphan*/ *, int);
#define ClientMessage 131
#define ConfigureNotify 130
int DefaultScreen(int /*<<< orphan*/ *);
#define Expose 129
long ExposureMask;
int /*<<< orphan*/ False;
#define KeyPress 128
long KeyPressMask;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int);
long StructureNotifyMask;
int WhitePixel(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCreateGC(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateSimpleWindow(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                       int /*<<< orphan*/, int /*<<< orphan*/,
                                       int, int, int /*<<< orphan*/, int, int);
char *XDisplayName(int /*<<< orphan*/ *);
int /*<<< orphan*/ XDrawLine(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/, int, int,
                             int);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
scalar_t__ XInternAtom(int /*<<< orphan*/ *, char *, 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*/, long);
int /*<<< orphan*/ XSetForeground(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int);
int /*<<< orphan*/ XSetWMProtocols(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   scalar_t__ *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ key_press(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  (void)argc;
  (void)argv;
  Display *dpy = XOpenDisplay(NULL);
  if (!dpy) {
    fprintf(stderr, "error: unable to open display '%s'\n", XDisplayName(NULL));
    exit(1);
  }
  int screen = DefaultScreen(dpy);
  int black_color = BlackPixel(dpy, screen),
      white_color = WhitePixel(dpy, screen);
  int width = 160, height = 120;
  Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, screen), 0, 0, width,
                                   height, 0, white_color, white_color);
  long event_mask = KeyPressMask | StructureNotifyMask | ExposureMask;
  XSelectInput(dpy, win, event_mask);
  XMapWindow(dpy, win);
  Atom wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", False);
  Atom wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
  XSetWMProtocols(dpy, win, &wm_delete_window, 1);
  GC gc = XCreateGC(dpy, win, 0, 0);
  XSetForeground(dpy, gc, black_color);
  while (1) {
    XEvent e;
    XNextEvent(dpy, &e);
    switch (e.type) {
    case Expose:
      XDrawLine(dpy, win, gc, 0, 0, width, height);
      XDrawLine(dpy, win, gc, 0, height, width, 0);
      XFlush(dpy);
      break;
    case ConfigureNotify:
      if (e.xconfigure.width != width || e.xconfigure.height != height) {
        width = e.xconfigure.width;
        height = e.xconfigure.height;
      }
      break;
    case ClientMessage:
      if (e.xclient.message_type == wm_protocols) {
        if (e.xclient.format == 32 &&
            e.xclient.data.l[0] == (long)wm_delete_window) {
          goto done;
        }
      }
      break;
    case KeyPress:
      key_press(&e.xkey);
      break;
    }
  }
done:
  XCloseDisplay(dpy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12a2 <main+0x62>
mov    0x2d50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <XDisplayName@plt>
mov    -0x7c(%rbp),%edi
mov    %rax,%rdx
lea    0xd7d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1140 <DefaultScreen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10e0 <BlackPixel@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <WhitePixel@plt>
mov    %eax,-0x24(%rbp)
movl   $0xa0,-0x28(%rbp)
movl   $0x78,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <RootWindow@plt>
mov    -0x88(%rbp),%rdi
mov    %eax,%esi
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x24(%rbp),%r10d
mov    -0x24(%rbp),%eax
xor    %ecx,%ecx
mov    %ecx,%edx
movl   $0x0,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   10d0 <XCreateSimpleWindow@plt>
mov    %eax,-0x30(%rbp)
mov    0x2cb4(%rip),%rax
mov    (%rax),%rax
mov    0x2c9a(%rip),%rcx
or     (%rcx),%rax
mov    0x2c80(%rip),%rcx
or     (%rcx),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   10b0 <XSelectInput@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1110 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
mov    0x2c7a(%rip),%rax
mov    (%rax),%edx
lea    0xcbd(%rip),%rsi
call   1080 <XInternAtom@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2c5d(%rip),%rax
mov    (%rax),%edx
lea    0xcad(%rip),%rsi
call   1080 <XInternAtom@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
lea    -0x48(%rbp),%rdx
mov    $0x1,%ecx
call   1060 <XSetWMProtocols@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   10c0 <XCreateGC@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   10f0 <XSetForeground@plt>
mov    -0x18(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1070 <XNextEvent@plt>
mov    -0x78(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x90(%rbp)
sub    $0x3,%eax
ja     14cb <main+0x28b>
mov    -0x90(%rbp),%rax
lea    0xbf9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    -0x28(%rbp),%r9d
mov    -0x2c(%rbp),%eax
xor    %r8d,%r8d
mov    %r8d,%ecx
mov    %eax,(%rsp)
call   1160 <XDrawLine@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    -0x2c(%rbp),%r8d
mov    -0x28(%rbp),%r9d
xor    %ecx,%ecx
movl   $0x0,(%rsp)
call   1160 <XDrawLine@plt>
mov    -0x18(%rbp),%rdi
call   1100 <XFlush@plt>
jmp    14cb <main+0x28b>
mov    -0x58(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    1475 <main+0x235>
mov    -0x54(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     1481 <main+0x241>
mov    -0x58(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    14cb <main+0x28b>
mov    -0x60(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    14b9 <main+0x279>
cmpl   $0x20,-0x70(%rbp)
jne    14b4 <main+0x274>
mov    -0x68(%rbp),%rax
mov    (%rax),%rax
cmp    -0x48(%rbp),%rax
jne    14b4 <main+0x274>
jmp    14d0 <main+0x290>
jmp    14b9 <main+0x279>
jmp    14cb <main+0x28b>
lea    -0x78(%rbp),%rdi
add    $0x4,%rdi
call   1120 <key_press@plt>
jmp    13d4 <main+0x194>
mov    -0x18(%rbp),%rdi
call   1150 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0xb0,%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   1040 <XOpenDisplay@plt>
test   %rax,%rax
je     1478 <main+0x238>
mov    %rax,%r15
mov    %rax,%rdi
call   1140 <DefaultScreen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %eax,%esi
call   10e0 <BlackPixel@plt>
mov    %eax,%r12d
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <WhitePixel@plt>
mov    %eax,%r14d
mov    %r15,%rdi
mov    %ebp,%esi
call   10a0 <RootWindow@plt>
mov    %r14d,0x10(%rsp)
mov    %r14d,0x8(%rsp)
movl   $0x0,(%rsp)
movl   $0xa0,0x24(%rsp)
mov    %r15,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0xa0,%r8d
mov    $0x78,%r9d
call   10d0 <XCreateSimpleWindow@plt>
mov    0x2d17(%rip),%rcx
mov    0x2d00(%rip),%rdx
mov    (%rdx),%rdx
or     (%rcx),%rdx
mov    %eax,%r13d
mov    0x2ce0(%rip),%rax
or     (%rax),%rdx
mov    %r15,%rdi
mov    %r13d,%esi
call   10b0 <XSelectInput@plt>
mov    %r15,%rdi
mov    %r13d,%esi
call   1110 <XMapWindow@plt>
mov    0x2ce8(%rip),%rbx
mov    (%rbx),%edx
lea    0xd2b(%rip),%rsi
mov    %r15,%rdi
call   1080 <XInternAtom@plt>
mov    %rax,0x38(%rsp)
mov    (%rbx),%edx
lea    0xd22(%rip),%rsi
mov    %r15,%rdi
call   1080 <XInternAtom@plt>
mov    %rax,0x30(%rsp)
lea    0x30(%rsp),%rdx
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x1,%ecx
call   1060 <XSetWMProtocols@plt>
mov    %r15,%rdi
mov    %r13d,0x2c(%rsp)
mov    %r13d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10c0 <XCreateGC@plt>
mov    %r15,%rdi
mov    %eax,0x28(%rsp)
mov    %eax,%esi
mov    %r12d,%edx
mov    $0x78,%r12d
call   10f0 <XSetForeground@plt>
lea    0x40(%rsp),%rbp
lea    0xc88(%rip),%rbx
mov    0x2c(%rsp),%r13d
jmp    13b0 <main+0x170>
nop
mov    0x60(%rsp),%eax
mov    0x64(%rsp),%ecx
mov    %eax,%edx
mov    0x24(%rsp),%edi
xor    %edi,%edx
mov    %ecx,%esi
xor    %r12d,%esi
or     %edx,%esi
cmovne %ecx,%r12d
cmovne %eax,%edi
mov    %edi,0x24(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <XNextEvent@plt>
mov    0x40(%rsp),%eax
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     13b0 <main+0x170>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
lea    0x44(%rsp),%rdi
call   1120 <key_press@plt>
jmp    13b0 <main+0x170>
nopl   0x0(%rax)
mov    0x38(%rsp),%rax
cmp    %rax,0x58(%rsp)
jne    13b0 <main+0x170>
cmpl   $0x20,0x48(%rsp)
jne    13b0 <main+0x170>
mov    0x50(%rsp),%rax
mov    (%rax),%rax
cmp    0x30(%rsp),%rax
jne    13b0 <main+0x170>
jmp    145f <main+0x21f>
mov    %r12d,(%rsp)
mov    %r15,%rdi
mov    %r13d,%esi
mov    %r12d,%ebx
mov    0x28(%rsp),%r12d
mov    %r12d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    0x24(%rsp),%r14d
mov    %r14d,%r9d
call   1160 <XDrawLine@plt>
movl   $0x0,(%rsp)
mov    %r15,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %ebx,%r12d
xor    %ecx,%ecx
mov    %ebx,%r8d
mov    %r14d,%r9d
lea    0xbb3(%rip),%rbx
call   1160 <XDrawLine@plt>
mov    %r15,%rdi
call   1100 <XFlush@plt>
jmp    13b0 <main+0x170>
mov    %r15,%rdi
call   1150 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b49(%rip),%rax
mov    (%rax),%ebx
xor    %edi,%edi
call   1090 <XDisplayName@plt>
lea    0xb81(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_9__ = type { i32, i32, %struct.TYPE_8__, %struct.TYPE_6__ }
%struct.TYPE_8__ = type { i32, %struct.TYPE_7__, i64 }
%struct.TYPE_7__ = type { i64* }
%struct.TYPE_6__ = type { i32, i32 }
@stderr = global i32 0
@.str = [36 x i8] c"error: unable to open display '%s'\0A\00"
@KeyPressMask = global i64 0
@StructureNotifyMask = global i64 0
@ExposureMask = global i64 0
@.str.1 = [13 x i8] c"WM_PROTOCOLS\00"
@False = global i32 0
@.str.2 = [17 x i8] c"WM_DELETE_WINDOW\00"
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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca %struct.TYPE_9__
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32* @XOpenDisplay(i32* null)
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %28, label %23
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = call i8* @XDisplayName(i32* null)
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = load i32*, i32** %6
%30 = call i32 @DefaultScreen(i32* %29)
store i32 %30, i32* %7
%31 = load i32*, i32** %6
%32 = load i32, i32* %7
%33 = call i32 @BlackPixel(i32* %31, i32 %32)
store i32 %33, i32* %8
%34 = load i32*, i32** %6
%35 = load i32, i32* %7
%36 = call i32 @WhitePixel(i32* %34, i32 %35)
store i32 %36, i32* %9
store i32 160, i32* %10
store i32 120, i32* %11
%37 = load i32*, i32** %6
%38 = load i32*, i32** %6
%39 = load i32, i32* %7
%40 = call i32 @RootWindow(i32* %38, i32 %39)
%41 = load i32, i32* %10
%42 = load i32, i32* %11
%43 = load i32, i32* %9
%44 = load i32, i32* %9
%45 = call i32 @XCreateSimpleWindow(i32* %37, i32 %40, i32 0, i32 0, i32 %41, i32 %42, i32 0, i32 %43, i32 %44)
store i32 %45, i32* %12
%46 = load i64, i64* @KeyPressMask
%47 = load i64, i64* @StructureNotifyMask
%48 = or i64 %46, %47
%49 = load i64, i64* @ExposureMask
%50 = or i64 %48, %49
store i64 %50, i64* %13
%51 = load i32*, i32** %6
%52 = load i32, i32* %12
%53 = load i64, i64* %13
%54 = call i32 @XSelectInput(i32* %51, i32 %52, i64 %53)
%55 = load i32*, i32** %6
%56 = load i32, i32* %12
%57 = call i32 @XMapWindow(i32* %55, i32 %56)
%58 = load i32*, i32** %6
%59 = load i32, i32* @False
%60 = call i64 @XInternAtom(i32* %58, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %59)
store i64 %60, i64* %14
%61 = load i32*, i32** %6
%62 = load i32, i32* @False
%63 = call i64 @XInternAtom(i32* %61, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %62)
store i64 %63, i64* %15
%64 = load i32*, i32** %6
%65 = load i32, i32* %12
%66 = call i32 @XSetWMProtocols(i32* %64, i32 %65, i64* %15, i32 1)
%67 = load i32*, i32** %6
%68 = load i32, i32* %12
%69 = call i32 @XCreateGC(i32* %67, i32 %68, i32 0, i32 0)
store i32 %69, i32* %16
%70 = load i32*, i32** %6
%71 = load i32, i32* %16
%72 = load i32, i32* %8
%73 = call i32 @XSetForeground(i32* %70, i32 %71, i32 %72)
br label %74
74: ; preds = %28, %140
%75 = load i32*, i32** %6
%76 = call i32 @XNextEvent(i32* %75, %struct.TYPE_9__* %17)
%77 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 0
%78 = load i32, i32* %77
switch i32 %78, label %140 [
i32 129, label %79
i32 130, label %94
i32 131, label %114
i32 128, label %137
]
79: ; preds = %74
%80 = load i32*, i32** %6
%81 = load i32, i32* %12
%82 = load i32, i32* %16
%83 = load i32, i32* %10
%84 = load i32, i32* %11
%85 = call i32 @XDrawLine(i32* %80, i32 %81, i32 %82, i32 0, i32 0, i32 %83, i32 %84)
%86 = load i32*, i32** %6
%87 = load i32, i32* %12
%88 = load i32, i32* %16
%89 = load i32, i32* %11
%90 = load i32, i32* %10
%91 = call i32 @XDrawLine(i32* %86, i32 %87, i32 %88, i32 0, i32 %89, i32 %90, i32 0)
%92 = load i32*, i32** %6
%93 = call i32 @XFlush(i32* %92)
br label %140
94: ; preds = %74
%95 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 3
%96 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %95, i32 0, i32 0
%97 = load i32, i32* %96
%98 = load i32, i32* %10
%99 = icmp ne i32 %97, %98
br i1 %99, label %106, label %100
100: ; preds = %94
%101 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 3
%102 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %101, i32 0, i32 1
%103 = load i32, i32* %102
%104 = load i32, i32* %11
%105 = icmp ne i32 %103, %104
br i1 %105, label %106, label %113
106: ; preds = %100, %94
%107 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 3
%108 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %107, i32 0, i32 0
%109 = load i32, i32* %108
store i32 %109, i32* %10
%110 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 3
%111 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %110, i32 0, i32 1
%112 = load i32, i32* %111
store i32 %112, i32* %11
br label %113
113: ; preds = %106, %100
br label %140
114: ; preds = %74
%115 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 2
%116 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %115, i32 0, i32 2
%117 = load i64, i64* %116
%118 = load i64, i64* %14
%119 = icmp eq i64 %117, %118
br i1 %119, label %120, label %136
120: ; preds = %114
%121 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 2
%122 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %121, i32 0, i32 0
%123 = load i32, i32* %122
%124 = icmp eq i32 %123, 32
br i1 %124, label %125, label %135
125: ; preds = %120
%126 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 2
%127 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %126, i32 0, i32 1
%128 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %127, i32 0, i32 0
%129 = load i64*, i64** %128
%130 = getelementptr inbounds i64, i64* %129, i64 0
%131 = load i64, i64* %130
%132 = load i64, i64* %15
%133 = icmp eq i64 %131, %132
br i1 %133, label %134, label %135
134: ; preds = %125
br label %141
135: ; preds = %125, %120
br label %136
136: ; preds = %135, %114
br label %140
137: ; preds = %74
%138 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 1
%139 = call i32 @key_press(i32* %138)
br label %140
140: ; preds = %74, %137, %136, %113, %79
br label %74
141: ; preds = %134
%142 = load i32*, i32** %6
%143 = call i32 @XCloseDisplay(i32* %142)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_9__ = type { i32, i32, %struct.TYPE_8__, %struct.TYPE_6__ }
%struct.TYPE_8__ = type { i32, %struct.TYPE_7__, i64 }
%struct.TYPE_7__ = type { i64* }
%struct.TYPE_6__ = type { i32, i32 }
@stderr = global i32 0
@.str = [36 x i8] c"error: unable to open display '%s'\0A\00"
@KeyPressMask = global i64 0
@StructureNotifyMask = global i64 0
@ExposureMask = global i64 0
@.str.1 = [13 x i8] c"WM_PROTOCOLS\00"
@False = global i32 0
@.str.2 = [17 x i8] c"WM_DELETE_WINDOW\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca %struct.TYPE_9__
%5 = tail call i32* @XOpenDisplay(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i8* @XDisplayName(i32* null)
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = tail call i32 @DefaultScreen(i32* %5)
%14 = tail call i32 @BlackPixel(i32* %5, i32 %13)
%15 = tail call i32 @WhitePixel(i32* %5, i32 %13)
%16 = tail call i32 @RootWindow(i32* %5, i32 %13)
%17 = tail call i32 @XCreateSimpleWindow(i32* %5, i32 %16, i32 0, i32 0, i32 160, i32 120, i32 0, i32 %15, i32 %15)
%18 = load i64, i64* @KeyPressMask
%19 = load i64, i64* @StructureNotifyMask
%20 = or i64 %19, %18
%21 = load i64, i64* @ExposureMask
%22 = or i64 %20, %21
%23 = tail call i32 @XSelectInput(i32* %5, i32 %17, i64 %22)
%24 = tail call i32 @XMapWindow(i32* %5, i32 %17)
%25 = load i32, i32* @False
%26 = tail call i64 @XInternAtom(i32* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = bitcast i64* %3 to i8*
%28 = load i32, i32* @False
%29 = tail call i64 @XInternAtom(i32* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %28)
store i64 %29, i64* %3
%30 = call i32 @XSetWMProtocols(i32* %5, i32 %17, i64* %3, i32 1)
%31 = call i32 @XCreateGC(i32* %5, i32 %17, i32 0, i32 0)
%32 = call i32 @XSetForeground(i32* %5, i32 %31, i32 %14)
%33 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %4, i64 0, i32 2, i32 1, i32 0
%34 = bitcast %struct.TYPE_9__* %4 to i8*
%35 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %4, i64 0, i32 0
%36 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %4, i64 0, i32 1
%37 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %4, i64 0, i32 2, i32 2
%38 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %4, i64 0, i32 2, i32 0
%39 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %4, i64 0, i32 3, i32 0
%40 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %4, i64 0, i32 3, i32 1
br label %41
41: ; preds = %71, %12
%42 = phi i32 [ 120, %12 ], [ %72, %71 ]
%43 = phi i32 [ 160, %12 ], [ %73, %71 ]
%44 = call i32 @XNextEvent(i32* %5, %struct.TYPE_9__* %4)
%45 = load i32, i32* %35
switch i32 %45, label %71 [
i32 129, label %46
i32 130, label %50
i32 131, label %58
i32 128, label %69
]
46: ; preds = %41
%47 = call i32 @XDrawLine(i32* %5, i32 %17, i32 %31, i32 0, i32 0, i32 %43, i32 %42)
%48 = call i32 @XDrawLine(i32* %5, i32 %17, i32 %31, i32 0, i32 %42, i32 %43, i32 0)
%49 = call i32 @XFlush(i32* %5)
br label %71
50: ; preds = %41
%51 = load i32, i32* %39
%52 = icmp eq i32 %51, %43
%53 = load i32, i32* %40
%54 = icmp eq i32 %53, %42
%55 = select i1 %52, i1 %54, i1 false
%56 = select i1 %55, i32 %42, i32 %53
%57 = select i1 %55, i32 %43, i32 %51
br label %71
58: ; preds = %41
%59 = load i64, i64* %37
%60 = icmp eq i64 %59, %26
%61 = load i32, i32* %38
%62 = icmp eq i32 %61, 32
%63 = select i1 %60, i1 %62, i1 false
br i1 %63, label %64, label %71
64: ; preds = %58
%65 = load i64*, i64** %33
%66 = load i64, i64* %65
%67 = load i64, i64* %3
%68 = icmp eq i64 %66, %67
br i1 %68, label %74, label %71
69: ; preds = %41
%70 = call i32 @key_press(i32* %36)
br label %71
71: ; preds = %50, %46, %69, %41, %64, %58
%72 = phi i32 [ %42, %41 ], [ %42, %69 ], [ %42, %64 ], [ %42, %58 ], [ %42, %46 ], [ %56, %50 ]
%73 = phi i32 [ %43, %41 ], [ %43, %69 ], [ %43, %64 ], [ %43, %58 ], [ %43, %46 ], [ %57, %50 ]
br label %41
74: ; preds = %64
%75 = call i32 @XCloseDisplay(i32* %5)
ret i32 0
}