// File: tbjohns[P]BlitzL1/src/solver.cpp
// Function: BlitzL1::Solver::run_prox_newton_iteration(double*, double&, double, BlitzL1::Loss const*, BlitzL1::Dataset const*)
value_t Solver::run_prox_newton_iteration(value_t *x,
                                            value_t &intercept,
                                            value_t lambda,
                                            const Loss *loss_function,
                                            const Dataset *data)
  {
    // Runs one iteration of subproblem solver
    // Returns theta_scale, which is the largest scaler value <= 1
    // for which scaler*theta is feasible for the subproblem

    // Initialize iteration:
    size_t n = data->get_n();
    vector<value_t> Delta_x(working_set_size, 0.0);
    vector<value_t> A_Delta_x(n, 0.0);
    value_t Delta_intercept = 0.0;

    // Permutation vector for shuffling indices:
    vector<size_t> rand_permutation;
    rand_permutation.reserve(working_set_size);
    for (size_t ind = 0; ind < working_set_size; ++ind)
      rand_permutation.push_back(ind);

    // Set up hessian values:
    vector<value_t> H;
    loss_function->compute_H(H, theta, Ax, data);
    vector<value_t> hess_cache(working_set_size, 0.0);
    for (size_t ind = 0; ind < working_set_size; ++ind)
    {
      size_t j = prioritized_features[ind];
      hess_cache[ind] = data->get_column(j)->h_norm_sq(H);
    }

    // Cache values for updating intercept:
    value_t sum_theta = sum_vector(theta);
    value_t sum_H = sum_vector(H);

    // Finish set up for approximate newton step:
    value_t prox_newton_epsilon = 0.0;
    int max_cd_itr = MAX_PROX_NEWTON_CD_ITR;
    if (first_prox_newton_iteration)
    {
      max_cd_itr = MIN_PROX_NEWTON_CD_ITR;
      first_prox_newton_iteration = false;

      // Set up gradient values:
      prox_newton_grad_cache.resize(working_set_size);
      for (size_t ind = 0; ind < working_set_size; ++ind)
      {
        size_t j = prioritized_features[ind];
        prox_newton_grad_cache[ind] = data->get_column(j)->inner_product(theta);
      }
    }
    else
    {
      prox_newton_epsilon = PROX_NEWTON_EPSILON_RATIO * prox_newton_grad_diff;
    }

    // std::random_device rd;
    std::mt19937 g(0);

    // Approximately solve for newton direction:
    for (int cd_itr = 0; cd_itr < max_cd_itr; ++cd_itr)
    {

      // Shuffle indices:
      shuffle(rand_permutation.begin(), rand_permutation.end(), g);
      for (size_t rp_ind = 0; rp_ind < working_set_size; ++rp_ind)
      {
        size_t new_index = rand_permutation[rp_ind];
        swap(prioritized_features[rp_ind], prioritized_features[new_index]);
        swap(Delta_x[rp_ind], Delta_x[new_index]);
        swap(prox_newton_grad_cache[rp_ind], prox_newton_grad_cache[new_index]);
        swap(hess_cache[rp_ind], hess_cache[new_index]);
      }

      // Compute newton direction using coordinate descent:
      value_t sum_sq_hess_diff = 0.0;
      for (size_t ind = 0; ind < working_set_size; ++ind)
      {
        size_t j = prioritized_features[ind];
        const Column *col = data->get_column(j);

        // Compute hessian and gradient for coordinate j:
        value_t hess = hess_cache[ind];
        if (hess <= 0.0)
          continue;

        value_t grad = prox_newton_grad_cache[ind] + col->weighted_inner_product(A_Delta_x, H);

        // Apply coordinate descent update:
        value_t old_value = x[j] + Delta_x[ind];
        value_t proposal = old_value - grad / hess;
        value_t new_value = soft_threshold(proposal, lambda / hess);
        value_t diff = new_value - old_value;

        if (diff == 0.0)
          continue;

        Delta_x[ind] = new_value - x[j];
        col->add_multiple(A_Delta_x, diff);
        sum_sq_hess_diff += diff * diff * hess * hess;
      }

      // Update intercept:
      if (use_intercept)
      {
        value_t ip = inner_product(H, A_Delta_x);
        value_t diff = -(ip + sum_theta) / sum_H;
        Delta_intercept += diff;
        add_scaler(A_Delta_x, diff);
      }

      if (sum_sq_hess_diff < prox_newton_epsilon && cd_itr + 1 >= MIN_PROX_NEWTON_CD_ITR)
      {
        break;
      }
    }

    // Apply update with backtracking:
    value_t t = 1.0;
    value_t last_t = 0.0;
    for (int backtrack_itr = 0; backtrack_itr < MAX_BACKTRACK_ITR; ++backtrack_itr)
    {
      value_t diff_t = t - last_t;

      intercept += diff_t * Delta_intercept;
      value_t subgrad_t = 0.0;

      for (size_t ind = 0; ind < working_set_size; ++ind)
      {
        size_t j = prioritized_features[ind];
        x[j] += diff_t * Delta_x[ind];
        if (x[j] < 0)
          subgrad_t -= lambda * Delta_x[ind];
        else if (x[j] > 0)
          subgrad_t += lambda * Delta_x[ind];
        else
          subgrad_t -= lambda * fabs(Delta_x[ind]);
      }
      for (size_t i = 0; i < n; ++i)
      {
        Ax[i] += diff_t * A_Delta_x[i];
      }

      loss_function->compute_dual_points(Ax, theta, aux_dual, data);
      subgrad_t += inner_product(A_Delta_x, theta);

      if (subgrad_t < 0)
      {
        break;
      }
      else
      {
        last_t = t;
        t *= 0.5;
      }
    }

    // Update intercept exactly:
    value_t delta_intercept = update_intercept(intercept, loss_function, data);

    // Cache gradients for next iteration:
    if (t != 1.0)
    {
      for (size_t i = 0; i < A_Delta_x.size(); ++i)
      {
        A_Delta_x[i] = t * A_Delta_x[i] + delta_intercept;
      }
    }
    for (size_t ind = 0; ind < working_set_size; ++ind)
    {
      size_t j = prioritized_features[ind];
      const Column *col = data->get_column(j);
      value_t actual_grad = col->inner_product(theta);
      value_t approximate_grad = prox_newton_grad_cache[ind] + col->weighted_inner_product(A_Delta_x, H);

      prox_newton_grad_cache[ind] = actual_grad;
      value_t diff = actual_grad - approximate_grad;
      prox_newton_grad_diff += diff * diff;
    }

    // Compute theta_scale return value:
    value_t max_grad_working_set = max_abs(prox_newton_grad_cache);
    if (max_grad_working_set > lambda)
      return lambda / max_grad_working_set;
    else
      return 1.0;
  }

