#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_COLOR_BUFFER_BIT;
int /*<<< orphan*/ GL_LINE_LOOP;
double cos(int);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glClear(int /*<<< orphan*/);
int /*<<< orphan*/ glClearColor(double, double, double, double);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glFlush();
int /*<<< orphan*/ glVertex3d(double, double, int /*<<< orphan*/);
int /*<<< orphan*/ glutSwapBuffers();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
double sin(int);
void print() {
  glClearColor(0.0, 0.0, 1.0, 1.0);
  glClear(GL_COLOR_BUFFER_BIT);
  int n;
  printf("Podaj ilosc katow:\n");
  scanf("%d", &n);
  glBegin(GL_LINE_LOOP);
  double PI = 3.14, fi, x, y;
  fi = 2 * PI / n;
  for (int i = 0; i < n; i++) {
    x = cos(i * fi);
    y = sin(i * fi);
    glVertex3d(x, y, 0);
  }
  glEnd();
  glFlush();
  glutSwapBuffers();
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xorps  %xmm1,%xmm1
movsd  0xe4d(%rip),%xmm3
movaps %xmm1,%xmm0
movaps %xmm3,%xmm2
call   1080 <glClearColor@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1030 <glClear@plt>
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
lea    0xe3d(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   10b0 <scanf@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   10d0 <glBegin@plt>
movsd  0xdfa(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xde5(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1290 <print+0xe0>
cvtsi2sdl -0x2c(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10c0 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1090 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
xor    %edi,%edi
call   1040 <glVertex3d@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1235 <print+0x85>
mov    $0x0,%al
call   1070 <glEnd@plt>
mov    $0x0,%al
call   10a0 <glFlush@plt>
mov    $0x0,%al
call   1060 <glutSwapBuffers@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  0xe42(%rip),%xmm2
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
movaps %xmm2,%xmm3
call   1080 <glClearColor@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1040 <glClear@plt>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
lea    0xe21(%rip),%rdi
lea    0x4(%rsp),%rsi
call   10b0 <scanf@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   10d0 <glBegin@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    126f <print+0xbf>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xdea(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%ebx
mov    %ebx,%edi
call   10c0 <cos@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1090 <sin@plt>
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
xor    %edi,%edi
call   1050 <glVertex3d@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1230 <print+0x80>
xor    %eax,%eax
call   1070 <glEnd@plt>
xor    %eax,%eax
call   10a0 <glFlush@plt>
xor    %eax,%eax
call   1060 <glutSwapBuffers@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@GL_COLOR_BUFFER_BIT = global i32 0
@.str = [20 x i8] c"Podaj ilosc katow:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@GL_LINE_LOOP = global i32 0
define void @print() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = call i32 @glClearColor(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double 1.000000e+00)
%8 = load i32, i32* @GL_COLOR_BUFFER_BIT
%9 = call i32 @glClear(i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = load i32, i32* @GL_LINE_LOOP
%13 = call i32 @glBegin(i32 %12)
store double 3.140000e+00, double* %2
%14 = load double, double* %2
%15 = fmul double 2.000000e+00, %14
%16 = load i32, i32* %1
%17 = sitofp i32 %16 to double
%18 = fdiv double %15, %17
store double %18, double* %3
store i32 0, i32* %6
br label %19
19: ; preds = %39, %0
%20 = load i32, i32* %6
%21 = load i32, i32* %1
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %42
23: ; preds = %19
%24 = load i32, i32* %6
%25 = sitofp i32 %24 to double
%26 = load double, double* %3
%27 = fmul double %25, %26
%28 = fptosi double %27 to i32
%29 = call double @cos(i32 %28)
store double %29, double* %4
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to double
%32 = load double, double* %3
%33 = fmul double %31, %32
%34 = fptosi double %33 to i32
%35 = call double @sin(i32 %34)
store double %35, double* %5
%36 = load double, double* %4
%37 = load double, double* %5
%38 = call i32 @glVertex3d(double %36, double %37, i32 0)
br label %39
39: ; preds = %23
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %19
42: ; preds = %19
%43 = call i32 (...) @glEnd()
%44 = call i32 (...) @glFlush()
%45 = call i32 (...) @glutSwapBuffers()
ret void
}

LLVM IR (-O2):
@GL_COLOR_BUFFER_BIT = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@GL_LINE_LOOP = global i32 0
@str = [19 x i8] c"Podaj ilosc katow:\00"
define void @print() {
%1 = alloca i32
%2 = tail call i32 @glClearColor(double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double 1.000000e+00)
%3 = load i32, i32* @GL_COLOR_BUFFER_BIT
%4 = tail call i32 @glClear(i32 %3)
%5 = bitcast i32* %1 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* @GL_LINE_LOOP
%9 = call i32 @glBegin(i32 %8)
%10 = load i32, i32* %1
%11 = sitofp i32 %10 to double
%12 = fdiv double 6.280000e+00, %11
%13 = icmp sgt i32 %10, 0
br i1 %13, label %18, label %14
14: ; preds = %18, %0
%15 = call i32 (...) @glEnd()
%16 = call i32 (...) @glFlush()
%17 = call i32 (...) @glutSwapBuffers()
ret void
18: ; preds = %0, %18
%19 = phi i32 [ %26, %18 ], [ 0, %0 ]
%20 = sitofp i32 %19 to double
%21 = fmul double %12, %20
%22 = fptosi double %21 to i32
%23 = call double @cos(i32 %22)
%24 = call double @sin(i32 %22)
%25 = call i32 @glVertex3d(double %23, double %24, i32 0)
%26 = add nuw nsw i32 %19, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %26, %27
br i1 %28, label %18, label %14
}