#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double AstAlg_mean_solar_anomaly(double);
double AstAlg_mean_solar_longitude(double);
double M_PI;
double sin(double);
double AstAlg_geometric_solar_longitude(double jd) {
  static double last_jd, last_gsl;
  double sml, sma, tau, gc;
  if (last_jd == jd)
    return last_gsl;
  tau = (jd - (2451545.0)) / 36525.0;
  sml = AstAlg_mean_solar_longitude(jd);
  sma = (M_PI / 180.0) * AstAlg_mean_solar_anomaly(jd);
  gc = (1.914602 - 0.004817 * tau - 0.000014 * (tau * tau)) * sin(sma) +
       (0.019993 - 0.000101 * tau) * sin(2.0 * sma) + 0.000289 * sin(3.0 * sma);
  sml = sml + gc;
  sml = ((double)((((long)sml) % ((long)360.0)) + (sml - (long)sml)));
  if (sml < 0.0)
    sml = sml + 360.0;
  last_jd = jd;
  last_gsl = sml;
  return sml;
}


x86 assembly (clang, -O0):
<AstAlg_geometric_solar_longitude>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0x2efb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    1168 <AstAlg_geometric_solar_longitude+0x38>
jp     1168 <AstAlg_geometric_solar_longitude+0x38>
movsd  0x2eea(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1323 <AstAlg_geometric_solar_longitude+0x1f3>
movsd  -0x10(%rbp),%xmm0
movsd  0xedb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xec7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <AstAlg_mean_solar_longitude@plt>
movsd  %xmm0,-0x18(%rbp)
mov    0x2e48(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe94(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <AstAlg_mean_solar_anomaly@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0xe53(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe4f(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xe29(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xdf0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdec(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdcb(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd8e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x38(%rbp),%xmm1
movsd  0xd6f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%rax
mov    $0x168,%ecx
cqto
idiv   %rcx
cvtsi2sd %rdx,%xmm0
movsd  -0x18(%rbp),%xmm1
cvttsd2si -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm2
subsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    12ff <AstAlg_geometric_solar_longitude+0x1cf>
movsd  0xd63(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,0x2d34(%rip)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,0x2d2f(%rip)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AstAlg_geometric_solar_longitude>:
sub    $0x38,%rsp
movsd  0x2f04(%rip),%xmm1
ucomisd %xmm0,%xmm1
jne    1151 <AstAlg_geometric_solar_longitude+0x21>
jp     1151 <AstAlg_geometric_solar_longitude+0x21>
movsd  0x2efc(%rip),%xmm1
jmp    12d9 <AstAlg_geometric_solar_longitude+0x1a9>
movsd  0xea7(%rip),%xmm1
addsd  %xmm0,%xmm1
divsd  0xea3(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x20(%rsp)
call   1040 <AstAlg_mean_solar_longitude@plt>
movsd  %xmm0,0x30(%rsp)
mov    0x2e65(%rip),%rax
movsd  (%rax),%xmm0
divsd  0xe81(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <AstAlg_mean_solar_anomaly@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0xe64(%rip),%xmm2
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm2
addsd  0xe5a(%rip),%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
mulsd  0xe52(%rip),%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,0x28(%rsp)
call   1050 <sin@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0xe3d(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
addsd  0xe37(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1050 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe00(%rip),%xmm0
call   1050 <sin@plt>
mulsd  0xdfb(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
cvttsd2si %xmm0,%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
xorps  %xmm2,%xmm2
cvtsi2sd %rcx,%xmm2
subsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
movsd  0xdaa(%rip),%xmm2
addsd  %xmm0,%xmm2
xorpd  %xmm3,%xmm3
movapd %xmm0,%xmm1
cmpltsd %xmm3,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x2d6f(%rip)
movlpd %xmm1,0x2d6f(%rip)
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@AstAlg_geometric_solar_longitude.last_jd = internal global double 0.000000e+00
@AstAlg_geometric_solar_longitude.last_gsl = internal global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @AstAlg_geometric_solar_longitude(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
%8 = load double, double* @AstAlg_geometric_solar_longitude.last_jd
%9 = load double, double* %3
%10 = fcmp oeq double %8, %9
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load double, double* @AstAlg_geometric_solar_longitude.last_gsl
store double %12, double* %2
br label %65
13: ; preds = %1
%14 = load double, double* %3
%15 = fsub double %14, 0x4142B42C80000000
%16 = fdiv double %15, 3.652500e+04
store double %16, double* %6
%17 = load double, double* %3
%18 = call double @AstAlg_mean_solar_longitude(double %17)
store double %18, double* %4
%19 = load double, double* @M_PI
%20 = fdiv double %19, 1.800000e+02
%21 = load double, double* %3
%22 = call double @AstAlg_mean_solar_anomaly(double %21)
%23 = fmul double %20, %22
store double %23, double* %5
%24 = load double, double* %6
%25 = call double @llvm.fmuladd.f64(double -4.817000e-03, double %24, double 0x3FFEA235B4EDB2F6)
%26 = load double, double* %6
%27 = load double, double* %6
%28 = fmul double %26, %27
%29 = call double @llvm.fmuladd.f64(double -1.400000e-05, double %28, double %25)
%30 = load double, double* %5
%31 = call double @sin(double %30)
%32 = load double, double* %6
%33 = call double @llvm.fmuladd.f64(double -1.010000e-04, double %32, double 1.999300e-02)
%34 = load double, double* %5
%35 = fmul double 2.000000e+00, %34
%36 = call double @sin(double %35)
%37 = fmul double %33, %36
%38 = call double @llvm.fmuladd.f64(double %29, double %31, double %37)
%39 = load double, double* %5
%40 = fmul double 3.000000e+00, %39
%41 = call double @sin(double %40)
%42 = call double @llvm.fmuladd.f64(double 2.890000e-04, double %41, double %38)
store double %42, double* %7
%43 = load double, double* %4
%44 = load double, double* %7
%45 = fadd double %43, %44
store double %45, double* %4
%46 = load double, double* %4
%47 = fptosi double %46 to i64
%48 = srem i64 %47, 360
%49 = sitofp i64 %48 to double
%50 = load double, double* %4
%51 = load double, double* %4
%52 = fptosi double %51 to i64
%53 = sitofp i64 %52 to double
%54 = fsub double %50, %53
%55 = fadd double %49, %54
store double %55, double* %4
%56 = load double, double* %4
%57 = fcmp olt double %56, 0.000000e+00
br i1 %57, label %58, label %61
58: ; preds = %13
%59 = load double, double* %4
%60 = fadd double %59, 3.600000e+02
store double %60, double* %4
br label %61
61: ; preds = %58, %13
%62 = load double, double* %3
store double %62, double* @AstAlg_geometric_solar_longitude.last_jd
%63 = load double, double* %4
store double %63, double* @AstAlg_geometric_solar_longitude.last_gsl
%64 = load double, double* %4
store double %64, double* %2
br label %65
65: ; preds = %61, %11
%66 = load double, double* %2
ret double %66
}

LLVM IR (-O2):
@AstAlg_geometric_solar_longitude.last_jd = internal unnamed_addr global double 0.000000e+00
@AstAlg_geometric_solar_longitude.last_gsl = internal unnamed_addr global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @AstAlg_geometric_solar_longitude(double %0) {
%2 = load double, double* @AstAlg_geometric_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_geometric_solar_longitude.last_gsl
br label %36
6: ; preds = %1
%7 = fadd double %0, 0xC142B42C80000000
%8 = fdiv double %7, 3.652500e+04
%9 = tail call double @AstAlg_mean_solar_longitude(double %0)
%10 = load double, double* @M_PI
%11 = fdiv double %10, 1.800000e+02
%12 = tail call double @AstAlg_mean_solar_anomaly(double %0)
%13 = fmul double %11, %12
%14 = tail call double @llvm.fmuladd.f64(double %8, double -4.817000e-03, double 0x3FFEA235B4EDB2F6)
%15 = fmul double %8, %8
%16 = tail call double @llvm.fmuladd.f64(double %15, double -1.400000e-05, double %14)
%17 = tail call double @sin(double %13)
%18 = tail call double @llvm.fmuladd.f64(double %8, double -1.010000e-04, double 1.999300e-02)
%19 = fmul double %13, 2.000000e+00
%20 = tail call double @sin(double %19)
%21 = fmul double %18, %20
%22 = tail call double @llvm.fmuladd.f64(double %16, double %17, double %21)
%23 = fmul double %13, 3.000000e+00
%24 = tail call double @sin(double %23)
%25 = tail call double @llvm.fmuladd.f64(double %24, double 2.890000e-04, double %22)
%26 = fadd double %9, %25
%27 = fptosi double %26 to i64
%28 = srem i64 %27, 360
%29 = sitofp i64 %28 to double
%30 = sitofp i64 %27 to double
%31 = fsub double %26, %30
%32 = fadd double %31, %29
%33 = fcmp olt double %32, 0.000000e+00
%34 = fadd double %32, 3.600000e+02
%35 = select i1 %33, double %34, double %32
store double %0, double* @AstAlg_geometric_solar_longitude.last_jd
store double %35, double* @AstAlg_geometric_solar_longitude.last_gsl
br label %36
36: ; preds = %6, %4
%37 = phi double [ %5, %4 ], [ %35, %6 ]
ret double %37
}