#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 cos(float);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3f(float, float, float);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glFlush();
int /*<<< orphan*/ glVertex2f(float, float);
int sin(float);
void drawCircle(int x, int y, int r, float red, float green, float blue) {
  int i;
  float tx, ty;
  float thita = 0;
  float incrThita = 12 * 3.1415 / 180;
  glColor3f(red, green, blue);
  glBegin(GL_LINE_LOOP);
  for (i = 0; i < 30; i++) {
    tx = x + r * sin(thita + incrThita);
    ty = y + r * cos(thita += incrThita);
    glVertex2f(tx, ty);
  }
  glEnd();
  glFlush();
}


x86 assembly (clang, -O0):
<drawCircle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
movss  %xmm1,-0x14(%rbp)
movss  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  0xe60(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
call   1050 <glColor3f@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1090 <glBegin@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1e,-0x1c(%rbp)
jge    125c <drawCircle+0xec>
mov    -0x4(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movss  -0x28(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
call   1040 <sin@plt>
mov    -0x3c(%rbp),%ecx
mov    %eax,%edx
mov    -0x38(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
movss  -0x2c(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
call   1080 <cos@plt>
mov    -0x34(%rbp),%ecx
mov    %eax,%edx
mov    -0x30(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
call   1070 <glVertex2f@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ce <drawCircle+0x5e>
mov    $0x0,%al
call   1030 <glEnd@plt>
mov    $0x0,%al
call   1060 <glFlush@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawCircle>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
call   1050 <glColor3f@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1090 <glBegin@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,(%rsp)
mov    $0x1e,%ebp
nop
movss  (%rsp),%xmm0
addss  0xe53(%rip),%xmm0
movss  %xmm0,(%rsp)
call   1040 <sin@plt>
imul   %ebx,%eax
add    %r15d,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
call   1080 <cos@plt>
imul   %ebx,%eax
add    %r14d,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
movss  0x4(%rsp),%xmm0
call   1070 <glVertex2f@plt>
add    $0xffffffff,%ebp
jne    11a0 <drawCircle+0x30>
xor    %eax,%eax
call   1030 <glEnd@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <glFlush@plt>

LLVM IR (-O0):
@GL_LINE_LOOP = global i32 0
define void @drawCircle(i32 %0, i32 %1, i32 %2, float %3, float %4, float %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca i32
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store float %3, float* %10
store float %4, float* %11
store float %5, float* %12
store float 0.000000e+00, float* %16
store float 0x3FCACEB620000000, float* %17
%18 = load float, float* %10
%19 = load float, float* %11
%20 = load float, float* %12
%21 = call i32 @glColor3f(float %18, float %19, float %20)
%22 = load i32, i32* @GL_LINE_LOOP
%23 = call i32 @glBegin(i32 %22)
store i32 0, i32* %13
br label %24
24: ; preds = %49, %6
%25 = load i32, i32* %13
%26 = icmp slt i32 %25, 30
br i1 %26, label %27, label %52
27: ; preds = %24
%28 = load i32, i32* %7
%29 = load i32, i32* %9
%30 = load float, float* %16
%31 = load float, float* %17
%32 = fadd float %30, %31
%33 = call i32 @sin(float %32)
%34 = mul nsw i32 %29, %33
%35 = add nsw i32 %28, %34
%36 = sitofp i32 %35 to float
store float %36, float* %14
%37 = load i32, i32* %8
%38 = load i32, i32* %9
%39 = load float, float* %17
%40 = load float, float* %16
%41 = fadd float %40, %39
store float %41, float* %16
%42 = call i32 @cos(float %41)
%43 = mul nsw i32 %38, %42
%44 = add nsw i32 %37, %43
%45 = sitofp i32 %44 to float
store float %45, float* %15
%46 = load float, float* %14
%47 = load float, float* %15
%48 = call i32 @glVertex2f(float %46, float %47)
br label %49
49: ; preds = %27
%50 = load i32, i32* %13
%51 = add nsw i32 %50, 1
store i32 %51, i32* %13
br label %24
52: ; preds = %24
%53 = call i32 (...) @glEnd()
%54 = call i32 (...) @glFlush()
ret void
}

LLVM IR (-O2):
@GL_LINE_LOOP = global i32 0
define void @drawCircle(i32 %0, i32 %1, i32 %2, float %3, float %4, float %5) {
%7 = tail call i32 @glColor3f(float %3, float %4, float %5)
%8 = load i32, i32* @GL_LINE_LOOP
%9 = tail call i32 @glBegin(i32 %8)
br label %10
10: ; preds = %6, %10
%11 = phi i32 [ 0, %6 ], [ %23, %10 ]
%12 = phi float [ 0.000000e+00, %6 ], [ %13, %10 ]
%13 = fadd float %12, 0x3FCACEB620000000
%14 = tail call i32 @sin(float %13)
%15 = mul nsw i32 %14, %2
%16 = add nsw i32 %15, %0
%17 = sitofp i32 %16 to float
%18 = tail call i32 @cos(float %13)
%19 = mul nsw i32 %18, %2
%20 = add nsw i32 %19, %1
%21 = sitofp i32 %20 to float
%22 = tail call i32 @glVertex2f(float %17, float %21)
%23 = add nuw nsw i32 %11, 1
%24 = icmp eq i32 %23, 30
br i1 %24, label %25, label %10
25: ; preds = %10
%26 = tail call i32 (...) @glEnd()
%27 = tail call i32 (...) @glFlush()
ret void
}