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

/* Type definitions */
typedef int /*<<< orphan*/ buf;
struct TYPE_6__ {
  int /*<<< orphan*/ height;
  int /*<<< orphan*/ width;
};
struct TYPE_5__ {
  int /*<<< orphan*/ window;
};
struct TYPE_7__ {
  int type;
  int /*<<< orphan*/ xkey;
  TYPE_2__ xconfigure;
  TYPE_1__ xany;
};
typedef TYPE_3__ XEvent;
typedef int /*<<< orphan*/ XComposeStatus;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ KeySym;
typedef double GLfloat;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
#define ConfigureNotify 130
#define Expose 129
#define KeyPress 128
int /*<<< orphan*/ Redraw(int /*<<< orphan*/ *, int /*<<< orphan*/, double);
int /*<<< orphan*/ Resize(int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ XK_Escape;
int /*<<< orphan*/ XK_R;
int /*<<< orphan*/ XK_a;
int /*<<< orphan*/ XK_r;
int /*<<< orphan*/ XLookupString(int /*<<< orphan*/ *, char *, int,
                                 int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_3__ *);
scalar_t__ XPending(int /*<<< orphan*/ *);
void EventLoop(Display *dpy, Window win) {
  GLfloat rot = 0.0;
  int anim = 0;
  while (1) {
    if (!anim || XPending(dpy) > 0) {
      XEvent event;
      XNextEvent(dpy, &event);
      switch (event.type) {
      case Expose:
        Redraw(dpy, win, rot);
        break;
      case ConfigureNotify:
        Resize(event.xany.window, event.xconfigure.width,
               event.xconfigure.height);
        break;
      case KeyPress: {
        char buf[100];
        KeySym keySym;
        XComposeStatus stat;
        XLookupString(&event.xkey, buf, sizeof(buf), &keySym, &stat);
        if (keySym == XK_Escape) {
          return;
        } else if (keySym == XK_r) {
          rot += 1.0;
          Redraw(dpy, win, rot);
        } else if (keySym == XK_a) {
          anim = !anim;
        } else if (keySym == XK_R) {
          rot -= 1.0;
          Redraw(dpy, win, rot);
        }
      } break;
      default:;
      }
    } else {
      rot += 1.0;
      Redraw(dpy, win, rot);
    }
  }
}


x86 assembly (clang, -O0):
<EventLoop>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     118e <EventLoop+0x3e>
mov    -0x8(%rbp),%rdi
call   1040 <XPending@plt>
cmp    $0x0,%rax
jle    1310 <EventLoop+0x1c0>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <XNextEvent@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0xac(%rbp)
sub    $0x80,%eax
je     1209 <EventLoop+0xb9>
jmp    11b4 <EventLoop+0x64>
mov    -0xac(%rbp),%eax
sub    $0x81,%eax
je     11e0 <EventLoop+0x90>
jmp    11ca <EventLoop+0x7a>
mov    -0xac(%rbp),%eax
sub    $0x82,%eax
je     11f6 <EventLoop+0xa6>
jmp    1306 <EventLoop+0x1b6>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
call   1060 <Redraw@plt>
jmp    130b <EventLoop+0x1bb>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1070 <Resize@plt>
jmp    130b <EventLoop+0x1bb>
lea    -0x30(%rbp),%rdi
add    $0x4,%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x64,%edx
lea    -0xa4(%rbp),%rcx
lea    -0xa8(%rbp),%r8
call   1030 <XLookupString@plt>
mov    -0xa4(%rbp),%eax
mov    0x2d9b(%rip),%rcx
cmp    (%rcx),%eax
jne    124e <EventLoop+0xfe>
add    $0xb0,%rsp
pop    %rbp
ret
mov    -0xa4(%rbp),%eax
mov    0x2d75(%rip),%rcx
cmp    (%rcx),%eax
jne    128b <EventLoop+0x13b>
movsd  0xd95(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
call   1060 <Redraw@plt>
jmp    12fc <EventLoop+0x1ac>
mov    -0xa4(%rbp),%eax
mov    0x2d50(%rip),%rcx
cmp    (%rcx),%eax
jne    12b6 <EventLoop+0x166>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    12f7 <EventLoop+0x1a7>
mov    -0xa4(%rbp),%eax
mov    0x2cfd(%rip),%rcx
cmp    (%rcx),%eax
jne    12f2 <EventLoop+0x1a2>
movsd  -0x18(%rbp),%xmm0
movsd  0xd28(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
call   1060 <Redraw@plt>
jmp    12f7 <EventLoop+0x1a7>
jmp    12fc <EventLoop+0x1ac>
jmp    1301 <EventLoop+0x1b1>
jmp    130b <EventLoop+0x1bb>
jmp    130b <EventLoop+0x1bb>
jmp    1333 <EventLoop+0x1e3>
movsd  0xce8(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
call   1060 <Redraw@plt>
jmp    1171 <EventLoop+0x21>

x86 assembly (clang, -O2):
<EventLoop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %r13d,%r13d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x18(%rsp),%r15
lea    0x2c(%rsp),%r14
mov    0x2e54(%rip),%r12
jmp    11b4 <EventLoop+0x64>
cs nopw 0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
addsd  0xe62(%rip),%xmm0
mov    %rbx,%rdi
mov    %ebp,%esi
movsd  %xmm0,0x8(%rsp)
call   1060 <Redraw@plt>
mov    $0x1,%r13d
test   %r13d,%r13d
je     11c6 <EventLoop+0x76>
mov    %rbx,%rdi
call   1040 <XPending@plt>
test   %rax,%rax
jle    1190 <EventLoop+0x40>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <XNextEvent@plt>
mov    0x18(%rsp),%eax
cmp    $0x80,%eax
je     120f <EventLoop+0xbf>
cmp    $0x82,%eax
je     11fc <EventLoop+0xac>
cmp    $0x81,%eax
jne    11b4 <EventLoop+0x64>
mov    %rbx,%rdi
mov    %ebp,%esi
movsd  0x8(%rsp),%xmm0
call   1060 <Redraw@plt>
jmp    11b4 <EventLoop+0x64>
mov    0x28(%rsp),%edi
mov    0x20(%rsp),%edx
mov    0x24(%rsp),%esi
call   1070 <Resize@plt>
jmp    11b4 <EventLoop+0x64>
lea    0x1c(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    $0x64,%edx
lea    0x14(%rsp),%rcx
mov    %r14,%r8
call   1030 <XLookupString@plt>
mov    0x14(%rsp),%eax
cmp    (%r12),%eax
je     129d <EventLoop+0x14d>
mov    0x2d94(%rip),%rcx
cmp    (%rcx),%eax
jne    1263 <EventLoop+0x113>
movsd  0x8(%rsp),%xmm0
addsd  0xdb2(%rip),%xmm0
mov    %rbx,%rdi
mov    %ebp,%esi
movsd  %xmm0,0x8(%rsp)
call   1060 <Redraw@plt>
jmp    11b4 <EventLoop+0x64>
mov    0x2d7e(%rip),%rcx
cmp    (%rcx),%eax
jne    127e <EventLoop+0x12e>
xor    %eax,%eax
test   %r13d,%r13d
sete   %al
mov    %eax,%r13d
jmp    11b4 <EventLoop+0x64>
mov    0x2d3b(%rip),%rcx
cmp    (%rcx),%eax
jne    11b4 <EventLoop+0x64>
movsd  0x8(%rsp),%xmm0
addsd  0xd6d(%rip),%xmm0
jmp    124e <EventLoop+0xfe>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i32, i32, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_6__ = type { i32, i32 }
%struct.TYPE_5__ = type { i32 }
@XK_Escape = global i32 0
@XK_r = global i32 0
@XK_a = global i32 0
@XK_R = global i32 0
define void @EventLoop(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca %struct.TYPE_7__
%8 = alloca [100 x i8]
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
store i32 0, i32* %6
br label %11
11: ; preds = %2, %91
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32*, i32** %3
%16 = call i64 @XPending(i32* %15)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %84
18: ; preds = %14, %11
%19 = load i32*, i32** %3
%20 = call i32 @XNextEvent(i32* %19, %struct.TYPE_7__* %7)
%21 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %7, i32 0, i32 0
%22 = load i32, i32* %21
switch i32 %22, label %82 [
i32 129, label %23
i32 130, label %28
i32 128, label %39
]
23: ; preds = %18
%24 = load i32*, i32** %3
%25 = load i32, i32* %4
%26 = load double, double* %5
%27 = call i32 @Redraw(i32* %24, i32 %25, double %26)
br label %83
28: ; preds = %18
%29 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %7, i32 0, i32 3
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %7, i32 0, i32 2
%33 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %32, i32 0, i32 1
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %7, i32 0, i32 2
%36 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %35, i32 0, i32 0
%37 = load i32, i32* %36
%38 = call i32 @Resize(i32 %31, i32 %34, i32 %37)
br label %83
39: ; preds = %18
%40 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %7, i32 0, i32 1
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%42 = call i32 @XLookupString(i32* %40, i8* %41, i32 100, i32* %9, i32* %10)
%43 = load i32, i32* %9
%44 = load i32, i32* @XK_Escape
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %47
46: ; preds = %39
ret void
47: ; preds = %39
%48 = load i32, i32* %9
%49 = load i32, i32* @XK_r
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %58
51: ; preds = %47
%52 = load double, double* %5
%53 = fadd double %52, 1.000000e+00
store double %53, double* %5
%54 = load i32*, i32** %3
%55 = load i32, i32* %4
%56 = load double, double* %5
%57 = call i32 @Redraw(i32* %54, i32 %55, double %56)
br label %80
58: ; preds = %47
%59 = load i32, i32* %9
%60 = load i32, i32* @XK_a
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %67
62: ; preds = %58
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
%65 = xor i1 %64, true
%66 = zext i1 %65 to i32
store i32 %66, i32* %6
br label %79
67: ; preds = %58
%68 = load i32, i32* %9
%69 = load i32, i32* @XK_R
%70 = icmp eq i32 %68, %69
br i1 %70, label %71, label %78
71: ; preds = %67
%72 = load double, double* %5
%73 = fsub double %72, 1.000000e+00
store double %73, double* %5
%74 = load i32*, i32** %3
%75 = load i32, i32* %4
%76 = load double, double* %5
%77 = call i32 @Redraw(i32* %74, i32 %75, double %76)
br label %78
78: ; preds = %71, %67
br label %79
79: ; preds = %78, %62
br label %80
80: ; preds = %79, %51
br label %81
81: ; preds = %80
br label %83
82: ; preds = %18
br label %83
83: ; preds = %82, %81, %28, %23
br label %91
84: ; preds = %14
%85 = load double, double* %5
%86 = fadd double %85, 1.000000e+00
store double %86, double* %5
%87 = load i32*, i32** %3
%88 = load i32, i32* %4
%89 = load double, double* %5
%90 = call i32 @Redraw(i32* %87, i32 %88, double %89)
br label %91
91: ; preds = %84, %83
br label %11
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i32, i32, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_6__ = type { i32, i32 }
%struct.TYPE_5__ = type { i32 }
@XK_Escape = global i32 0
@XK_r = global i32 0
@XK_a = global i32 0
@XK_R = global i32 0
define void @EventLoop(i32* %0, i32 %1) {
%3 = alloca %struct.TYPE_7__
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = bitcast %struct.TYPE_7__* %3 to i8*
%9 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 0
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 1
%13 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 3, i32 0
%14 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 2, i32 1
%15 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %3, i64 0, i32 2, i32 0
br label %16
16: ; preds = %61, %2
%17 = phi double [ 0.000000e+00, %2 ], [ %62, %61 ]
%18 = phi i32 [ 0, %2 ], [ %63, %61 ]
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = call i64 @XPending(i32* %0)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %64
23: ; preds = %20, %16
%24 = call i32 @XNextEvent(i32* %0, %struct.TYPE_7__* %3)
%25 = load i32, i32* %9
switch i32 %25, label %58 [
i32 129, label %26
i32 130, label %28
i32 128, label %33
]
26: ; preds = %23
%27 = call i32 @Redraw(i32* %0, i32 %1, double %17)
br label %58
28: ; preds = %23
%29 = load i32, i32* %13
%30 = load i32, i32* %14
%31 = load i32, i32* %15
%32 = call i32 @Resize(i32 %29, i32 %30, i32 %31)
br label %58
33: ; preds = %23
%34 = call i32 @XLookupString(i32* %12, i8* %7, i32 100, i32* %5, i32* %6)
%35 = load i32, i32* %5
%36 = load i32, i32* @XK_Escape
%37 = icmp eq i32 %35, %36
br i1 %37, label %67, label %38
38: ; preds = %33
%39 = load i32, i32* @XK_r
%40 = icmp eq i32 %35, %39
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = fadd double %17, 1.000000e+00
%43 = call i32 @Redraw(i32* %0, i32 %1, double %42)
br label %55
44: ; preds = %38
%45 = load i32, i32* @XK_a
%46 = icmp eq i32 %35, %45
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = zext i1 %19 to i32
br label %55
49: ; preds = %44
%50 = load i32, i32* @XK_R
%51 = icmp eq i32 %35, %50
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = fadd double %17, -1.000000e+00
%54 = call i32 @Redraw(i32* %0, i32 %1, double %53)
br label %55
55: ; preds = %47, %52, %49, %41
%56 = phi double [ %17, %49 ], [ %53, %52 ], [ %17, %47 ], [ %42, %41 ]
%57 = phi i32 [ %18, %49 ], [ %18, %52 ], [ %48, %47 ], [ %18, %41 ]
br label %58
58: ; preds = %55, %23, %28, %26
%59 = phi double [ %56, %55 ], [ %17, %26 ], [ %17, %28 ], [ %17, %23 ]
%60 = phi i32 [ %57, %55 ], [ %18, %26 ], [ %18, %28 ], [ %18, %23 ]
br label %61
61: ; preds = %58, %64
%62 = phi double [ %65, %64 ], [ %59, %58 ]
%63 = phi i32 [ 1, %64 ], [ %60, %58 ]
br label %16
64: ; preds = %20
%65 = fadd double %17, 1.000000e+00
%66 = call i32 @Redraw(i32* %0, i32 %1, double %65)
br label %61
67: ; preds = %33
ret void
}