#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 glmRandomNumberd(double, double);
double sin(double);
double sqrt(double);
void glmGenerateRandomVector3d(double v[3]) {
  double a, r;
  v[2] = glmRandomNumberd(-1.0, 1.0);
  a = glmRandomNumberd(0.0, 6.283185307179586476925286766559);
  r = sqrt(1.0 - v[2] * v[2]);
  v[0] = r * cos(a);
  v[1] = r * sin(a);
}


x86 assembly (clang, -O0):
<glmGenerateRandomVector3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  0xea4(%rip),%xmm1
call   1060 <glmRandomNumberd@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
xorps  %xmm0,%xmm0
movsd  0xe93(%rip),%xmm1
call   1060 <glmRandomNumberd@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe4c(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmGenerateRandomVector3d>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  0xeb0(%rip),%xmm0
movsd  0xeb0(%rip),%xmm1
call   1060 <glmRandomNumberd@plt>
movsd  %xmm0,0x10(%rbx)
movsd  0xea6(%rip),%xmm1
xorps  %xmm0,%xmm0
call   1060 <glmRandomNumberd@plt>
movsd  0xe8e(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
mulsd  %xmm0,%xmm0
subsd  %xmm0,%xmm1
ucomisd 0xe83(%rip),%xmm1
jb     11a0 <glmGenerateRandomVector3d+0x60>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    11a9 <glmGenerateRandomVector3d+0x69>
movapd %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @glmGenerateRandomVector3d(double* %0) {
%2 = alloca double*
%3 = alloca double
%4 = alloca double
store double* %0, double** %2
%5 = call double @glmRandomNumberd(double -1.000000e+00, double 1.000000e+00)
%6 = load double*, double** %2
%7 = getelementptr inbounds double, double* %6, i64 2
store double %5, double* %7
%8 = call double @glmRandomNumberd(double 0.000000e+00, double 0x401921FB54442D18)
store double %8, double* %3
%9 = load double*, double** %2
%10 = getelementptr inbounds double, double* %9, i64 2
%11 = load double, double* %10
%12 = load double*, double** %2
%13 = getelementptr inbounds double, double* %12, i64 2
%14 = load double, double* %13
%15 = fneg double %11
%16 = call double @llvm.fmuladd.f64(double %15, double %14, double 1.000000e+00)
%17 = call double @sqrt(double %16)
store double %17, double* %4
%18 = load double, double* %4
%19 = load double, double* %3
%20 = call double @cos(double %19)
%21 = fmul double %18, %20
%22 = load double*, double** %2
%23 = getelementptr inbounds double, double* %22, i64 0
store double %21, double* %23
%24 = load double, double* %4
%25 = load double, double* %3
%26 = call double @sin(double %25)
%27 = fmul double %24, %26
%28 = load double*, double** %2
%29 = getelementptr inbounds double, double* %28, i64 1
store double %27, double* %29
ret void
}

LLVM IR (-O2):
define void @glmGenerateRandomVector3d(double* nocapture %0) {
%2 = tail call double @glmRandomNumberd(double -1.000000e+00, double 1.000000e+00)
%3 = getelementptr inbounds double, double* %0, i64 2
store double %2, double* %3
%4 = tail call double @glmRandomNumberd(double 0.000000e+00, double 0x401921FB54442D18)
%5 = load double, double* %3
%6 = fneg double %5
%7 = tail call double @llvm.fmuladd.f64(double %6, double %5, double 1.000000e+00)
%8 = tail call double @sqrt(double %7)
%9 = tail call double @cos(double %4)
%10 = fmul double %8, %9
store double %10, double* %0
%11 = tail call double @sin(double %4)
%12 = fmul double %8, %11
%13 = getelementptr inbounds double, double* %0, i64 1
store double %12, double* %13
ret void
}