#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 cos(double);
double phi(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double, double, double);
int /*<<< orphan*/ rand_norm();
double sin(double);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
double theta(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int i;
  double t, p;
  srand(time(NULL));
  for (i = 0; i < (1 << 11); i++) {
    t = theta(rand_norm());
    p = phi(rand_norm());
    printf("%.12f %.12f %.12f\n", sin(t) * cos(p), sin(t) * sin(p), cos(t));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x800,-0x8(%rbp)
jge    125e <main+0xde>
mov    $0x0,%al
call   1030 <rand_norm@plt>
mov    %eax,%edi
call   1050 <theta@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand_norm@plt>
mov    %eax,%edi
call   1090 <phi@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   10a0 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   10a0 <cos@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
lea    0xdb5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a6 <main+0x26>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x800,%ebp
lea    0xe60(%rip),%rbx
xor    %eax,%eax
call   1030 <rand_norm@plt>
mov    %eax,%edi
call   1050 <theta@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <rand_norm@plt>
mov    %eax,%edi
call   1090 <phi@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   10a0 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1070 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   10a0 <cos@plt>
movaps %xmm0,%xmm2
mov    %rbx,%rdi
movsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    11a0 <main+0x20>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [19 x i8] c"%.12f %.12f %.12f\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %17, %3 ]
%5 = tail call i32 (...) @rand_norm()
%6 = tail call double @theta(i32 %5)
%7 = tail call i32 (...) @rand_norm()
%8 = tail call double @phi(i32 %7)
%9 = tail call double @sin(double %6)
%10 = tail call double @cos(double %8)
%11 = fmul double %9, %10
%12 = tail call double @sin(double %6)
%13 = tail call double @sin(double %8)
%14 = fmul double %12, %13
%15 = tail call double @cos(double %6)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %11, double %14, double %15)
%17 = add nuw nsw i32 %4, 1
%18 = icmp eq i32 %17, 2048
br i1 %18, label %19, label %3
19: ; preds = %3
ret i32 0
}