#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 cosf(float);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex3f(float, float, float);
float sinf(float);
void drawDisc(float cx, float cy, float r, int num_segments) {
  int i = 0;
  float angle;
  glBegin(GL_LINE_LOOP);
  for (i = 0; i < num_segments; i++) {
    angle = i * 2 * 3.14159 / num_segments;
    glVertex3f(cx, cy, -5.0f);
    glVertex3f(cx + r * cosf(angle), cy + r * sinf(angle), -5.0f);
  }
  glEnd();
}


x86 assembly (clang, -O0):
<drawDisc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    125c <drawDisc+0x10c>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe64(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  0xe34(%rip),%xmm2
call   1050 <glVertex3f@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <cosf@plt>
movss  -0x2c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x28(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <sinf@plt>
movss  -0x24(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x1c(%rbp),%xmm0
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
movss  0xdb7(%rip),%xmm2
call   1050 <glVertex3f@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1186 <drawDisc+0x36>
mov    $0x0,%al
call   1060 <glEnd@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawDisc>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebx
movss  %xmm2,0x14(%rsp)
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
test   %ebx,%ebx
jle    121e <drawDisc+0xce>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x20(%rsp)
xor    %ebp,%ebp
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe61(%rip),%xmm0
divsd  0x20(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x18(%rsp)
movss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  0xe45(%rip),%xmm2
call   1050 <glVertex3f@plt>
movss  0x18(%rsp),%xmm0
call   1040 <cosf@plt>
mulss  0x14(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0x1c(%rsp)
movss  0x18(%rsp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
mulss  0x14(%rsp),%xmm1
addss  0x10(%rsp),%xmm1
movss  0x1c(%rsp),%xmm0
movss  0xdfb(%rip),%xmm2
call   1050 <glVertex3f@plt>
add    $0x2,%ebp
add    $0xffffffff,%ebx
jne    1190 <drawDisc+0x40>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <glEnd@plt>

LLVM IR (-O0):
@GL_LINE_LOOP = global i32 0
define void @drawDisc(float %0, float %1, float %2, i32 %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store i32 %3, i32* %8
store i32 0, i32* %9
%11 = load i32, i32* @GL_LINE_LOOP
%12 = call i32 @glBegin(i32 %11)
store i32 0, i32* %9
br label %13
13: ; preds = %40, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %43
17: ; preds = %13
%18 = load i32, i32* %9
%19 = mul nsw i32 %18, 2
%20 = sitofp i32 %19 to double
%21 = fmul double %20, 3.141590e+00
%22 = load i32, i32* %8
%23 = sitofp i32 %22 to double
%24 = fdiv double %21, %23
%25 = fptrunc double %24 to float
store float %25, float* %10
%26 = load float, float* %5
%27 = load float, float* %6
%28 = call i32 @glVertex3f(float %26, float %27, float -5.000000e+00)
%29 = load float, float* %5
%30 = load float, float* %7
%31 = load float, float* %10
%32 = call float @cosf(float %31)
%33 = call float @llvm.fmuladd.f32(float %30, float %32, float %29)
%34 = load float, float* %6
%35 = load float, float* %7
%36 = load float, float* %10
%37 = call float @sinf(float %36)
%38 = call float @llvm.fmuladd.f32(float %35, float %37, float %34)
%39 = call i32 @glVertex3f(float %33, float %38, float -5.000000e+00)
br label %40
40: ; preds = %17
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %13
43: ; preds = %13
%44 = call i32 (...) @glEnd()
ret void
}

LLVM IR (-O2):
@GL_LINE_LOOP = global i32 0
define void @drawDisc(float %0, float %1, float %2, i32 %3) {
%5 = load i32, i32* @GL_LINE_LOOP
%6 = tail call i32 @glBegin(i32 %5)
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %25
8: ; preds = %4
%9 = sitofp i32 %3 to double
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ 0, %8 ], [ %23, %10 ]
%12 = shl nuw nsw i32 %11, 1
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 3.141590e+00
%15 = fdiv double %14, %9
%16 = fptrunc double %15 to float
%17 = tail call i32 @glVertex3f(float %0, float %1, float -5.000000e+00)
%18 = tail call float @cosf(float %16)
%19 = tail call float @llvm.fmuladd.f32(float %2, float %18, float %0)
%20 = tail call float @sinf(float %16)
%21 = tail call float @llvm.fmuladd.f32(float %2, float %20, float %1)
%22 = tail call i32 @glVertex3f(float %19, float %21, float -5.000000e+00)
%23 = add nuw nsw i32 %11, 1
%24 = icmp eq i32 %23, %3
br i1 %24, label %25, label %10
25: ; preds = %10, %4
%26 = tail call i32 (...) @glEnd()
ret void
}