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

/* Variables and functions */
int /*<<< orphan*/ GL_LINES;
int /*<<< orphan*/ GL_TRIANGLE_FAN;
int cos(int);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3f(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glPopMatrix();
int /*<<< orphan*/ glPushMatrix();
int /*<<< orphan*/ glTranslatef(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ glVertex2f(int, int);
int sin(int);
void drawCircle(int x, int y, int r, int dir) {
  float angle;
  glPushMatrix();
  glTranslatef(x, y, 0);
  glBegin(GL_TRIANGLE_FAN);
  glVertex2f(0, 0);
  for (angle = 2 * 3.14159265358979323846; angle >= 0;
       angle -= 3.14159265358979323846 / 12) {
    glVertex2f(r * cos(angle), r * sin(angle));
  }
  glEnd();
  glColor3f(0, 0, 1);
  glBegin(GL_LINES);
  glVertex2f(0, 0);
  glVertex2f(r * cos(dir * 3.14159265358979323846 / 180),
             r * sin(dir * 3.14159265358979323846 / 180));
  glEnd();
  glPopMatrix();
}


x86 assembly (clang, -O0):
<drawCircle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    $0x0,%al
call   1070 <glPushMatrix@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %edx,%edx
call   10a0 <glTranslatef@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   10b0 <glBegin@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1080 <glVertex2f@plt>
movss  0xe29(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1249 <drawCircle+0xb9>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
cvttss2si -0x14(%rbp),%edi
call   1090 <cos@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvttss2si -0x14(%rbp),%edi
call   1050 <sin@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edi
imul   %eax,%esi
call   1080 <glVertex2f@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xde1(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11dc <drawCircle+0x4c>
mov    $0x0,%al
call   1030 <glEnd@plt>
xor    %esi,%esi
mov    $0x1,%edx
mov    %esi,%edi
call   1060 <glColor3f@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
call   10b0 <glBegin@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1080 <glVertex2f@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xd88(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd74(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1090 <cos@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xd51(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd3d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edi
imul   %eax,%esi
call   1080 <glVertex2f@plt>
mov    $0x0,%al
call   1030 <glEnd@plt>
mov    $0x0,%al
call   1040 <glPopMatrix@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawCircle>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%r15d
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <glPushMatrix@plt>
mov    %ebp,%edi
mov    %r15d,%esi
xor    %edx,%edx
call   10a0 <glTranslatef@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   10b0 <glBegin@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1080 <glVertex2f@plt>
movss  0xe27(%rip),%xmm0
nopl   0x0(%rax)
movss  %xmm0,0xc(%rsp)
cvttss2si %xmm0,%ebp
mov    %ebp,%edi
call   1090 <cos@plt>
mov    %eax,%ebx
imul   %r12d,%ebx
mov    %ebp,%edi
call   1050 <sin@plt>
imul   %r12d,%eax
mov    %ebx,%edi
mov    %eax,%esi
call   1080 <glVertex2f@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xdeb(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
ucomiss 0xddc(%rip),%xmm0
jae    11e0 <drawCircle+0x50>
xor    %eax,%eax
call   1030 <glEnd@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <glColor3f@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
call   10b0 <glBegin@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1080 <glVertex2f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  0xdaa(%rip),%xmm0
divsd  0xdaa(%rip),%xmm0
cvttsd2si %xmm0,%ebx
mov    %ebx,%edi
call   1090 <cos@plt>
mov    %eax,%ebp
imul   %r12d,%ebp
mov    %ebx,%edi
call   1050 <sin@plt>
imul   %eax,%r12d
mov    %ebp,%edi
mov    %r12d,%esi
call   1080 <glVertex2f@plt>
xor    %eax,%eax
call   1030 <glEnd@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <glPopMatrix@plt>

LLVM IR (-O0):
@GL_TRIANGLE_FAN = global i32 0
@GL_LINES = global i32 0
define void @drawCircle(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = call i32 (...) @glPushMatrix()
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i32 @glTranslatef(i32 %11, i32 %12, i32 0)
%14 = load i32, i32* @GL_TRIANGLE_FAN
%15 = call i32 @glBegin(i32 %14)
%16 = call i32 @glVertex2f(i32 0, i32 0)
store float 0x401921FB60000000, float* %9
br label %17
17: ; preds = %32, %4
%18 = load float, float* %9
%19 = fcmp oge float %18, 0.000000e+00
br i1 %19, label %20, label %37
20: ; preds = %17
%21 = load i32, i32* %7
%22 = load float, float* %9
%23 = fptosi float %22 to i32
%24 = call i32 @cos(i32 %23)
%25 = mul nsw i32 %21, %24
%26 = load i32, i32* %7
%27 = load float, float* %9
%28 = fptosi float %27 to i32
%29 = call i32 @sin(i32 %28)
%30 = mul nsw i32 %26, %29
%31 = call i32 @glVertex2f(i32 %25, i32 %30)
br label %32
32: ; preds = %20
%33 = load float, float* %9
%34 = fpext float %33 to double
%35 = fsub double %34, 0x3FD0C152382D7365
%36 = fptrunc double %35 to float
store float %36, float* %9
br label %17
37: ; preds = %17
%38 = call i32 (...) @glEnd()
%39 = call i32 @glColor3f(i32 0, i32 0, i32 1)
%40 = load i32, i32* @GL_LINES
%41 = call i32 @glBegin(i32 %40)
%42 = call i32 @glVertex2f(i32 0, i32 0)
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = sitofp i32 %44 to double
%46 = fmul double %45, 0x400921FB54442D18
%47 = fdiv double %46, 1.800000e+02
%48 = fptosi double %47 to i32
%49 = call i32 @cos(i32 %48)
%50 = mul nsw i32 %43, %49
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = sitofp i32 %52 to double
%54 = fmul double %53, 0x400921FB54442D18
%55 = fdiv double %54, 1.800000e+02
%56 = fptosi double %55 to i32
%57 = call i32 @sin(i32 %56)
%58 = mul nsw i32 %51, %57
%59 = call i32 @glVertex2f(i32 %50, i32 %58)
%60 = call i32 (...) @glEnd()
%61 = call i32 (...) @glPopMatrix()
ret void
}

LLVM IR (-O2):
@GL_TRIANGLE_FAN = global i32 0
@GL_LINES = global i32 0
define void @drawCircle(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 (...) @glPushMatrix()
%6 = tail call i32 @glTranslatef(i32 %0, i32 %1, i32 0)
%7 = load i32, i32* @GL_TRIANGLE_FAN
%8 = tail call i32 @glBegin(i32 %7)
%9 = tail call i32 @glVertex2f(i32 0, i32 0)
br label %10
10: ; preds = %4, %10
%11 = phi float [ 0x401921FB60000000, %4 ], [ %20, %10 ]
%12 = fptosi float %11 to i32
%13 = tail call i32 @cos(i32 %12)
%14 = mul nsw i32 %13, %2
%15 = tail call i32 @sin(i32 %12)
%16 = mul nsw i32 %15, %2
%17 = tail call i32 @glVertex2f(i32 %14, i32 %16)
%18 = fpext float %11 to double
%19 = fadd double %18, 0xBFD0C152382D7365
%20 = fptrunc double %19 to float
%21 = fcmp ult float %20, 0.000000e+00
br i1 %21, label %22, label %10
22: ; preds = %10
%23 = tail call i32 (...) @glEnd()
%24 = tail call i32 @glColor3f(i32 0, i32 0, i32 1)
%25 = load i32, i32* @GL_LINES
%26 = tail call i32 @glBegin(i32 %25)
%27 = tail call i32 @glVertex2f(i32 0, i32 0)
%28 = sitofp i32 %3 to double
%29 = fmul double %28, 0x400921FB54442D18
%30 = fdiv double %29, 1.800000e+02
%31 = fptosi double %30 to i32
%32 = tail call i32 @cos(i32 %31)
%33 = mul nsw i32 %32, %2
%34 = tail call i32 @sin(i32 %31)
%35 = mul nsw i32 %34, %2
%36 = tail call i32 @glVertex2f(i32 %33, i32 %35)
%37 = tail call i32 (...) @glEnd()
%38 = tail call i32 (...) @glPopMatrix()
ret void
}