void s2v3(rra, rdec, r, pos) double rra;
double rdec;
double r;
double pos[3];
{
  pos[0] = r * cos(rra) * cos(rdec);
  pos[1] = r * sin(rra) * cos(rdec);
  pos[2] = r * sin(rdec);
  return;
}


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

LLVM IR (-O0):
define void @s2v3(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* %7
%10 = load double, double* %5
%11 = call double @cos(double %10)
%12 = fmul double %9, %11
%13 = load double, double* %6
%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* %7
%19 = load double, double* %5
%20 = call double @sin(double %19)
%21 = fmul double %18, %20
%22 = load double, double* %6
%23 = call double @cos(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* %7
%28 = load double, double* %6
%29 = call double @sin(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 @s2v3(double %0, double %1, double %2, double* nocapture writeonly %3) {
%5 = tail call double @cos(double %0)
%6 = fmul double %5, %2
%7 = tail call double @cos(double %1)
%8 = fmul double %6, %7
store double %8, double* %3
%9 = tail call double @sin(double %0)
%10 = fmul double %9, %2
%11 = tail call double @cos(double %1)
%12 = fmul double %10, %11
%13 = getelementptr inbounds double, double* %3, i64 1
store double %12, double* %13
%14 = tail call double @sin(double %1)
%15 = fmul double %14, %2
%16 = getelementptr inbounds double, double* %3, i64 2
store double %15, double* %16
ret void
}