// Assembly:
subq $0x1748, %rsp           # imm = 0x1748
movq %rdi, 0x1738(%rsp)
movq %rsi, 0x1730(%rsp)
movq %rdx, 0x1728(%rsp)
movsd %xmm0, 0x1720(%rsp)
movq %rcx, 0x1718(%rsp)
movq %r8, 0x1710(%rsp)
movq 0x1738(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x1710(%rsp), %rdi
callq 0xe7f0
movq %rax, %rcx
movq 0x148(%rsp), %rax
movq %rcx, 0x1708(%rsp)
movq 0x98(%rax), %rax
movq %rax, 0x150(%rsp)
movq $0x0, 0x16e8(%rsp)
leaq 0x16e7(%rsp), %rdi
movq %rdi, 0x158(%rsp)
callq 0xf420
movq 0x150(%rsp), %rsi
movq 0x158(%rsp), %rcx
leaq 0x16f0(%rsp), %rdi
leaq 0x16e8(%rsp), %rdx
callq 0xf4c0
jmp 0x152cf
leaq 0x16e7(%rsp), %rdi
callq 0xe520
movq 0x1708(%rsp), %rax
movq %rax, 0x138(%rsp)
movq $0x0, 0x16b0(%rsp)
leaq 0x16af(%rsp), %rdi
movq %rdi, 0x140(%rsp)
callq 0xf420
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rcx
leaq 0x16b8(%rsp), %rdi
leaq 0x16b0(%rsp), %rdx
callq 0xf4c0
jmp 0x15334
leaq 0x16af(%rsp), %rdi
callq 0xe520
movq $0x0, 0x16a0(%rsp)
leaq 0x1688(%rsp), %rdi
movq %rdi, 0x130(%rsp)
callq 0xf7a0
movq 0x148(%rsp), %rax
movq 0x130(%rsp), %rdi
movq 0x98(%rax), %rsi
callq 0xecb0
jmp 0x15380
movq $0x0, 0x1680(%rsp)
movq 0x148(%rsp), %rcx
movq 0x1680(%rsp), %rax
cmpq 0x98(%rcx), %rax
jae 0x1543d
leaq 0x1688(%rsp), %rdi
leaq 0x1680(%rsp), %rsi
callq 0xe590
jmp 0x153c0
jmp 0x153c2
movq 0x1680(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1680(%rsp)
jmp 0x1538c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x16d8(%rsp)
movl %eax, 0x16d4(%rsp)
leaq 0x16e7(%rsp), %rdi
callq 0xe520
jmp 0x16562
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x16d8(%rsp)
movl %eax, 0x16d4(%rsp)
leaq 0x16af(%rsp), %rdi
callq 0xe520
jmp 0x16555
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x16d8(%rsp)
movl %eax, 0x16d4(%rsp)
jmp 0x1653b
leaq 0x1668(%rsp), %rdi
movq %rdi, 0x128(%rsp)
callq 0xe940
movq 0x128(%rsp), %rsi
movq 0x148(%rsp), %rdx
movq 0x1718(%rsp), %rdi
movq %rdx, %rcx
addq $0x18, %rcx
movq 0x1710(%rsp), %r8
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0x15484
movq 0x148(%rsp), %rax
movq 0x98(%rax), %rax
movq %rax, 0x118(%rsp)
movq $0x0, 0x1648(%rsp)
leaq 0x1647(%rsp), %rdi
movq %rdi, 0x120(%rsp)
callq 0xf420
movq 0x118(%rsp), %rsi
movq 0x120(%rsp), %rcx
leaq 0x1650(%rsp), %rdi
leaq 0x1648(%rsp), %rdx
callq 0xf4c0
jmp 0x154e3
leaq 0x1647(%rsp), %rdi
callq 0xe520
movq $0x0, 0x1638(%rsp)
movq 0x148(%rsp), %rcx
movq 0x1638(%rsp), %rax
cmpq 0x98(%rcx), %rax
jae 0x15622
movq 0x148(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1638(%rsp), %rsi
callq 0xe2d0
movq (%rax), %rax
movq %rax, 0x1630(%rsp)
movq 0x1710(%rsp), %rdi
movl 0x1630(%rsp), %esi
callq 0xf530
movq %rax, 0x110(%rsp)
jmp 0x1555e
movq 0x110(%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
leaq 0x1668(%rsp), %rsi
callq *%rax
movsd %xmm0, 0x108(%rsp)
jmp 0x15582
movq 0x1638(%rsp), %rsi
leaq 0x1650(%rsp), %rdi
callq 0xebf0
movsd 0x108(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x1638(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1638(%rsp)
jmp 0x154fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x16d8(%rsp)
movl %eax, 0x16d4(%rsp)
jmp 0x1652e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x16d8(%rsp)
movl %eax, 0x16d4(%rsp)
leaq 0x1647(%rsp), %rdi
callq 0xe520
jmp 0x1652e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x16d8(%rsp)
movl %eax, 0x16d4(%rsp)
leaq 0x1650(%rsp), %rdi
callq 0xf1c0
jmp 0x1652e
movq 0x148(%rsp), %rdi
callq 0xe8c0
movsd %xmm0, 0x100(%rsp)
jmp 0x1563a
movsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x1628(%rsp)
leaq 0x1668(%rsp), %rdi
callq 0xe8c0
movsd %xmm0, 0xf8(%rsp)
jmp 0x15664
movq 0x148(%rsp), %rax
movsd 0xf8(%rsp), %xmm0
movsd %xmm0, 0x1620(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1618(%rsp)
movl $0x14, 0x1614(%rsp)
testb $0x1, 0xf0(%rax)
je 0x157a9
movq 0x148(%rsp), %rax
movl $0x2, 0x1614(%rsp)
movb $0x0, 0xf0(%rax)
movq %rax, %rdi
addq $0x100, %rdi            # imm = 0x100
movq 0x98(%rax), %rsi
callq 0xebc0
jmp 0x156d4
movq $0x0, 0x1608(%rsp)
movq 0x148(%rsp), %rcx
movq 0x1608(%rsp), %rax
cmpq 0x98(%rcx), %rax
jae 0x157a7
movq 0x148(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1608(%rsp), %rsi
callq 0xe2d0
movq (%rax), %rax
movq %rax, 0x1600(%rsp)
movq 0x1710(%rsp), %rdi
movl 0x1600(%rsp), %esi
callq 0xf530
movq %rax, 0xf0(%rsp)
jmp 0x15742
movq 0x148(%rsp), %rsi
movq 0xf0(%rsp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movsd %xmm0, 0xe8(%rsp)
jmp 0x15765
movq 0x148(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movq 0x1608(%rsp), %rsi
callq 0xebf0
movsd 0xe8(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x1608(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1608(%rsp)
jmp 0x156e0
jmp 0x157ca
movq 0x148(%rsp), %rax
movsd 0x6a2f(%rip), %xmm0     # 0x1c1e8
mulsd 0xf8(%rax), %xmm0
movsd %xmm0, 0x1618(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0x278(%rsp), %rdi
callq 0xe870
jmp 0x157dd
movl $0x0, 0x274(%rsp)
movl 0x274(%rsp), %eax
cmpl 0x1614(%rsp), %eax
jge 0x15db4
leaq 0x1688(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0xe100
movq 0xe0(%rsp), %rdi
movq %rax, 0x268(%rsp)
callq 0xf890
movq %rax, 0x260(%rsp)
movq 0x268(%rsp), %rdi
movq 0x260(%rsp), %rsi
leaq 0x278(%rsp), %rdx
callq 0xf3c0
jmp 0x1584d
movq $0x0, 0x258(%rsp)
movq 0x148(%rsp), %rcx
movq 0x258(%rsp), %rax
cmpq 0x98(%rcx), %rax
jae 0x159d3
movq 0x258(%rsp), %rsi
leaq 0x1688(%rsp), %rdi
callq 0xe2d0
movq 0x148(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x250(%rsp)
addq $0xa0, %rdi
movq 0x258(%rsp), %rsi
callq 0xe2d0
movq 0x148(%rsp), %rdi
movq %rax, 0xc0(%rsp)
addq $0xa0, %rdi
movq 0x250(%rsp), %rsi
callq 0xe2d0
movq 0xc0(%rsp), %rdi
movq %rax, %rsi
callq 0xe4a0
movq 0x258(%rsp), %rsi
leaq 0x16f0(%rsp), %rdi
callq 0xebf0
movq %rax, 0xc8(%rsp)
movq 0x250(%rsp), %rsi
leaq 0x16f0(%rsp), %rdi
callq 0xebf0
movq 0xc8(%rsp), %rdi
movq %rax, %rsi
callq 0xe770
movq 0x148(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movq 0x258(%rsp), %rsi
callq 0xebf0
movq 0x148(%rsp), %rdi
movq %rax, 0xd0(%rsp)
addq $0x100, %rdi            # imm = 0x100
movq 0x250(%rsp), %rsi
callq 0xebf0
movq 0xd0(%rsp), %rdi
movq %rax, %rsi
callq 0xe770
movq 0x258(%rsp), %rsi
leaq 0x1650(%rsp), %rdi
callq 0xebf0
movq %rax, 0xd8(%rsp)
movq 0x250(%rsp), %rsi
leaq 0x1650(%rsp), %rdi
callq 0xebf0
movq 0xd8(%rsp), %rdi
movq %rax, %rsi
callq 0xe770
movq 0x258(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x258(%rsp)
jmp 0x15859
xorps %xmm0, %xmm0
movsd %xmm0, 0x248(%rsp)
movq $0x0, 0x240(%rsp)
movq 0x148(%rsp), %rcx
movq 0x240(%rsp), %rax
cmpq 0x98(%rcx), %rax
jae 0x15cbc
movq 0x148(%rsp), %rdi
addq $0xa0, %rdi
movq 0x240(%rsp), %rsi
callq 0xe2d0
movq (%rax), %rax
movq %rax, 0x238(%rsp)
movq 0x1710(%rsp), %rdi
movl 0x238(%rsp), %esi
callq 0xf530
movq %rax, 0xb8(%rsp)
jmp 0x15a4d
movq 0xb8(%rsp), %rax
movq %rax, 0x230(%rsp)
movq 0x240(%rsp), %rsi
leaq 0x1650(%rsp), %rdi
callq 0xebf0
movsd (%rax), %xmm0
movsd %xmm0, 0x228(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x228(%rsp), %xmm0
jb 0x15a92
jmp 0x15ca3
movq 0x148(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movq 0x240(%rsp), %rsi
callq 0xebf0
movsd (%rax), %xmm0
movsd %xmm0, 0xa8(%rsp)
movq 0x230(%rsp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
leaq 0x16b8(%rsp), %rsi
leaq 0x1668(%rsp), %rdx
callq *%rax
movsd %xmm0, 0xb0(%rsp)
jmp 0x15ae7
movsd 0xb0(%rsp), %xmm1
movsd 0xa8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x220(%rsp)
movq 0x1730(%rsp), %rax
movq 0x238(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x240(%rsp), %rsi
leaq 0x16f0(%rsp), %rdi
callq 0xebf0
movsd 0x98(%rsp), %xmm0
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x218(%rsp)
movsd 0x218(%rsp), %xmm0
movsd 0x220(%rsp), %xmm1
movsd 0x228(%rsp), %xmm2
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x210(%rsp)
movsd 0x210(%rsp), %xmm0
movsd 0x1720(%rsp), %xmm1
movsd 0x228(%rsp), %xmm2
divsd %xmm2, %xmm1
callq 0xe950
movsd %xmm0, 0xa0(%rsp)
jmp 0x15bae
movsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0x208(%rsp)
movsd 0x208(%rsp), %xmm0
subsd 0x218(%rsp), %xmm0
movsd %xmm0, 0x200(%rsp)
movsd 0x200(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x15bf4
jp 0x15bf4
jmp 0x15ca3
movsd 0x208(%rsp), %xmm0
movq 0x1730(%rsp), %rax
movq 0x238(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
movq 0x240(%rsp), %rsi
leaq 0x16f0(%rsp), %rdi
callq 0xebf0
movsd 0x90(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x230(%rsp), %rdi
movsd 0x200(%rsp), %xmm0
movq (%rdi), %rax
movq 0x18(%rax), %rax
leaq 0x16b8(%rsp), %rsi
callq *%rax
jmp 0x15c65
movsd 0x200(%rsp), %xmm0
mulsd 0x200(%rsp), %xmm0
mulsd 0x228(%rsp), %xmm0
movsd 0x228(%rsp), %xmm2
movsd 0x248(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x248(%rsp)
movq 0x240(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x240(%rsp)
jmp 0x159eb
movq 0x148(%rsp), %rax
testb $0x1, 0xd9(%rax)
je 0x15d73
leaq 0x1668(%rsp), %rdi
leaq 0x16b8(%rsp), %rsi
callq 0xed90
movsd %xmm0, 0x88(%rsp)
jmp 0x15cf1
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movsd 0x1f8(%rsp), %xmm0
movsd 0x1628(%rsp), %xmm1
addsd %xmm1, %xmm0
movaps 0x64e0(%rip), %xmm1     # 0x1c200
pxor %xmm1, %xmm0
movsd 0x1620(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x1f0(%rsp), %xmm1
movsd 0x16a0(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x16a0(%rsp)
movsd 0x1f0(%rsp), %xmm0
leaq 0x16b8(%rsp), %rdi
callq 0xe3f0
jmp 0x15d71
jmp 0x15d73
movsd 0x248(%rsp), %xmm1
movsd 0x1618(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x15d9c
movl 0x274(%rsp), %eax
addl $0x1, %eax
cmpl $0x2, %eax
jl 0x15d9c
jmp 0x15db4
jmp 0x15d9e
movl 0x274(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x274(%rsp)
jmp 0x157e8
movsd 0x6394(%rip), %xmm0     # 0x1c150
movsd %xmm0, 0x1e8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1e0(%rsp)
movl $0x0, 0x1dc(%rsp)
cmpl $0x14, 0x1dc(%rsp)
jge 0x161a2
movsd 0x1e8(%rsp), %xmm0
subsd 0x1e0(%rsp), %xmm0
movsd %xmm0, 0x1d0(%rsp)
movsd 0x1d0(%rsp), %xmm0
movsd 0x16a0(%rsp), %xmm2
movq 0x1728(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1c8(%rsp)
movq $0x0, 0x1c0(%rsp)
movq 0x148(%rsp), %rcx
movq 0x1c0(%rsp), %rax
cmpq 0x98(%rcx), %rax
jae 0x1604e
movq 0x148(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1c0(%rsp), %rsi
callq 0xe2d0
movq (%rax), %rax
movq %rax, 0x1b8(%rsp)
movsd 0x1d0(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0x1c0(%rsp), %rsi
leaq 0x16f0(%rsp), %rdi
callq 0xebf0
movsd 0x80(%rsp), %xmm0
movsd (%rax), %xmm2
movq 0x1730(%rsp), %rax
movq 0x1b8(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x1730(%rsp), %rax
movq 0x1b8(%rsp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x15f5f
movsd 0x1720(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movq 0x1c0(%rsp), %rsi
leaq 0x16f0(%rsp), %rdi
callq 0xebf0
movsd 0x78(%rsp), %xmm0
movsd (%rax), %xmm2
movsd 0x1c8(%rsp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
jmp 0x16033
movq 0x1730(%rsp), %rax
movq 0x1b8(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x15fc7
movsd 0x1720(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0x1c0(%rsp), %rsi
leaq 0x16f0(%rsp), %rdi
callq 0xebf0
movsd 0x70(%rsp), %xmm0
movsd (%rax), %xmm2
movsd 0x1c8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
jmp 0x16031
movsd 0x1720(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0x1c0(%rsp), %rsi
leaq 0x16f0(%rsp), %rdi
callq 0xebf0
movsd 0x68(%rsp), %xmm0
movsd (%rax), %xmm2
movaps 0x6044(%rip), %xmm1     # 0x1c040
pand %xmm1, %xmm2
movsd 0x1c8(%rsp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
jmp 0x16033
jmp 0x16035
movq 0x1c0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1c0(%rsp)
jmp 0x15e47
movq $0x0, 0x1b0(%rsp)
movq 0x1b0(%rsp), %rax
cmpq 0x1708(%rsp), %rax
jae 0x160e8
movsd 0x1d0(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x1b0(%rsp), %rsi
leaq 0x16b8(%rsp), %rdi
callq 0xebf0
movq 0x148(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
addq $0x18, %rdi
movq 0x1b0(%rsp), %rsi
callq 0xebf0
movsd 0x58(%rsp), %xmm0
movsd 0x60(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq 0x1b0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1b0(%rsp)
jmp 0x1605a
movq 0x148(%rsp), %rdx
movq 0x1718(%rsp), %rdi
movq %rdx, %rsi
addq $0x18, %rsi
movq %rdx, %rcx
addq $0x78, %rcx
movq 0x1710(%rsp), %r8
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0x16119
movq 0x148(%rsp), %rsi
leaq 0x16b8(%rsp), %rdi
callq 0xed90
movsd %xmm0, 0x50(%rsp)
jmp 0x16136
movsd 0x50(%rsp), %xmm0
addsd 0x1c8(%rsp), %xmm0
movsd %xmm0, 0x1c8(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x1c8(%rsp), %xmm0
jbe 0x1615e
jmp 0x161a2
movsd 0x1e8(%rsp), %xmm0
movsd %xmm0, 0x1e0(%rsp)
movsd 0x6038(%rip), %xmm0     # 0x1c1b0
mulsd 0x1e8(%rsp), %xmm0
movsd %xmm0, 0x1e8(%rsp)
jmp 0x1618c
movl 0x1dc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1dc(%rsp)
jmp 0x15ddc
movq 0x148(%rsp), %rdi
movq 0x1728(%rsp), %rsi
movq 0x1718(%rsp), %rdx
movq 0x1710(%rsp), %rcx
callq 0xf7e0
movsd %xmm0, 0x48(%rsp)
jmp 0x161cf
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x1a8(%rsp)
movsd 0x1e8(%rsp), %xmm0
movsd 0x5f61(%rip), %xmm1     # 0x1c150
ucomisd %xmm1, %xmm0
jne 0x161fc
jp 0x161fc
jmp 0x162ae
movq $0x0, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x16b8(%rsp), %rdi
callq 0xe730
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0x162ac
movsd 0x1e8(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x1a0(%rsp), %rsi
leaq 0x16b8(%rsp), %rdi
callq 0xebf0
movsd 0x30(%rsp), %xmm0
movsd (%rax), %xmm2
movsd 0x1a8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x1a0(%rsp), %rsi
leaq 0x16b8(%rsp), %rdi
callq 0xebf0
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x1a0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1a0(%rsp)
jmp 0x16208
jmp 0x162ae
movq $0x0, 0x198(%rsp)
movq 0x148(%rsp), %rcx
movq 0x198(%rsp), %rax
cmpq 0x98(%rcx), %rax
jae 0x1645b
movq 0x148(%rsp), %rdi
addq $0xa0, %rdi
movq 0x198(%rsp), %rsi
callq 0xe2d0
movq (%rax), %rax
movq %rax, 0x190(%rsp)
movq 0x1710(%rsp), %rdi
movl 0x190(%rsp), %esi
callq 0xf530
movq %rax, 0x28(%rsp)
jmp 0x16319
movq 0x148(%rsp), %rsi
movq 0x28(%rsp), %rax
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movsd %xmm0, 0x20(%rsp)
jmp 0x16346
movq 0x148(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x180(%rsp)
addq $0x100, %rdi            # imm = 0x100
movq 0x198(%rsp), %rsi
callq 0xebf0
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x188(%rsp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
leaq 0x16b8(%rsp), %rsi
leaq 0x1668(%rsp), %rdx
callq *%rax
movsd %xmm0, 0x18(%rsp)
jmp 0x163a4
movq 0x148(%rsp), %rdi
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x178(%rsp)
movsd 0x180(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
addq $0x100, %rdi            # imm = 0x100
movq 0x198(%rsp), %rsi
callq 0xebf0
movsd 0x8(%rsp), %xmm0
movq %rax, %rcx
movq 0x148(%rsp), %rax
movsd %xmm0, (%rcx)
movsd 0x180(%rsp), %xmm0
subsd 0x178(%rsp), %xmm0
movsd %xmm0, 0x170(%rsp)
movsd 0x170(%rsp), %xmm0
movsd 0x170(%rsp), %xmm2
movsd 0xf8(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xf8(%rax)
movq 0x198(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x198(%rsp)
jmp 0x162ba
movq 0x148(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
callq 0xef80
movsd %xmm0, (%rsp)
jmp 0x16476
movsd (%rsp), %xmm0
movsd %xmm0, 0x168(%rsp)
movsd 0x168(%rsp), %xmm0
ucomisd 0x1720(%rsp), %xmm0
jbe 0x164c0
movsd 0x1720(%rsp), %xmm0
divsd 0x168(%rsp), %xmm0
movsd %xmm0, 0x1740(%rsp)
movl $0x1, 0x164(%rsp)
jmp 0x164dc
movsd 0x5c88(%rip), %xmm0     # 0x1c150
movsd %xmm0, 0x1740(%rsp)
movl $0x1, 0x164(%rsp)
leaq 0x1650(%rsp), %rdi
callq 0xf1c0
leaq 0x1668(%rsp), %rdi
callq 0xf1c0
leaq 0x1688(%rsp), %rdi
callq 0xe350
leaq 0x16b8(%rsp), %rdi
callq 0xf1c0
leaq 0x16f0(%rsp), %rdi
callq 0xf1c0
movsd 0x1740(%rsp), %xmm0
addq $0x1748, %rsp           # imm = 0x1748
retq
leaq 0x1668(%rsp), %rdi
callq 0xf1c0
leaq 0x1688(%rsp), %rdi
callq 0xe350
leaq 0x16b8(%rsp), %rdi
callq 0xf1c0
leaq 0x16f0(%rsp), %rdi
callq 0xf1c0
movq 0x16d8(%rsp), %rdi
callq 0xf590
nop