// File: jkingan[P]ladyheather/heathgps.cpp
// Function: calc_sat_posn(int)
void calc_sat_posn(int prn)
{
int j;
double mu;
double omega_dot_earth;
double A;
double cmm;
double tk;
double n;
double mk;
double Ek;
double nu;
double Phi;
double du,dr,di;
double u;
double r;
double i;
double x_prime;
double y_prime;
double sat_x, sat_y, sat_z;
double omega;
int compute_harmonic_correction;
double E;
double pr;

int iii;
int cp_wrap;
double p1,p2;
double pr0;
double pr1, pr2, pr3;
static double last_pr = 0.0;

   // calculate sat position from ephermeris data, then convert distance to
   // sat into a pseudorange value.
if(0 && log_file) fprintf(log_file, "# prn:%d  eph_flag:%d  eph_valid:%d\n", prn, sat[prn].eph_flag,sat[prn].eph_valid); // rnx3

   if(prn < 1) return;
   if(prn > 32) return;

   pr = 0.0;
   if(sat[prn].eph_flag == 0) {
      sat[prn].iii = (-1);
      goto no_range;
   }
   if(sat[prn].eph_valid == 0) {
      sat[prn].iii = (-1);
      goto no_range;
   }

   compute_harmonic_correction = 1;

   mu = 3.986005e14;
   omega_dot_earth = 7.2921151467e-5; //(rad/sec)

   // Now follow ICD table 20-IV
   A = sat[prn].sqrtA;
   A *= A;

   cmm = sqrt(mu/(A*A*A)); // computed mean motion
   tk = sat[prn].raw_time - sat[prn].eph_toe;

   // account for beginning of end of week crossover
   if(tk > 302400.0)  tk = tk - 604800.0;
   if(tk < -302400.0) tk = tk + 604800.0;

   // apply mean motion correction
   n = cmm + sat[prn].delta_n;

   // Mean anomaly
   mk = sat[prn].M0 + n*tk;

   // solve Kepler's equation for eccentric anomaly
   E = mk;
   Ek = 0.0;
   for(j=0; j<30; j++) {  // Kepler's equation
      Ek = E;
      E -= (E - sat[prn].e*sin(E) - mk) / (1.0-sat[prn].e*cos(E));
      if(fabs(E - Ek) < 1.0E-14) break;
   }

   // True anomaly:
   nu = atan2( (sqrt(1.0-(sat[prn].e*sat[prn].e))*sin(Ek)/(1.0-sat[prn].e*cos(Ek))), 
               ((cos(Ek)-sat[prn].e)/(1.0-sat[prn].e*cos(Ek))) );
   // Ek = acos((e + cos(nu)) / (1.0+e*cos(nu)));

   Phi = nu + sat[prn].omega;
   du = 0.0;
   dr = 0.0;
   di = 0.0;
   if(compute_harmonic_correction == 1) {    // compute harmonic corrections
      du = sat[prn].Cus*sin(2.0*Phi) + sat[prn].Cuc*cos(2.0*Phi);
      dr = sat[prn].Crs*sin(2.0*Phi) + sat[prn].Crc*cos(2.0*Phi);
      di = sat[prn].Cis*sin(2.0*Phi) + sat[prn].Cic*cos(2.0*Phi);
   }

   u = Phi + du;
   r = A*(1.0-sat[prn].e*cos(Ek)) + dr;

   // inclination angle at reference time
   i = sat[prn].io + sat[prn].i_dot*tk + di;
   x_prime = r*cos(u);
   y_prime = r*sin(u);
   omega = sat[prn].omega_0 + (sat[prn].omega_dot - omega_dot_earth)*tk - omega_dot_earth*sat[prn].toe;

   sat_x = x_prime*cos(omega) - y_prime*cos(i)*sin(omega);
   sat_y = x_prime*sin(omega) + y_prime*cos(i)*cos(omega);
   sat_z = y_prime*sin(i);
   if(sat_x != sat_x) goto no_range;  // rnx - kludgy NAN check
   if(sat_y != sat_y) goto no_range;
   if(sat_z != sat_z) goto no_range;

   lla_to_ecef(lat,lon,alt);
   du = (ecef_x - sat_x);
   dr = (ecef_y - sat_y);
   di = (ecef_z - sat_z);
   pr = sqrt(du*du + dr*dr + di*di);

   iii = (-1);
   if(1) { // piss - adjust raw pseudorange for code_phase
      pr0 = pr;
if(CP_WRAP == 0) sat[prn].iii = (-1);
      if(sat[prn].iii < 0) {
         iii = (int) (pr / (LIGHTSPEED*1000.0 * 1.0e-3));
         p1 = p2 = sat[prn].code_phase/(16.0*1023.0)*1e-3;
         p1 += (double) iii * 1.0e-3;
         p2 += (double) (iii+1) * 1.0e-3;
         if(fabs(pr - p1) > fabs(pr - p2)) ++iii;
         sat[prn].iii = iii;
      }
      iii = sat[prn].iii;

      cp_wrap = 0;
      if(CP_WRAP) { 
         if((sat[prn].code_phase > 15000.0) && (sat[prn].last_cp < 1000.0)) cp_wrap = (-1);
         else if((sat[prn].code_phase < 1000.0) && (sat[prn].last_cp > 15000.0)) cp_wrap = (1);
         iii += cp_wrap;
         sat[prn].iii = iii;
      }

if(0 && (prn == plot_prn) && debug_file) {  //piss
   if(cp_wrap) fprintf(debug_file, "code phase wrap %d!\n", cp_wrap);
   fprintf(debug_file, "prn:%-2d iii:%d  pr0:%.4f ", 
                        prn,     iii,    pr0);
}

      /* Check which is closest to pseudorange */
      pr1 = ((double) (iii-1) * 1.0e-3) + sat[prn].code_phase/(16.0*1023.0)*1e-3;
      pr1 *= (LIGHTSPEED*1000.0);
      pr2 = ((double) iii * 1.0e-3) + sat[prn].code_phase/(16.0*1023.0)*1e-3;
      pr2 *= (LIGHTSPEED*1000.0);
      pr3 = ((double) (iii+1) * 1.0e-3) + sat[prn].code_phase/(16.0*1023.0)*1e-3;
      pr3 *= (LIGHTSPEED*1000.0);

////  if(fabs(pr - p1) > fabs(pr - p2)) ++iii;
      pr = ((double) iii * 1.0e-3) + sat[prn].code_phase/(16.0*1023.0)*1e-3;
      pr *= (LIGHTSPEED*1000.0);
   }

if(0 && (prn == plot_prn) && debug_file) {  //piss
   fprintf(debug_file, "iii2:%d  iiix:%d pr1:%.3f pr2:%.3f pr3:%.3f pr:%.3f  cp:%g  dpr:%.3f\n", 
      iii, sat[prn].iii, pr1,pr2,pr3, pr, sat[prn].code_phase, pr-last_pr);
   last_pr = pr;
}


if(0 && debug_file) {
   fprintf(debug_file, "ex:%.9f ey:%.9f  ez:%.9f\n", ecef_x,ecef_y,ecef_z);
   fprintf(debug_file, "sx:%.9f sy:%.9f  sz:%.9f\n", sat_x,sat_y,sat_z);
   fprintf(debug_file, "dx:%.9f dy:%.9f  dz:%.9f\n", du,dr,di);
   fprintf(debug_file, "prn:%d  flag:%d  valid:%d  prange:%.9f  (pr0:%.9f)   time:%.9f\n", prn, sat[prn].eph_flag, sat[prn].eph_valid, pr, pr0, sat[prn].raw_time);
   fprintf(debug_file, "\n");
}
   
   if(pr) {
      have_range |= rinex_gnss(prn);
   }

   no_range:
   sat[prn].range = pr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movl %edi, -0x4(%rbp)
cmpl $0x1, -0x4(%rbp)
jge 0x9e589
jmp 0x9f4bd
cmpl $0x20, -0x4(%rbp)
jle 0x9e594
jmp 0x9f4bd
xorps %xmm0, %xmm0
movsd %xmm0, -0xd0(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ffbe6(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movzbl 0x202(%rax), %eax
cmpl $0x0, %eax
jne 0x9e5e1
movslq -0x4(%rbp), %rcx
leaq 0x1ffbc5(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0xffffffff, 0x50(%rax) # imm = 0xFFFFFFFF
jmp 0x9f49b
movslq -0x4(%rbp), %rcx
leaq 0x1ffba4(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cmpl $0x0, 0x244(%rax)
jne 0x9e620
movslq -0x4(%rbp), %rcx
leaq 0x1ffb86(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0xffffffff, 0x50(%rax) # imm = 0xFFFFFFFF
jmp 0x9f49b
movl $0x1, -0xbc(%rbp)
movsd 0xe45de(%rip), %xmm0    # 0x182c10
movsd %xmm0, -0x10(%rbp)
movsd 0xe45c9(%rip), %xmm0    # 0x182c08
movsd %xmm0, -0x18(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ffb41(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2d0(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
mulsd -0x20(%rbp), %xmm1
mulsd -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x9280
movsd %xmm0, -0x28(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ffaee(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ffad4(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
subsd 0x2d8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0xe4520(%rip), %xmm1    # 0x182c00
ucomisd %xmm1, %xmm0
jbe 0x9e6fc
movsd -0x30(%rbp), %xmm0
movsd 0xd2f15(%rip), %xmm1    # 0x171608
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0xe4514(%rip), %xmm0    # 0x182c18
ucomisd -0x30(%rbp), %xmm0
jbe 0x9e71d
movsd 0xd2ef5(%rip), %xmm0    # 0x171608
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ffa63(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
addsd 0x2a8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ffa41(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2b0(%rax), %xmm1
movsd -0x38(%rbp), %xmm0
movsd -0x30(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x8(%rbp)
cmpl $0x1e, -0x8(%rbp)
jge 0x9e8e8
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0x128(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff9ca(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2c0(%rax), %xmm0
movsd %xmm0, -0x120(%rbp)
movsd -0xc8(%rbp), %xmm0
callq 0x9080
movsd -0x128(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x120(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
subsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff959(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2c0(%rax), %xmm0
movsd %xmm0, -0x110(%rbp)
movsd -0xc8(%rbp), %xmm0
callq 0x96f0
movsd -0x118(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x110(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
movsd 0xd07d4(%rip), %xmm2    # 0x16f068
addsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movsd -0xc8(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0xc8(%rbp), %xmm1
subsd -0x48(%rbp), %xmm1
movaps 0xd09cc(%rip), %xmm0    # 0x16f290
pand %xmm0, %xmm1
movsd 0xe4350(%rip), %xmm0    # 0x182c20
ucomisd %xmm1, %xmm0
jbe 0x9e8d8
jmp 0x9e8e8
jmp 0x9e8da
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x9e794
movslq -0x4(%rbp), %rcx
leaq 0x1ff89d(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2c0(%rax), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ff880(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2c0(%rax), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm1, %xmm0
movsd 0xd0723(%rip), %xmm1    # 0x16f068
addsd %xmm1, %xmm0
callq 0x9280
movsd %xmm0, -0x158(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x9080
movaps %xmm0, %xmm1
movsd -0x158(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x148(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff80e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2c0(%rax), %xmm0
movsd %xmm0, -0x150(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x96f0
movsd -0x150(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x148(%rbp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
movsd 0xd068c(%rip), %xmm2    # 0x16f068
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x130(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x96f0
movslq -0x4(%rbp), %rcx
leaq 0x1ff78f(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
subsd 0x2c0(%rax), %xmm0
movsd %xmm0, -0x138(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff76a(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2c0(%rax), %xmm0
movsd %xmm0, -0x140(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x96f0
movsd -0x140(%rbp), %xmm2
movsd -0x138(%rbp), %xmm1
movaps %xmm0, %xmm3
movsd -0x130(%rbp), %xmm0
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm2
movsd 0xd05e0(%rip), %xmm3    # 0x16f068
addsd %xmm3, %xmm2
divsd %xmm2, %xmm1
callq 0x9050
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ff6e6(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
addsd 0x308(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
cmpl $0x1, -0xbc(%rbp)
jne 0x9eccc
movslq -0x4(%rbp), %rcx
leaq 0x1ff69f(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2c8(%rax), %xmm0
movsd %xmm0, -0x190(%rbp)
movsd 0xd063d(%rip), %xmm0    # 0x16f150
mulsd -0x58(%rbp), %xmm0
callq 0x9080
movsd %xmm0, -0x198(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff660(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2b8(%rax), %xmm0
movsd %xmm0, -0x1a0(%rbp)
movsd 0xd05fe(%rip), %xmm0    # 0x16f150
mulsd -0x58(%rbp), %xmm0
callq 0x96f0
movsd -0x1a0(%rbp), %xmm1
movsd -0x198(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x190(%rbp), %xmm0
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff5fd(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2a0(%rax), %xmm0
movsd %xmm0, -0x178(%rbp)
movsd 0xd059b(%rip), %xmm0    # 0x16f150
mulsd -0x58(%rbp), %xmm0
callq 0x9080
movsd %xmm0, -0x180(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff5be(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x300(%rax), %xmm0
movsd %xmm0, -0x188(%rbp)
movsd 0xd055c(%rip), %xmm0    # 0x16f150
mulsd -0x58(%rbp), %xmm0
callq 0x96f0
movsd -0x188(%rbp), %xmm1
movsd -0x180(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x178(%rbp), %xmm0
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff55b(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2f0(%rax), %xmm0
movsd %xmm0, -0x160(%rbp)
movsd 0xd04f9(%rip), %xmm0    # 0x16f150
mulsd -0x58(%rbp), %xmm0
callq 0x9080
movsd %xmm0, -0x168(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff51c(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2e0(%rax), %xmm0
movsd %xmm0, -0x170(%rbp)
movsd 0xd04ba(%rip), %xmm0    # 0x16f150
mulsd -0x58(%rbp), %xmm0
callq 0x96f0
movsd -0x170(%rbp), %xmm1
movsd -0x168(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x160(%rbp), %xmm0
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x58(%rbp), %xmm0
addsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x200(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff49d(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2c0(%rax), %xmm0
movsd %xmm0, -0x208(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x96f0
movsd -0x208(%rbp), %xmm2
movaps %xmm0, %xmm1
movsd -0x200(%rbp), %xmm0
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm1, %xmm2
movsd 0xd031b(%rip), %xmm1    # 0x16f068
addsd %xmm1, %xmm2
movsd -0x68(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff422(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2f8(%rax), %xmm1
movslq -0x4(%rbp), %rcx
leaq 0x1ff405(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x318(%rax), %xmm0
movsd -0x30(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x1f8(%rbp)
movsd -0x78(%rbp), %xmm0
callq 0x96f0
movaps %xmm0, %xmm1
movsd -0x1f8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x1f0(%rbp)
movsd -0x78(%rbp), %xmm0
callq 0x9080
movaps %xmm0, %xmm1
movsd -0x1f0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff372(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2e8(%rax), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ff355(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x310(%rax), %xmm1
subsd -0x18(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x18(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ff321(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movss 0x1f4(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x1d0(%rbp)
movsd -0xb8(%rbp), %xmm0
callq 0x96f0
movsd %xmm0, -0x1d8(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x1e8(%rbp)
movsd -0x88(%rbp), %xmm0
callq 0x96f0
movaps %xmm0, %xmm1
movsd -0x1e8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x1e0(%rbp)
movsd -0xb8(%rbp), %xmm0
callq 0x9080
movsd -0x1e0(%rbp), %xmm1
movsd -0x1d8(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x1d0(%rbp), %xmm0
mulsd %xmm3, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x1b0(%rbp)
movsd -0xb8(%rbp), %xmm0
callq 0x9080
movsd %xmm0, -0x1b8(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x1c8(%rbp)
movsd -0x88(%rbp), %xmm0
callq 0x96f0
movaps %xmm0, %xmm1
movsd -0x1c8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x1c0(%rbp)
movsd -0xb8(%rbp), %xmm0
callq 0x96f0
movsd -0x1c0(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x1b0(%rbp), %xmm0
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x1a8(%rbp)
movsd -0x88(%rbp), %xmm0
callq 0x9080
movaps %xmm0, %xmm1
movsd -0x1a8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xa0(%rbp), %xmm0
ucomisd -0xa0(%rbp), %xmm0
jne 0x9f037
jp 0x9f037
jmp 0x9f03c
jmp 0x9f49b
movsd -0xa8(%rbp), %xmm0
ucomisd -0xa8(%rbp), %xmm0
jne 0x9f052
jp 0x9f052
jmp 0x9f057
jmp 0x9f49b
movsd -0xb0(%rbp), %xmm0
ucomisd -0xb0(%rbp), %xmm0
jne 0x9f06d
jp 0x9f06d
jmp 0x9f072
jmp 0x9f49b
leaq 0x2cd137(%rip), %rax    # 0x36c1b0
movsd (%rax), %xmm0
leaq 0x2cd134(%rip), %rax    # 0x36c1b8
movsd (%rax), %xmm1
leaq 0x2cd131(%rip), %rax    # 0x36c1c0
movsd (%rax), %xmm2
callq 0x7fcf0
leaq 0x2cd129(%rip), %rax    # 0x36c1c8
movsd (%rax), %xmm0
subsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
leaq 0x2cd119(%rip), %rax    # 0x36c1d0
movsd (%rax), %xmm0
subsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
leaq 0x2cd109(%rip), %rax    # 0x36c1d8
movsd (%rax), %xmm0
subsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x60(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
movsd -0x68(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
movsd -0x70(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x9280
movsd %xmm0, -0xd0(%rbp)
movl $0xffffffff, -0xd4(%rbp) # imm = 0xFFFFFFFF
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1ff050(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0xffffffff, 0x50(%rax) # imm = 0xFFFFFFFF
movslq -0x4(%rbp), %rcx
leaq 0x1ff034(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cmpl $0x0, 0x50(%rax)
jge 0x9f28e
movsd -0xd0(%rbp), %xmm0
movsd 0xe3ab0(%rip), %xmm1    # 0x182c30
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xd4(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1feff7(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x28(%rax), %xmm0
movsd 0xe3a78(%rip), %xmm1    # 0x182c28
divsd %xmm1, %xmm0
movsd 0xcffd4(%rip), %xmm1    # 0x16f190
mulsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd %xmm0, -0xe0(%rbp)
cvtsi2sdl -0xd4(%rbp), %xmm0
movsd -0xe0(%rbp), %xmm1
movsd 0xcffa8(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movl -0xd4(%rbp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm0
movsd -0xe8(%rbp), %xmm1
movsd 0xcff7b(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0xd0(%rbp), %xmm0
subsd -0xe0(%rbp), %xmm0
movaps 0xd0054(%rip), %xmm1    # 0x16f290
pand %xmm1, %xmm0
movsd -0xd0(%rbp), %xmm1
subsd -0xe8(%rbp), %xmm1
movaps 0xd0039(%rip), %xmm2    # 0x16f290
pand %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x9f270
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %ecx
movslq -0x4(%rbp), %rdx
leaq 0x1fef0f(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x50(%rax)
movslq -0x4(%rbp), %rcx
leaq 0x1feef7(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl 0x50(%rax), %eax
movl %eax, -0xd4(%rbp)
movl $0x0, -0xd8(%rbp)
movl -0xd4(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1feec2(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x28(%rax), %xmm1
movsd 0xe3943(%rip), %xmm2    # 0x182c28
divsd %xmm2, %xmm1
movsd 0xcfe9f(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm1
movsd 0xcfe93(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd 0xd22d3(%rip), %xmm0    # 0x1715e8
mulsd -0xf8(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
cvtsi2sdl -0xd4(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1fee58(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x28(%rax), %xmm1
movsd 0xe38d9(%rip), %xmm2    # 0x182c28
divsd %xmm2, %xmm1
movsd 0xcfe35(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm1
movsd 0xcfe29(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x100(%rbp)
movsd 0xd2269(%rip), %xmm0    # 0x1715e8
mulsd -0x100(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movl -0xd4(%rbp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1fede9(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x28(%rax), %xmm1
movsd 0xe386a(%rip), %xmm2    # 0x182c28
divsd %xmm2, %xmm1
movsd 0xcfdc6(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm1
movsd 0xcfdba(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x108(%rbp)
movsd 0xd21fa(%rip), %xmm0    # 0x1715e8
mulsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
cvtsi2sdl -0xd4(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1fed7f(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x28(%rax), %xmm1
movsd 0xe3800(%rip), %xmm2    # 0x182c28
divsd %xmm2, %xmm1
movsd 0xcfd5c(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm1
movsd 0xcfd50(%rip), %xmm2    # 0x16f190
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd 0xd2190(%rip), %xmm0    # 0x1715e8
mulsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0xd0(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x9f47d
jp 0x9f47d
jmp 0x9f499
movl -0x4(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2cd09a(%rip), %rax    # 0x36c528
orl (%rax), %ecx
leaq 0x2cd091(%rip), %rax    # 0x36c528
movl %ecx, (%rax)
jmp 0x9f49b
movsd -0xd0(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1fece2(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x38(%rax)
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopw %cs:(%rax,%rax)