// File: tbjohns[P]BlitzL1/src/solver.cpp
// Function: BlitzL1::Solver::prioritize_features(BlitzL1::Dataset const*, double, double const*, unsigned long)
void Solver::prioritize_features(const Dataset *data, value_t lambda, const value_t *x, size_t max_size_C)
  {
    // Reorders prioritized_features so that first max_size_C
    // elements are feature indices with highest priority in order

    size_t d = data->get_d();
    feature_priorities.resize(d);

    for (vector<size_t>::iterator j = prioritized_features.begin();
         j != prioritized_features.end();
         ++j)
    {
      if (x[*j] != 0)
      {
        feature_priorities[*j] = 0.0;
      }
      else
      {
        value_t norm = priority_norm_j(*j, data);
        if (norm <= 0)
        {
          feature_priorities[*j] = std::numeric_limits<value_t>::max();
        }
        else
        {
          value_t priority_value = (lambda - fabs(ATphi[*j])) / norm;
          feature_priorities[*j] = priority_value;
        }
      }
    }
    IndirectComparator cmp(feature_priorities);
    nth_element(
        prioritized_features.begin(),
        prioritized_features.begin() + max_size_C,
        prioritized_features.end(),
        cmp);
    sort(
        prioritized_features.begin(),
        prioritized_features.end(),
        cmp);
  }

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movsd %xmm0, 0xd0(%rsp)
movq %rdx, 0xc8(%rsp)
movq %rcx, 0xc0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xd8(%rsp), %rdi
callq 0xf1b0
movq 0x48(%rsp), %rdi
movq %rax, 0xb8(%rsp)
addq $0xb8, %rdi
movq 0xb8(%rsp), %rsi
callq 0xebc0
movq 0x48(%rsp), %rdi
addq $0xa0, %rdi
callq 0xe100
movq %rax, 0xb0(%rsp)
movq 0x48(%rsp), %rdi
addq $0xa0, %rdi
callq 0xf890
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xe4d0
testb $0x1, %al
jne 0x16abb
jmp 0x16c63
movq 0xc8(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xf120
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq (%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x16af2
jp 0x16af2
jmp 0x16b28
movq 0x48(%rsp), %rax
addq $0xb8, %rax
movq %rax, 0x38(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xf120
movq 0x38(%rsp), %rdi
movq (%rax), %rsi
callq 0xebf0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x16c4f
leaq 0xb0(%rsp), %rdi
callq 0xf120
movq 0x48(%rsp), %rdi
movq (%rax), %rsi
movq 0xd8(%rsp), %rdx
callq 0xe050
movsd %xmm0, 0xa0(%rsp)
xorps %xmm0, %xmm0
ucomisd 0xa0(%rsp), %xmm0
jb 0x16ba5
callq 0xe830
movq 0x48(%rsp), %rax
movsd %xmm0, 0x30(%rsp)
addq $0xb8, %rax
movq %rax, 0x28(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xf120
movq 0x28(%rsp), %rdi
movq (%rax), %rsi
callq 0xebf0
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x16c4d
movq 0x48(%rsp), %rax
movsd 0xd0(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0x60, %rax
movq %rax, 0x8(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xf120
movq 0x8(%rsp), %rdi
movq (%rax), %rsi
callq 0xebf0
movsd 0x10(%rsp), %xmm0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movsd (%rcx), %xmm1
movaps 0x544b(%rip), %xmm2     # 0x1c040
pand %xmm2, %xmm1
subsd %xmm1, %xmm0
divsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0xb8, %rax
movq %rax, 0x18(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xf120
movq 0x18(%rsp), %rdi
movq (%rax), %rsi
callq 0xebf0
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x16c4f
jmp 0x16c51
leaq 0xb0(%rsp), %rdi
callq 0xf5c0
jmp 0x16a84
movq 0x48(%rsp), %rsi
addq $0xb8, %rsi
leaq 0x90(%rsp), %rdi
callq 0xf430
movq 0x48(%rsp), %rdi
addq $0xa0, %rdi
callq 0xe100
movq 0x48(%rsp), %rdi
movq %rax, 0x88(%rsp)
addq $0xa0, %rdi
callq 0xe100
movq %rax, 0x78(%rsp)
movq 0xc0(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0xe5a0
movq 0x48(%rsp), %rdi
movq %rax, 0x80(%rsp)
addq $0xa0, %rdi
callq 0xf890
movq %rax, 0x70(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x88(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x68(%rsp), %rcx
callq 0xf320
movq 0x48(%rsp), %rdi
addq $0xa0, %rdi
callq 0xe100
movq 0x48(%rsp), %rdi
movq %rax, 0x60(%rsp)
addq $0xa0, %rdi
callq 0xf890
movq %rax, 0x58(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0xeb80
addq $0xe8, %rsp
retq
nopl (%rax)