#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_16__ TYPE_5__;
typedef struct TYPE_15__ TYPE_3__;
typedef struct TYPE_14__ TYPE_2__;
typedef struct TYPE_13__ TYPE_1__;

/* Type definitions */
struct timespec {
  double tv_sec;
  int tv_nsec;
};
struct TYPE_15__ {
  int flags;
  int min_width;
  int min_height;
  int /*<<< orphan*/ initial_state;
  void *input;
};
typedef TYPE_3__ XWMHints;
typedef TYPE_3__ XSizeHints;
struct TYPE_13__ {
  int /*<<< orphan*/ *l;
};
struct TYPE_14__ {
  TYPE_1__ data;
  int /*<<< orphan*/ message_type;
};
struct TYPE_16__ {
  int type;
  int /*<<< orphan*/ xkey;
  TYPE_2__ xclient;
};
typedef TYPE_5__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ KeySym;
typedef int /*<<< orphan*/ Display;
typedef void *Bool;
typedef int /*<<< orphan*/ Atom;

/* Variables and functions */
unsigned long BlackPixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ CLOCK_MONOTONIC_RAW;
#define ClientMessage 129
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ DefaultScreen(int /*<<< orphan*/ *);
scalar_t__ EINTR;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ ExposureMask;
void *False;
int InputHint;
#define KeyPress 128
int /*<<< orphan*/ KeyPressMask;
int /*<<< orphan*/ NormalState;
int PMinSize;
int StateHint;
void *True;
TYPE_3__ *XAllocSizeHints();
TYPE_3__ *XAllocWMHints();
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCreateSimpleWindow(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                       int /*<<< orphan*/, int /*<<< orphan*/,
                                       int, int, int /*<<< orphan*/,
                                       unsigned long, unsigned long);
int /*<<< orphan*/ XDestroyWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XFree(TYPE_3__ *);
int /*<<< orphan*/ XInternAtom(int /*<<< orphan*/ *, char *, void *);
char *XKeysymToString(int /*<<< orphan*/);
int /*<<< orphan*/ XLookupKeysym(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_5__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
scalar_t__ XPending(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSelectInput(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ XSetWMProtocols(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XWindowEvent(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/, TYPE_5__ *);
int /*<<< orphan*/ Xutf8SetWMProperties(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, char *, char *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, TYPE_3__ *,
                                        TYPE_3__ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
scalar_t__ errno;
int nanosleep(struct timespec *, struct timespec *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ timespec_diff(struct timespec *, struct timespec *);
int main(int argc, char *argv[]) {
  Display *dpy = XOpenDisplay(NULL);
  if (dpy == NULL) {
    return EXIT_FAILURE;
  }
  unsigned long black = BlackPixel(dpy, DefaultScreen(dpy));
  Window win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 800, 600,
                                   0, black, black);
  XWMHints *wmhints = XAllocWMHints();
  wmhints->flags = InputHint | StateHint;
  wmhints->input = True;
  wmhints->initial_state = NormalState;
  XSizeHints *sizehints = XAllocSizeHints();
  sizehints->flags = PMinSize;
  sizehints->min_width = 400;
  sizehints->min_height = 300;
  Xutf8SetWMProperties(dpy, win, "Phase 01", "", NULL, 0, sizehints, wmhints,
                       NULL);
  XSelectInput(dpy, win, ExposureMask);
  Atom wm_protocol = XInternAtom(dpy, "WM_PROTOCOLS", True);
  Atom wm_delete = XInternAtom(dpy, "WM_DELETE_WINDOW", True);
  XSetWMProtocols(dpy, win, &wm_delete, 1);
  XMapWindow(dpy, win);
  XEvent e;
  XWindowEvent(dpy, win, ExposureMask, &e);
  XSelectInput(dpy, win, KeyPressMask);
  Bool done = False;
  struct timespec prev, curr;
  clock_gettime(CLOCK_MONOTONIC_RAW, &curr);
  prev.tv_sec = curr.tv_sec;
  prev.tv_nsec = curr.tv_nsec;
  double mill_store = 0;
  KeySym event_key;
  char *key_string = NULL;
  while (!done) {
    clock_gettime(CLOCK_MONOTONIC_RAW, &curr);
    mill_store += timespec_diff(&curr, &prev);
    while (XPending(dpy) > 0) {
      XNextEvent(dpy, &e);
      switch (e.type) {
      case ClientMessage:
        if (e.xclient.message_type == wm_protocol) {
          if (e.xclient.data.l[0] == wm_delete) {
            done = True;
          }
        }
        break;
      case KeyPress:
        event_key = XLookupKeysym(&(e.xkey), 0);
        key_string = XKeysymToString(event_key);
        printf("Key pressed: %s\n", key_string);
        break;
      }
    }
    if (mill_store > 16.6 && !done) {
      for (; mill_store > 16.6 && !done; mill_store -= 16.6) {
      }
    }
    prev.tv_sec = curr.tv_sec;
    prev.tv_nsec = curr.tv_nsec;
    if (mill_store < 16.6 && !done) {
      struct timespec sleep_required, sleep_remaining;
      int was_error = 0;
      sleep_remaining.tv_sec = mill_store / 1000.0;
      sleep_remaining.tv_nsec = ((int)mill_store % 1000) * 1000000;
      do {
        sleep_required.tv_sec = sleep_remaining.tv_sec;
        sleep_required.tv_nsec = sleep_remaining.tv_nsec;
        errno = 0;
        was_error = nanosleep(&sleep_required, &sleep_remaining);
      } while (was_error == -1 && errno == EINTR);
    }
  }
  XFree(sizehints);
  sizehints = NULL;
  XFree(wmhints);
  wmhints = NULL;
  XDestroyWindow(dpy, win);
  XCloseDisplay(dpy);
  dpy = NULL;
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12c2 <main+0x42>
mov    0x2cf0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17ba <main+0x53a>
mov    -0x18(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x18(%rbp),%rdi
call   1180 <DefaultScreen@plt>
mov    -0xd0(%rbp),%rdi
mov    %eax,%esi
call   1140 <BlackPixel@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <DefaultRootWindow@plt>
mov    -0xc8(%rbp),%rdi
mov    %eax,%esi
mov    -0x20(%rbp),%r10
mov    -0x20(%rbp),%rax
xor    %ecx,%ecx
mov    $0x320,%r8d
mov    $0x258,%r9d
mov    %ecx,%edx
movl   $0x0,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1130 <XCreateSimpleWindow@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   10e0 <XAllocWMHints@plt>
mov    %rax,-0x30(%rbp)
mov    0x2c98(%rip),%rax
mov    (%rax),%ecx
mov    0x2ca7(%rip),%rax
or     (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2c68(%rip),%rax
mov    (%rax),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    0x2c26(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    $0x0,%al
call   10d0 <XAllocSizeHints@plt>
mov    %rax,-0x38(%rbp)
mov    0x2bf3(%rip),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x190,0x4(%rax)
mov    -0x38(%rbp),%rax
movl   $0x12c,0x8(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x38(%rbp),%r10
mov    -0x30(%rbp),%rax
lea    0xc4f(%rip),%rdx
lea    0xc7f(%rip),%rcx
xor    %r8d,%r8d
xor    %r9d,%r9d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   10a0 <Xutf8SetWMProperties@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2b95(%rip),%rax
mov    (%rax),%edx
call   1120 <XSelectInput@plt>
mov    -0x18(%rbp),%rdi
mov    0x2bc3(%rip),%rax
mov    (%rax),%rdx
lea    0xc0a(%rip),%rsi
call   1100 <XInternAtom@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2ba6(%rip),%rax
mov    (%rax),%rdx
lea    0xbfa(%rip),%rsi
call   1100 <XInternAtom@plt>
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x40(%rbp),%rdx
mov    $0x1,%ecx
call   10c0 <XSetWMProtocols@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1150 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2b25(%rip),%rax
mov    (%rax),%edx
lea    -0x58(%rbp),%rcx
call   1160 <XWindowEvent@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2b54(%rip),%rax
mov    (%rax),%edx
call   1120 <XSelectInput@plt>
mov    0x2b4e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    0x2b28(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rsi
call   1030 <clock_gettime@plt>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movq   $0x0,-0x98(%rbp)
cmpq   $0x0,-0x60(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    14e0 <main+0x260>
jmp    176f <main+0x4ef>
mov    0x2ad9(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rsi
call   1030 <clock_gettime@plt>
lea    -0x80(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1170 <timespec_diff@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x18(%rbp),%rdi
call   1040 <XPending@plt>
cmp    $0x0,%rax
jle    15d5 <main+0x355>
mov    -0x18(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   10f0 <XNextEvent@plt>
mov    -0x58(%rbp),%eax
mov    %eax,-0xd4(%rbp)
sub    $0x80,%eax
je     1596 <main+0x316>
jmp    154d <main+0x2cd>
mov    -0xd4(%rbp),%eax
sub    $0x81,%eax
jne    15d0 <main+0x350>
jmp    1563 <main+0x2e3>
mov    -0x48(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jne    1591 <main+0x311>
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
cmp    -0x40(%rbp),%eax
jne    158c <main+0x30c>
mov    0x2a43(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    1591 <main+0x311>
jmp    15d0 <main+0x350>
lea    -0x58(%rbp),%rdi
add    $0x4,%rdi
xor    %esi,%esi
call   1110 <XLookupKeysym@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%edi
call   11a0 <XKeysymToString@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rsi
lea    0xa6c(%rip),%rdi
call   1060 <printf@plt>
jmp    1514 <main+0x294>
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xa1b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    166f <main+0x3ef>
cmpq   $0x0,-0x60(%rbp)
jne    166f <main+0x3ef>
jmp    15ff <main+0x37f>
movsd  -0x88(%rbp),%xmm0
ff
xor    %eax,%eax
movsd  0x9ef(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0xd5(%rbp)
jbe    1631 <main+0x3b1>
cmpq   $0x0,-0x60(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0xd5(%rbp)
mov    -0xd5(%rbp),%al
test   $0x1,%al
jne    1644 <main+0x3c4>
jmp    166a <main+0x3ea>
jmp    1649 <main+0x3c9>
movsd  -0x88(%rbp),%xmm0
ff
movsd  0x9a7(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    15ff <main+0x37f>
jmp    166f <main+0x3ef>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x68(%rbp)
movsd  0x979(%rip),%xmm0
ucomisd -0x88(%rbp),%xmm0
ff
jbe    176a <main+0x4ea>
cmpq   $0x0,-0x60(%rbp)
jne    176a <main+0x4ea>
movl   $0x0,-0xbc(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
movsd  0x94e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
cvttsd2si -0x88(%rbp),%eax
ff
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   $0xf4240,%edx,%eax
mov    %eax,-0xb0(%rbp)
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0xb0(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    0x28ab(%rip),%rax
movq   $0x0,(%rax)
lea    -0xa8(%rbp),%rdi
lea    -0xb8(%rbp),%rsi
call   1080 <nanosleep@plt>
mov    %eax,-0xbc(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0xbc(%rbp)
mov    %al,-0xd6(%rbp)
jne    1757 <main+0x4d7>
mov    0x286f(%rip),%rax
mov    (%rax),%rax
mov    0x2855(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0xd6(%rbp)
mov    -0xd6(%rbp),%al
test   $0x1,%al
jne    16e2 <main+0x462>
jmp    176a <main+0x4ea>
jmp    14c9 <main+0x249>
mov    -0x38(%rbp),%rdi
call   1070 <XFree@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <XFree@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1090 <XDestroyWindow@plt>
mov    -0x18(%rbp),%rdi
call   1190 <XCloseDisplay@plt>
movq   $0x0,-0x18(%rbp)
mov    0x27db(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
xor    %edi,%edi
call   10b0 <XOpenDisplay@plt>
test   %rax,%rax
je     1476 <main+0x1f6>
mov    %rax,%rbx
mov    %rax,%rdi
call   1180 <DefaultScreen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1140 <BlackPixel@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <DefaultRootWindow@plt>
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x320,%r8d
mov    $0x258,%r9d
push   %rbp
push   %rbp
push   $0x0
call   1130 <XCreateSimpleWindow@plt>
add    $0x20,%rsp
mov    %eax,%r13d
xor    %eax,%eax
call   10e0 <XAllocWMHints@plt>
mov    0x2ce8(%rip),%rcx
mov    0x2cf9(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    %rax,%rbp
mov    %edx,(%rax)
mov    0x2cb9(%rip),%r12
mov    (%r12),%rax
mov    %rax,0x10(%rbp)
mov    0x2c7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rbp)
xor    %eax,%eax
call   10d0 <XAllocSizeHints@plt>
mov    0x2c4f(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,(%rax)
movabs $0x12c00000190,%rcx
mov    %rcx,0x4(%rax)
sub    $0x8,%rsp
lea    0xcca(%rip),%rdx
lea    0xcfa(%rip),%rcx
mov    %rbx,%rdi
mov    %r13d,%esi
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x0
mov    %rbp,0x80(%rsp)
push   %rbp
mov    %rax,0x80(%rsp)
push   %rax
call   10a0 <Xutf8SetWMProperties@plt>
add    $0x20,%rsp
mov    0x2c03(%rip),%r14
mov    (%r14),%edx
mov    %rbx,%rdi
mov    %r13d,%esi
call   1120 <XSelectInput@plt>
mov    (%r12),%rdx
lea    0xc83(%rip),%rsi
mov    %rbx,%rdi
call   1100 <XInternAtom@plt>
mov    %eax,%r15d
mov    (%r12),%rdx
lea    0xc7a(%rip),%rsi
mov    %rbx,%rdi
call   1100 <XInternAtom@plt>
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdx
mov    %rbx,%rdi
mov    %r13d,%esi
mov    $0x1,%ecx
call   10c0 <XSetWMProtocols@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1150 <XMapWindow@plt>
mov    (%r14),%edx
lea    0x80(%rsp),%rcx
mov    %rbx,%rdi
mov    %r13d,%esi
call   1160 <XWindowEvent@plt>
mov    0x2bd3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r13d,0x24(%rsp)
mov    %r13d,%esi
call   1120 <XSelectInput@plt>
mov    0x2bc2(%rip),%rax
mov    (%rax),%r14
mov    0x2ba0(%rip),%rax
mov    (%rax),%edi
lea    0x38(%rsp),%rsi
call   1030 <clock_gettime@plt>
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
mov    0x40(%rsp),%eax
mov    %eax,0x60(%rsp)
test   %r14,%r14
je     1491 <main+0x211>
mov    0x68(%rsp),%rdi
call   1070 <XFree@plt>
mov    0x70(%rsp),%rdi
call   1070 <XFree@plt>
mov    %rbx,%rdi
mov    0x24(%rsp),%esi
call   1090 <XDestroyWindow@plt>
mov    %rbx,%rdi
call   1190 <XCloseDisplay@plt>
mov    0x2b1c(%rip),%rax
jmp    147d <main+0x1fd>
mov    0x2b2b(%rip),%rax
mov    (%rax),%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xorpd  %xmm1,%xmm1
lea    0x80(%rsp),%r12
lea    0xb9b(%rip),%r13
lea    0x48(%rsp),%r14
jmp    14c0 <main+0x240>
nopl   0x0(%rax,%rax,1)
movsd  0x18(%rsp),%xmm1
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
jne    1445 <main+0x1c5>
movsd  %xmm1,0x18(%rsp)
mov    0x2af3(%rip),%rax
mov    (%rax),%edi
lea    0x38(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <clock_gettime@plt>
mov    %rbp,%rdi
lea    0x58(%rsp),%rsi
call   1170 <timespec_diff@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <XPending@plt>
test   %rax,%rax
mov    %rbp,0x78(%rsp)
jle    15a0 <main+0x320>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x2aa0(%rip),%rbp
jmp    154e <main+0x2ce>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x84(%rsp),%rdi
xor    %esi,%esi
call   1110 <XLookupKeysym@plt>
mov    %eax,%edi
call   11a0 <XKeysymToString@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <XPending@plt>
test   %rax,%rax
jle    15ae <main+0x32e>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10f0 <XNextEvent@plt>
mov    0x80(%rsp),%eax
cmp    $0x80,%eax
je     1520 <main+0x2a0>
cmp    $0x81,%eax
jne    1541 <main+0x2c1>
cmp    %r15d,0x90(%rsp)
jne    1541 <main+0x2c1>
mov    0x88(%rsp),%rax
mov    (%rax),%eax
cmp    0x14(%rsp),%eax
jne    1541 <main+0x2c1>
mov    0x2a39(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
jmp    1541 <main+0x2c1>
nopl   0x0(%rax)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x2a02(%rip),%rbp
xorps  %xmm0,%xmm0
cvtsi2sdq 0x78(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0xa36(%rip),%xmm2
ucomisd %xmm2,%xmm1
jbe    1600 <main+0x380>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
jne    1605 <main+0x385>
movsd  0xa26(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addsd  %xmm0,%xmm1
ucomisd %xmm2,%xmm1
ja     15f0 <main+0x370>
jmp    1605 <main+0x385>
nopl   0x0(%rax)
mov    0x8(%rsp),%rcx
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
mov    0x40(%rsp),%eax
mov    %eax,0x60(%rsp)
ucomisd %xmm1,%xmm2
jbe    14bb <main+0x23b>
test   %rcx,%rcx
jne    14bb <main+0x23b>
movapd %xmm1,%xmm0
divsd  0x9d8(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  %xmm1,0x18(%rsp)
cvttsd2si %xmm1,%eax
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
imul   $0xf4240,%eax,%eax
mov    %eax,0x30(%rsp)
movsd  %xmm0,0x48(%rsp)
mov    %eax,0x50(%rsp)
movq   $0x0,0x0(%rbp)
mov    %r14,%rdi
lea    0x28(%rsp),%rsi
call   1080 <nanosleep@plt>
cmp    $0xffffffff,%eax
jne    14b0 <main+0x230>
mov    0x2901(%rip),%rax
mov    (%rax),%rax
cmp    %rax,0x0(%rbp)
jne    14b0 <main+0x230>
movsd  0x28(%rsp),%xmm0
mov    0x30(%rsp),%eax
jmp    1670 <main+0x3f0>

LLVM IR (-O0):
%struct.TYPE_15__ = type { i32, i32, i32, i32, i8* }
%struct.TYPE_16__ = type { i32, i32, %struct.TYPE_14__ }
%struct.TYPE_14__ = type { %struct.TYPE_13__, i32 }
%struct.TYPE_13__ = type { i32* }
%struct.timespec = type { double, i32 }
@EXIT_FAILURE = global i32 0
@InputHint = global i32 0
@StateHint = global i32 0
@True = global i8* null
@NormalState = global i32 0
@PMinSize = global i32 0
@.str = [9 x i8] c"Phase 01\00"
@.str.1 = [1 x i8] zeroinitializer
@ExposureMask = global i32 0
@.str.2 = [13 x i8] c"WM_PROTOCOLS\00"
@.str.3 = [17 x i8] c"WM_DELETE_WINDOW\00"
@KeyPressMask = global i32 0
@False = global i8* null
@CLOCK_MONOTONIC_RAW = global i32 0
@.str.4 = [17 x i8] c"Key pressed: %s\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32
%9 = alloca %struct.TYPE_15__*
%10 = alloca %struct.TYPE_15__*
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.TYPE_16__
%14 = alloca i8*
%15 = alloca %struct.timespec
%16 = alloca %struct.timespec
%17 = alloca double
%18 = alloca i32
%19 = alloca i8*
%20 = alloca %struct.timespec
%21 = alloca %struct.timespec
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = call i32* @XOpenDisplay(i32* null)
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %2
%27 = load i32, i32* @EXIT_FAILURE
store i32 %27, i32* %3
br label %216
28: ; preds = %2
%29 = load i32*, i32** %6
%30 = load i32*, i32** %6
%31 = call i32 @DefaultScreen(i32* %30)
%32 = call i64 @BlackPixel(i32* %29, i32 %31)
store i64 %32, i64* %7
%33 = load i32*, i32** %6
%34 = load i32*, i32** %6
%35 = call i32 @DefaultRootWindow(i32* %34)
%36 = load i64, i64* %7
%37 = load i64, i64* %7
%38 = call i32 @XCreateSimpleWindow(i32* %33, i32 %35, i32 0, i32 0, i32 800, i32 600, i32 0, i64 %36, i64 %37)
store i32 %38, i32* %8
%39 = call %struct.TYPE_15__* (...) @XAllocWMHints()
store %struct.TYPE_15__* %39, %struct.TYPE_15__** %9
%40 = load i32, i32* @InputHint
%41 = load i32, i32* @StateHint
%42 = or i32 %40, %41
%43 = load %struct.TYPE_15__*, %struct.TYPE_15__** %9
%44 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %43, i32 0, i32 0
store i32 %42, i32* %44
%45 = load i8*, i8** @True
%46 = load %struct.TYPE_15__*, %struct.TYPE_15__** %9
%47 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %46, i32 0, i32 4
store i8* %45, i8** %47
%48 = load i32, i32* @NormalState
%49 = load %struct.TYPE_15__*, %struct.TYPE_15__** %9
%50 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %49, i32 0, i32 3
store i32 %48, i32* %50
%51 = call %struct.TYPE_15__* (...) @XAllocSizeHints()
store %struct.TYPE_15__* %51, %struct.TYPE_15__** %10
%52 = load i32, i32* @PMinSize
%53 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%54 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %53, i32 0, i32 0
store i32 %52, i32* %54
%55 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%56 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %55, i32 0, i32 1
store i32 400, i32* %56
%57 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%58 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %57, i32 0, i32 2
store i32 300, i32* %58
%59 = load i32*, i32** %6
%60 = load i32, i32* %8
%61 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%62 = load %struct.TYPE_15__*, %struct.TYPE_15__** %9
%63 = call i32 @Xutf8SetWMProperties(i32* %59, i32 %60, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32* null, i32 0, %struct.TYPE_15__* %61, %struct.TYPE_15__* %62, i32* null)
%64 = load i32*, i32** %6
%65 = load i32, i32* %8
%66 = load i32, i32* @ExposureMask
%67 = call i32 @XSelectInput(i32* %64, i32 %65, i32 %66)
%68 = load i32*, i32** %6
%69 = load i8*, i8** @True
%70 = call i32 @XInternAtom(i32* %68, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %69)
store i32 %70, i32* %11
%71 = load i32*, i32** %6
%72 = load i8*, i8** @True
%73 = call i32 @XInternAtom(i32* %71, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %72)
store i32 %73, i32* %12
%74 = load i32*, i32** %6
%75 = load i32, i32* %8
%76 = call i32 @XSetWMProtocols(i32* %74, i32 %75, i32* %12, i32 1)
%77 = load i32*, i32** %6
%78 = load i32, i32* %8
%79 = call i32 @XMapWindow(i32* %77, i32 %78)
%80 = load i32*, i32** %6
%81 = load i32, i32* %8
%82 = load i32, i32* @ExposureMask
%83 = call i32 @XWindowEvent(i32* %80, i32 %81, i32 %82, %struct.TYPE_16__* %13)
%84 = load i32*, i32** %6
%85 = load i32, i32* %8
%86 = load i32, i32* @KeyPressMask
%87 = call i32 @XSelectInput(i32* %84, i32 %85, i32 %86)
%88 = load i8*, i8** @False
store i8* %88, i8** %14
%89 = load i32, i32* @CLOCK_MONOTONIC_RAW
%90 = call i32 @clock_gettime(i32 %89, %struct.timespec* %16)
%91 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 0
%92 = load double, double* %91
%93 = getelementptr inbounds %struct.timespec, %struct.timespec* %15, i32 0, i32 0
store double %92, double* %93
%94 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 1
%95 = load i32, i32* %94
%96 = getelementptr inbounds %struct.timespec, %struct.timespec* %15, i32 0, i32 1
store i32 %95, i32* %96
store double 0.000000e+00, double* %17
store i8* null, i8** %19
br label %97
97: ; preds = %204, %28
%98 = load i8*, i8** %14
%99 = icmp ne i8* %98, null
%100 = xor i1 %99, true
br i1 %100, label %101, label %205
101: ; preds = %97
%102 = load i32, i32* @CLOCK_MONOTONIC_RAW
%103 = call i32 @clock_gettime(i32 %102, %struct.timespec* %16)
%104 = call i64 @timespec_diff(%struct.timespec* %16, %struct.timespec* %15)
%105 = sitofp i64 %104 to double
%106 = load double, double* %17
%107 = fadd double %106, %105
store double %107, double* %17
br label %108
108: ; preds = %143, %101
%109 = load i32*, i32** %6
%110 = call i64 @XPending(i32* %109)
%111 = icmp sgt i64 %110, 0
br i1 %111, label %112, label %144
112: ; preds = %108
%113 = load i32*, i32** %6
%114 = call i32 @XNextEvent(i32* %113, %struct.TYPE_16__* %13)
%115 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %13, i32 0, i32 0
%116 = load i32, i32* %115
switch i32 %116, label %143 [
i32 129, label %117
i32 128, label %136
]
117: ; preds = %112
%118 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %13, i32 0, i32 2
%119 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %118, i32 0, i32 1
%120 = load i32, i32* %119
%121 = load i32, i32* %11
%122 = icmp eq i32 %120, %121
br i1 %122, label %123, label %135
123: ; preds = %117
%124 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %13, i32 0, i32 2
%125 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %124, i32 0, i32 0
%126 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %125, i32 0, i32 0
%127 = load i32*, i32** %126
%128 = getelementptr inbounds i32, i32* %127, i64 0
%129 = load i32, i32* %128
%130 = load i32, i32* %12
%131 = icmp eq i32 %129, %130
br i1 %131, label %132, label %134
132: ; preds = %123
%133 = load i8*, i8** @True
store i8* %133, i8** %14
br label %134
134: ; preds = %132, %123
br label %135
135: ; preds = %134, %117
br label %143
136: ; preds = %112
%137 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %13, i32 0, i32 1
%138 = call i32 @XLookupKeysym(i32* %137, i32 0)
store i32 %138, i32* %18
%139 = load i32, i32* %18
%140 = call i8* @XKeysymToString(i32 %139)
store i8* %140, i8** %19
%141 = load i8*, i8** %19
%142 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %141)
br label %143
143: ; preds = %112, %136, %135
br label %108
144: ; preds = %108
%145 = load double, double* %17
%146 = fcmp ogt double %145, 1.660000e+01
br i1 %146, label %147, label %165
147: ; preds = %144
%148 = load i8*, i8** %14
%149 = icmp ne i8* %148, null
br i1 %149, label %165, label %150
150: ; preds = %147
br label %151
151: ; preds = %161, %150
%152 = load double, double* %17
%153 = fcmp ogt double %152, 1.660000e+01
br i1 %153, label %154, label %158
154: ; preds = %151
%155 = load i8*, i8** %14
%156 = icmp ne i8* %155, null
%157 = xor i1 %156, true
br label %158
158: ; preds = %154, %151
%159 = phi i1 [ false, %151 ], [ %157, %154 ]
br i1 %159, label %160, label %164
160: ; preds = %158
br label %161
161: ; preds = %160
%162 = load double, double* %17
%163 = fsub double %162, 1.660000e+01
store double %163, double* %17
br label %151
164: ; preds = %158
br label %165
165: ; preds = %164, %147, %144
%166 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 0
%167 = load double, double* %166
%168 = getelementptr inbounds %struct.timespec, %struct.timespec* %15, i32 0, i32 0
store double %167, double* %168
%169 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 1
%170 = load i32, i32* %169
%171 = getelementptr inbounds %struct.timespec, %struct.timespec* %15, i32 0, i32 1
store i32 %170, i32* %171
%172 = load double, double* %17
%173 = fcmp olt double %172, 1.660000e+01
br i1 %173, label %174, label %204
174: ; preds = %165
%175 = load i8*, i8** %14
%176 = icmp ne i8* %175, null
br i1 %176, label %204, label %177
177: ; preds = %174
store i32 0, i32* %22
%178 = load double, double* %17
%179 = fdiv double %178, 1.000000e+03
%180 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
store double %179, double* %180
%181 = load double, double* %17
%182 = fptosi double %181 to i32
%183 = srem i32 %182, 1000
%184 = mul nsw i32 %183, 1000000
%185 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
store i32 %184, i32* %185
br label %186
186: ; preds = %201, %177
%187 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%188 = load double, double* %187
%189 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 0
store double %188, double* %189
%190 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%191 = load i32, i32* %190
%192 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 1
store i32 %191, i32* %192
store i64 0, i64* @errno
%193 = call i32 @nanosleep(%struct.timespec* %20, %struct.timespec* %21)
store i32 %193, i32* %22
br label %194
194: ; preds = %186
%195 = load i32, i32* %22
%196 = icmp eq i32 %195, -1
br i1 %196, label %197, label %201
197: ; preds = %194
%198 = load i64, i64* @errno
%199 = load i64, i64* @EINTR
%200 = icmp eq i64 %198, %199
br label %201
201: ; preds = %197, %194
%202 = phi i1 [ false, %194 ], [ %200, %197 ]
br i1 %202, label %186, label %203
203: ; preds = %201
br label %204
204: ; preds = %203, %174, %165
br label %97
205: ; preds = %97
%206 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%207 = call i32 @XFree(%struct.TYPE_15__* %206)
store %struct.TYPE_15__* null, %struct.TYPE_15__** %10
%208 = load %struct.TYPE_15__*, %struct.TYPE_15__** %9
%209 = call i32 @XFree(%struct.TYPE_15__* %208)
store %struct.TYPE_15__* null, %struct.TYPE_15__** %9
%210 = load i32*, i32** %6
%211 = load i32, i32* %8
%212 = call i32 @XDestroyWindow(i32* %210, i32 %211)
%213 = load i32*, i32** %6
%214 = call i32 @XCloseDisplay(i32* %213)
store i32* null, i32** %6
%215 = load i32, i32* @EXIT_SUCCESS
store i32 %215, i32* %3
br label %216
216: ; preds = %205, %26
%217 = load i32, i32* %3
ret i32 %217
}

LLVM IR (-O2):
%struct.TYPE_16__ = type { i32, i32, %struct.TYPE_14__ }
%struct.TYPE_14__ = type { %struct.TYPE_13__, i32 }
%struct.TYPE_13__ = type { i32* }
%struct.timespec = type { double, i32 }
%struct.TYPE_15__ = type { i32, i32, i32, i32, i8* }
@EXIT_FAILURE = global i32 0
@InputHint = global i32 0
@StateHint = global i32 0
@True = global i8* null
@NormalState = global i32 0
@PMinSize = global i32 0
@.str = [9 x i8] c"Phase 01\00"
@.str.1 = [1 x i8] zeroinitializer
@ExposureMask = global i32 0
@.str.2 = [13 x i8] c"WM_PROTOCOLS\00"
@.str.3 = [17 x i8] c"WM_DELETE_WINDOW\00"
@KeyPressMask = global i32 0
@False = global i8* null
@CLOCK_MONOTONIC_RAW = global i32 0
@.str.4 = [17 x i8] c"Key pressed: %s\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_16__
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = alloca %struct.timespec
%9 = tail call i32* @XOpenDisplay(i32* null)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32, i32* @EXIT_FAILURE
br label %145
13: ; preds = %2
%14 = tail call i32 @DefaultScreen(i32* %9)
%15 = tail call i64 @BlackPixel(i32* %9, i32 %14)
%16 = tail call i32 @DefaultRootWindow(i32* %9)
%17 = tail call i32 @XCreateSimpleWindow(i32* %9, i32 %16, i32 0, i32 0, i32 800, i32 600, i32 0, i64 %15, i64 %15)
%18 = tail call %struct.TYPE_15__* (...) @XAllocWMHints()
%19 = load i32, i32* @InputHint
%20 = load i32, i32* @StateHint
%21 = or i32 %20, %19
%22 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %18, i64 0, i32 0
store i32 %21, i32* %22
%23 = load i8*, i8** @True
%24 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %18, i64 0, i32 4
store i8* %23, i8** %24
%25 = load i32, i32* @NormalState
%26 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %18, i64 0, i32 3
store i32 %25, i32* %26
%27 = tail call %struct.TYPE_15__* (...) @XAllocSizeHints()
%28 = load i32, i32* @PMinSize
%29 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %27, i64 0, i32 0
store i32 %28, i32* %29
%30 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %27, i64 0, i32 1
store i32 400, i32* %30
%31 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %27, i64 0, i32 2
store i32 300, i32* %31
%32 = tail call i32 @Xutf8SetWMProperties(i32* %9, i32 %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32* null, i32 0, %struct.TYPE_15__* %27, %struct.TYPE_15__* %18, i32* null)
%33 = load i32, i32* @ExposureMask
%34 = tail call i32 @XSelectInput(i32* %9, i32 %17, i32 %33)
%35 = load i8*, i8** @True
%36 = tail call i32 @XInternAtom(i32* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = bitcast i32* %3 to i8*
%38 = load i8*, i8** @True
%39 = tail call i32 @XInternAtom(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %38)
store i32 %39, i32* %3
%40 = call i32 @XSetWMProtocols(i32* %9, i32 %17, i32* %3, i32 1)
%41 = call i32 @XMapWindow(i32* %9, i32 %17)
%42 = bitcast %struct.TYPE_16__* %4 to i8*
%43 = load i32, i32* @ExposureMask
%44 = call i32 @XWindowEvent(i32* %9, i32 %17, i32 %43, %struct.TYPE_16__* %4)
%45 = load i32, i32* @KeyPressMask
%46 = call i32 @XSelectInput(i32* %9, i32 %17, i32 %45)
%47 = load i8*, i8** @False
%48 = bitcast %struct.timespec* %5 to i8*
%49 = bitcast %struct.timespec* %6 to i8*
%50 = load i32, i32* @CLOCK_MONOTONIC_RAW
%51 = call i32 @clock_gettime(i32 %50, %struct.timespec* %6)
%52 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%53 = load double, double* %52
%54 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
store double %53, double* %54
%55 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 1
%56 = load i32, i32* %55
%57 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
store i32 %56, i32* %57
%58 = icmp eq i8* %47, null
br i1 %58, label %59, label %139
59: ; preds = %13
%60 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %4, i64 0, i32 0
%61 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %4, i64 0, i32 1
%62 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %4, i64 0, i32 2, i32 1
%63 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %4, i64 0, i32 2, i32 0, i32 0
%64 = bitcast %struct.timespec* %7 to i8*
%65 = bitcast %struct.timespec* %8 to i8*
%66 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i64 0, i32 0
%67 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i64 0, i32 1
%68 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 0
%69 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 1
br label %70
70: ; preds = %59, %137
%71 = phi double [ 0.000000e+00, %59 ], [ %111, %137 ]
%72 = load i32, i32* @CLOCK_MONOTONIC_RAW
%73 = call i32 @clock_gettime(i32 %72, %struct.timespec* %6)
%74 = call i64 @timespec_diff(%struct.timespec* %6, %struct.timespec* %5)
%75 = sitofp i64 %74 to double
%76 = fadd double %71, %75
%77 = call i64 @XPending(i32* %9)
%78 = icmp sgt i64 %77, 0
br i1 %78, label %79, label %101
79: ; preds = %70, %97
%80 = phi i8* [ %98, %97 ], [ null, %70 ]
%81 = call i32 @XNextEvent(i32* %9, %struct.TYPE_16__* %4)
%82 = load i32, i32* %60
switch i32 %82, label %97 [
i32 129, label %83
i32 128, label %93
]
83: ; preds = %79
%84 = load i32, i32* %62
%85 = icmp eq i32 %84, %36
br i1 %85, label %86, label %97
86: ; preds = %83
%87 = load i32*, i32** %63
%88 = load i32, i32* %87
%89 = load i32, i32* %3
%90 = icmp eq i32 %88, %89
%91 = load i8*, i8** @True
%92 = select i1 %90, i8* %91, i8* %80
br label %97
93: ; preds = %79
%94 = call i32 @XLookupKeysym(i32* %61, i32 0)
%95 = call i8* @XKeysymToString(i32 %94)
%96 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %95)
br label %97
97: ; preds = %86, %83, %79, %93
%98 = phi i8* [ %80, %79 ], [ %80, %93 ], [ %80, %83 ], [ %92, %86 ]
%99 = call i64 @XPending(i32* %9)
%100 = icmp sgt i64 %99, 0
br i1 %100, label %79, label %101
101: ; preds = %97, %70
%102 = phi i8* [ null, %70 ], [ %98, %97 ]
%103 = fcmp ule double %76, 1.660000e+01
%104 = icmp ne i8* %102, null
%105 = select i1 %103, i1 true, i1 %104
br i1 %105, label %110, label %106
106: ; preds = %101, %106
%107 = phi double [ %108, %106 ], [ %76, %101 ]
%108 = fadd double %107, -1.660000e+01
%109 = fcmp ogt double %108, 1.660000e+01
br i1 %109, label %106, label %110
110: ; preds = %106, %101
%111 = phi double [ %76, %101 ], [ %108, %106 ]
%112 = load double, double* %52
store double %112, double* %54
%113 = load i32, i32* %55
store i32 %113, i32* %57
%114 = fcmp uge double %111, 1.660000e+01
%115 = select i1 %114, i1 true, i1 %104
br i1 %115, label %137, label %116
116: ; preds = %110
%117 = fdiv double %111, 1.000000e+03
store double %117, double* %66
%118 = fptosi double %111 to i32
%119 = srem i32 %118, 1000
%120 = mul nsw i32 %119, 1000000
store i32 %120, i32* %67
store double %117, double* %68
store i32 %120, i32* %69
store i64 0, i64* @errno
%121 = call i32 @nanosleep(%struct.timespec* %7, %struct.timespec* %8)
%122 = icmp eq i32 %121, -1
%123 = load i64, i64* @errno
%124 = load i64, i64* @EINTR
%125 = icmp eq i64 %123, %124
%126 = select i1 %122, i1 %125, i1 false
br i1 %126, label %127, label %136
127: ; preds = %116, %127
%128 = load double, double* %66
%129 = load i32, i32* %67
store double %128, double* %68
store i32 %129, i32* %69
store i64 0, i64* @errno
%130 = call i32 @nanosleep(%struct.timespec* %7, %struct.timespec* %8)
%131 = icmp eq i32 %130, -1
%132 = load i64, i64* @errno
%133 = load i64, i64* @EINTR
%134 = icmp eq i64 %132, %133
%135 = select i1 %131, i1 %134, i1 false
br i1 %135, label %127, label %136
136: ; preds = %127, %116
br label %137
137: ; preds = %136, %110
%138 = icmp eq i8* %102, null
br i1 %138, label %70, label %139
139: ; preds = %137, %13
%140 = call i32 @XFree(%struct.TYPE_15__* %27)
%141 = call i32 @XFree(%struct.TYPE_15__* %18)
%142 = call i32 @XDestroyWindow(i32* %9, i32 %17)
%143 = call i32 @XCloseDisplay(i32* %9)
%144 = load i32, i32* @EXIT_SUCCESS
br label %145
145: ; preds = %139, %11
%146 = phi i32 [ %12, %11 ], [ %144, %139 ]
ret i32 %146
}