#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;
int M_PI;
float cos(float);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex3f(float, int /*<<< orphan*/, float);
float sin(float);
void drawCircle(float radius) {
  glBegin(GL_LINE_LOOP);
  int i;
  for (i = 0; i < 360; i++) {
    float angle = i * M_PI / 180.0;
    glVertex3f(cos(angle) * radius, 0, sin(angle) * radius);
  }
  glEnd();
}


x86 assembly (clang, -O0):
<drawCircle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x168,-0x8(%rbp)
jge    11e5 <drawCircle+0x95>
mov    -0x8(%rbp),%eax
mov    0x2e5f(%rip),%rcx
imul   (%rcx),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe68(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1060 <cos@plt>
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm1
xor    %edi,%edi
call   1030 <glVertex3f@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1172 <drawCircle+0x22>
mov    $0x0,%al
call   1040 <glEnd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawCircle>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movss  %xmm0,0xc(%rsp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
xor    %ebx,%ebx
mov    0x2e74(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%eax
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe6b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
call   1060 <cos@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
mulss  0xc(%rsp),%xmm1
movss  0x14(%rsp),%xmm0
xor    %edi,%edi
call   1030 <glVertex3f@plt>
add    $0x1,%ebx
cmp    $0x168,%ebx
jne    1180 <drawCircle+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1040 <glEnd@plt>

LLVM IR (-O0):
@GL_LINE_LOOP = global i32 0
@M_PI = global i32 0
define void @drawCircle(float %0) {
%2 = alloca float
%3 = alloca i32
%4 = alloca float
store float %0, float* %2
%5 = load i32, i32* @GL_LINE_LOOP
%6 = call i32 @glBegin(i32 %5)
store i32 0, i32* %3
br label %7
7: ; preds = %26, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 360
br i1 %9, label %10, label %29
10: ; preds = %7
%11 = load i32, i32* %3
%12 = load i32, i32* @M_PI
%13 = mul nsw i32 %11, %12
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, 1.800000e+02
%16 = fptrunc double %15 to float
store float %16, float* %4
%17 = load float, float* %4
%18 = call float @cos(float %17)
%19 = load float, float* %2
%20 = fmul float %18, %19
%21 = load float, float* %4
%22 = call float @sin(float %21)
%23 = load float, float* %2
%24 = fmul float %22, %23
%25 = call i32 @glVertex3f(float %20, i32 0, float %24)
br label %26
26: ; preds = %10
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %7
29: ; preds = %7
%30 = call i32 (...) @glEnd()
ret void
}

LLVM IR (-O2):
@GL_LINE_LOOP = global i32 0
@M_PI = global i32 0
define void @drawCircle(float %0) {
%2 = load i32, i32* @GL_LINE_LOOP
%3 = tail call i32 @glBegin(i32 %2)
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ 0, %1 ], [ %16, %4 ]
%6 = load i32, i32* @M_PI
%7 = mul nsw i32 %6, %5
%8 = sitofp i32 %7 to double
%9 = fdiv double %8, 1.800000e+02
%10 = fptrunc double %9 to float
%11 = tail call float @cos(float %10)
%12 = fmul float %11, %0
%13 = tail call float @sin(float %10)
%14 = fmul float %13, %0
%15 = tail call i32 @glVertex3f(float %12, i32 0, float %14)
%16 = add nuw nsw i32 %5, 1
%17 = icmp eq i32 %16, 360
br i1 %17, label %18, label %4
18: ; preds = %4
%19 = tail call i32 (...) @glEnd()
ret void
}