// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: calc_sunrise(double, int)
int calc_sunrise(double delta, int why)
{
double zenith;
int hh;
double jd, jd0;
double start, mid, end;
double start_el, mid_el, end_el;
double old_az, old_el;
double old_maz, old_mel;
#define SUN_RES 5 //was 14 - 5 approximation steps gets us within 2 minutes, then we interpolate

   // A more accurate sunrise / sunset calculator than the old one...
   //
   // Sunrise and sunset times are calculated by finding the hours that the
   // sun elevation crosses the desired horizon angles.  Then a 
   // successive-approximation binary seach of those hours is used to
   // refine the times to 2 second levels. The we interpolate to get to 100 msec.
   //
   // Solar noon is first appoximated as midway between sunrise and sunset.
   // Then the time interval +/- 600 seconds from that point is checked for
   // being the peak solar elevation.  If no peak is found the mid-point value
   // between sunrise and sunset is used.

sp_count = 0;
if(debug_file) fprintf(debug_file, "#calc_sunrise(%d)\n", why);

   old_az = sun_az;
   old_el = sun_el;
   old_maz = moon_az;
   old_mel = moon_el;

   have_sun_times = 0x00;
   rise_hh = rise_mm = rise_ss = 0;         
   rise_frac = 0.0;
   set_hh = set_mm =  set_ss = 0;
   set_frac = 0.0;
   noon_hh = noon_mm = noon_ss = 0;         
   noon_frac = 0.0;

   if((sunrise_type == 0) || (lat == 0.0) || (lon == 0.0)) {  // assume GPS not tracking yet
      goto no_sun;
   }

   zenith = sunrise_horizon;

   gregorian(0, jd_local);
   jd0 = start = jdate(g_year,g_month,g_day) + delta;

   jd = jd0; // + jtime(5,0,0,0.0);  // start sunrise search at 5:00 in the morning local time
   start_el = sun_posn(jd, do_moonrise);

   for(hh=1; hh<25; hh++) {  // find the hour of the rising zenith crossing
      end = jd + jtime((hh%25),0,0,0.0);
      end_el = sun_posn(end, do_moonrise);
if(0 && debug_file) fprintf(debug_file, "rise hr:%d  spc:%d  s_el:%f  e_el:%f\n", hh, sp_count, start_el,end_el);
      if((start_el <= zenith) && (end_el >= zenith)) {
         goto got_rise_hh;
      }
      start_el = end_el;
      start = end;
   }
   start = jd0;
   goto no_rise;

   got_rise_hh:
   for(hh=0; hh<SUN_RES; hh++) {  // do a binary search for the rising zenith crossing
      mid = (start + end) / 2.0;
      mid_el = sun_posn(mid, do_moonrise);
      if(mid_el <= zenith) start = mid;
      else if(mid_el >= zenith) end = mid;
if(0 && debug_file) fprintf(debug_file, "refine rise %d:  spc:%d  rise_el:%f  diff:%f\n", hh, sp_count, mid_el, ((end-start) * 24.0*60.0*60.0));
      if(((end-start) * 24.0*60.0*60.0) < 1.0) break;
   }
   sunrise_time = interp_sun_posn(start,end, zenith, do_moonrise);
   sunrise_el = sun_posn(sunrise_time, do_moonrise);
   sunrise_az = sun_az;

   gregorian(0, sunrise_time + time_zone() + jtime(0,0,0,0.50));
   rise_hh = g_hours;
   rise_mm = g_minutes;
   rise_ss = g_seconds;
   rise_frac = g_frac;
   have_sun_times |= 0x01;  // we have a sun rise

   // now calculate the sunset time
   if(0 && do_moonrise) start = jd0; // moon can set before it rises!
   else start = sunrise_time;   // jd0;

   no_rise:
   zenith = sunset_horizon;
   start_el = sun_posn(start, do_moonrise);
   jd = start;

   for(hh=1; hh<25; hh++) {  // find the hour of the setting zenith crossing
      end = jd + jtime(hh%25,0,0,0.0);
      end_el = sun_posn(end, do_moonrise);
      if((start_el >= zenith) && (end_el <= zenith)) {
         goto got_set_hh;
      }
if(0 && debug_file) fprintf(debug_file, "set hr:%d  spc:%d  s_el:%f  e_el:%f\n", hh, sp_count, start_el,end_el);
      start_el = end_el;
      start = end;
   }
   goto no_sun;   // sun never sets, we cant calculate a sun rise

   got_set_hh:
   for(hh=0; hh<SUN_RES; hh++) {  // do a binary search for the setting zenith crossing
      mid = (start + end) / 2.0;
      mid_el = sun_posn(mid, do_moonrise);
      if(mid_el >= zenith) start = mid;
      else if(mid_el <= zenith) end = mid;
if(0 && debug_file) fprintf(debug_file, "refine set %d:  spc:%d  set_el:%f  diff:%f\n", hh, sp_count, mid_el, ((end-start) * 24.0*60.0*60.0));
      if(((end-start) * 24.0*60.0*60.0) < 1.0) break;
   }
   sunset_time = interp_sun_posn(start,end, zenith, do_moonrise);
   sunset_el = sun_posn(sunset_time, do_moonrise);
   sunset_az = sun_az;

   gregorian(0, sunset_time + time_zone() + jtime(0,0,0,0.50));
   set_hh = g_hours;
   set_mm = g_minutes;
   set_ss = g_seconds;
   set_frac = g_frac;
   have_sun_times |= 0x04;

   solar_noon = (sunrise_time + sunset_time) / 2.0;
   if(sunset_time < sunrise_time) {
      solar_noon += 0.50;
   }
   refine_solar_noon(do_moonrise); // a better succesive-approximation refinement over a longer interval

   noon_el = sun_posn(solar_noon, do_moonrise);
   noon_az = sun_az;

   gregorian(0, solar_noon + time_zone() + jtime(0,0,0,0.50));
   noon_hh = g_hours;
   noon_mm = g_minutes;
   noon_ss = g_seconds;
   noon_frac = g_frac;
   if((have_sun_times & 0x01) && (have_sun_times & 0x04)) {  // we have a rise and set
      have_sun_times |= 0x02;
   }

   if(STATUS_RCVR) { // make sure we can trigger alarms during status message
      if((rise_ss >= SCPI_STATUS_SECOND) && (rise_ss <= SCPI_STATUS_SECOND+5)) {
         rise_ss = SCPI_STATUS_SECOND-1;
      }
      if((set_ss >= SCPI_STATUS_SECOND) && (set_ss <= SCPI_STATUS_SECOND+5)) {
         set_ss = SCPI_STATUS_SECOND-1;
      }
   }

   no_sun:
   if(0 && !have_local_time) have_sun_times = 0;  // we don't need to do this anymore since we use jd_local to calc sunrise/sunset
   if(!do_moonrise) log_sun_times();

   sun_az = old_az;
   sun_el = old_el;
   moon_az = old_maz;
   moon_el = old_mel;
   return have_sun_times;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movsd %xmm0, -0x8(%rbp)
movl %edi, -0xc(%rbp)
movl $0x0, 0x29b427(%rip)    # 0x3d97f4
leaq 0x15f19c(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0x13e3f5
leaq 0x15f18f(%rip), %rax    # 0x29d570
movq (%rax), %rdi
movl -0xc(%rbp), %edx
leaq 0x593a4(%rip), %rsi     # 0x197792
movb $0x0, %al
callq 0x9550
leaq 0x22e5b4(%rip), %rax    # 0x36c9b0
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
leaq 0x22e58c(%rip), %rax    # 0x36c998
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
leaq 0x22e5ac(%rip), %rax    # 0x36c9c8
movsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
leaq 0x22e5a4(%rip), %rax    # 0x36c9d0
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
leaq 0x22e3ec(%rip), %rax    # 0x36c828
movl $0x0, (%rax)
leaq 0x22e39f(%rip), %rax    # 0x36c7e8
movl $0x0, (%rax)
leaq 0x22e38e(%rip), %rax    # 0x36c7e4
movl $0x0, (%rax)
leaq 0x22e37d(%rip), %rax    # 0x36c7e0
movl $0x0, (%rax)
leaq 0x22e380(%rip), %rax    # 0x36c7f0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
leaq 0x22e39a(%rip), %rax    # 0x36c818
movl $0x0, (%rax)
leaq 0x22e389(%rip), %rax    # 0x36c814
movl $0x0, (%rax)
leaq 0x22e378(%rip), %rax    # 0x36c810
movl $0x0, (%rax)
leaq 0x22e37b(%rip), %rax    # 0x36c820
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
leaq 0x22e39d(%rip), %rax    # 0x36c850
movl $0x0, (%rax)
leaq 0x22e38c(%rip), %rax    # 0x36c84c
movl $0x0, (%rax)
leaq 0x22e37b(%rip), %rax    # 0x36c848
movl $0x0, (%rax)
leaq 0x22e37e(%rip), %rax    # 0x36c858
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
leaq 0x22e2c0(%rip), %rax    # 0x36c7a8
cmpq $0x0, (%rax)
je 0x13e51c
leaq 0x22dcbb(%rip), %rax    # 0x36c1b0
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x13e506
jp 0x13e506
jmp 0x13e51c
leaq 0x22dcab(%rip), %rax    # 0x36c1b8
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x13e521
jp 0x13e521
jmp 0x13ece0
leaq 0x22e288(%rip), %rax    # 0x36c7b0
movsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
leaq 0x22e1f0(%rip), %rax    # 0x36c728
movsd (%rax), %xmm0
xorl %edi, %edi
callq 0x11dd00
leaq 0x22e33a(%rip), %rax    # 0x36c884
movl (%rax), %edi
leaq 0x22e329(%rip), %rax    # 0x36c87c
movl (%rax), %esi
leaq 0x22e324(%rip), %rax    # 0x36c880
movl (%rax), %edx
callq 0x122140
addsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
leaq 0x22e2d8(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
movsd %xmm0, -0x50(%rbp)
movl $0x1, -0x1c(%rbp)
cmpl $0x19, -0x1c(%rbp)
jge 0x13e637
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl -0x1c(%rbp), %eax
movl $0x19, %ecx
cltd
idivl %ecx
movl %edx, %edi
xorl %edx, %edx
xorps %xmm0, %xmm0
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x88(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
leaq 0x22e275(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
movsd %xmm0, -0x60(%rbp)
movsd -0x50(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x13e615
movsd -0x60(%rbp), %xmm0
ucomisd -0x18(%rbp), %xmm0
jb 0x13e615
jmp 0x13e646
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13e59b
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x13e837
movl $0x0, -0x1c(%rbp)
cmpl $0x5, -0x1c(%rbp)
jge 0x13e70c
movsd -0x38(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movsd 0x30ae7(%rip), %xmm1    # 0x16f150
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
leaq 0x22e1e2(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x13e6a6
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x13e6be
movsd -0x58(%rbp), %xmm0
ucomisd -0x18(%rbp), %xmm0
jb 0x13e6bc
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x13e6be
movsd -0x48(%rbp), %xmm1
subsd -0x38(%rbp), %xmm1
movsd 0x30968(%rip), %xmm0    # 0x16f038
mulsd %xmm0, %xmm1
movsd 0x3093c(%rip), %xmm0    # 0x16f018
mulsd %xmm0, %xmm1
movsd 0x30930(%rip), %xmm0    # 0x16f018
mulsd %xmm0, %xmm1
movsd 0x30974(%rip), %xmm0    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0x13e6fc
jmp 0x13e70c
jmp 0x13e6fe
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13e64d
movsd -0x38(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
movsd -0x18(%rbp), %xmm2
leaq 0x22e13e(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13dcd0
leaq 0x22e0a8(%rip), %rax    # 0x36c7d8
movsd %xmm0, (%rax)
leaq 0x22e09d(%rip), %rax    # 0x36c7d8
movsd (%rax), %xmm0
leaq 0x22e11a(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
leaq 0x22e07c(%rip), %rax    # 0x36c7d0
movsd %xmm0, (%rax)
leaq 0x22e251(%rip), %rax    # 0x36c9b0
movsd (%rax), %xmm0
leaq 0x22e05e(%rip), %rax    # 0x36c7c8
movsd %xmm0, (%rax)
leaq 0x22e063(%rip), %rax    # 0x36c7d8
movsd (%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
callq 0x133f80
movaps %xmm0, %xmm1
movsd -0x98(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
xorl %edx, %edx
movsd 0x308e9(%rip), %xmm0    # 0x16f090
movl %edx, %edi
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x90(%rbp), %xmm0
addsd %xmm1, %xmm0
xorl %edi, %edi
callq 0x11dd00
leaq 0x22e0bb(%rip), %rax    # 0x36c888
movl (%rax), %ecx
leaq 0x22e00a(%rip), %rax    # 0x36c7e0
movl %ecx, (%rax)
leaq 0x22e0ad(%rip), %rax    # 0x36c88c
movl (%rax), %ecx
leaq 0x22dffc(%rip), %rax    # 0x36c7e4
movl %ecx, (%rax)
leaq 0x22e09f(%rip), %rax    # 0x36c890
movl (%rax), %ecx
leaq 0x22dfee(%rip), %rax    # 0x36c7e8
movl %ecx, (%rax)
leaq 0x22e095(%rip), %rax    # 0x36c898
movsd (%rax), %xmm0
leaq 0x22dfe2(%rip), %rax    # 0x36c7f0
movsd %xmm0, (%rax)
leaq 0x22e00f(%rip), %rax    # 0x36c828
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x22e003(%rip), %rax    # 0x36c828
movl %ecx, (%rax)
leaq 0x22dfaa(%rip), %rax    # 0x36c7d8
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
leaq 0x22df7a(%rip), %rax    # 0x36c7b8
movsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x38(%rbp), %xmm0
leaq 0x22e00d(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
movsd %xmm0, -0x50(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x1, -0x1c(%rbp)
cmpl $0x19, -0x1c(%rbp)
jge 0x13e90c
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movl -0x1c(%rbp), %eax
movl $0x19, %ecx
cltd
idivl %ecx
movl %edx, %edi
xorl %edx, %edx
xorps %xmm0, %xmm0
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0xa0(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
leaq 0x22dfa0(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
movsd %xmm0, -0x60(%rbp)
movsd -0x50(%rbp), %xmm0
ucomisd -0x18(%rbp), %xmm0
jb 0x13e8ea
movsd -0x60(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x13e8ea
jmp 0x13e911
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13e870
jmp 0x13ece0
movl $0x0, -0x1c(%rbp)
cmpl $0x5, -0x1c(%rbp)
jge 0x13e9d7
movsd -0x38(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movsd 0x3081c(%rip), %xmm1    # 0x16f150
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
leaq 0x22df17(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
ucomisd -0x18(%rbp), %xmm0
jb 0x13e96d
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x13e989
movsd -0x58(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x13e987
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x13e989
movsd -0x48(%rbp), %xmm1
subsd -0x38(%rbp), %xmm1
movsd 0x3069d(%rip), %xmm0    # 0x16f038
mulsd %xmm0, %xmm1
movsd 0x30671(%rip), %xmm0    # 0x16f018
mulsd %xmm0, %xmm1
movsd 0x30665(%rip), %xmm0    # 0x16f018
mulsd %xmm0, %xmm1
movsd 0x306a9(%rip), %xmm0    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0x13e9c7
jmp 0x13e9d7
jmp 0x13e9c9
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13e918
movsd -0x38(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
movsd -0x18(%rbp), %xmm2
leaq 0x22de73(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13dcd0
leaq 0x22de0d(%rip), %rax    # 0x36c808
movsd %xmm0, (%rax)
leaq 0x22de02(%rip), %rax    # 0x36c808
movsd (%rax), %xmm0
leaq 0x22de4f(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
leaq 0x22dde1(%rip), %rax    # 0x36c800
movsd %xmm0, (%rax)
leaq 0x22df86(%rip), %rax    # 0x36c9b0
movsd (%rax), %xmm0
leaq 0x22ddc3(%rip), %rax    # 0x36c7f8
movsd %xmm0, (%rax)
leaq 0x22ddc8(%rip), %rax    # 0x36c808
movsd (%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
callq 0x133f80
movaps %xmm0, %xmm1
movsd -0xb0(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
xorl %edx, %edx
movsd 0x3061e(%rip), %xmm0    # 0x16f090
movl %edx, %edi
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0xa8(%rbp), %xmm0
addsd %xmm1, %xmm0
xorl %edi, %edi
callq 0x11dd00
leaq 0x22ddf0(%rip), %rax    # 0x36c888
movl (%rax), %ecx
leaq 0x22dd6f(%rip), %rax    # 0x36c810
movl %ecx, (%rax)
leaq 0x22dde2(%rip), %rax    # 0x36c88c
movl (%rax), %ecx
leaq 0x22dd61(%rip), %rax    # 0x36c814
movl %ecx, (%rax)
leaq 0x22ddd4(%rip), %rax    # 0x36c890
movl (%rax), %ecx
leaq 0x22dd53(%rip), %rax    # 0x36c818
movl %ecx, (%rax)
leaq 0x22ddca(%rip), %rax    # 0x36c898
movsd (%rax), %xmm0
leaq 0x22dd47(%rip), %rax    # 0x36c820
movsd %xmm0, (%rax)
leaq 0x22dd44(%rip), %rax    # 0x36c828
movl (%rax), %ecx
orl $0x4, %ecx
leaq 0x22dd38(%rip), %rax    # 0x36c828
movl %ecx, (%rax)
leaq 0x22dcdf(%rip), %rax    # 0x36c7d8
movsd (%rax), %xmm0
leaq 0x22dd04(%rip), %rax    # 0x36c808
addsd (%rax), %xmm0
movsd 0x30640(%rip), %xmm1    # 0x16f150
divsd %xmm1, %xmm0
leaq 0x22dd25(%rip), %rax    # 0x36c840
movsd %xmm0, (%rax)
leaq 0x22dce2(%rip), %rax    # 0x36c808
movsd (%rax), %xmm1
leaq 0x22dca7(%rip), %rax    # 0x36c7d8
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x13eb59
movsd 0x3054d(%rip), %xmm0    # 0x16f090
leaq 0x22dcf6(%rip), %rax    # 0x36c840
addsd (%rax), %xmm0
leaq 0x22dceb(%rip), %rax    # 0x36c840
movsd %xmm0, (%rax)
leaq 0x22dd00(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13d9d0
leaq 0x22dcd2(%rip), %rax    # 0x36c840
movsd (%rax), %xmm0
leaq 0x22dce7(%rip), %rax    # 0x36c860
movl (%rax), %edi
callq 0x13cd20
leaq 0x22dcb1(%rip), %rax    # 0x36c838
movsd %xmm0, (%rax)
leaq 0x22de1e(%rip), %rax    # 0x36c9b0
movsd (%rax), %xmm0
leaq 0x22dc93(%rip), %rax    # 0x36c830
movsd %xmm0, (%rax)
leaq 0x22dc98(%rip), %rax    # 0x36c840
movsd (%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
callq 0x133f80
movaps %xmm0, %xmm1
movsd -0xc0(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
xorl %edx, %edx
movsd 0x304b6(%rip), %xmm0    # 0x16f090
movl %edx, %edi
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0xb8(%rbp), %xmm0
addsd %xmm1, %xmm0
xorl %edi, %edi
callq 0x11dd00
leaq 0x22dc88(%rip), %rax    # 0x36c888
movl (%rax), %ecx
leaq 0x22dc3f(%rip), %rax    # 0x36c848
movl %ecx, (%rax)
leaq 0x22dc7a(%rip), %rax    # 0x36c88c
movl (%rax), %ecx
leaq 0x22dc31(%rip), %rax    # 0x36c84c
movl %ecx, (%rax)
leaq 0x22dc6c(%rip), %rax    # 0x36c890
movl (%rax), %ecx
leaq 0x22dc23(%rip), %rax    # 0x36c850
movl %ecx, (%rax)
leaq 0x22dc62(%rip), %rax    # 0x36c898
movsd (%rax), %xmm0
leaq 0x22dc17(%rip), %rax    # 0x36c858
movsd %xmm0, (%rax)
leaq 0x22dbdc(%rip), %rax    # 0x36c828
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x13ec7c
leaq 0x22dbcb(%rip), %rax    # 0x36c828
movl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x13ec7c
leaq 0x22dbba(%rip), %rax    # 0x36c828
movl (%rax), %ecx
orl $0x2, %ecx
leaq 0x22dbae(%rip), %rax    # 0x36c828
movl %ecx, (%rax)
leaq 0x138e2d(%rip), %rax    # 0x277ab0
movq (%rax), %rax
andq $0x45018, %rax          # imm = 0x45018
cmpq $0x0, %rax
je 0x13ecde
leaq 0x22db4f(%rip), %rax    # 0x36c7e8
cmpl $0x20, (%rax)
jl 0x13ecb7
leaq 0x22db43(%rip), %rax    # 0x36c7e8
cmpl $0x25, (%rax)
jg 0x13ecb7
leaq 0x22db37(%rip), %rax    # 0x36c7e8
movl $0x1f, (%rax)
leaq 0x22db5a(%rip), %rax    # 0x36c818
cmpl $0x20, (%rax)
jl 0x13ecdc
leaq 0x22db4e(%rip), %rax    # 0x36c818
cmpl $0x25, (%rax)
jg 0x13ecdc
leaq 0x22db42(%rip), %rax    # 0x36c818
movl $0x1f, (%rax)
jmp 0x13ecde
jmp 0x13ece0
leaq 0x22db79(%rip), %rax    # 0x36c860
cmpl $0x0, (%rax)
jne 0x13ecf1
callq 0x13dda0
movsd -0x68(%rbp), %xmm0
leaq 0x22dcb3(%rip), %rax    # 0x36c9b0
movsd %xmm0, (%rax)
movsd -0x70(%rbp), %xmm0
leaq 0x22dc8b(%rip), %rax    # 0x36c998
movsd %xmm0, (%rax)
movsd -0x78(%rbp), %xmm0
leaq 0x22dcab(%rip), %rax    # 0x36c9c8
movsd %xmm0, (%rax)
movsd -0x80(%rbp), %xmm0
leaq 0x22dca3(%rip), %rax    # 0x36c9d0
movsd %xmm0, (%rax)
leaq 0x22daf0(%rip), %rax    # 0x36c828
movl (%rax), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)