void astro_sunpos(double jd, double *lon, double *r) {
  double d = ((jd)-2451544.0);
  double M;
  double w;
  double e;
  double E;
  double x, y;
  double v;
  M = astro_range(356.0470 + 0.9856002585 * d, 360.0);
  w = 282.9404 + 4.70935E-5 * d;
  e = 0.016709 - 1.151E-9 * d;
  E = M + e * (180.0 / 3.1415926535897932384) *
              sin((M) * (3.1415926535897932384 / 180.0)) *
              (1.0 + e * cos((M) * (3.1415926535897932384 / 180.0)));
  x = cos((E) * (3.1415926535897932384 / 180.0)) - e;
  y = sqrt(1.0 - e * e) * sin((E) * (3.1415926535897932384 / 180.0));
  *r = sqrt(x * x + y * y);
  v = ((180.0 / 3.1415926535897932384) * atan2(y, x));
  *lon = astro_range(v + w, 360.0);
}


x86 assembly (clang, -O0):
<astro_sunpos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xedb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb1(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe5d(%rip),%xmm1
mov    $0x2,%al
call   1040 <astro_range@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe70(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe6c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe3a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xdff(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xdf5(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xdc8(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x78(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm3,%xmm2
movsd  0xda8(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd87(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
call   1060 <cos@plt>
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd4e(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  0xd30(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
call   1030 <atan2@plt>
movaps %xmm0,%xmm1
movsd  0xcca(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xca7(%rip),%xmm1
mov    $0x2,%al
call   1040 <astro_range@plt>
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<astro_sunpos>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movapd %xmm0,%xmm1
addsd  0xe97(%rip),%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe92(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xe8e(%rip),%xmm0
movsd  0xe8e(%rip),%xmm1
mov    $0x2,%al
call   1040 <astro_range@plt>
cvtsi2sd %eax,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0xe7d(%rip),%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
mulsd  0xe76(%rip),%xmm1
addsd  0xe76(%rip),%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe71(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm2,%xmm0
mulsd  0xe63(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1050 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
addsd  0xe3c(%rip),%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
mulsd  0xe20(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1060 <cos@plt>
movsd  (%rsp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mulsd  %xmm1,%xmm1
movsd  0xe02(%rip),%xmm2
subsd  %xmm1,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
movapd %xmm2,%xmm0
jb     1266 <astro_sunpos+0x116>
sqrtsd %xmm0,%xmm0
jmp    126b <astro_sunpos+0x11b>
call   1070 <sqrt@plt>
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
addsd  0xdaa(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movapd %xmm0,%xmm2
mulsd  (%rsp),%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd 0xda2(%rip),%xmm0
jb     12be <astro_sunpos+0x16e>
sqrtsd %xmm0,%xmm0
jmp    12cd <astro_sunpos+0x17d>
movsd  %xmm2,(%rsp)
call   1070 <sqrt@plt>
movsd  (%rsp),%xmm2
movsd  %xmm0,(%rbx)
movapd %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <atan2@plt>
mulsd  0xd58(%rip),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  0xd22(%rip),%xmm1
mov    $0x2,%al
call   1040 <astro_range@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @astro_sunpos(double %0, double* %1, double* %2) {
%4 = alloca double
%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
store double %0, double* %4
store double* %1, double** %5
store double* %2, double** %6
%15 = load double, double* %4
%16 = fsub double %15, 0x4142B42C00000000
store double %16, double* %7
%17 = load double, double* %7
%18 = call double @llvm.fmuladd.f64(double 0x3FEF8A098DA5F901, double %17, double 3.560470e+02)
%19 = call i32 (double, double, ...) bitcast (i32 (...)* @astro_range to i32 (double, double, ...)*)(double %18, double 3.600000e+02)
%20 = sitofp i32 %19 to double
store double %20, double* %8
%21 = load double, double* %7
%22 = call double @llvm.fmuladd.f64(double 4.709350e-05, double %21, double 0x4071AF0BE0DED289)
store double %22, double* %9
%23 = load double, double* %7
%24 = call double @llvm.fmuladd.f64(double -1.151000e-09, double %23, double 1.670900e-02)
store double %24, double* %10
%25 = load double, double* %8
%26 = load double, double* %10
%27 = fmul double %26, 0x404CA5DC1A63C1F8
%28 = load double, double* %8
%29 = fmul double %28, 0x3F91DF46A2529D39
%30 = call double @sin(double %29)
%31 = fmul double %27, %30
%32 = load double, double* %10
%33 = load double, double* %8
%34 = fmul double %33, 0x3F91DF46A2529D39
%35 = call double @cos(double %34)
%36 = call double @llvm.fmuladd.f64(double %32, double %35, double 1.000000e+00)
%37 = call double @llvm.fmuladd.f64(double %31, double %36, double %25)
store double %37, double* %11
%38 = load double, double* %11
%39 = fmul double %38, 0x3F91DF46A2529D39
%40 = call double @cos(double %39)
%41 = load double, double* %10
%42 = fsub double %40, %41
store double %42, double* %12
%43 = load double, double* %10
%44 = load double, double* %10
%45 = fneg double %43
%46 = call double @llvm.fmuladd.f64(double %45, double %44, double 1.000000e+00)
%47 = call double @sqrt(double %46)
%48 = load double, double* %11
%49 = fmul double %48, 0x3F91DF46A2529D39
%50 = call double @sin(double %49)
%51 = fmul double %47, %50
store double %51, double* %13
%52 = load double, double* %12
%53 = load double, double* %12
%54 = load double, double* %13
%55 = load double, double* %13
%56 = fmul double %54, %55
%57 = call double @llvm.fmuladd.f64(double %52, double %53, double %56)
%58 = call double @sqrt(double %57)
%59 = load double*, double** %6
store double %58, double* %59
%60 = load double, double* %13
%61 = load double, double* %12
%62 = call double @atan2(double %60, double %61)
%63 = fmul double 0x404CA5DC1A63C1F8, %62
store double %63, double* %14
%64 = load double, double* %14
%65 = load double, double* %9
%66 = fadd double %64, %65
%67 = call i32 (double, double, ...) bitcast (i32 (...)* @astro_range to i32 (double, double, ...)*)(double %66, double 3.600000e+02)
%68 = sitofp i32 %67 to double
%69 = load double*, double** %5
store double %68, double* %69
ret void
}

LLVM IR (-O2):
define void @astro_sunpos(double %0, double* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = fadd double %0, 0xC142B42C00000000
%5 = tail call double @llvm.fmuladd.f64(double %4, double 0x3FEF8A098DA5F901, double 3.560470e+02)
%6 = tail call i32 (double, double, ...) bitcast (i32 (...)* @astro_range to i32 (double, double, ...)*)(double %5, double 3.600000e+02)
%7 = sitofp i32 %6 to double
%8 = tail call double @llvm.fmuladd.f64(double %4, double 4.709350e-05, double 0x4071AF0BE0DED289)
%9 = tail call double @llvm.fmuladd.f64(double %4, double -1.151000e-09, double 1.670900e-02)
%10 = fmul double %9, 0x404CA5DC1A63C1F8
%11 = fmul double %7, 0x3F91DF46A2529D39
%12 = tail call double @sin(double %11)
%13 = fmul double %10, %12
%14 = tail call double @cos(double %11)
%15 = tail call double @llvm.fmuladd.f64(double %9, double %14, double 1.000000e+00)
%16 = tail call double @llvm.fmuladd.f64(double %13, double %15, double %7)
%17 = fmul double %16, 0x3F91DF46A2529D39
%18 = tail call double @cos(double %17)
%19 = fsub double %18, %9
%20 = fneg double %9
%21 = tail call double @llvm.fmuladd.f64(double %20, double %9, double 1.000000e+00)
%22 = tail call double @sqrt(double %21)
%23 = tail call double @sin(double %17)
%24 = fmul double %22, %23
%25 = fmul double %24, %24
%26 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %25)
%27 = tail call double @sqrt(double %26)
store double %27, double* %2
%28 = tail call double @atan2(double %24, double %19)
%29 = fmul double %28, 0x404CA5DC1A63C1F8
%30 = fadd double %8, %29
%31 = tail call i32 (double, double, ...) bitcast (i32 (...)* @astro_range to i32 (double, double, ...)*)(double %30, double 3.600000e+02)
%32 = sitofp i32 %31 to double
store double %32, double* %1
ret void
}