#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 cos(double);
int /*<<< orphan*/ printf(char *, int, int);
int sin(double);
int main() {
  int i, count = 32;
  for (i = 0; i < count; ++i) {
    double a = 3.141592654 / 2 / count * i;
    double s = sin(a) * (1 << 16);
    double c = cos(a) * (1 << 16);
    printf("    {%d, %d},\n", (int)s, (int)c);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x20,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c8 <main+0x98>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe9a(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
shl    $0x10,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
shl    $0x10,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x20(%rbp),%esi
cvttsd2si -0x28(%rbp),%edx
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm0,%xmm0
mov    $0x20,%ebx
lea    0xec8(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
mulsd  0xea2(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <sin@plt>
mov    %eax,%ebp
shl    $0x10,%ebp
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
shl    $0x10,%eax
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe74(%rip),%xmm0
add    $0xffffffff,%ebx
jne    1150 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c" {%d, %d},\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
store i32 32, i32* %3
store i32 0, i32* %2
br label %7
7: ; preds = %31, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %7
%12 = load i32, i32* %3
%13 = sitofp i32 %12 to double
%14 = fdiv double 0x3FF921FB54524550, %13
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = fmul double %14, %16
store double %17, double* %4
%18 = load double, double* %4
%19 = call i32 @sin(double %18)
%20 = mul nsw i32 %19, 65536
%21 = sitofp i32 %20 to double
store double %21, double* %5
%22 = load double, double* %4
%23 = call i32 @cos(double %22)
%24 = mul nsw i32 %23, 65536
%25 = sitofp i32 %24 to double
store double %25, double* %6
%26 = load double, double* %5
%27 = fptosi double %26 to i32
%28 = load double, double* %6
%29 = fptosi double %28 to i32
%30 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %29)
br label %31
31: ; preds = %11
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %7
34: ; preds = %7
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [15 x i8] c" {%d, %d},\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %10, %1 ]
%3 = sitofp i32 %2 to double
%4 = fmul double %3, 0x3FA921FB54524550
%5 = tail call i32 @sin(double %4)
%6 = shl nsw i32 %5, 16
%7 = tail call i32 @cos(double %4)
%8 = shl nsw i32 %7, 16
%9 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8)
%10 = add nuw nsw i32 %2, 1
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %1
12: ; preds = %1
ret i32 0
}