// File: jkingan[P]ladyheather/heathgps.cpp
// Function: constant_load()
void constant_load()
{
DATA_SIZE delta;
u16 pwm;

   if(cc_mode == 0) return;
   if(cc_state < 5) ++cc_state;
   if(sweep_rate <= 0) {
      sweep_rate = sweep_tick = 1;
   }

   if(cc_state == 1) {  // starting up
      if(cc_mode == PWM_SWEEP) {
         cc_pwm = sweep_val = sweep_start;
         goto charged;
      }
      else if((cc_mode == CC_LIPO) && (led_v < unsafe_v)) {  // potentially unsafe cell - don't charge
         goto stop_charge;
      }
      term_timer = TERM_TIME;
      if(sweep_stop) cc_pwm = 0.0;
      else           cc_pwm = PWM_STEP;
   }
   else if(cc_mode == PWM_SWEEP) {   // sweeping PWM value between limits
      if(sweep_start > sweep_end) {  // down sweep
         if(--sweep_tick <= 0) {
            sweep_tick = sweep_rate;
            sweep_val -= PWM_STEP;
            if(sweep_val < 0.0) end_sweep();
         }
         if(sweep_val < sweep_end) {
            end_sweep();
         }
      }
      else {                         // up sweep;
         if(--sweep_tick <= 0) {
            sweep_tick = sweep_rate;
            sweep_val += PWM_STEP;
            if(sweep_val > 1.0) end_sweep();
         }
         if(sweep_val > sweep_end) {
            end_sweep();
         }
      }
      cc_pwm = sweep_val;
      goto charged;
   }
   else {
      if((cc_mode == CC_LIPO) && (led_v > (lipo_volts-0.05))) {  // constant V mode
//       if(led_v > (lipo_volts+0.05)) goto stop_charge;
         if(led_v > (lipo_volts+0.10)) goto stop_charge;
         if(led_i < (cc_val/20.0)) {  // constant I mode - charge done at charge_rate/20
            if(--term_timer < 0) {
               stop_charge:
               end_sweep();
               cc_pwm = 0.0;
               goto charged;
            }
         }
         else term_timer = TERM_TIME;

         if(led_i < cc_val) {
            if((led_v > lipo_volts) && cc_pwm) {
               cc_pwm -= PWM_STEP;
               if(cc_pwm < PWM_STEP) cc_pwm = PWM_STEP;
            }
            goto charged;
         }
      }

      if((cc_mode == CC_VOLTS) && (led_v > 0.050)) {  // must have at least 50mv load voltage
         if(sweep_stop) {
            if(led_v > sweep_stop) {
               end_sweep();
               cc_pwm = 0.0;
            }
            else if(--sweep_tick <= 0) {
               sweep_tick = sweep_rate;
               cc_pwm += PWM_STEP;
               if(cc_pwm > 1.0) {
                  end_sweep();
                  cc_pwm = 0.0;
               }
            }
         }
         else {
            delta = (cc_val - led_v);
            delta /= led_v;
            if(delta < 0.0) delta *= (DATA_SIZE) 0.50;
            else            delta *= (DATA_SIZE) 0.20;
            cc_pwm += (delta * cc_pwm);
         }
      }
      else if((cc_mode == CC_WATTS) && (led_w > 0.050)) {  // must have at least 50mw load power
         if(sweep_stop) {
            if(led_w > sweep_stop) {
               end_sweep();
               cc_pwm = 0.0;
            }
            else if(--sweep_tick <= 0) {
               sweep_tick = sweep_rate;
               cc_pwm += PWM_STEP;
               if(cc_pwm > 1.0) {
                  end_sweep();
                  cc_pwm = 0.0;
               }
            }
         }
         else {
            delta = (cc_val - led_w);
            delta /= led_w;
            if(delta < 0.0) delta *= (DATA_SIZE) 0.25;  // power is a squared function, reduce gain
            else            delta *= (DATA_SIZE) 0.04;
            cc_pwm += (delta * cc_pwm);
         }
      }
      else if((cc_mode > 1) && (led_i > 0.050)) {  // must have at least 50mA load current
         if(sweep_stop) {
            if(led_i > sweep_stop) {
               end_sweep();
               cc_pwm = 0.0;
            }
            else if(--sweep_tick <= 0) {
               sweep_tick = sweep_rate;
               cc_pwm += PWM_STEP;
               if(cc_pwm > 1.0) {
                  end_sweep();
                  cc_pwm = 0.0;
               }
            }
         }
         else {
            delta = (cc_val - led_i);
            delta /= led_i;
            if(delta < 0.0) delta *= (DATA_SIZE) 0.50;
            else            delta *= (DATA_SIZE) 0.20;
            cc_pwm += (delta * cc_pwm);
         }
      }
      else {
         if(sweep_stop) {
            if(--sweep_tick <= 0) {
               sweep_tick = sweep_rate;
               cc_pwm += PWM_STEP;
               if(cc_pwm > 1.0) {
                  end_sweep();
                  cc_pwm = 0.0;
               }
            }
         }
         else {
            cc_pwm += PWM_STEP;
         }
      }
   }

   charged:
   if(cc_pwm > 1.0)        cc_pwm = 1.0;
   else if(cc_pwm <= 0.0F) cc_pwm = 0.0;

   pwm = (u16) (cc_pwm * 65535.0);
   set_batt_pwm(pwm);

   if(cc_mode == CC_LIPO) {
      sprintf(plot_title, " LiPo Charge %.3fA to %.3fV: led_i=%.3fA  pwm=%f %04X %04X", cc_val,lipo_volts, led_i, cc_pwm,pwm,pwm>>6);
   }
   else if(cc_mode == CC_AMPS) {
      sprintf(plot_title, " CC Load %.3fA: led_i=%.3fA  pwm=%f %04X %04X", cc_val, led_i, cc_pwm,pwm,pwm>>6);
   }
   else if(cc_mode == CC_VOLTS) {
      sprintf(plot_title, " CV Load %.3fV: led_v=%.3fV  pwm=%f %04X %04X", cc_val, led_v, cc_pwm,pwm,pwm>>6);
   }
   else if(cc_mode == CC_WATTS) {
      sprintf(plot_title, " CW Load %.3fW: led_v=%.3fV  led_i=%.3fA  led_w=%.3fW  pwm=%f %04X %04X", cc_val, led_v, led_i, led_w, cc_pwm,pwm,pwm>>6);
   }
   else if(cc_mode == PWM_SWEEP) {
      sprintf(plot_title, " PWM sweep from %.3f to %.3f:  pwm=%f %04X %04X", sweep_start, sweep_end, cc_pwm,pwm,pwm>>6);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x2c1df9(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0xaa27c
jmp 0xaae1d
leaq 0x2c1de6(%rip), %rax    # 0x36c069
movzbl (%rax), %eax
cmpl $0x5, %eax
jge 0xaa2a0
leaq 0x2c1dd7(%rip), %rax    # 0x36c069
movb (%rax), %cl
addb $0x1, %cl
leaq 0x2c1dcb(%rip), %rax    # 0x36c069
movb %cl, (%rax)
leaq 0x2c1e09(%rip), %rax    # 0x36c0b0
cmpl $0x0, (%rax)
jg 0xaa2c6
leaq 0x2c1e01(%rip), %rax    # 0x36c0b4
movl $0x1, (%rax)
leaq 0x2c1df0(%rip), %rax    # 0x36c0b0
movl $0x1, (%rax)
leaq 0x2c1d9c(%rip), %rax    # 0x36c069
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0xaa38d
leaq 0x2c1d88(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x5, %eax
jne 0xaa30e
leaq 0x2c1da1(%rip), %rax    # 0x36c090
movsd (%rax), %xmm0
leaq 0x2c1da6(%rip), %rax    # 0x36c0a0
movsd %xmm0, (%rax)
leaq 0x2c1d83(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
jmp 0xaabdd
leaq 0x2c1d53(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0xaa33e
leaq 0x2c1c8c(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm1
leaq 0x2c1d49(%rip), %rax    # 0x36c078
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xaa33e
jmp 0xaa594
jmp 0xaa340
movl $0x3c, 0x325c6a(%rip)   # 0x3cffb4
leaq 0x2c1d57(%rip), %rax    # 0x36c0a8
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaa362
jp 0xaa362
jmp 0xaa372
leaq 0x2c1d1f(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaa388
leaq 0x2c1c7f(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
leaq 0x2c1d04(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
jmp 0xaabdb
leaq 0x2c1cd4(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x5, %eax
jne 0xaa4f1
leaq 0x2c1ce9(%rip), %rax    # 0x36c090
movsd (%rax), %xmm0
leaq 0x2c1ce6(%rip), %rax    # 0x36c098
ucomisd (%rax), %xmm0
jbe 0xaa44a
leaq 0x2c1cf1(%rip), %rax    # 0x36c0b4
movl (%rax), %eax
addl $-0x1, %eax
leaq 0x2c1ce5(%rip), %rcx    # 0x36c0b4
movl %eax, (%rcx)
cmpl $0x0, %eax
jg 0xaa424
leaq 0x2c1cd3(%rip), %rax    # 0x36c0b0
movl (%rax), %ecx
leaq 0x2c1cce(%rip), %rax    # 0x36c0b4
movl %ecx, (%rax)
leaq 0x2c1c09(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm1
leaq 0x2c1ca6(%rip), %rax    # 0x36c0a0
movsd (%rax), %xmm0
subsd %xmm1, %xmm0
leaq 0x2c1c97(%rip), %rax    # 0x36c0a0
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
leaq 0x2c1c89(%rip), %rax    # 0x36c0a0
ucomisd (%rax), %xmm0
jbe 0xaa422
callq 0xaa1f0
jmp 0xaa424
leaq 0x2c1c75(%rip), %rax    # 0x36c0a0
movsd (%rax), %xmm1
leaq 0x2c1c62(%rip), %rax    # 0x36c098
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xaa445
callq 0xaa1f0
jmp 0xaa4d6
leaq 0x2c1c63(%rip), %rax    # 0x36c0b4
movl (%rax), %eax
addl $-0x1, %eax
leaq 0x2c1c57(%rip), %rcx    # 0x36c0b4
movl %eax, (%rcx)
cmpl $0x0, %eax
jg 0xaa4b7
leaq 0x2c1c45(%rip), %rax    # 0x36c0b0
movl (%rax), %ecx
leaq 0x2c1c40(%rip), %rax    # 0x36c0b4
movl %ecx, (%rax)
leaq 0x2c1b7b(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
leaq 0x2c1c18(%rip), %rax    # 0x36c0a0
addsd (%rax), %xmm0
leaq 0x2c1c0d(%rip), %rax    # 0x36c0a0
movsd %xmm0, (%rax)
leaq 0x2c1c02(%rip), %rax    # 0x36c0a0
movsd (%rax), %xmm0
movsd 0xc4bbe(%rip), %xmm1    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0xaa4b5
callq 0xaa1f0
jmp 0xaa4b7
leaq 0x2c1be2(%rip), %rax    # 0x36c0a0
movsd (%rax), %xmm0
leaq 0x2c1bcf(%rip), %rax    # 0x36c098
ucomisd (%rax), %xmm0
jbe 0xaa4d4
callq 0xaa1f0
jmp 0xaa4d6
leaq 0x2c1bc3(%rip), %rax    # 0x36c0a0
movsd (%rax), %xmm0
leaq 0x2c1ba0(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
jmp 0xaabdd
leaq 0x2c1b70(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0xaa668
leaq 0x2c1aa5(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm0
leaq 0x2c1b5a(%rip), %rax    # 0x36c070
movsd (%rax), %xmm1
movsd 0xc724e(%rip), %xmm2    # 0x171770
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xaa668
leaq 0x2c1a79(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm0
movsd 0xc4be5(%rip), %xmm1    # 0x16f128
leaq 0x2c1b26(%rip), %rax    # 0x36c070
addsd (%rax), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xaa556
jmp 0xaa594
leaq 0x2c1a5b(%rip), %rax    # 0x36bfb8
movsd (%rax), %xmm1
leaq 0x2c1b18(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
movsd 0xc4b54(%rip), %xmm2    # 0x16f0c8
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xaa5ae
movl 0x325a30(%rip), %eax    # 0x3cffb4
addl $-0x1, %eax
movl %eax, 0x325a27(%rip)    # 0x3cffb4
cmpl $0x0, %eax
jge 0xaa5ac
jmp 0xaa594
callq 0xaa1f0
leaq 0x2c1ae8(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaabdd
jmp 0xaa5b8
movl $0x3c, 0x3259fc(%rip)   # 0x3cffb4
leaq 0x2c19f9(%rip), %rax    # 0x36bfb8
movsd (%rax), %xmm1
leaq 0x2c1ab6(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xaa666
leaq 0x2c19d1(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm0
leaq 0x2c1a86(%rip), %rax    # 0x36c070
ucomisd (%rax), %xmm0
jbe 0xaa661
leaq 0x2c1a91(%rip), %rax    # 0x36c088
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaa608
jp 0xaa608
jmp 0xaa661
leaq 0x2c19e9(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm1
leaq 0x2c1a6e(%rip), %rax    # 0x36c088
movsd (%rax), %xmm0
subsd %xmm1, %xmm0
leaq 0x2c1a5f(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
leaq 0x2c1a54(%rip), %rax    # 0x36c088
movsd (%rax), %xmm1
leaq 0x2c19b9(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xaa65f
leaq 0x2c19a8(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
leaq 0x2c1a2d(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
jmp 0xaa661
jmp 0xaabdd
jmp 0xaa668
leaq 0x2c19f9(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0xaa7f9
leaq 0x2c192e(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm0
movsd 0xc70e2(%rip), %xmm1    # 0x171770
ucomisd %xmm1, %xmm0
jbe 0xaa7f9
leaq 0x2c1a09(%rip), %rax    # 0x36c0a8
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaa6b3
jp 0xaa6b3
jmp 0xaa762
leaq 0x2c18f6(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm0
leaq 0x2c19e3(%rip), %rax    # 0x36c0a8
ucomisd (%rax), %xmm0
jbe 0xaa6e0
callq 0xaa1f0
leaq 0x2c19b1(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaa75d
leaq 0x2c19cd(%rip), %rax    # 0x36c0b4
movl (%rax), %eax
addl $-0x1, %eax
leaq 0x2c19c1(%rip), %rcx    # 0x36c0b4
movl %eax, (%rcx)
cmpl $0x0, %eax
jg 0xaa75b
leaq 0x2c19af(%rip), %rax    # 0x36c0b0
movl (%rax), %ecx
leaq 0x2c19aa(%rip), %rax    # 0x36c0b4
movl %ecx, (%rax)
leaq 0x2c18e5(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
leaq 0x2c196a(%rip), %rax    # 0x36c088
addsd (%rax), %xmm0
leaq 0x2c195f(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
leaq 0x2c1954(%rip), %rax    # 0x36c088
movsd (%rax), %xmm0
movsd 0xc4928(%rip), %xmm1    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0xaa759
callq 0xaa1f0
leaq 0x2c1936(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaa75b
jmp 0xaa75d
jmp 0xaa7f4
leaq 0x2c1917(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
leaq 0x2c183c(%rip), %rax    # 0x36bfb0
subsd (%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
leaq 0x2c182c(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm1
movsd -0x8(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x8(%rbp), %xmm0
jbe 0xaa7b4
movsd 0xc48e8(%rip), %xmm0    # 0x16f090
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xaa7c6
movsd 0xd86a4(%rip), %xmm0    # 0x182e60
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
leaq 0x2c18b6(%rip), %rax    # 0x36c088
movsd (%rax), %xmm2
leaq 0x2c18ab(%rip), %rax    # 0x36c088
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
leaq 0x2c1898(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
jmp 0xaabd7
leaq 0x2c1868(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x4, %eax
jne 0xaa98a
leaq 0x2c180d(%rip), %rax    # 0x36c020
movsd (%rax), %xmm0
movsd 0xc6f51(%rip), %xmm1    # 0x171770
ucomisd %xmm1, %xmm0
jbe 0xaa98a
leaq 0x2c1878(%rip), %rax    # 0x36c0a8
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaa844
jp 0xaa844
jmp 0xaa8f3
leaq 0x2c17d5(%rip), %rax    # 0x36c020
movsd (%rax), %xmm0
leaq 0x2c1852(%rip), %rax    # 0x36c0a8
ucomisd (%rax), %xmm0
jbe 0xaa871
callq 0xaa1f0
leaq 0x2c1820(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaa8ee
leaq 0x2c183c(%rip), %rax    # 0x36c0b4
movl (%rax), %eax
addl $-0x1, %eax
leaq 0x2c1830(%rip), %rcx    # 0x36c0b4
movl %eax, (%rcx)
cmpl $0x0, %eax
jg 0xaa8ec
leaq 0x2c181e(%rip), %rax    # 0x36c0b0
movl (%rax), %ecx
leaq 0x2c1819(%rip), %rax    # 0x36c0b4
movl %ecx, (%rax)
leaq 0x2c1754(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
leaq 0x2c17d9(%rip), %rax    # 0x36c088
addsd (%rax), %xmm0
leaq 0x2c17ce(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
leaq 0x2c17c3(%rip), %rax    # 0x36c088
movsd (%rax), %xmm0
movsd 0xc4797(%rip), %xmm1    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0xaa8ea
callq 0xaa1f0
leaq 0x2c17a5(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaa8ec
jmp 0xaa8ee
jmp 0xaa985
leaq 0x2c1786(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
leaq 0x2c171b(%rip), %rax    # 0x36c020
subsd (%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
leaq 0x2c170b(%rip), %rax    # 0x36c020
movsd (%rax), %xmm1
movsd -0x8(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x8(%rbp), %xmm0
jbe 0xaa945
movsd 0xc6d8f(%rip), %xmm0    # 0x1716c8
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xaa957
movsd 0xd865b(%rip), %xmm0    # 0x182fa8
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
leaq 0x2c1725(%rip), %rax    # 0x36c088
movsd (%rax), %xmm2
leaq 0x2c171a(%rip), %rax    # 0x36c088
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
leaq 0x2c1707(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
jmp 0xaabd5
leaq 0x2c16d7(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x1, %eax
jle 0xaab1b
leaq 0x2c1614(%rip), %rax    # 0x36bfb8
movsd (%rax), %xmm0
movsd 0xc6dc0(%rip), %xmm1    # 0x171770
ucomisd %xmm1, %xmm0
jbe 0xaab1b
leaq 0x2c16e7(%rip), %rax    # 0x36c0a8
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaa9d5
jp 0xaa9d5
jmp 0xaaa84
leaq 0x2c15dc(%rip), %rax    # 0x36bfb8
movsd (%rax), %xmm0
leaq 0x2c16c1(%rip), %rax    # 0x36c0a8
ucomisd (%rax), %xmm0
jbe 0xaaa02
callq 0xaa1f0
leaq 0x2c168f(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaaa7f
leaq 0x2c16ab(%rip), %rax    # 0x36c0b4
movl (%rax), %eax
addl $-0x1, %eax
leaq 0x2c169f(%rip), %rcx    # 0x36c0b4
movl %eax, (%rcx)
cmpl $0x0, %eax
jg 0xaaa7d
leaq 0x2c168d(%rip), %rax    # 0x36c0b0
movl (%rax), %ecx
leaq 0x2c1688(%rip), %rax    # 0x36c0b4
movl %ecx, (%rax)
leaq 0x2c15c3(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
leaq 0x2c1648(%rip), %rax    # 0x36c088
addsd (%rax), %xmm0
leaq 0x2c163d(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
leaq 0x2c1632(%rip), %rax    # 0x36c088
movsd (%rax), %xmm0
movsd 0xc4606(%rip), %xmm1    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0xaaa7b
callq 0xaa1f0
leaq 0x2c1614(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaaa7d
jmp 0xaaa7f
jmp 0xaab16
leaq 0x2c15f5(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
leaq 0x2c1522(%rip), %rax    # 0x36bfb8
subsd (%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
leaq 0x2c1512(%rip), %rax    # 0x36bfb8
movsd (%rax), %xmm1
movsd -0x8(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x8(%rbp), %xmm0
jbe 0xaaad6
movsd 0xc45c6(%rip), %xmm0    # 0x16f090
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xaaae8
movsd 0xd8382(%rip), %xmm0    # 0x182e60
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
leaq 0x2c1594(%rip), %rax    # 0x36c088
movsd (%rax), %xmm2
leaq 0x2c1589(%rip), %rax    # 0x36c088
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
leaq 0x2c1576(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
jmp 0xaabd3
leaq 0x2c1586(%rip), %rax    # 0x36c0a8
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaab33
jp 0xaab33
jmp 0xaabb0
leaq 0x2c157a(%rip), %rax    # 0x36c0b4
movl (%rax), %eax
addl $-0x1, %eax
leaq 0x2c156e(%rip), %rcx    # 0x36c0b4
movl %eax, (%rcx)
cmpl $0x0, %eax
jg 0xaabae
leaq 0x2c155c(%rip), %rax    # 0x36c0b0
movl (%rax), %ecx
leaq 0x2c1557(%rip), %rax    # 0x36c0b4
movl %ecx, (%rax)
leaq 0x2c1492(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
leaq 0x2c1517(%rip), %rax    # 0x36c088
addsd (%rax), %xmm0
leaq 0x2c150c(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
leaq 0x2c1501(%rip), %rax    # 0x36c088
movsd (%rax), %xmm0
movsd 0xc44d5(%rip), %xmm1    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0xaabac
callq 0xaa1f0
leaq 0x2c14e3(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaabae
jmp 0xaabd1
leaq 0x2c1441(%rip), %rax    # 0x36bff8
movsd (%rax), %xmm0
leaq 0x2c14c6(%rip), %rax    # 0x36c088
addsd (%rax), %xmm0
leaq 0x2c14bb(%rip), %rax    # 0x36c088
movsd %xmm0, (%rax)
jmp 0xaabd3
jmp 0xaabd5
jmp 0xaabd7
jmp 0xaabd9
jmp 0xaabdb
jmp 0xaabdd
leaq 0x2c14a4(%rip), %rax    # 0x36c088
movsd (%rax), %xmm0
movsd 0xc4478(%rip), %xmm1    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0xaac0b
leaq 0x2c148b(%rip), %rax    # 0x36c088
movsd 0xc4463(%rip), %xmm0    # 0x16f068
movsd %xmm0, (%rax)
jmp 0xaac2b
xorps %xmm0, %xmm0
leaq 0x2c1473(%rip), %rax    # 0x36c088
ucomisd (%rax), %xmm0
jb 0xaac29
leaq 0x2c1466(%rip), %rax    # 0x36c088
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xaac2b
leaq 0x2c1456(%rip), %rax    # 0x36c088
movsd (%rax), %xmm0
movsd 0xc6a82(%rip), %xmm1    # 0x1716c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movw %ax, -0xa(%rbp)
movzwl -0xa(%rbp), %edi
callq 0xaa160
leaq 0x2c140e(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0xaacb3
leaq 0x2c1417(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
leaq 0x2c13fc(%rip), %rax    # 0x36c070
movsd (%rax), %xmm1
leaq 0x2c1339(%rip), %rax    # 0x36bfb8
movsd (%rax), %xmm2
leaq 0x2c13fe(%rip), %rax    # 0x36c088
movsd (%rax), %xmm3
movzwl -0xa(%rbp), %edx
movzwl -0xa(%rbp), %ecx
sarl $0x6, %ecx
leaq 0x2f2d90(%rip), %rdi    # 0x39da30
leaq 0xdac44(%rip), %rsi     # 0x1858eb
movb $0x4, %al
callq 0x9060
jmp 0xaae1d
leaq 0x2c13ae(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x2, %eax
jne 0xaad08
leaq 0x2c13b7(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
leaq 0x2c12e4(%rip), %rax    # 0x36bfb8
movsd (%rax), %xmm1
leaq 0x2c13a9(%rip), %rax    # 0x36c088
movsd (%rax), %xmm2
movzwl -0xa(%rbp), %edx
movzwl -0xa(%rbp), %ecx
sarl $0x6, %ecx
leaq 0x2f2d3b(%rip), %rdi    # 0x39da30
leaq 0xdac2a(%rip), %rsi     # 0x185926
movb $0x3, %al
callq 0x9060
jmp 0xaae1b
leaq 0x2c1359(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0xaad5d
leaq 0x2c1362(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
leaq 0x2c1287(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm1
leaq 0x2c1354(%rip), %rax    # 0x36c088
movsd (%rax), %xmm2
movzwl -0xa(%rbp), %edx
movzwl -0xa(%rbp), %ecx
sarl $0x6, %ecx
leaq 0x2f2ce6(%rip), %rdi    # 0x39da30
leaq 0xdac03(%rip), %rsi     # 0x185954
movb $0x3, %al
callq 0x9060
jmp 0xaae19
leaq 0x2c1304(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x4, %eax
jne 0xaadc5
leaq 0x2c130d(%rip), %rax    # 0x36c080
movsd (%rax), %xmm0
leaq 0x2c1232(%rip), %rax    # 0x36bfb0
movsd (%rax), %xmm1
leaq 0x2c122f(%rip), %rax    # 0x36bfb8
movsd (%rax), %xmm2
leaq 0x2c128c(%rip), %rax    # 0x36c020
movsd (%rax), %xmm3
leaq 0x2c12e9(%rip), %rax    # 0x36c088
movsd (%rax), %xmm4
movzwl -0xa(%rbp), %edx
movzwl -0xa(%rbp), %ecx
sarl $0x6, %ecx
leaq 0x2f2c7b(%rip), %rdi    # 0x39da30
leaq 0xdabc6(%rip), %rsi     # 0x185982
movb $0x5, %al
callq 0x9060
jmp 0xaae17
leaq 0x2c129c(%rip), %rax    # 0x36c068
movzbl (%rax), %eax
cmpl $0x5, %eax
jne 0xaae15
leaq 0x2c12b5(%rip), %rax    # 0x36c090
movsd (%rax), %xmm0
leaq 0x2c12b2(%rip), %rax    # 0x36c098
movsd (%rax), %xmm1
leaq 0x2c1297(%rip), %rax    # 0x36c088
movsd (%rax), %xmm2
movzwl -0xa(%rbp), %edx
movzwl -0xa(%rbp), %ecx
sarl $0x6, %ecx
leaq 0x2f2c29(%rip), %rdi    # 0x39da30
leaq 0xdabbc(%rip), %rsi     # 0x1859ca
movb $0x3, %al
callq 0x9060
jmp 0xaae17
jmp 0xaae19
jmp 0xaae1b
jmp 0xaae1d
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)