// File: epfml[P]Bi-Sent2Vec/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;
  if (quant_ && args_->qout) {
    f= sigmoid(qwo_->dotRow(hidden, node - osz_));
  } else {
    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 0x23b60
movslq -0xc(%rbp), %rcx
cmpq %rcx, %rax
jne 0x22582
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movq -0x20(%rbp), %rdi
callq 0x23b80
movss -0x64(%rbp), %xmm1
movss (%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x22582
jmp 0x227c9
movq -0x60(%rbp), %rdi
addq $0xf8, %rdi
movslq -0x10(%rbp), %rsi
callq 0x23d40
cmpl $-0x1, 0x4(%rax)
jne 0x22660
movq -0x60(%rbp), %rdi
addq $0xf8, %rdi
movslq -0x10(%rbp), %rsi
callq 0x23d40
cmpl $-0x1, 0x8(%rax)
jne 0x22660
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x23d60
movq -0x70(%rbp), %rdi
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x23bb0
movq -0x20(%rbp), %rdi
callq 0x23b00
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x23b30
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x21d(%rip), %rdx      # 0x223f0
callq 0x23c10
movq -0x20(%rbp), %rdi
callq 0x23b60
movslq -0xc(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x2265b
movq -0x20(%rbp), %rdi
callq 0x23b00
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
callq 0x23b30
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
leaq -0x25d(%rip), %rdx      # 0x223f0
callq 0x23ca0
movq -0x20(%rbp), %rdi
callq 0x23d10
jmp 0x227c9
movq -0x60(%rbp), %rax
testb $0x1, 0x118(%rax)
je 0x226bc
movq -0x60(%rbp), %rdi
addq $0x40, %rdi
callq 0xe6e0
testb $0x1, 0x12c(%rax)
je 0x226bc
movq -0x60(%rbp), %rdi
addq $0x30, %rdi
callq 0x23860
movq -0x60(%rbp), %rcx
movq %rax, %rdi
movq -0x28(%rbp), %rsi
movl -0x10(%rbp), %eax
subl 0x88(%rcx), %eax
movslq %eax, %rdx
callq 0x20100
movq -0x60(%rbp), %rdi
callq 0x21c00
movss %xmm0, -0x54(%rbp)
jmp 0x226f3
movq -0x60(%rbp), %rdi
addq $0x10, %rdi
callq 0x235f0
movq -0x60(%rbp), %rcx
movq %rax, %rdi
movq -0x28(%rbp), %rsi
movl -0x10(%rbp), %eax
subl 0x88(%rcx), %eax
movslq %eax, %rdx
callq 0x1e0d0
movq -0x60(%rbp), %rdi
callq 0x21c00
movss %xmm0, -0x54(%rbp)
movq -0x60(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x88(%rbp)
addq $0xf8, %rdi
movslq -0x10(%rbp), %rsi
callq 0x23d40
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 0x20180(%rip), %xmm0    # 0x428b8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x21cb0
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 0x22520
movq -0x60(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x7c(%rbp)
addq $0xf8, %rdi
movslq -0x10(%rbp), %rsi
callq 0x23d40
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 0x21cb0
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 0x22520
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)