#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_obliquity(double);
double AstAlg_mean_solar_longitude(double);
int /*<<< orphan*/ AstAlg_nutation_corr(double, double *, double *);
double AstAlg_solar_right_ascension(double);
double M_PI;
double cos(double);
double AstAlg_equation_of_time(double jd) {
  static double last_jd, last_eqt;
  double eqt;
  double dpsi, deps, sml, sra, obliq;
  if (jd == last_jd)
    return last_eqt;
  sml = AstAlg_mean_solar_longitude(jd);
  sra = AstAlg_solar_right_ascension(jd);
  obliq = AstAlg_mean_obliquity(jd);
  AstAlg_nutation_corr(jd, &dpsi, &deps);
  eqt = sml - 0.0057183 - sra + dpsi * cos((M_PI / 180.0) * (obliq + deps));
  eqt = ((double)((((long)eqt) % ((long)360.0)) + (eqt - (long)eqt)));
  eqt = 4.0 * eqt;
  if (eqt > 20.0)
    eqt = eqt - 24.0 * 60.0;
  if (eqt < -20.0)
    eqt = 24.0 * 60.0 + eqt;
  last_jd = jd;
  last_eqt = eqt;
  return eqt;
}


x86 assembly (clang, -O0):
<AstAlg_equation_of_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd 0x2ee6(%rip),%xmm0
jne    1188 <AstAlg_equation_of_time+0x38>
jp     1188 <AstAlg_equation_of_time+0x38>
movsd  0x2eda(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12ea <AstAlg_equation_of_time+0x19a>
movsd  -0x10(%rbp),%xmm0
call   1030 <AstAlg_mean_solar_longitude@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <AstAlg_solar_right_ascension@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <AstAlg_mean_obliquity@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <AstAlg_nutation_corr@plt>
movsd  -0x30(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
subsd  %xmm1,%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    0x2df5(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe11(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1070 <cos@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%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)
movsd  0xd9e(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xd7f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12a1 <AstAlg_equation_of_time+0x151>
movsd  -0x18(%rbp),%xmm0
movsd  0xd88(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd7f(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    12c6 <AstAlg_equation_of_time+0x176>
movsd  0xd64(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,0x2d7d(%rip)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,0x2d78(%rip)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AstAlg_equation_of_time>:
sub    $0x38,%rsp
movsd  0x2ef4(%rip),%xmm1
ucomisd %xmm0,%xmm1
jne    1171 <AstAlg_equation_of_time+0x21>
jp     1171 <AstAlg_equation_of_time+0x21>
movsd  0x2eec(%rip),%xmm0
add    $0x38,%rsp
ret
movsd  %xmm0,0x8(%rsp)
call   1030 <AstAlg_mean_solar_longitude@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <AstAlg_solar_right_ascension@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <AstAlg_mean_obliquity@plt>
movsd  %xmm0,0x20(%rsp)
lea    0x30(%rsp),%rdi
lea    0x28(%rsp),%rsi
movsd  0x8(%rsp),%xmm0
call   1040 <AstAlg_nutation_corr@plt>
movsd  0x18(%rsp),%xmm0
addsd  0xe39(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    0x2e0e(%rip),%rax
movsd  (%rax),%xmm0
divsd  0xe22(%rip),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x20(%rsp),%xmm1
addsd  0x28(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1070 <cos@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%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
cvtsi2sd %rcx,%xmm2
subsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  0xdaf(%rip),%xmm0
movsd  0xdaf(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xdab(%rip),%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
movsd  0xd9a(%rip),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm2,%xmm0
cmpltsd 0xd91(%rip),%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x2d97(%rip)
movlpd %xmm0,0x2d97(%rip)
add    $0x38,%rsp
ret

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

LLVM IR (-O2):
@AstAlg_equation_of_time.last_jd = internal unnamed_addr global double 0.000000e+00
@AstAlg_equation_of_time.last_eqt = internal unnamed_addr global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @AstAlg_equation_of_time(double %0) {
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %2 to i8*
%5 = bitcast double* %3 to i8*
%6 = load double, double* @AstAlg_equation_of_time.last_jd
%7 = fcmp oeq double %6, %0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load double, double* @AstAlg_equation_of_time.last_eqt
br label %38
10: ; preds = %1
%11 = tail call double @AstAlg_mean_solar_longitude(double %0)
%12 = tail call double @AstAlg_solar_right_ascension(double %0)
%13 = tail call double @AstAlg_mean_obliquity(double %0)
%14 = call i32 @AstAlg_nutation_corr(double %0, double* %2, double* %3)
%15 = fadd double %11, -5.718300e-03
%16 = fsub double %15, %12
%17 = load double, double* %2
%18 = load double, double* @M_PI
%19 = fdiv double %18, 1.800000e+02
%20 = load double, double* %3
%21 = fadd double %13, %20
%22 = fmul double %19, %21
%23 = call double @cos(double %22)
%24 = call double @llvm.fmuladd.f64(double %17, double %23, double %16)
%25 = fptosi double %24 to i64
%26 = srem i64 %25, 360
%27 = sitofp i64 %26 to double
%28 = sitofp i64 %25 to double
%29 = fsub double %24, %28
%30 = fadd double %29, %27
%31 = fmul double %30, 4.000000e+00
%32 = fcmp ogt double %31, 2.000000e+01
%33 = fadd double %31, -1.440000e+03
%34 = select i1 %32, double %33, double %31
%35 = fcmp olt double %34, -2.000000e+01
%36 = fadd double %34, 1.440000e+03
%37 = select i1 %35, double %36, double %34
store double %0, double* @AstAlg_equation_of_time.last_jd
store double %37, double* @AstAlg_equation_of_time.last_eqt
br label %38
38: ; preds = %10, %8
%39 = phi double [ %9, %8 ], [ %37, %10 ]
ret double %39
}