// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: sun_refraction(double)
double sun_refraction(double el)
{
double r;
double htan;
double r2;

   // calculation sun refraction angle (in degrees) given its 
   // elevation "el" in degrees

   r = r2 = (-1.0);
   if(0) {
      htan = el + 5.11;
      if(htan == 0.0) return (-1.0);
      htan = el + (10.3 / htan);
      htan = tan(htan*PI/180.0);
      if(htan == 0.0) return (-1.0);
      r2 = 1.02 / htan; // refraction in minutes
      r2 /= 60.0;       // refraction in degrees
      r = r2;
   }
   else {
      if(el >= 85.0) r = 0.0;
      else if(el >= 5.0) {
         htan = tan(el*PI/180.0);
         if(htan == 0.0) return (-1.0);
         r = (58.1 / htan) - (0.07 / (htan*htan*htan)) + (0.000086 / (htan*htan*htan*htan*htan));
      }
      else if(el >= (-0.575)) {
         r = 1735.0;
         r -= (518.2*el);
         r += (103.4*el*el);
         r -= (12.79*el*el*el);
         r += (0.711*el*el*el*el);
      }
      else {
         htan = tan(el*PI/180.0);
         if(htan == 0.0) return (-1.0);
         r = (-20.774/htan);
      }
      r /= 3600.0;
   }
   return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movsd %xmm0, -0x10(%rbp)
movsd 0x302e3(%rip), %xmm0    # 0x16f118
movsd %xmm0, -0x28(%rbp)
movsd 0x302d6(%rip), %xmm0    # 0x16f118
movsd %xmm0, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
movsd 0x4fccc(%rip), %xmm1    # 0x18eb20
ucomisd %xmm1, %xmm0
jb 0x13ee67
xorps %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x13f051
movsd -0x10(%rbp), %xmm0
movsd 0x302ec(%rip), %xmm1    # 0x16f160
ucomisd %xmm1, %xmm0
jb 0x13ef22
movsd 0x32742(%rip), %xmm0    # 0x1715c8
mulsd -0x10(%rbp), %xmm0
movsd 0x301e5(%rip), %xmm1    # 0x16f078
divsd %xmm1, %xmm0
callq 0x91b0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x13eec3
jp 0x13eec3
movsd 0x3025f(%rip), %xmm0    # 0x16f118
movsd %xmm0, -0x8(%rbp)
jmp 0x13f071
movsd 0x4fc9d(%rip), %xmm0    # 0x18eb68
divsd -0x20(%rbp), %xmm0
movsd -0x20(%rbp), %xmm2
mulsd -0x20(%rbp), %xmm2
mulsd -0x20(%rbp), %xmm2
movsd 0x44049(%rip), %xmm1    # 0x182f30
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd -0x20(%rbp), %xmm2
mulsd -0x20(%rbp), %xmm2
mulsd -0x20(%rbp), %xmm2
mulsd -0x20(%rbp), %xmm2
mulsd -0x20(%rbp), %xmm2
movsd 0x4fc50(%rip), %xmm1    # 0x18eb60
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x13f04f
movsd -0x10(%rbp), %xmm0
movsd 0x4fbf9(%rip), %xmm1    # 0x18eb28
ucomisd %xmm1, %xmm0
jb 0x13eff9
movsd 0x4fc17(%rip), %xmm0    # 0x18eb58
movsd %xmm0, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd 0x4fbf8(%rip), %xmm2    # 0x18eb50
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd 0x4fbdb(%rip), %xmm0    # 0x18eb48
mulsd -0x10(%rbp), %xmm0
movsd -0x10(%rbp), %xmm2
movsd -0x18(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd 0x4fbaf(%rip), %xmm0    # 0x18eb40
mulsd -0x10(%rbp), %xmm0
mulsd -0x10(%rbp), %xmm0
movsd -0x10(%rbp), %xmm2
movsd -0x18(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd 0x4fb67(%rip), %xmm0    # 0x18eb38
mulsd -0x10(%rbp), %xmm0
mulsd -0x10(%rbp), %xmm0
mulsd -0x10(%rbp), %xmm0
movsd -0x10(%rbp), %xmm2
movsd -0x18(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x13f04d
movsd 0x325c7(%rip), %xmm0    # 0x1715c8
mulsd -0x10(%rbp), %xmm0
movsd 0x3006a(%rip), %xmm1    # 0x16f078
divsd %xmm1, %xmm0
callq 0x91b0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x13f03b
jp 0x13f03b
movsd 0x300e4(%rip), %xmm0    # 0x16f118
movsd %xmm0, -0x8(%rbp)
jmp 0x13f071
movsd 0x4faed(%rip), %xmm0    # 0x18eb30
divsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x13f04f
jmp 0x13f051
movsd -0x18(%rbp), %xmm0
movsd 0x2ffb2(%rip), %xmm1    # 0x16f010
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)