// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: eot(double)
double eot(double jd)
{
double t;
double lon_ofs;
double m;
double e;

   // calculate the equation of time
   // adapted from code by Mike Chirico and NOAA

   t = jd;
///t += jtime(3,12,30, 0.0);       // !!!!! fudge factor to get closer to SPA results
   t += jtime(2,36,00, 0.0);       // !!!!! fudge factor to get closer to SPA results
   t = (t - JD2000) / 36525.0;

   double epsilon = calcObliquityCorrection(t);               
   double l0 = 280.46646 + t * (36000.76983 + 0.0003032 * t);
   while(l0 > 360.0) l0 -= 360.0;
   while(l0 < 0.0) l0 += 360.0;
   e = orbit_eccentricity(jd);
   m = (357.52772 + (35999.05034*t) - (0.0001603*t*t) - (t*t*t / 300000.0));

   double y = tan((epsilon*PI/180.0)/2.0);
   y *= y;

   double sinm   = sin(m * PI/180.0);
   double sin2m  = sin(2.0 * m*PI/180.0);
   double sin2l0 = sin(2.0 * l0*PI/180.0);
   double cos2l0 = cos(2.0 * l0*PI/180.0);
   double sin4l0 = sin(4.0 * l0*PI/180.0);
   eot_ofs = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0
           - 0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m;

   eot_ofs = (eot_ofs * 180.0 / PI) * 4.0;
///eot_ofs -= 0.008343;  // more fudge factor to match SPA results
   lon_ofs = (-lon*RAD_TO_DEG*4.0); // + (time_zone()*60.0);

   return (eot_ofs - lon_ofs);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movsd 0x49f7d(%rip), %xmm1    # 0x12baa8
movsd %xmm0, -0x8(%rbp)
addsd %xmm0, %xmm1
addsd 0x49cf4(%rip), %xmm1    # 0x12b830
divsd 0x49cf4(%rip), %xmm1    # 0x12b838
movsd %xmm1, -0x18(%rbp)
movsd 0x49f3f(%rip), %xmm0    # 0x12ba90
mulsd %xmm1, %xmm0
addsd 0x49f3b(%rip), %xmm0    # 0x12ba98
mulsd 0x29cc3(%rip), %xmm0    # 0x10b828
divsd 0x29cc3(%rip), %xmm0    # 0x10b830
callq 0x9710
movsd -0x18(%rbp), %xmm4
movsd 0x49f31(%rip), %xmm3    # 0x12bab0
mulsd %xmm4, %xmm3
addsd 0x49f2d(%rip), %xmm3    # 0x12bab8
mulsd %xmm4, %xmm3
addsd 0x49f29(%rip), %xmm3    # 0x12bac0
ucomisd 0x3c599(%rip), %xmm3    # 0x11e138
jbe 0xe1bbb
movsd 0x49f1f(%rip), %xmm1    # 0x12bac8
movsd 0x3c587(%rip), %xmm2    # 0x11e138
addsd %xmm1, %xmm3
ucomisd %xmm2, %xmm3
ja 0xe1bb1
xorpd %xmm1, %xmm1
ucomisd %xmm3, %xmm1
jbe 0xe1bd7
movsd 0x3c56b(%rip), %xmm2    # 0x11e138
addsd %xmm2, %xmm3
ucomisd %xmm3, %xmm1
ja 0xe1bcd
movsd %xmm3, -0x20(%rbp)
movsd 0x49e84(%rip), %xmm1    # 0x12ba68
mulsd %xmm4, %xmm1
addsd 0x49e80(%rip), %xmm1    # 0x12ba70
mulsd %xmm4, %xmm1
addsd 0x49e7c(%rip), %xmm1    # 0x12ba78
mulsd %xmm4, %xmm1
movsd 0x49e78(%rip), %xmm2    # 0x12ba80
subsd %xmm1, %xmm2
movsd 0x273f4(%rip), %xmm1    # 0x109008
divsd %xmm1, %xmm2
addsd 0x49d40(%rip), %xmm2    # 0x12b960
divsd %xmm1, %xmm2
addsd 0x49e5c(%rip), %xmm2    # 0x12ba88
mulsd 0x49e6c(%rip), %xmm0    # 0x12baa0
addsd %xmm2, %xmm0
movsd -0x8(%rbp), %xmm5
addsd 0x49beb(%rip), %xmm5    # 0x12b830
divsd 0x49dbb(%rip), %xmm5    # 0x12ba08
movsd 0x49dbb(%rip), %xmm1    # 0x12ba10
mulsd %xmm5, %xmm1
addsd 0x49db7(%rip), %xmm1    # 0x12ba18
movsd 0x49db7(%rip), %xmm2    # 0x12ba20
mulsd %xmm5, %xmm2
mulsd %xmm5, %xmm2
addsd %xmm1, %xmm2
movsd 0x49dab(%rip), %xmm1    # 0x12ba28
mulsd %xmm5, %xmm1
mulsd %xmm5, %xmm1
mulsd %xmm5, %xmm1
addsd %xmm2, %xmm1
movsd 0x49d9b(%rip), %xmm2    # 0x12ba30
mulsd %xmm5, %xmm2
mulsd %xmm5, %xmm2
mulsd %xmm5, %xmm2
mulsd %xmm5, %xmm2
addsd %xmm1, %xmm2
movsd 0x49d87(%rip), %xmm1    # 0x12ba38
mulsd %xmm5, %xmm1
mulsd %xmm5, %xmm1
mulsd %xmm5, %xmm1
mulsd %xmm5, %xmm1
mulsd %xmm5, %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, -0x38(%rbp)
movsd 0x49b6a(%rip), %xmm1    # 0x12b840
mulsd %xmm4, %xmm1
movsd 0x49b6e(%rip), %xmm2    # 0x12b850
mulsd %xmm4, %xmm2
mulsd %xmm4, %xmm2
movapd %xmm4, %xmm3
mulsd %xmm4, %xmm3
mulsd %xmm4, %xmm3
addsd 0x49b4a(%rip), %xmm1    # 0x12b848
divsd 0x49b52(%rip), %xmm3    # 0x12b858
addsd %xmm1, %xmm2
addsd %xmm2, %xmm3
movsd %xmm3, -0x8(%rbp)
mulsd 0x29b0d(%rip), %xmm0    # 0x10b828
divsd 0x29b0d(%rip), %xmm0    # 0x10b830
mulsd 0x2733d(%rip), %xmm0    # 0x109068
callq 0x91b0
mulsd %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x8(%rbp), %xmm0
mulsd 0x29ae2(%rip), %xmm0    # 0x10b828
divsd 0x29ae2(%rip), %xmm0    # 0x10b830
callq 0x9080
movsd %xmm0, -0x30(%rbp)
movsd -0x8(%rbp), %xmm0
addsd %xmm0, %xmm0
mulsd 0x29abf(%rip), %xmm0    # 0x10b828
divsd 0x29abf(%rip), %xmm0    # 0x10b830
callq 0x9080
movsd %xmm0, -0x8(%rbp)
movsd -0x20(%rbp), %xmm0
addsd %xmm0, %xmm0
mulsd 0x29a9c(%rip), %xmm0    # 0x10b828
divsd 0x29a9c(%rip), %xmm0    # 0x10b830
movsd %xmm0, -0x10(%rbp)
callq 0x9080
movsd %xmm0, -0x28(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x9710
movsd %xmm0, -0x10(%rbp)
movsd -0x20(%rbp), %xmm1
mulsd 0x29bb1(%rip), %xmm1    # 0x10b970
mulsd 0x29a61(%rip), %xmm1    # 0x10b828
divsd 0x29a61(%rip), %xmm1    # 0x10b830
movapd %xmm1, %xmm0
callq 0x9080
movsd 0x29c40(%rip), %xmm1    # 0x10ba20
movsd -0x38(%rbp), %xmm2
mulsd %xmm2, %xmm1
movsd -0x30(%rbp), %xmm5
mulsd %xmm5, %xmm1
movsd -0x18(%rbp), %xmm4
movsd -0x28(%rbp), %xmm3
mulsd %xmm4, %xmm3
addsd %xmm1, %xmm3
movapd %xmm3, %xmm7
movapd %xmm2, %xmm1
movapd %xmm2, %xmm3
movsd 0x29b58(%rip), %xmm6    # 0x10b970
mulsd %xmm6, %xmm1
mulsd %xmm4, %xmm1
mulsd %xmm5, %xmm1
mulsd -0x10(%rbp), %xmm1
addsd %xmm7, %xmm1
movsd 0x29b53(%rip), %xmm2    # 0x10b988
mulsd %xmm4, %xmm2
mulsd %xmm4, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x49c83(%rip), %xmm1    # 0x12bad0
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
mulsd -0x8(%rbp), %xmm1
addsd %xmm1, %xmm0
mulsd 0x299ca(%rip), %xmm0    # 0x10b830
divsd 0x299ba(%rip), %xmm0    # 0x10b828
mulsd %xmm6, %xmm0
leaq 0x22b15f(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm1
leaq 0x22b73c(%rip), %rax    # 0x30d5c0
mulsd 0x272d4(%rip), %xmm1    # 0x109160
movsd %xmm0, (%rax)
mulsd %xmm6, %xmm1
addsd %xmm1, %xmm0
addq $0x40, %rsp
popq %rbp
retq