double AstAlg_mean_lunar_longitude(double jd) {
  static double last_jd, last_llong;
  double tau, llong;
  if (jd == last_jd)
    return last_llong;
  tau = (jd - (2451545.0)) / 36525.0;
  llong = 218.3165 + 481267.8813 * tau;
  llong = ((double)((((long)llong) % ((long)360.0)) + (llong - (long)llong)));
  if (llong < 0)
    llong = llong + 360.0;
  last_jd = jd;
  last_llong = llong;
  return llong;
}


x86 assembly (clang, -O0):
<AstAlg_mean_lunar_longitude>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd 0x2f12(%rip),%xmm0
jne    1134 <AstAlg_mean_lunar_longitude+0x34>
jp     1134 <AstAlg_mean_lunar_longitude+0x34>
movsd  0x2f06(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ee <AstAlg_mean_lunar_longitude+0xee>
movsd  -0x10(%rbp),%xmm0
movsd  0xed7(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xec3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe9d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe99(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
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    11ca <AstAlg_mean_lunar_longitude+0xca>
movsd  0xe60(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,0x2e51(%rip)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,0x2e4c(%rip)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<AstAlg_mean_lunar_longitude>:
movsd  0x2f20(%rip),%xmm1
ucomisd %xmm0,%xmm1
jne    1119 <AstAlg_mean_lunar_longitude+0x19>
jp     1119 <AstAlg_mean_lunar_longitude+0x19>
movsd  0x2f18(%rip),%xmm0
ret
movsd  0xedf(%rip),%xmm2
addsd  %xmm0,%xmm2
divsd  0xedb(%rip),%xmm2
mulsd  0xedb(%rip),%xmm2
addsd  0xedb(%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
xorps  %xmm1,%xmm1
cvtsi2sd %rcx,%xmm1
imul   $0x168,%rdx,%rax
sub    %rax,%rcx
cvtsi2sd %rcx,%xmm3
subsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
movsd  0xe99(%rip),%xmm3
addsd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
movapd %xmm2,%xmm1
cmpltsd %xmm4,%xmm1
andpd  %xmm1,%xmm3
andnpd %xmm2,%xmm1
orpd   %xmm3,%xmm1
movsd  %xmm0,0x2e7c(%rip)
movlpd %xmm1,0x2e7c(%rip)
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
@AstAlg_mean_lunar_longitude.last_jd = internal global double 0.000000e+00
@AstAlg_mean_lunar_longitude.last_llong = internal global double 0.000000e+00
define double @AstAlg_mean_lunar_longitude(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
%6 = load double, double* %3
%7 = load double, double* @AstAlg_mean_lunar_longitude.last_jd
%8 = fcmp oeq double %6, %7
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load double, double* @AstAlg_mean_lunar_longitude.last_llong
store double %10, double* %2
br label %36
11: ; preds = %1
%12 = load double, double* %3
%13 = fsub double %12, 0x4142B42C80000000
%14 = fdiv double %13, 3.652500e+04
store double %14, double* %4
%15 = load double, double* %4
%16 = call double @llvm.fmuladd.f64(double 0x411D5FCF867381D8, double %15, double 0x406B4A20C49BA5E3)
store double %16, double* %5
%17 = load double, double* %5
%18 = fptosi double %17 to i64
%19 = srem i64 %18, 360
%20 = sitofp i64 %19 to double
%21 = load double, double* %5
%22 = load double, double* %5
%23 = fptosi double %22 to i64
%24 = sitofp i64 %23 to double
%25 = fsub double %21, %24
%26 = fadd double %20, %25
store double %26, double* %5
%27 = load double, double* %5
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %32
29: ; preds = %11
%30 = load double, double* %5
%31 = fadd double %30, 3.600000e+02
store double %31, double* %5
br label %32
32: ; preds = %29, %11
%33 = load double, double* %3
store double %33, double* @AstAlg_mean_lunar_longitude.last_jd
%34 = load double, double* %5
store double %34, double* @AstAlg_mean_lunar_longitude.last_llong
%35 = load double, double* %5
store double %35, double* %2
br label %36
36: ; preds = %32, %9
%37 = load double, double* %2
ret double %37
}

LLVM IR (-O2):
@AstAlg_mean_lunar_longitude.last_jd = internal unnamed_addr global double 0.000000e+00
@AstAlg_mean_lunar_longitude.last_llong = internal unnamed_addr global double 0.000000e+00
define double @AstAlg_mean_lunar_longitude(double %0) {
%2 = load double, double* @AstAlg_mean_lunar_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_lunar_longitude.last_llong
br label %19
6: ; preds = %1
%7 = fadd double %0, 0xC142B42C80000000
%8 = fdiv double %7, 3.652500e+04
%9 = tail call double @llvm.fmuladd.f64(double %8, double 0x411D5FCF867381D8, double 0x406B4A20C49BA5E3)
%10 = fptosi double %9 to i64
%11 = srem i64 %10, 360
%12 = sitofp i64 %11 to double
%13 = sitofp i64 %10 to double
%14 = fsub double %9, %13
%15 = fadd double %14, %12
%16 = fcmp olt double %15, 0.000000e+00
%17 = fadd double %15, 3.600000e+02
%18 = select i1 %16, double %17, double %15
store double %0, double* @AstAlg_mean_lunar_longitude.last_jd
store double %18, double* @AstAlg_mean_lunar_longitude.last_llong
br label %19
19: ; preds = %6, %4
%20 = phi double [ %5, %4 ], [ %18, %6 ]
ret double %20
}