#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_LINE_LOOP;
float cos(float);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex2f(float, float);
float sin(float);
void DrawCircle(float cx, float cy, float r, int segments) {
  float theta, x, y, ii;
  glBegin(GL_LINE_LOOP);
  for (ii = 0; ii < segments; ii++) {
    theta = 2.0f * 3.1415926535897932384626433832795029L * (float)ii /
            (float)segments;
    x = r * cos(theta);
    y = r * sin(theta);
    glVertex2f(x + cx, y + cy);
  }
  glEnd();
}


x86 assembly (clang, -O0):
<DrawCircle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm1
cvtsi2ssl -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1234 <DrawCircle+0xe4>
flds   -0x20(%rbp)
fldt   0xe64(%rip)
fmulp  %st,%st(1)
cvtsi2ssl -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
flds   -0x24(%rbp)
fdivrp %st,%st(1)
fstps  -0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x4(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
addss  -0x8(%rbp),%xmm1
call   1050 <glVertex2f@plt>
movss  0xdeb(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1180 <DrawCircle+0x30>
mov    $0x0,%al
call   1030 <glEnd@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawCircle>:
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebx
movss  %xmm2,0x4(%rsp)
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
test   %ebx,%ebx
jle    123c <DrawCircle+0xec>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0x8(%rsp)
movss  %xmm0,0x24(%rsp)
xorps  %xmm0,%xmm0
flds   0x24(%rsp)
fstpt  0x34(%rsp)
fldt   0xe5d(%rip)
fstpt  0x28(%rsp)
nopw   0x0(%rax,%rax,1)
movss  %xmm0,(%rsp)
movss  %xmm0,0x20(%rsp)
fldt   0x28(%rsp)
fmuls  0x20(%rsp)
fldt   0x34(%rsp)
fdivrp %st,%st(1)
fstps  0x1c(%rsp)
movss  0x1c(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
call   1060 <cos@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,0x18(%rsp)
movss  0x14(%rsp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
mulss  0x4(%rsp),%xmm1
movss  0x18(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
addss  0x10(%rsp),%xmm1
call   1050 <glVertex2f@plt>
movss  (%rsp),%xmm0
addss  0xdee(%rip),%xmm0
movss  %xmm0,(%rsp)
movss  0x8(%rsp),%xmm0
ucomiss (%rsp),%xmm0
movss  (%rsp),%xmm0
ja     11b0 <DrawCircle+0x60>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
jmp    1030 <glEnd@plt>

LLVM IR (-O0):
@GL_LINE_LOOP = global i32 0
define void @DrawCircle(float %0, float %1, float %2, i32 %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store i32 %3, i32* %8
%13 = load i32, i32* @GL_LINE_LOOP
%14 = call i32 @glBegin(i32 %13)
store float 0.000000e+00, float* %12
br label %15
15: ; preds = %44, %4
%16 = load float, float* %12
%17 = load i32, i32* %8
%18 = sitofp i32 %17 to float
%19 = fcmp olt float %16, %18
br i1 %19, label %20, label %47
20: ; preds = %15
%21 = load float, float* %12
%22 = fpext float %21 to x86_fp80
%23 = fmul x86_fp80 0xK4001C90FDAA22168C235, %22
%24 = load i32, i32* %8
%25 = sitofp i32 %24 to float
%26 = fpext float %25 to x86_fp80
%27 = fdiv x86_fp80 %23, %26
%28 = fptrunc x86_fp80 %27 to float
store float %28, float* %9
%29 = load float, float* %7
%30 = load float, float* %9
%31 = call float @cos(float %30)
%32 = fmul float %29, %31
store float %32, float* %10
%33 = load float, float* %7
%34 = load float, float* %9
%35 = call float @sin(float %34)
%36 = fmul float %33, %35
store float %36, float* %11
%37 = load float, float* %10
%38 = load float, float* %5
%39 = fadd float %37, %38
%40 = load float, float* %11
%41 = load float, float* %6
%42 = fadd float %40, %41
%43 = call i32 @glVertex2f(float %39, float %42)
br label %44
44: ; preds = %20
%45 = load float, float* %12
%46 = fadd float %45, 1.000000e+00
store float %46, float* %12
br label %15
47: ; preds = %15
%48 = call i32 (...) @glEnd()
ret void
}

LLVM IR (-O2):
@GL_LINE_LOOP = global i32 0
define void @DrawCircle(float %0, float %1, float %2, i32 %3) {
%5 = load i32, i32* @GL_LINE_LOOP
%6 = tail call i32 @glBegin(i32 %5)
%7 = sitofp i32 %3 to float
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %26
9: ; preds = %4
%10 = fpext float %7 to x86_fp80
br label %11
11: ; preds = %9, %11
%12 = phi float [ 0.000000e+00, %9 ], [ %24, %11 ]
%13 = fpext float %12 to x86_fp80
%14 = fmul x86_fp80 %13, 0xK4001C90FDAA22168C235
%15 = fdiv x86_fp80 %14, %10
%16 = fptrunc x86_fp80 %15 to float
%17 = tail call float @cos(float %16)
%18 = fmul float %17, %2
%19 = tail call float @sin(float %16)
%20 = fmul float %19, %2
%21 = fadd float %18, %0
%22 = fadd float %20, %1
%23 = tail call i32 @glVertex2f(float %21, float %22)
%24 = fadd float %12, 1.000000e+00
%25 = fcmp olt float %24, %7
br i1 %25, label %11, label %26
26: ; preds = %11, %4
%27 = tail call i32 (...) @glEnd()
ret void
}