// File: /workspace/github_cpp_makefile_star2_O1/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, 0xe0(%rsp)
xorl %eax, %eax
movq %rax, 0xf0(%rsp)
movq %rax, 0x120(%rsp)
movaps %xmm0, 0x110(%rsp)
movups 0x2d6f(%rip), %xmm0     # 0x40b8
leaq 0x60(%rsp), %rsi
movaps %xmm0, 0x30(%rsi)
movups 0x2d4f(%rip), %xmm0     # 0x40a8
movaps %xmm0, 0x20(%rsi)
movups 0x2d34(%rip), %xmm0     # 0x4098
movaps %xmm0, 0x10(%rsi)
movupd 0x2d18(%rip), %xmm0     # 0x4088
movapd %xmm0, (%rsi)
leaq 0x28(%rsp), %rdi
leaq 0xa0(%rsp), %rcx
movl $0x8, %edx
callq 0x2a94
movups 0x2d66(%rip), %xmm0     # 0x40f8
leaq 0x60(%rsp), %rsi
movaps %xmm0, 0x30(%rsi)
movups 0x2d46(%rip), %xmm0     # 0x40e8
movaps %xmm0, 0x20(%rsi)
movups 0x2d2b(%rip), %xmm0     # 0x40d8
movaps %xmm0, 0x10(%rsi)
movupd 0x2d0f(%rip), %xmm0     # 0x40c8
movapd %xmm0, (%rsi)
leaq 0x128(%rsp), %rdi
leaq 0xa0(%rsp), %rcx
movl $0x8, %edx
callq 0x2a94
xorl %eax, %eax
movq %rax, 0xd0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xc0(%rsp)
movq %rax, 0x150(%rsp)
movapd %xmm0, 0x140(%rsp)
movq %rax, 0x50(%rsp)
movq 0x30(%rsp), %rsi
subq 0x28(%rsp), %rsi
movapd %xmm0, 0x40(%rsp)
sarq $0x3, %rsi
leaq 0x60(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x8(%rsp), %rdi
leaq 0xa0(%rsp), %rcx
callq 0x2ada
movq 0x30(%rsp), %rsi
subq 0x28(%rsp), %rsi
sarq $0x3, %rsi
leaq 0x60(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x170(%rsp), %rdi
leaq 0xa0(%rsp), %rcx
callq 0x2ada
movq $0x0, 0x108(%rsp)
movq 0x4b64(%rip), %r15      # 0x5fd8
leaq 0x230(%rsp), %r12
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x2ccc(%rip), %r13      # 0x4159
cmpl $0x2, 0x108(%rsp)
je 0x2078
movl $0x11, %edx
movq %r15, %rdi
leaq 0x2c5e(%rip), %rsi      # 0x4108
callq 0x1100
movq 0x108(%rsp), %rsi
incl %esi
movq %r15, %rdi
movq %rsi, 0x108(%rsp)
callq 0x1160
movq %rax, %r14
movl $0xa, %edx
movq %rax, %rdi
leaq 0x2c3f(%rip), %rsi      # 0x411a
callq 0x1100
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq %r12, %rbx
movq 0x30(%rsp), %rax
cmpq 0x28(%rsp), %rax
je 0x16a8
movsd 0x20(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
andpd 0x2acd(%rip), %xmm0     # 0x4010
ucomisd 0x20(%rsp), %xmm0
jbe 0x168b
movl $0x15, %edx
movq %r15, %rdi
leaq 0x2bc7(%rip), %rsi      # 0x4125
callq 0x1100
movq %r15, %rdi
movl %r14d, %esi
callq 0x1160
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
leaq 0x2bbb(%rip), %rsi      # 0x413b
callq 0x1100
movq 0x28(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
movq %rbp, %rdi
callq 0x1130
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2b95(%rip), %rsi      # 0x413f
callq 0x1100
movq 0x128(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
movq %rbp, %rdi
callq 0x1130
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2c09(%rip), %rsi      # 0x41e0
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), %rdx
leaq (%rax,%r12,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x1627
leaq (%rax,%r12,8), %rdi
subq %rsi, %rdx
callq 0x1140
addq $-0x8, 0x30(%rsp)
movq 0x128(%rsp), %rax
movq 0x130(%rsp), %rdx
leaq (%rax,%r12,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x1656
leaq (%rax,%r12,8), %rdi
subq %rsi, %rdx
callq 0x1140
addq $-0x8, 0x130(%rsp)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
leaq (%rax,%r12,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x1682
leaq (%rax,%r12,8), %rdi
subq %rsi, %rdx
callq 0x1140
addq $-0x8, 0x10(%rsp)
decl %r14d
incl %r14d
movslq %r14d, %r12
movq 0x30(%rsp), %rax
subq 0x28(%rsp), %rax
sarq $0x3, %rax
cmpq %r12, %rax
ja 0x1530
movq %rbx, %r12
movq %rbx, %rdi
leaq 0x28(%rsp), %rbx
movq %rbx, %rsi
callq 0x2b5c
leaq 0x218(%rsp), %r14
movq %r14, %rdi
leaq 0x128(%rsp), %rsi
callq 0x2b5c
leaq 0x60(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x239f
xorpd %xmm0, %xmm0
movapd %xmm0, 0xa0(%rsp)
movaps 0xc0(%rsp), %xmm0
movq 0xd0(%rsp), %rax
movups 0x78(%rsp), %xmm1
movaps %xmm1, 0xc0(%rsp)
movq 0x88(%rsp), %rcx
movq %rcx, 0xd0(%rsp)
movaps 0xa0(%rsp), %xmm1
movaps %xmm0, 0xa0(%rsp)
movq %rax, 0xb0(%rsp)
movups %xmm1, 0x78(%rsp)
movq $0x0, 0x88(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x2c76
leaq 0x140(%rsp), %rdi
movq %rbp, %rsi
callq 0x2ff6
leaq 0x78(%rsp), %rdi
callq 0x2c76
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1787
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x218(%rsp), %rdi
testq %rdi, %rdi
je 0x17a4
movq 0x228(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x230(%rsp), %rdi
testq %rdi, %rdi
je 0x17c1
movq 0x240(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x260(%rsp), %rbp
movq %rbp, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x2bdc
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x25cd
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps 0x110(%rsp), %xmm0
movq 0x120(%rsp), %rax
movups 0xa0(%rsp), %xmm1
movaps %xmm1, 0x110(%rsp)
movq 0xb0(%rsp), %rcx
movq %rcx, 0x120(%rsp)
movaps 0x60(%rsp), %xmm1
movaps %xmm0, 0x60(%rsp)
movq %rax, 0x70(%rsp)
movups %xmm1, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x2c76
movq %r14, %rdi
callq 0x2c76
movq %rbp, %rdi
callq 0x2c76
leaq 0x248(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x2bdc
leaq 0x200(%rsp), %r14
movq %r14, %rdi
leaq 0x140(%rsp), %rsi
callq 0x2b5c
leaq 0x60(%rsp), %rdi
leaq 0x248(%rsp), %rsi
movq %r14, %rdx
callq 0x2714
movq 0xe0(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movq 0x60(%rsp), %rax
movq %rax, 0xe0(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, 0xe8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %rdi, %rdi
je 0x18eb
subq %rdi, %rsi
callq 0x10f0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1902
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x200(%rsp), %rdi
testq %rdi, %rdi
je 0x191f
movq 0x210(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x248(%rsp), %rdi
callq 0x2c76
movl $0xc, %edx
movq %r15, %rdi
leaq 0x2806(%rip), %rsi      # 0x4141
callq 0x1100
movq 0xc0(%rsp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
leaq 0x27ef(%rip), %rsi      # 0x4158
callq 0x1100
movq 0xc0(%rsp), %rax
movq (%rax), %rax
movsd 0x8(%rax), %xmm0
movq %r14, %rdi
callq 0x1130
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movl $0xc, %edx
movq %r15, %rdi
leaq 0x278f(%rip), %rsi      # 0x414e
callq 0x1100
movq 0xc0(%rsp), %rax
movq 0x18(%rax), %rax
movsd (%rax), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
leaq 0x276a(%rip), %rsi      # 0x4158
callq 0x1100
movq 0xc0(%rsp), %rax
movq 0x18(%rax), %rax
movsd 0x8(%rax), %xmm0
movq %r14, %rdi
callq 0x1130
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movl $0xc, %edx
movq %r15, %rdi
leaq 0x2716(%rip), %rsi      # 0x415b
callq 0x1100
movq 0x140(%rsp), %rax
movsd (%rax), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
leaq 0x26e8(%rip), %rsi      # 0x4158
callq 0x1100
movq 0x140(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq %r14, %rdi
callq 0x1130
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
leaq 0x1b8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2b5c
leaq 0x1e8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2b5c
leaq 0x60(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
movq %r14, %rdx
callq 0x289e
movq 0x40(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movupd 0x68(%rsp), %xmm0
movupd %xmm0, 0x48(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %rdi, %rdi
je 0x1b31
subq %rdi, %rsi
callq 0x10f0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1b48
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1e8(%rsp), %rdi
testq %rdi, %rdi
je 0x1b65
movq 0x1f8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x1b82
movq 0x1c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movl $0x14, %edx
movq %r15, %rdi
leaq 0x25d7(%rip), %rsi      # 0x4168
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 0x40(%rsp), %rax
cmpq %rax, 0x48(%rsp)
je 0x1c03
xorl %r14d, %r14d
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
callq 0x1130
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x1100
incq %r14
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
ja 0x1bcc
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
leaq 0x1a0(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x2b5c
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x2b5c
leaq 0x60(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
movq %rbx, %rdx
callq 0x2919
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x60(%rsp), %rax
movq %rax, 0x8(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %rdi, %rdi
je 0x1ca5
subq %rdi, %rsi
callq 0x10f0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1cbc
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x1cd9
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0x1cf6
movq 0x1b0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpq %rcx, %rax
movaps 0x2316(%rip), %xmm1     # 0x4020
je 0x1d33
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 0x1d14
movl $0x10, %edx
movq %r15, %rdi
leaq 0x243b(%rip), %rsi      # 0x417d
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 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rax
je 0x1db9
xorl %r14d, %r14d
movq 0x170(%rsp), %rax
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
callq 0x1130
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x1100
incq %r14
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
sarq $0x3, %rax
cmpq %r14, %rax
ja 0x1d7d
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
leaq 0x188(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2b5c
leaq 0x188(%rsp), %rdi
callq 0x298e
movsd %xmm0, 0x20(%rsp)
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x1e22
movq 0x198(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movl $0x6, %edx
movq %r15, %rdi
leaq 0x235d(%rip), %rsi      # 0x418e
callq 0x1100
movq %r15, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x1130
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movq 0x110(%rsp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
ucomisd 0x21f3(%rip), %xmm0     # 0x4078
jb 0x1e8d
sqrtsd %xmm0, %xmm0
jmp 0x1e92
callq 0x10b0
movsd %xmm0, 0x168(%rsp)
movq 0x110(%rsp), %rax
movq 0x18(%rax), %rax
movsd 0x8(%rax), %xmm0
ucomisd 0x21c4(%rip), %xmm0     # 0x4078
jb 0x1ebc
sqrtsd %xmm0, %xmm0
jmp 0x1ec1
callq 0x10b0
movsd %xmm0, 0x160(%rsp)
movsd 0x20(%rsp), %xmm0
mulsd %xmm0, %xmm0
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
sarq $0x3, %rax
movq %rax, %xmm1
punpckldq 0x2141(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2149(%rip), %xmm1     # 0x4040
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd %xmm2, %xmm0
addsd 0x2161(%rip), %xmm2     # 0x4070
divsd %xmm2, %xmm0
ucomisd 0x215d(%rip), %xmm0     # 0x4078
jb 0x1f23
sqrtsd %xmm0, %xmm0
jmp 0x1f28
callq 0x10b0
movsd %xmm0, 0x100(%rsp)
movl $0x7, %edx
movq %r15, %rdi
leaq 0x2255(%rip), %rsi      # 0x4195
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
movl $0x6, %edx
movq %r15, %rdi
leaq 0x2222(%rip), %rsi      # 0x419d
callq 0x1100
movq 0xe0(%rsp), %rax
movsd (%rax), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r14
movl $0x5, %edx
movq %rax, %rdi
leaq 0x21fe(%rip), %rsi      # 0x41a4
callq 0x1100
movsd 0x168(%rsp), %xmm0
mulsd 0x100(%rsp), %xmm0
movq %r14, %rdi
callq 0x1130
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
movl $0x6, %edx
movq %r15, %rdi
leaq 0x21ac(%rip), %rsi      # 0x41aa
callq 0x1100
movq 0xe0(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
callq 0x1130
movq %rax, %r14
movl $0x5, %edx
movq %rax, %rdi
leaq 0x217a(%rip), %rsi      # 0x41a4
callq 0x1100
movsd 0x160(%rsp), %xmm0
mulsd 0x100(%rsp), %xmm0
movq %r14, %rdi
callq 0x1130
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1090
jmp 0x148d
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x2095
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x20ac
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x20c3
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x20e0
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0xc0(%rsp), %rdi
callq 0x2c76
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x210a
movq 0x138(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2121
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x110(%rsp), %rdi
callq 0x2c76
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x214b
movq 0xf0(%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 0x22e1
movq %rax, %rbx
jmp 0x22f8
movq %rax, %rbx
jmp 0x2356
movq %rax, %rbx
jmp 0x236d
movq %rax, %rbx
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x22c4
movq 0x198(%rsp), %rsi
jmp 0x229d
jmp 0x22c1
movq %rax, %rbx
jmp 0x21ca
movq %rax, %rbx
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x21ca
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0x22c4
movq 0x1b0(%rsp), %rsi
jmp 0x229d
jmp 0x22c1
movq %rax, %rbx
jmp 0x2212
movq %rax, %rbx
movq 0x1e8(%rsp), %rdi
testq %rdi, %rdi
je 0x2212
movq 0x1f8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x22c4
movq 0x1c8(%rsp), %rsi
jmp 0x229d
jmp 0x22c1
movq %rax, %rbx
jmp 0x2257
movq %rax, %rbx
movq 0x200(%rsp), %rdi
testq %rdi, %rdi
je 0x2257
movq 0x210(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x248(%rsp), %rdi
jmp 0x22b4
jmp 0x22c1
movq %rax, %rbx
jmp 0x2288
movq %rax, %rbx
movq 0x218(%rsp), %rdi
testq %rdi, %rdi
je 0x2288
movq 0x228(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x230(%rsp), %rdi
testq %rdi, %rdi
je 0x22c4
movq 0x240(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
jmp 0x22c4
jmp 0x22c1
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x2c76
jmp 0x22c4
jmp 0x22c1
jmp 0x22c1
jmp 0x22c1
movq %rax, %rbx
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x22e1
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x22f8
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x230f
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x232c
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0xc0(%rsp), %rdi
callq 0x2c76
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x2356
movq 0x138(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x236d
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
leaq 0x110(%rsp), %rdi
callq 0x2c76
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x2397
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x10f0
movq %rbx, %rdi
callq 0x1170