// File: epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::findNN(fasttext::Matrix const&, fasttext::Vector const&, int, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
void FastText::findNN(const Matrix& wordVectors, const Vector& queryVec,
                      int32_t k, const std::set<std::string>& banSet) {
  real queryNorm = queryVec.norm();
  if (std::abs(queryNorm) < 1e-8) {
    queryNorm = 1;
  }
  std::priority_queue<std::pair<real, std::string>> heap;
  Vector vec(args_->dim);
  for (int32_t i = 0; i < dict_->nwords(); i++) {
    std::string word = dict_->getWord(i);
    real dp = wordVectors.dotRow(queryVec, i);
    heap.push(std::make_pair(dp / queryNorm, word));
  }
  int32_t i = 0;
  while (i < k && heap.size() > 0) {
    auto it = banSet.find(heap.top().second);
    if (it == banSet.end()) {
      std::cout << heap.top().second << " " << heap.top().first << std::endl;
      i++;
    }
    heap.pop();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20d00
movss %xmm0, -0x2c(%rbp)
movss -0x2c(%rbp), %xmm0
callq 0x352f0
cvtss2sd %xmm0, %xmm1
movsd 0x15513(%rip), %xmm0    # 0x43690
ucomisd %xmm1, %xmm0
jbe 0x2e190
movss 0x1473d(%rip), %xmm0    # 0x428c8
movss %xmm0, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x35310
movq -0xe0(%rbp), %rdi
callq 0xe6e0
movslq 0x94(%rax), %rsi
leaq -0x60(%rbp), %rdi
callq 0x20c00
jmp 0x2e1b7
movl $0x0, -0x70(%rbp)
movq -0xe0(%rbp), %rdi
movl -0x70(%rbp), %eax
movl %eax, -0xe8(%rbp)
addq $0x10, %rdi
callq 0x34050
movq %rax, %rdi
callq 0x8340
movl %eax, -0xe4(%rbp)
jmp 0x2e1e7
movl -0xe8(%rbp), %eax
movl -0xe4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x2e310
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq %rax, %rsi
movl -0x70(%rbp), %edx
leaq -0x90(%rbp), %rdi
callq 0x8de0
jmp 0x2e21f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x70(%rbp), %rdx
callq 0x1e0d0
movss %xmm0, -0xec(%rbp)
jmp 0x2e23a
movss -0xec(%rbp), %xmm0
movss %xmm0, -0x94(%rbp)
movss -0x94(%rbp), %xmm0
movss -0x2c(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0xc4(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc4(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x35390
jmp 0x2e27f
leaq -0x50(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x35340
jmp 0x2e291
leaq -0xc0(%rbp), %rdi
callq 0x34f90
leaq -0x90(%rbp), %rdi
callq 0x58d8
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x2e1be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2e4b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2e4a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2e2ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x34f90
leaq -0x90(%rbp), %rdi
callq 0x58d8
jmp 0x2e4a8
movl $0x0, -0xc8(%rbp)
movl -0xc8(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0xed(%rbp)
jge 0x2e353
leaq -0x50(%rbp), %rdi
callq 0x353d0
movq %rax, -0xf8(%rbp)
jmp 0x2e33f
movq -0xf8(%rbp), %rax
cmpq $0x0, %rax
seta %al
movb %al, -0xed(%rbp)
movb -0xed(%rbp), %al
testb $0x1, %al
jne 0x2e362
jmp 0x2e48d
movq -0x28(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x35420
movq %rax, -0x100(%rbp)
jmp 0x2e37f
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
addq $0x8, %rsi
callq 0x353f0
movq %rax, -0x110(%rbp)
jmp 0x2e39f
movq -0x110(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x35470
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x35440
testb $0x1, %al
jne 0x2e3d9
jmp 0x2e47d
leaq -0x50(%rbp), %rdi
callq 0x35420
movq %rax, -0x118(%rbp)
jmp 0x2e3eb
movq -0x118(%rbp), %rsi
addq $0x8, %rsi
movq 0x30bbb(%rip), %rdi     # 0x5efb8
callq 0x53e0
movq %rax, -0x120(%rbp)
jmp 0x2e40b
movq -0x120(%rbp), %rdi
leaq 0x14728(%rip), %rsi     # 0x42b41
callq 0x5420
movq %rax, -0x128(%rbp)
jmp 0x2e427
leaq -0x50(%rbp), %rdi
callq 0x35420
movq %rax, -0x130(%rbp)
jmp 0x2e439
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %rax
movss (%rax), %xmm0
callq 0x5330
movq %rax, -0x138(%rbp)
jmp 0x2e459
movq -0x138(%rbp), %rdi
movq 0x30b29(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2e46e
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x354a0
jmp 0x2e488
jmp 0x2e31a
leaq -0x60(%rbp), %rdi
callq 0x20c60
leaq -0x50(%rbp), %rdi
callq 0x354f0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x20c60
leaq -0x50(%rbp), %rdi
callq 0x354f0
movq -0x68(%rbp), %rdi
callq 0x57a0
nopw %cs:(%rax,%rax)