#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 sin(double);
void vec3Spherical(double rho, double phi, double theta, double v[3]) {
  v[0] = rho * sin(phi) * cos(theta);
  v[1] = rho * sin(phi) * sin(theta);
  v[2] = rho * cos(phi);
}


x86 assembly (clang, -O0):
<vec3Spherical>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x8(%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    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec3Spherical>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @vec3Spherical(double %0, double %1, double %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double*
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%9 = load double, double* %5
%10 = load double, double* %6
%11 = call double @sin(double %10)
%12 = fmul double %9, %11
%13 = load double, double* %7
%14 = call double @cos(double %13)
%15 = fmul double %12, %14
%16 = load double*, double** %8
%17 = getelementptr inbounds double, double* %16, i64 0
store double %15, double* %17
%18 = load double, double* %5
%19 = load double, double* %6
%20 = call double @sin(double %19)
%21 = fmul double %18, %20
%22 = load double, double* %7
%23 = call double @sin(double %22)
%24 = fmul double %21, %23
%25 = load double*, double** %8
%26 = getelementptr inbounds double, double* %25, i64 1
store double %24, double* %26
%27 = load double, double* %5
%28 = load double, double* %6
%29 = call double @cos(double %28)
%30 = fmul double %27, %29
%31 = load double*, double** %8
%32 = getelementptr inbounds double, double* %31, i64 2
store double %30, double* %32
ret void
}

LLVM IR (-O2):
define void @vec3Spherical(double %0, double %1, double %2, double* nocapture writeonly %3) {
%5 = tail call double @sin(double %1)
%6 = fmul double %5, %0
%7 = tail call double @cos(double %2)
%8 = fmul double %6, %7
store double %8, double* %3
%9 = tail call double @sin(double %1)
%10 = fmul double %9, %0
%11 = tail call double @sin(double %2)
%12 = fmul double %10, %11
%13 = getelementptr inbounds double, double* %3, i64 1
store double %12, double* %13
%14 = tail call double @cos(double %1)
%15 = fmul double %14, %0
%16 = getelementptr inbounds double, double* %3, i64 2
store double %15, double* %16
ret void
}