#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 */

/* Type definitions */
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ GL_COLOR_BUFFER_BIT;
int /*<<< orphan*/ GL_TRIANGLES;
int M_PI;
double cos(int);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glClear(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3d(double, double, double);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glFlush();
int /*<<< orphan*/ glVertex2d(double, double);
int /*<<< orphan*/ glXSwapBuffers(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
double sin(int);
void redraw(Display *dpy, Window w) {
  printf("Redraw event\n");
  glClear(GL_COLOR_BUFFER_BIT);
  glBegin(GL_TRIANGLES);
  glColor3d(1.0, 0.0, 0.0);
  glVertex2d(0.9 * cos(M_PI / 2), 0.9 * sin(M_PI / 2));
  glColor3d(0.0, 1.0, 0.0);
  glVertex2d(0.9 * cos(M_PI / 2 + 2.0 * M_PI / 3.0),
             0.9 * sin(M_PI / 2 + 2.0 * M_PI / 3.0));
  glColor3d(0.0, 0.0, 1.0);
  glVertex2d(0.9 * cos(M_PI / 2 + 2.0 * M_PI * 2.0 / 3.0),
             0.9 * sin(M_PI / 2 + 2.0 * M_PI * 2.0 / 3.0));
  glEnd();
  glFlush();
  glXSwapBuffers(dpy, w);
}


x86 assembly (clang, -O0):
<redraw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1030 <glClear@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   10b0 <glBegin@plt>
movsd  0xe39(%rip),%xmm0
xorps  %xmm2,%xmm2
movaps %xmm2,%xmm1
call   1070 <glColor3d@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   10a0 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xdf3(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1060 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  0xdc2(%rip),%xmm1
mulsd  %xmm2,%xmm1
call   1090 <glVertex2d@plt>
xorps  %xmm2,%xmm2
movsd  0xdc6(%rip),%xmm1
movaps %xmm2,%xmm0
call   1070 <glColor3d@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mov    0x2d72(%rip),%rax
cvtsi2sdl (%rax),%xmm2
movsd  0xd8e(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xd7a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xd56(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2d2e(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mov    0x2d19(%rip),%rax
cvtsi2sdl (%rax),%xmm2
movsd  0xd35(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xd21(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  0xcf8(%rip),%xmm1
mulsd  %xmm2,%xmm1
call   1090 <glVertex2d@plt>
xorps  %xmm1,%xmm1
movsd  0xcfc(%rip),%xmm2
movaps %xmm1,%xmm0
call   1070 <glColor3d@plt>
mov    0x2cbd(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mov    0x2ca8(%rip),%rax
cvtsi2sdl (%rax),%xmm2
movsd  0xcc4(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xcb8(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xca4(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xc80(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2c58(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mov    0x2c43(%rip),%rax
cvtsi2sdl (%rax),%xmm2
movsd  0xc5f(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xc53(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xc3f(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x18(%rbp),%xmm0
movsd  0xc16(%rip),%xmm1
mulsd  %xmm2,%xmm1
call   1090 <glVertex2d@plt>
mov    $0x0,%al
call   1050 <glEnd@plt>
mov    $0x0,%al
call   1080 <glFlush@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10c0 <glXSwapBuffers@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<redraw>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1040 <glClear@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   10b0 <glBegin@plt>
movsd  0xe22(%rip),%xmm0
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
call   1070 <glColor3d@plt>
mov    0x2df8(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
call   10a0 <cos@plt>
mulsd  0xdff(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x0(%rbp),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
call   1060 <sin@plt>
movapd %xmm0,%xmm1
mulsd  0xddc(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
call   1090 <glVertex2d@plt>
xorps  %xmm0,%xmm0
xorps  %xmm2,%xmm2
movsd  0xdbb(%rip),%xmm1
call   1070 <glColor3d@plt>
mov    0x0(%rbp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm1
divsd  0xda0(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   10a0 <cos@plt>
mov    0x0(%rbp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
mulsd  0xd70(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm1
divsd  0xd5f(%rip),%xmm1
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1060 <sin@plt>
movapd %xmm0,%xmm1
mulsd  0xd3e(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
call   1090 <glVertex2d@plt>
xorps  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
movsd  0xd1c(%rip),%xmm2
call   1070 <glColor3d@plt>
mov    0x0(%rbp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm1,%xmm1
divsd  0xcfd(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   10a0 <cos@plt>
mulsd  0xce0(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x0(%rbp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm1,%xmm1
divsd  0xcb8(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1060 <sin@plt>
movsd  0xc9b(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
call   1090 <glVertex2d@plt>
xor    %eax,%eax
call   1050 <glEnd@plt>
xor    %eax,%eax
call   1080 <glFlush@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    10c0 <glXSwapBuffers@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Redraw event\0A\00"
@GL_COLOR_BUFFER_BIT = global i32 0
@GL_TRIANGLES = global i32 0
@M_PI = global i32 0
define void @redraw(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @GL_COLOR_BUFFER_BIT
%7 = call i32 @glClear(i32 %6)
%8 = load i32, i32* @GL_TRIANGLES
%9 = call i32 @glBegin(i32 %8)
%10 = call i32 @glColor3d(double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
%11 = load i32, i32* @M_PI
%12 = sdiv i32 %11, 2
%13 = call double @cos(i32 %12)
%14 = fmul double 9.000000e-01, %13
%15 = load i32, i32* @M_PI
%16 = sdiv i32 %15, 2
%17 = call double @sin(i32 %16)
%18 = fmul double 9.000000e-01, %17
%19 = call i32 @glVertex2d(double %14, double %18)
%20 = call i32 @glColor3d(double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%21 = load i32, i32* @M_PI
%22 = sdiv i32 %21, 2
%23 = sitofp i32 %22 to double
%24 = load i32, i32* @M_PI
%25 = sitofp i32 %24 to double
%26 = fmul double 2.000000e+00, %25
%27 = fdiv double %26, 3.000000e+00
%28 = fadd double %23, %27
%29 = fptosi double %28 to i32
%30 = call double @cos(i32 %29)
%31 = fmul double 9.000000e-01, %30
%32 = load i32, i32* @M_PI
%33 = sdiv i32 %32, 2
%34 = sitofp i32 %33 to double
%35 = load i32, i32* @M_PI
%36 = sitofp i32 %35 to double
%37 = fmul double 2.000000e+00, %36
%38 = fdiv double %37, 3.000000e+00
%39 = fadd double %34, %38
%40 = fptosi double %39 to i32
%41 = call double @sin(i32 %40)
%42 = fmul double 9.000000e-01, %41
%43 = call i32 @glVertex2d(double %31, double %42)
%44 = call i32 @glColor3d(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%45 = load i32, i32* @M_PI
%46 = sdiv i32 %45, 2
%47 = sitofp i32 %46 to double
%48 = load i32, i32* @M_PI
%49 = sitofp i32 %48 to double
%50 = fmul double 2.000000e+00, %49
%51 = fmul double %50, 2.000000e+00
%52 = fdiv double %51, 3.000000e+00
%53 = fadd double %47, %52
%54 = fptosi double %53 to i32
%55 = call double @cos(i32 %54)
%56 = fmul double 9.000000e-01, %55
%57 = load i32, i32* @M_PI
%58 = sdiv i32 %57, 2
%59 = sitofp i32 %58 to double
%60 = load i32, i32* @M_PI
%61 = sitofp i32 %60 to double
%62 = fmul double 2.000000e+00, %61
%63 = fmul double %62, 2.000000e+00
%64 = fdiv double %63, 3.000000e+00
%65 = fadd double %59, %64
%66 = fptosi double %65 to i32
%67 = call double @sin(i32 %66)
%68 = fmul double 9.000000e-01, %67
%69 = call i32 @glVertex2d(double %56, double %68)
%70 = call i32 (...) @glEnd()
%71 = call i32 (...) @glFlush()
%72 = load i32*, i32** %3
%73 = load i32, i32* %4
%74 = call i32 @glXSwapBuffers(i32* %72, i32 %73)
ret void
}

LLVM IR (-O2):
@GL_COLOR_BUFFER_BIT = global i32 0
@GL_TRIANGLES = global i32 0
@M_PI = global i32 0
@str = [13 x i8] c"Redraw event\00"
define void @redraw(i32* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @GL_COLOR_BUFFER_BIT
%5 = tail call i32 @glClear(i32 %4)
%6 = load i32, i32* @GL_TRIANGLES
%7 = tail call i32 @glBegin(i32 %6)
%8 = tail call i32 @glColor3d(double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
%9 = load i32, i32* @M_PI
%10 = sdiv i32 %9, 2
%11 = tail call double @cos(i32 %10)
%12 = fmul double %11, 9.000000e-01
%13 = load i32, i32* @M_PI
%14 = sdiv i32 %13, 2
%15 = tail call double @sin(i32 %14)
%16 = fmul double %15, 9.000000e-01
%17 = tail call i32 @glVertex2d(double %12, double %16)
%18 = tail call i32 @glColor3d(double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%19 = load i32, i32* @M_PI
%20 = sdiv i32 %19, 2
%21 = sitofp i32 %20 to double
%22 = sitofp i32 %19 to double
%23 = fmul double %22, 2.000000e+00
%24 = fdiv double %23, 3.000000e+00
%25 = fadd double %24, %21
%26 = fptosi double %25 to i32
%27 = tail call double @cos(i32 %26)
%28 = fmul double %27, 9.000000e-01
%29 = load i32, i32* @M_PI
%30 = sdiv i32 %29, 2
%31 = sitofp i32 %30 to double
%32 = sitofp i32 %29 to double
%33 = fmul double %32, 2.000000e+00
%34 = fdiv double %33, 3.000000e+00
%35 = fadd double %34, %31
%36 = fptosi double %35 to i32
%37 = tail call double @sin(i32 %36)
%38 = fmul double %37, 9.000000e-01
%39 = tail call i32 @glVertex2d(double %28, double %38)
%40 = tail call i32 @glColor3d(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%41 = load i32, i32* @M_PI
%42 = sdiv i32 %41, 2
%43 = sitofp i32 %42 to double
%44 = sitofp i32 %41 to double
%45 = fmul double %44, 2.000000e+00
%46 = fmul double %45, 2.000000e+00
%47 = fdiv double %46, 3.000000e+00
%48 = fadd double %47, %43
%49 = fptosi double %48 to i32
%50 = tail call double @cos(i32 %49)
%51 = fmul double %50, 9.000000e-01
%52 = load i32, i32* @M_PI
%53 = sdiv i32 %52, 2
%54 = sitofp i32 %53 to double
%55 = sitofp i32 %52 to double
%56 = fmul double %55, 2.000000e+00
%57 = fmul double %56, 2.000000e+00
%58 = fdiv double %57, 3.000000e+00
%59 = fadd double %58, %54
%60 = fptosi double %59 to i32
%61 = tail call double @sin(i32 %60)
%62 = fmul double %61, 9.000000e-01
%63 = tail call i32 @glVertex2d(double %51, double %62)
%64 = tail call i32 (...) @glEnd()
%65 = tail call i32 (...) @glFlush()
%66 = tail call i32 @glXSwapBuffers(i32* %0, i32 %1)
ret void
}