void sun_RA_dec(double d, double *RA, double *dec, double *r) {
  double lon, obl_ecl;
  double xs, ys, zs;
  double xe, ye, ze;
  sunpos(d, &lon, r);
  xs = *r * cos((lon) * (3.1415926535897932384 / 180.0));
  ys = *r * sin((lon) * (3.1415926535897932384 / 180.0));
  zs = 0;
  obl_ecl = 23.4393 - 3.563E-7 * d;
  xe = xs;
  ye = ys * cos((obl_ecl) * (3.1415926535897932384 / 180.0));
  ze = ys * sin((obl_ecl) * (3.1415926535897932384 / 180.0));
  *RA = ((180.0 / 3.1415926535897932384) * atan2(ye, xe));
  *dec = ((180.0 / 3.1415926535897932384) * atan2(ze, sqrt(xe * xe + ye * ye)));
}


x86 assembly (clang, -O0):
<sun_RA_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x1,%al
call   1070 <sunpos@plt>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xe70(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xe3d(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe15(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe11(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xddc(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xdaf(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
call   1030 <atan2@plt>
movaps %xmm0,%xmm1
movsd  0xd72(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
call   1030 <atan2@plt>
movaps %xmm0,%xmm1
movsd  0xd23(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sun_RA_dec>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
movsd  %xmm0,0x8(%rsp)
lea    0x28(%rsp),%rdi
mov    %rdx,%rsi
mov    $0x1,%al
call   1070 <sunpos@plt>
movsd  (%rbx),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  0xe71(%rip),%xmm0
call   1050 <cos@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%rbx),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  0xe48(%rip),%xmm0
call   1040 <sin@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  0xe39(%rip),%xmm0
mulsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
addsd  0xe2d(%rip),%xmm0
mulsd  0xe15(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1030 <atan2@plt>
mulsd  0xde6(%rip),%xmm0
movsd  %xmm0,(%r15)
movsd  0x20(%rsp),%xmm0
mulsd  %xmm0,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jb     1266 <sun_RA_dec+0x116>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    126f <sun_RA_dec+0x11f>
call   1060 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <atan2@plt>
mulsd  0xd96(%rip),%xmm0
movsd  %xmm0,(%r14)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @sun_RA_dec(double %0, double* %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%17 = load double, double* %5
%18 = load double*, double** %8
%19 = call i32 (double, double*, double*, ...) bitcast (i32 (...)* @sunpos to i32 (double, double*, double*, ...)*)(double %17, double* %9, double* %18)
%20 = load double*, double** %8
%21 = load double, double* %20
%22 = load double, double* %9
%23 = fmul double %22, 0x3F91DF46A2529D39
%24 = call double @cos(double %23)
%25 = fmul double %21, %24
store double %25, double* %11
%26 = load double*, double** %8
%27 = load double, double* %26
%28 = load double, double* %9
%29 = fmul double %28, 0x3F91DF46A2529D39
%30 = call double @sin(double %29)
%31 = fmul double %27, %30
store double %31, double* %12
store double 0.000000e+00, double* %13
%32 = load double, double* %5
%33 = call double @llvm.fmuladd.f64(double -3.563000e-07, double %32, double 2.343930e+01)
store double %33, double* %10
%34 = load double, double* %11
store double %34, double* %14
%35 = load double, double* %12
%36 = load double, double* %10
%37 = fmul double %36, 0x3F91DF46A2529D39
%38 = call double @cos(double %37)
%39 = fmul double %35, %38
store double %39, double* %15
%40 = load double, double* %12
%41 = load double, double* %10
%42 = fmul double %41, 0x3F91DF46A2529D39
%43 = call double @sin(double %42)
%44 = fmul double %40, %43
store double %44, double* %16
%45 = load double, double* %15
%46 = load double, double* %14
%47 = call double @atan2(double %45, double %46)
%48 = fmul double 0x404CA5DC1A63C1F8, %47
%49 = load double*, double** %6
store double %48, double* %49
%50 = load double, double* %16
%51 = load double, double* %14
%52 = load double, double* %14
%53 = load double, double* %15
%54 = load double, double* %15
%55 = fmul double %53, %54
%56 = call double @llvm.fmuladd.f64(double %51, double %52, double %55)
%57 = call double @sqrt(double %56)
%58 = call double @atan2(double %50, double %57)
%59 = fmul double 0x404CA5DC1A63C1F8, %58
%60 = load double*, double** %7
store double %59, double* %60
ret void
}

LLVM IR (-O2):
define void @sun_RA_dec(double %0, double* nocapture writeonly %1, double* nocapture writeonly %2, double* %3) {
%5 = alloca double
%6 = bitcast double* %5 to i8*
%7 = call i32 (double, double*, double*, ...) bitcast (i32 (...)* @sunpos to i32 (double, double*, double*, ...)*)(double %0, double* %5, double* %3)
%8 = load double, double* %3
%9 = load double, double* %5
%10 = fmul double %9, 0x3F91DF46A2529D39
%11 = call double @cos(double %10)
%12 = fmul double %8, %11
%13 = load double, double* %3
%14 = load double, double* %5
%15 = fmul double %14, 0x3F91DF46A2529D39
%16 = call double @sin(double %15)
%17 = fmul double %13, %16
%18 = call double @llvm.fmuladd.f64(double %0, double -3.563000e-07, double 2.343930e+01)
%19 = fmul double %18, 0x3F91DF46A2529D39
%20 = call double @cos(double %19)
%21 = fmul double %17, %20
%22 = call double @sin(double %19)
%23 = fmul double %17, %22
%24 = call double @atan2(double %21, double %12)
%25 = fmul double %24, 0x404CA5DC1A63C1F8
store double %25, double* %1
%26 = fmul double %21, %21
%27 = call double @llvm.fmuladd.f64(double %12, double %12, double %26)
%28 = call double @sqrt(double %27)
%29 = call double @atan2(double %23, double %28)
%30 = fmul double %29, 0x404CA5DC1A63C1F8
store double %30, double* %2
ret void
}