// File: /workspace/github_cpp_makefile_star2_O3/jamesgrimmett[P]orbital_determination/ex10-2_linear_least_squares.cc
// Function: main
int main() {

  int i, ii;

  // The state vector (alpha and beta)
  std::vector<double> state;
  // The inverse of the information matrix (A^T * A)^-1
  // i.e. the covariance matrix without weighting
  std::vector<std::vector<double> > inv;

  // The observed values of x  
  std::vector<double> xobs = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
  // The observed values of y (the observation matrix, b)
  std::vector<double> yobs = {1.0, 1.0, 2.0, 3.0, 3.0, 4.0, 7.0, 6.0};

  // The two components of the general solution (A^T * A, and A^T * b)
  std::vector<std::vector<double> > ata;
  std::vector<double> atb;

  // The expected values after propagation
  std::vector<double> yexp;
  // Residuals (observed - expected). 
  // Must be initialised to <= RMS for first loop 
  std::vector<double> res(xobs.size(), 0.0);
  // Absolute value of residuals. 
  std::vector<double> absres(xobs.size(), 0.0);
  // Root mean square of residuals.
  // Must be initialised  >= residuals for first loop
  double rms = 0.0;
  // Observational variance
  double obs_var;
  // Standard deviation in alpha, beta
  double stdev_a;
  double stdev_b;
 
  // Complete two iterations of the propagate and fit algorithm
  for ( i = 0; i < 2; i++ ) {
    std::cout << "\n********* Loop #" << i + 1 << " *********" <<std::endl;
    // Remove observed value with residuals outside 2*RMS
    // This will have no affect during the first iteration, if initialised 
    // RMS >= residuals.
    for ( ii = 0; ii < xobs.size(); ii++ ) {
      if (std::abs(res[ii]) > 2.0 * rms) {
        std::cout << "Dropping observation " << ii << ": (" << xobs[ii] << "," << yobs[ii] << ")" << std::endl;
        xobs.erase(xobs.begin() + ii);
        yobs.erase(yobs.begin() + ii);
        res.erase(res.begin() + ii);
        ii--;
      }
    }

    // Fill the matrices for the general solution
    tie(ata, atb) = fill_ata_atb(xobs, yobs);
    // Calculate the covariance matrix (A^T * A)*-1
    inv = inverse(ata);
    // Calculate the state vector
    state = dot_product(inv, atb);

    std::cout << "ATA matrix  " << ata[0][0] << "  " << ata[0][1] << std::endl;
    std::cout << "            " << ata[1][0] << "  " << ata[1][1] << std::endl;
    std::cout << "ATb matrix  " << atb[0] << "  " << atb[1] << std::endl; 
  
    // Propagate the x observations with the state to find the expected y values
    yexp = propagate(state, xobs);

    std::cout << "\nCalculated Y values" << std::endl;
    for ( ii = 0; ii < yexp.size(); ii++ ) {
      std::cout << yexp[ii] << " ";
    }
    std::cout << std::endl;

    // Calculate the residuals
    res = residuals(yobs, yexp);
    std::transform(res.begin(), res.end(), absres.begin(),
                         static_cast<float (*)(float)>(&std::abs));

    std::cout << "\nResidual values" << std::endl;
    for ( ii = 0; ii < res.size(); ii++ ) {
      std::cout << absres[ii] << " ";
    }
    std::cout << std::endl;

    // Calculate the RMS of the residuals
    rms = root_mean_sq(res);

    std::cout << "\nRMS: " << rms << std::endl;

    // Standard deviation in alpha and beta are taken from the covariance matrix
    stdev_a = std::sqrt(inv[0][0]);
    stdev_b = std::sqrt(inv[1][1]);

    // Without a weighting matrix, observational variance is estimated as:
    obs_var = std::sqrt(pow(rms, 2.0) * res.size() / (res.size() - 1.0)); 

    std::cout << "\nState:" << std::endl;
    std::cout << "alpha " << state[0] << " +/- " << obs_var * stdev_a << std::endl;
    std::cout << "beta  " << state[1] << " +/- " << obs_var * stdev_b << std::endl;
 
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
xorl %eax, %eax
movq %rax, 0x70(%rsp)
movq %rax, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movups 0x2dc5(%rip), %xmm0     # 0x40d8
leaq 0xc0(%rsp), %rsi
movaps %xmm0, 0x30(%rsi)
movups 0x2da2(%rip), %xmm0     # 0x40c8
movaps %xmm0, 0x20(%rsi)
movups 0x2d87(%rip), %xmm0     # 0x40b8
movaps %xmm0, 0x10(%rsi)
movupd 0x2d6b(%rip), %xmm0     # 0x40a8
movapd %xmm0, (%rsi)
leaq 0x28(%rsp), %rdi
leaq 0x78(%rsp), %rcx
movl $0x8, %edx
callq 0x29dc
movups 0x2dbc(%rip), %xmm0     # 0x4118
leaq 0xc0(%rsp), %rsi
movaps %xmm0, 0x30(%rsi)
movups 0x2d99(%rip), %xmm0     # 0x4108
movaps %xmm0, 0x20(%rsi)
movups 0x2d7e(%rip), %xmm0     # 0x40f8
movaps %xmm0, 0x10(%rsi)
movupd 0x2d62(%rip), %xmm0     # 0x40e8
movapd %xmm0, (%rsi)
leaq 0x78(%rsp), %rdi
leaq 0x120(%rsp), %rcx
movl $0x8, %edx
callq 0x29dc
xorl %eax, %eax
movq %rax, 0x130(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x120(%rsp)
movq %rax, 0x110(%rsp)
movapd %xmm0, 0x100(%rsp)
movq %rax, 0x50(%rsp)
movq 0x30(%rsp), %rsi
subq 0x28(%rsp), %rsi
movapd %xmm0, 0x40(%rsp)
sarq $0x3, %rsi
leaq 0xc0(%rsp), %rdx
movq %rax, (%rdx)
movq %rsp, %rdi
leaq 0x170(%rsp), %rcx
callq 0x2a22
movq 0x30(%rsp), %rsi
subq 0x28(%rsp), %rsi
sarq $0x3, %rsi
leaq 0xc0(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x170(%rsp), %rdi
leaq 0x140(%rsp), %rcx
callq 0x2a22
movq $0x0, 0x98(%rsp)
movq 0x4b96(%rip), %r12      # 0x5fd8
leaq 0x230(%rsp), %r14
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x2d1e(%rip), %rbx      # 0x4179
cmpl $0x2, 0x98(%rsp)
je 0x2000
movl $0x11, %edx
movq %r12, %rdi
leaq 0x2cb0(%rip), %rsi      # 0x4128
callq 0x1100
movq 0x98(%rsp), %rsi
incl %esi
movq %r12, %rdi
movq %rsi, 0x98(%rsp)
callq 0x1160
movq %rax, %rbp
movl $0xa, %edx
movq %rax, %rdi
leaq 0x2c91(%rip), %rsi      # 0x413a
callq 0x1100
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq %rax, %rcx
je 0x168b
movsd 0x20(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movq (%rsp), %rdx
movsd (%rdx,%r13,8), %xmm0
andpd 0x2b00(%rip), %xmm0     # 0x4010
ucomisd 0x20(%rsp), %xmm0
jbe 0x1673
movl $0x15, %edx
movq %r12, %rdi
leaq 0x2c1a(%rip), %rsi      # 0x4145
callq 0x1100
movq %r12, %rdi
movl %ebp, %esi
callq 0x1160
movq %rax, %r15
movl $0x3, %edx
movq %rax, %rdi
leaq 0x2c0f(%rip), %rsi      # 0x415b
callq 0x1100
movq 0x28(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2be9(%rip), %rsi      # 0x415f
callq 0x1100
movq 0x78(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2c60(%rip), %rsi      # 0x4200
callq 0x1100
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rdx
leaq (%rax,%r13,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x15f4
leaq (%rax,%r13,8), %rdi
subq %rsi, %rdx
callq 0x1140
movq 0x30(%rsp), %rdx
addq $-0x8, %rdx
movq %rdx, 0x30(%rsp)
movq 0x78(%rsp), %rax
movq 0x80(%rsp), %rdx
leaq (%rax,%r13,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x162b
leaq (%rax,%r13,8), %rdi
subq %rsi, %rdx
callq 0x1140
movq 0x80(%rsp), %rdx
addq $-0x8, %rdx
movq %rdx, 0x80(%rsp)
movq (%rsp), %rax
movq 0x8(%rsp), %rdx
leaq (%rax,%r13,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x165e
leaq (%rax,%r13,8), %rdi
subq %rsi, %rdx
callq 0x1140
movq 0x8(%rsp), %rdx
addq $-0x8, %rdx
movq %rdx, 0x8(%rsp)
decl %ebp
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
incl %ebp
movslq %ebp, %r13
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r13, %rdx
ja 0x14fe
leaq 0x1d0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x2b44
movq %r14, %rdi
leaq 0x78(%rsp), %rsi
callq 0x2b44
leaq 0x120(%rsp), %r13
leaq 0xc0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x1d0(%rsp), %rsi
movq %r14, %rdx
callq 0x231e
leaq 0x100(%rsp), %rax
movq %rax, 0x140(%rsp)
movq %r13, 0x148(%rsp)
leaq 0x140(%rsp), %rdi
movq %rbp, %rsi
callq 0x2f40
leaq 0xd8(%rsp), %rdi
callq 0x2c5e
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x171f
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x230(%rsp), %rdi
testq %rdi, %rdi
je 0x173c
movq 0x240(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x1759
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x260(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2bc4
leaq 0x140(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2534
movq 0xb0(%rsp), %rax
movapd 0x140(%rsp), %xmm0
movq 0x150(%rsp), %rcx
movq %rcx, 0xb0(%rsp)
movaps 0xa0(%rsp), %xmm1
movapd %xmm0, 0xa0(%rsp)
movaps %xmm1, 0xc0(%rsp)
movq %rax, 0xd0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x140(%rsp)
movq $0x0, 0x150(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x2c5e
movq %r15, %rdi
callq 0x2c5e
movq %rbp, %rdi
callq 0x2c5e
leaq 0x248(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2bc4
leaq 0x218(%rsp), %r15
movq %r15, %rdi
leaq 0x100(%rsp), %rsi
callq 0x2b44
leaq 0xc0(%rsp), %rdi
leaq 0x248(%rsp), %rsi
movq %r15, %rdx
callq 0x267b
movq 0x60(%rsp), %rdi
movq 0x70(%rsp), %rsi
movaps 0xc0(%rsp), %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x70(%rsp)
testq %rdi, %rdi
je 0x186d
subq %rdi, %rsi
callq 0x10f0
movq 0x218(%rsp), %rdi
testq %rdi, %rdi
je 0x188a
movq 0x228(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x248(%rsp), %rdi
callq 0x2c5e
movl $0xc, %edx
movq %r12, %rdi
leaq 0x28bb(%rip), %rsi      # 0x4161
callq 0x1100
movq 0x120(%rsp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
movq %r12, %rdi
callq 0x1130
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
leaq 0x28a4(%rip), %rsi      # 0x4178
callq 0x1100
movq 0x120(%rsp), %rax
movq (%rax), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movl $0xc, %edx
movq %r12, %rdi
leaq 0x2844(%rip), %rsi      # 0x416e
callq 0x1100
movq 0x120(%rsp), %rax
movq 0x18(%rax), %rax
movsd (%rax), %xmm0
movq %r12, %rdi
callq 0x1130
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
leaq 0x281f(%rip), %rsi      # 0x4178
callq 0x1100
movq 0x120(%rsp), %rax
movq 0x18(%rax), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movl $0xc, %edx
movq %r12, %rdi
leaq 0x27cb(%rip), %rsi      # 0x417b
callq 0x1100
movq 0x100(%rsp), %rax
movsd (%rax), %xmm0
movq %r12, %rdi
callq 0x1130
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
leaq 0x279d(%rip), %rsi      # 0x4178
callq 0x1100
movq 0x100(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
leaq 0x1b8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2b44
leaq 0x200(%rsp), %r15
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x2b44
leaq 0xc0(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
movq %r15, %rdx
callq 0x27e5
movq 0x40(%rsp), %rdi
movq 0x50(%rsp), %rsi
movapd 0xc0(%rsp), %xmm0
movapd %xmm0, 0x40(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x50(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xc0(%rsp)
movq $0x0, 0xd0(%rsp)
testq %rdi, %rdi
je 0x1ac7
subq %rdi, %rsi
callq 0x10f0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x1ac7
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x200(%rsp), %rdi
testq %rdi, %rdi
je 0x1ae4
movq 0x210(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x1b01
movq 0x1c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movl $0x14, %edx
movq %r12, %rdi
leaq 0x2678(%rip), %rsi      # 0x4188
callq 0x1100
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq 0x40(%rsp), %rax
cmpq %rax, 0x48(%rsp)
je 0x1b83
xorl %r15d, %r15d
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
callq 0x1130
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1100
incq %r15
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x1b4c
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
leaq 0x1a0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x2b44
leaq 0x1e8(%rsp), %r15
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
callq 0x2b44
leaq 0xc0(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
movq %r15, %rdx
callq 0x2860
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movaps 0xc0(%rsp), %xmm0
movaps %xmm0, (%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movq $0x0, 0xd0(%rsp)
testq %rdi, %rdi
je 0x1c4d
subq %rdi, %rsi
callq 0x10f0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x1c4d
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1e8(%rsp), %rdi
testq %rdi, %rdi
je 0x1c6a
movq 0x1f8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0x1c87
movq 0x1b0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
cmpq %rcx, %rax
movaps 0x2386(%rip), %xmm1     # 0x4020
je 0x1cc3
movq 0x170(%rsp), %rdx
xorps %xmm0, %xmm0
cvtsd2ss (%rax), %xmm0
andps %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rdx)
addq $0x8, %rax
addq $0x8, %rdx
cmpq %rcx, %rax
jne 0x1ca4
movl $0x10, %edx
movq %r12, %rdi
leaq 0x24cb(%rip), %rsi      # 0x419d
callq 0x1100
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq 0x8(%rsp), %rax
cmpq (%rsp), %rax
je 0x1d48
xorl %r15d, %r15d
movq 0x170(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
callq 0x1130
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1100
incq %r15
movq 0x8(%rsp), %rax
subq (%rsp), %rax
sarq $0x3, %rax
cmpq %r15, %rax
ja 0x1d0d
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
leaq 0x188(%rsp), %rdi
movq %rsp, %rsi
callq 0x2b44
leaq 0x188(%rsp), %rdi
callq 0x28d5
movsd %xmm0, 0x20(%rsp)
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x1db0
movq 0x198(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movl $0x6, %edx
movq %r12, %rdi
leaq 0x23ef(%rip), %rsi      # 0x41ae
callq 0x1100
movq %r12, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x1130
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq 0xa0(%rsp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
ucomisd 0x2285(%rip), %xmm0     # 0x4098
jb 0x1e1b
sqrtsd %xmm0, %xmm0
jmp 0x1e20
callq 0x10b0
movsd %xmm0, 0x168(%rsp)
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rax
movsd 0x8(%rax), %xmm0
ucomisd 0x2256(%rip), %xmm0     # 0x4098
jb 0x1e4a
sqrtsd %xmm0, %xmm0
jmp 0x1e4f
callq 0x10b0
movsd %xmm0, 0x160(%rsp)
movsd 0x20(%rsp), %xmm0
mulsd %xmm0, %xmm0
movq 0x8(%rsp), %rax
subq (%rsp), %rax
sarq $0x3, %rax
movq %rax, %xmm1
punpckldq 0x21b4(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x21bc(%rip), %xmm1     # 0x4040
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd %xmm2, %xmm0
addsd 0x21f4(%rip), %xmm2     # 0x4090
divsd %xmm2, %xmm0
ucomisd 0x21f0(%rip), %xmm0     # 0x4098
jb 0x1eb0
sqrtsd %xmm0, %xmm0
jmp 0x1eb5
callq 0x10b0
movsd %xmm0, 0x90(%rsp)
movl $0x7, %edx
movq %r12, %rdi
leaq 0x22e8(%rip), %rsi      # 0x41b5
callq 0x1100
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movl $0x6, %edx
movq %r12, %rdi
leaq 0x22b4(%rip), %rsi      # 0x41bd
callq 0x1100
movq 0x60(%rsp), %rax
movsd (%rax), %xmm0
movq %r12, %rdi
callq 0x1130
movq %rax, %r15
movl $0x5, %edx
movq %rax, %rdi
leaq 0x2293(%rip), %rsi      # 0x41c4
callq 0x1100
movsd 0x168(%rsp), %xmm0
mulsd 0x90(%rsp), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movl $0x6, %edx
movq %r12, %rdi
leaq 0x2241(%rip), %rsi      # 0x41ca
callq 0x1100
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq %r12, %rdi
callq 0x1130
movq %rax, %r15
movl $0x5, %edx
movq %rax, %rdi
leaq 0x2212(%rip), %rsi      # 0x41c4
callq 0x1100
movsd 0x160(%rsp), %xmm0
mulsd 0x90(%rsp), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
jmp 0x145b
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x201d
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2033
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x204a
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x2067
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x120(%rsp), %rdi
callq 0x2c5e
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x208e
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x20a5
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0xa0(%rsp), %rdi
callq 0x2c5e
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x20c9
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
xorl %eax, %eax
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x226a
movq %rax, %rbx
jmp 0x2280
movq %rax, %rbx
jmp 0x22db
movq %rax, %rbx
jmp 0x22f2
movq %rax, %rbx
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x224d
movq 0x198(%rsp), %rsi
jmp 0x221e
jmp 0x224a
movq %rax, %rbx
jmp 0x2148
movq %rax, %rbx
movq 0x1e8(%rsp), %rdi
testq %rdi, %rdi
je 0x2148
movq 0x1f8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0x224d
movq 0x1b0(%rsp), %rsi
jmp 0x221e
jmp 0x224a
movq %rax, %rbx
jmp 0x2190
movq %rax, %rbx
movq 0x200(%rsp), %rdi
testq %rdi, %rdi
je 0x2190
movq 0x210(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x224d
movq 0x1c8(%rsp), %rsi
jmp 0x221e
jmp 0x224a
movq %rax, %rbx
jmp 0x21da
jmp 0x224a
movq %rax, %rbx
movq 0x218(%rsp), %rdi
testq %rdi, %rdi
je 0x21da
movq 0x228(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x248(%rsp), %rdi
jmp 0x223d
movq %rax, %rbx
jmp 0x2209
movq %rax, %rbx
movq 0x230(%rsp), %rdi
testq %rdi, %rdi
je 0x2209
movq 0x240(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x224d
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
jmp 0x224d
movq %rax, %rdi
callq 0x2e21
jmp 0x224a
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x2c5e
jmp 0x224d
jmp 0x224a
jmp 0x224a
jmp 0x224a
movq %rax, %rbx
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x226a
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2280
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2297
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x22b4
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x120(%rsp), %rdi
callq 0x2c5e
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x22db
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x22f2
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0xa0(%rsp), %rdi
callq 0x2c5e
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x2316
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq %rbx, %rdi
callq 0x1170