#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);
int drand48();
double pow(double, int);
double sin(double);
void make_points(double *x, double *y, double *z, int npoints) {
  int i, j, k;
  double r, theta, phi;
  for (i = 0; i < npoints; i++) {
    r = drand48();
    theta = drand48() * 3.14159;
    phi = drand48() * 2 * 3.14159;
    x[i] = pow(r, 1) * sin(theta) * cos(phi);
    y[i] = pow(r, 1) * sin(theta) * sin(phi);
    z[i] = pow(r, 1) * cos(theta);
  }
}


x86 assembly (clang, -O0):
<make_points>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    129e <make_points+0x15e>
mov    $0x0,%al
call   1060 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe73(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe54(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115e <make_points+0x1e>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_points>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
test   %ecx,%ecx
jle    127c <make_points+0x13c>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %ecx,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <drand48@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xe66(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe44(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%rsp),%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <make_points+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @make_points(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %15
15: ; preds = %62, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %65
19: ; preds = %15
%20 = call i32 (...) @drand48()
%21 = sitofp i32 %20 to double
store double %21, double* %12
%22 = call i32 (...) @drand48()
%23 = sitofp i32 %22 to double
%24 = fmul double %23, 3.141590e+00
store double %24, double* %13
%25 = call i32 (...) @drand48()
%26 = mul nsw i32 %25, 2
%27 = sitofp i32 %26 to double
%28 = fmul double %27, 3.141590e+00
store double %28, double* %14
%29 = load double, double* %12
%30 = call double @pow(double %29, i32 1)
%31 = load double, double* %13
%32 = call double @sin(double %31)
%33 = fmul double %30, %32
%34 = load double, double* %14
%35 = call double @cos(double %34)
%36 = fmul double %33, %35
%37 = load double*, double** %5
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %36, double* %40
%41 = load double, double* %12
%42 = call double @pow(double %41, i32 1)
%43 = load double, double* %13
%44 = call double @sin(double %43)
%45 = fmul double %42, %44
%46 = load double, double* %14
%47 = call double @sin(double %46)
%48 = fmul double %45, %47
%49 = load double*, double** %6
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
store double %48, double* %52
%53 = load double, double* %12
%54 = call double @pow(double %53, i32 1)
%55 = load double, double* %13
%56 = call double @cos(double %55)
%57 = fmul double %54, %56
%58 = load double*, double** %7
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
store double %57, double* %61
br label %62
62: ; preds = %19
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %15
65: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @make_points(double* nocapture writeonly %0, double* nocapture writeonly %1, double* nocapture writeonly %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %37
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %35, %8 ]
%10 = tail call i32 (...) @drand48()
%11 = sitofp i32 %10 to double
%12 = tail call i32 (...) @drand48()
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 3.141590e+00
%15 = tail call i32 (...) @drand48()
%16 = shl nsw i32 %15, 1
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 3.141590e+00
%19 = tail call double @pow(double %11, i32 1)
%20 = tail call double @sin(double %14)
%21 = fmul double %19, %20
%22 = tail call double @cos(double %18)
%23 = fmul double %21, %22
%24 = getelementptr inbounds double, double* %0, i64 %9
store double %23, double* %24
%25 = tail call double @pow(double %11, i32 1)
%26 = tail call double @sin(double %14)
%27 = fmul double %25, %26
%28 = tail call double @sin(double %18)
%29 = fmul double %27, %28
%30 = getelementptr inbounds double, double* %1, i64 %9
store double %29, double* %30
%31 = tail call double @pow(double %11, i32 1)
%32 = tail call double @cos(double %14)
%33 = fmul double %31, %32
%34 = getelementptr inbounds double, double* %2, i64 %9
store double %33, double* %34
%35 = add nuw nsw i64 %9, 1
%36 = icmp eq i64 %35, %7
br i1 %36, label %37, label %8
37: ; preds = %8, %4
ret void
}