// File: ddu1[P]polarizedtext/src/model.cc
// Function: fasttext::Model::dfs(int, int, float, std::vector<std::pair<float, int>, std::allocator<std::pair<float, int>>>&, fasttext::Vector&) const
void Model::dfs(int32_t k, int32_t node, real score,
                std::vector<std::pair<real, int32_t>>& heap,
                Vector& hidden) const {
  if (heap.size() == k && score < heap.front().first) {
    return;
  }

  if (tree[node].left == -1 && tree[node].right == -1) {
    heap.push_back(std::make_pair(score, node));
    std::push_heap(heap.begin(), heap.end(), comparePairs);
    if (heap.size() > k) {
      std::pop_heap(heap.begin(), heap.end(), comparePairs);
      heap.pop_back();
    }
    return;
  }

  real f = sigmoid(wo_->dotRow(hidden, node - osz_));
  dfs(k, tree[node].left, score + log(1.0 - f), heap, hidden);
  dfs(k, tree[node].right, score + log(f), heap, hidden);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
callq 0x15d20
movslq -0xc(%rbp), %rcx
cmpq %rcx, %rax
jne 0x14982
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movq -0x20(%rbp), %rdi
callq 0x15d40
movss -0x64(%rbp), %xmm1
movss (%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x14982
jmp 0x14b6d
movq -0x60(%rbp), %rdi
addq $0xf0, %rdi
movslq -0x10(%rbp), %rsi
callq 0x15f00
cmpl $-0x1, 0x4(%rax)
jne 0x14a60
movq -0x60(%rbp), %rdi
addq $0xf0, %rdi
movslq -0x10(%rbp), %rsi
callq 0x15f00
cmpl $-0x1, 0x8(%rax)
jne 0x14a60
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x15f20
movq -0x70(%rbp), %rdi
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x15d70
movq -0x20(%rbp), %rdi
callq 0x15cc0
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x15cf0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x21d(%rip), %rdx      # 0x147f0
callq 0x15dd0
movq -0x20(%rbp), %rdi
callq 0x15d20
movslq -0xc(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x14a5b
movq -0x20(%rbp), %rdi
callq 0x15cc0
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
callq 0x15cf0
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
leaq -0x25d(%rip), %rdx      # 0x147f0
callq 0x15e60
movq -0x20(%rbp), %rdi
callq 0x15ed0
jmp 0x14b6d
movq -0x60(%rbp), %rdi
addq $0x10, %rdi
callq 0x15820
movq -0x60(%rbp), %rcx
movq %rax, %rdi
movq -0x28(%rbp), %rsi
movl -0x10(%rbp), %eax
subl 0x80(%rcx), %eax
movslq %eax, %rdx
callq 0x12cb0
movq -0x60(%rbp), %rdi
callq 0x13f30
movq -0x60(%rbp), %rdi
movss %xmm0, -0x54(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x88(%rbp)
addq $0xf0, %rdi
movslq -0x10(%rbp), %rsi
callq 0x15f00
movq -0x60(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x84(%rbp)
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x80(%rbp)
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x14aec(%rip), %xmm0    # 0x295c8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x13fe0
movl -0x88(%rbp), %esi
movl -0x84(%rbp), %edx
movq -0x60(%rbp), %rdi
movaps %xmm0, %xmm1
movss -0x80(%rbp), %xmm0
addss %xmm1, %xmm0
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x14920
movq -0x60(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x7c(%rbp)
addq $0xf0, %rdi
movslq -0x10(%rbp), %rsi
callq 0x15f00
movq -0x60(%rbp), %rdi
movl 0x8(%rax), %eax
movl %eax, -0x78(%rbp)
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
movss -0x54(%rbp), %xmm0
callq 0x13fe0
movq -0x60(%rbp), %rdi
movl -0x7c(%rbp), %esi
movl -0x78(%rbp), %edx
movaps %xmm0, %xmm1
movss -0x74(%rbp), %xmm0
addss %xmm1, %xmm0
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x14920
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)