// File: /workspace/github_cpp_makefile_star2_O1/epfml[P]Bi-Sent2Vec/src/model.cc
// Function: fasttext::Model::findKBest(int, std::vector<std::pair<float, int>, std::allocator<std::pair<float, int>>>&, fasttext::Vector&, fasttext::Vector&) const
void Model::findKBest(int32_t k, std::vector<std::pair<real, int32_t>>& heap,
                      Vector& hidden, Vector& output) const {
  computeOutputSoftmax(hidden, output);
  for (int32_t i = 0; i < osz_; i++) {
    if (heap.size() == k && log(output[i]) < heap.front().first) {
      continue;
    }
    heap.push_back(std::make_pair(log(output[i]), i));
    std::push_heap(heap.begin(), heap.end(), comparePairs);
    if (heap.size() > k) {
      std::pop_heap(heap.begin(), heap.end(), comparePairs);
      heap.pop_back();
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
movq %rcx, %rsi
movq %r8, %rdx
callq 0xfbec
cmpl $0x0, 0x88(%r15)
jle 0x105c3
movslq %ebp, %rbp
xorl %r12d, %r12d
movq %rsp, %r13
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x3, %rax
cmpq %rbp, %rax
jne 0x103e3
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf3ce
movss (%rax), %xmm1
xorps %xmm0, %xmm0
ucomiss 0xedb9(%rip), %xmm1     # 0x1f170
ja 0x103d3
mulss 0xf0a3(%rip), %xmm1     # 0x1f464
cvttss2si %xmm1, %eax
movq 0xa0(%r15), %rcx
cltq
movss (%rcx,%rax,4), %xmm0
movq (%r14), %rax
movss (%rax), %xmm1
ucomiss %xmm0, %xmm1
ja 0x105b0
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf3ce
movss (%rax), %xmm0
ucomiss 0xed77(%rip), %xmm0     # 0x1f170
jbe 0x103ff
xorl %eax, %eax
jmp 0x10417
mulss 0xf05d(%rip), %xmm0     # 0x1f464
cvttss2si %xmm0, %eax
movq 0xa0(%r15), %rcx
cltq
movl (%rcx,%rax,4), %eax
movq %r12, %rcx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, (%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x111ec
movq (%r14), %rax
movq 0x8(%r14), %rsi
movss -0x8(%rsi), %xmm0
movl -0x4(%rsi), %ecx
movq %rsi, %rdx
subq %rax, %rdx
movq %rdx, %rdi
sarq $0x3, %rdi
leaq -0x1(%rdi), %r8
cmpq $0x2, %rdi
jl 0x1048d
leaq -0x1(%r8), %r9
shrq $0x3f, %r9
addq %r8, %r9
decq %r9
sarq %r9
movss (%rax,%r9,8), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x1048d
movss %xmm1, (%rax,%r8,8)
movl 0x4(%rax,%r9,8), %r10d
movl %r10d, 0x4(%rax,%r8,8)
cmpq $0x2, %r8
movq %r9, %r8
jg 0x10456
jmp 0x10490
movq %r8, %r9
movss %xmm0, (%rax,%r9,8)
movl %ecx, 0x4(%rax,%r9,8)
cmpq %rbp, %rdi
jbe 0x105b0
leaq -0x8(%rsi), %rcx
cmpq $0x9, %rdx
jl 0x105ac
movss -0x8(%rsi), %xmm0
movl -0x4(%rsi), %edx
movss (%rax), %xmm1
movss %xmm1, -0x8(%rsi)
movl 0x4(%rax), %edi
movl %edi, -0x4(%rsi)
movq %rcx, %r8
subq %rax, %r8
movq %r8, %rdi
sarq $0x3, %rdi
cmpq $0x3, %rdi
jl 0x10533
leaq -0x1(%rdi), %rsi
shrq $0x3f, %rsi
leaq (%rdi,%rsi), %r9
decq %r9
sarq %r9
xorl %r10d, %r10d
leaq (%r10,%r10), %rsi
movss 0x10(%rax,%rsi,8), %xmm1
ucomiss 0x8(%rax,%rsi,8), %xmm1
ja 0x1050c
leaq 0x2(,%r10,2), %rsi
jmp 0x10514
leaq 0x1(,%r10,2), %rsi
movss (%rax,%rsi,8), %xmm1
movss %xmm1, (%rax,%r10,8)
movl 0x4(%rax,%rsi,8), %r11d
movl %r11d, 0x4(%rax,%r10,8)
movq %rsi, %r10
cmpq %r9, %rsi
jl 0x104f1
jmp 0x10535
xorl %esi, %esi
testb $0x8, %r8b
jne 0x10566
addq $-0x2, %rdi
sarq %rdi
cmpq %rdi, %rsi
jne 0x10566
leaq (%rsi,%rsi), %rdi
movss 0x8(%rax,%rdi,8), %xmm1
movss %xmm1, (%rax,%rsi,8)
movl 0xc(%rax,%rdi,8), %edi
movl %edi, 0x4(%rax,%rsi,8)
leaq 0x1(,%rsi,2), %rsi
testq %rsi, %rsi
jle 0x105a0
leaq -0x1(%rsi), %rdi
shrq $0x3f, %rdi
addq %rsi, %rdi
decq %rdi
sarq %rdi
movss (%rax,%rdi,8), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x105a0
movss %xmm1, (%rax,%rsi,8)
movl 0x4(%rax,%rdi,8), %r8d
movl %r8d, 0x4(%rax,%rsi,8)
cmpq $0x2, %rsi
movq %rdi, %rsi
jg 0x1056b
jmp 0x105a3
movq %rsi, %rdi
movss %xmm0, (%rax,%rdi,8)
movl %edx, 0x4(%rax,%rdi,8)
movq %rcx, 0x8(%r14)
incq %r12
movslq 0x88(%r15), %rax
cmpq %rax, %r12
jl 0x1038e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq