#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 */
double M_PI;
double cos(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
double sin(double);
void main() {
  int pts;
  printf("How many points in the circle? ");
  scanf("%d", &pts);
  double pi = M_PI;
  double ang = 2.0 * pi / ((double)pts);
  int i;
  for (i = 0; i < pts; i++) {
    double ang2 = ang + ang * i;
    double x = cos(ang2);
    double y = sin(ang2);
    printf("(%f, %f)\n", x, y);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e7b(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe82(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1204 <main+0xc4>
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xe3c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <main+0x58>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
lea    0xeb3(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11ee <main+0xae>
mov    0x2e72(%rip),%rcx
movsd  (%rcx),%xmm1
addsd  %xmm1,%xmm1
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
lea    0xe90(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
call   1060 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <sin@plt>
movapd %xmm0,%xmm1
mov    %rbx,%rdi
movsd  0x20(%rsp),%xmm0
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     11a0 <main+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"How many points in the circle? \00"
@.str.1 = [3 x i8] c"%d\00"
@M_PI = global double 0.000000e+00
@.str.2 = [10 x i8] c"(%f, %f)\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load double, double* @M_PI
store double %10, double* %2
%11 = load double, double* %2
%12 = fmul double 2.000000e+00, %11
%13 = load i32, i32* %1
%14 = sitofp i32 %13 to double
%15 = fdiv double %12, %14
store double %15, double* %3
store i32 0, i32* %4
br label %16
16: ; preds = %33, %0
%17 = load i32, i32* %4
%18 = load i32, i32* %1
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load double, double* %3
%22 = load double, double* %3
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to double
%25 = call double @llvm.fmuladd.f64(double %22, double %24, double %21)
store double %25, double* %5
%26 = load double, double* %5
%27 = call double @cos(double %26)
store double %27, double* %6
%28 = load double, double* %5
%29 = call double @sin(double %28)
store double %29, double* %7
%30 = load double, double* %6
%31 = load double, double* %7
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %30, double %31)
br label %33
33: ; preds = %20
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %16
36: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"How many points in the circle? \00"
@.str.1 = [3 x i8] c"%d\00"
@M_PI = global double 0.000000e+00
@.str.2 = [10 x i8] c"(%f, %f)\0A\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load double, double* @M_PI
%6 = fmul double %5, 2.000000e+00
%7 = load i32, i32* %1
%8 = sitofp i32 %7 to double
%9 = fdiv double %6, %8
%10 = icmp sgt i32 %7, 0
br i1 %10, label %11, label %21
11: ; preds = %0, %11
%12 = phi i32 [ %18, %11 ], [ 0, %0 ]
%13 = sitofp i32 %12 to double
%14 = call double @llvm.fmuladd.f64(double %9, double %13, double %9)
%15 = call double @cos(double %14)
%16 = call double @sin(double %14)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %15, double %16)
%18 = add nuw nsw i32 %12, 1
%19 = load i32, i32* %1
%20 = icmp slt i32 %18, %19
br i1 %20, label %11, label %21
21: ; preds = %11, %0
ret void
}