double AstAlg_mean_solar_longitude(double jd) {
  static double last_jd, last_sl;
  static const double coefs[] = {280.4664567,       360007.6982779,
                                 0.03032028,        2.00276381406e-5,
                                 -6.53594771242e-5, -0.50e-6};
  double tau, sl;
  int i;
  if (jd == last_jd)
    return last_sl;
  tau = (jd - (2451545.0)) / 365250.0;
  sl = 0.0;
  for (i = 5; i >= 0; i--) {
    sl = tau * sl + coefs[i];
  }
  sl = ((double)((((long)sl) % ((long)360)) + (sl - (long)sl)));
  if (sl < 0.0)
    sl = sl + 360.0;
  last_jd = jd;
  last_sl = sl;
  return sl;
}


x86 assembly (clang, -O0):
<AstAlg_mean_solar_longitude>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd 0x2f12(%rip),%xmm0
jne    1134 <AstAlg_mean_solar_longitude+0x34>
jp     1134 <AstAlg_mean_solar_longitude+0x34>
movsd  0x2f06(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <AstAlg_mean_solar_longitude+0x11a>
movsd  -0x10(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xeb3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x5,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11a4 <AstAlg_mean_solar_longitude+0xa4>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movslq -0x24(%rbp),%rcx
lea    0xe9c(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1165 <AstAlg_mean_solar_longitude+0x65>
cvttsd2si -0x20(%rbp),%rax
mov    $0x168,%ecx
cqto
idiv   %rcx
cvtsi2sd %rdx,%xmm0
movsd  -0x20(%rbp),%xmm1
cvttsd2si -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm2
subsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f6 <AstAlg_mean_solar_longitude+0xf6>
movsd  0xe24(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,0x2e25(%rip)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,0x2e20(%rip)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<AstAlg_mean_solar_longitude>:
movsd  0x2f20(%rip),%xmm1
ucomisd %xmm0,%xmm1
jne    1119 <AstAlg_mean_solar_longitude+0x19>
jp     1119 <AstAlg_mean_solar_longitude+0x19>
movsd  0x2f18(%rip),%xmm0
ret
movsd  0xedf(%rip),%xmm1
addsd  %xmm0,%xmm1
divsd  0xedb(%rip),%xmm1
xorpd  %xmm3,%xmm3
movapd %xmm1,%xmm2
mulsd  %xmm3,%xmm2
addsd  0xecf(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xecb(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xec7(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xec3(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xebf(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xebb(%rip),%xmm2
cvttsd2si %xmm2,%rcx
movabs $0x2d82d82d82d82d83,%rdx
d8 82 2d
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x6,%rdx
add    %rax,%rdx
imul   $0x168,%rdx,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rcx,%xmm1
sub    %rax,%rcx
cvtsi2sd %rcx,%xmm4
subsd  %xmm1,%xmm2
addsd  %xmm4,%xmm2
movsd  0xe79(%rip),%xmm4
addsd  %xmm2,%xmm4
movapd %xmm2,%xmm1
cmpltsd %xmm3,%xmm1
andpd  %xmm1,%xmm4
andnpd %xmm2,%xmm1
orpd   %xmm4,%xmm1
movsd  %xmm0,0x2e40(%rip)
movlpd %xmm1,0x2e40(%rip)
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
@AstAlg_mean_solar_longitude.last_jd = internal global double 0.000000e+00
@AstAlg_mean_solar_longitude.last_sl = internal global double 0.000000e+00
@AstAlg_mean_solar_longitude.coefs = internal constant [6 x double] [double 0x407187769B4CF800, double 0x4115F91ECB095CA0, double 0x3F9F0C478C05B247, double 0x3EF50020D0331E07, double 0xBF11223344556B5D, double -5.000000e-07]
define double @AstAlg_mean_solar_longitude(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double %0, double* %3
%7 = load double, double* %3
%8 = load double, double* @AstAlg_mean_solar_longitude.last_jd
%9 = fcmp oeq double %7, %8
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load double, double* @AstAlg_mean_solar_longitude.last_sl
store double %11, double* %2
br label %50
12: ; preds = %1
%13 = load double, double* %3
%14 = fsub double %13, 0x4142B42C80000000
%15 = fdiv double %14, 3.652500e+05
store double %15, double* %4
store double 0.000000e+00, double* %5
store i32 5, i32* %6
br label %16
16: ; preds = %27, %12
%17 = load i32, i32* %6
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %16
%20 = load double, double* %4
%21 = load double, double* %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [6 x double], [6 x double]* @AstAlg_mean_solar_longitude.coefs, i64 0, i64 %23
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double %20, double %21, double %25)
store double %26, double* %5
br label %27
27: ; preds = %19
%28 = load i32, i32* %6
%29 = add nsw i32 %28, -1
store i32 %29, i32* %6
br label %16
30: ; preds = %16
%31 = load double, double* %5
%32 = fptosi double %31 to i64
%33 = srem i64 %32, 360
%34 = sitofp i64 %33 to double
%35 = load double, double* %5
%36 = load double, double* %5
%37 = fptosi double %36 to i64
%38 = sitofp i64 %37 to double
%39 = fsub double %35, %38
%40 = fadd double %34, %39
store double %40, double* %5
%41 = load double, double* %5
%42 = fcmp olt double %41, 0.000000e+00
br i1 %42, label %43, label %46
43: ; preds = %30
%44 = load double, double* %5
%45 = fadd double %44, 3.600000e+02
store double %45, double* %5
br label %46
46: ; preds = %43, %30
%47 = load double, double* %3
store double %47, double* @AstAlg_mean_solar_longitude.last_jd
%48 = load double, double* %5
store double %48, double* @AstAlg_mean_solar_longitude.last_sl
%49 = load double, double* %5
store double %49, double* %2
br label %50
50: ; preds = %46, %10
%51 = load double, double* %2
ret double %51
}

LLVM IR (-O2):
@AstAlg_mean_solar_longitude.last_jd = internal unnamed_addr global double 0.000000e+00
@AstAlg_mean_solar_longitude.last_sl = internal unnamed_addr global double 0.000000e+00
define double @AstAlg_mean_solar_longitude(double %0) {
%2 = load double, double* @AstAlg_mean_solar_longitude.last_jd
%3 = fcmp oeq double %2, %0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = load double, double* @AstAlg_mean_solar_longitude.last_sl
br label %24
6: ; preds = %1
%7 = fadd double %0, 0xC142B42C80000000
%8 = fdiv double %7, 3.652500e+05
%9 = tail call double @llvm.fmuladd.f64(double %8, double 0.000000e+00, double -5.000000e-07)
%10 = tail call double @llvm.fmuladd.f64(double %8, double %9, double 0xBF11223344556B5D)
%11 = tail call double @llvm.fmuladd.f64(double %8, double %10, double 0x3EF50020D0331E07)
%12 = tail call double @llvm.fmuladd.f64(double %8, double %11, double 0x3F9F0C478C05B247)
%13 = tail call double @llvm.fmuladd.f64(double %8, double %12, double 0x4115F91ECB095CA0)
%14 = tail call double @llvm.fmuladd.f64(double %8, double %13, double 0x407187769B4CF800)
%15 = fptosi double %14 to i64
%16 = srem i64 %15, 360
%17 = sitofp i64 %16 to double
%18 = sitofp i64 %15 to double
%19 = fsub double %14, %18
%20 = fadd double %19, %17
%21 = fcmp olt double %20, 0.000000e+00
%22 = fadd double %20, 3.600000e+02
%23 = select i1 %21, double %22, double %20
store double %0, double* @AstAlg_mean_solar_longitude.last_jd
store double %23, double* @AstAlg_mean_solar_longitude.last_sl
br label %24
24: ; preds = %6, %4
%25 = phi double [ %5, %4 ], [ %23, %6 ]
ret double %25
}