// File: /workspace/github_cpp_makefile_star2_O3/epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::analogiesSent(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void FastText::analogiesSent(int32_t k, std::string filename) {
  std::string sentence;
  std::ifstream in1(filename);
  int64_t n = 0;

  Vector buffer(args_->dim), query(args_->dim);
  std::vector<std::string> sentences;

  std::vector<int32_t> line, labels;

  std::ifstream in2(filename);

  while (in2.peek() != EOF) {
    std::getline(in2, sentence);
    sentences.push_back(sentence);
    n++;
  }
  std::cout << "Number of sentences in the corpus file is " << n << "." << std::endl ;

  Matrix sentenceVectors(n+1, args_->dim);

  precomputeSentenceVectors(sentenceVectors, in1);
  std::set<std::string> banSet;
  std::cerr << "Query triplet sentences (A - B + C)? " << std::endl;
  while (true) {
    banSet.clear();
    query.zero();
    dict_->getLine(std::cin, line, labels, model_->rng);
    dict_->addNgrams(line, args_->wordNgrams);
    buffer.zero();
    for (auto it = line.cbegin(); it != line.cend(); ++it) {
      buffer.addRow(*input_, *it);
    }
    if (!line.empty()) {
      buffer.mul(1.0 / line.size());
    }
    query.addVector(buffer, 1.0);

    dict_->getLine(std::cin, line, labels, model_->rng);
    dict_->addNgrams(line, args_->wordNgrams);
    buffer.zero();
    for (auto it = line.cbegin(); it != line.cend(); ++it) {
      buffer.addRow(*input_, *it);
    }
    if (!line.empty()) {
      buffer.mul(1.0 / line.size());
    }

    query.addVector(buffer, -1.0);

    dict_->getLine(std::cin, line, labels, model_->rng);
    dict_->addNgrams(line, args_->wordNgrams);
    buffer.zero();
    for (auto it = line.cbegin(); it != line.cend(); ++it) {
      buffer.addRow(*input_, *it);
    }
    if (!line.empty()) {
      buffer.mul(1.0 / line.size());
    }

    query.addVector(buffer, 1.0);

    findNNSent(sentenceVectors, query, k, banSet, n, sentences);
    std::cerr << "Query triplet sentences (A - B + C)? " << std::endl;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x508, %rsp            # imm = 0x508
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %r14
leaq 0x70(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
leaq 0x300(%rsp), %rdi
movq %rdx, %rsi
movl $0x8, %edx
callq 0x44f0
movq (%r14), %rax
movslq 0x94(%rax), %rsi
leaq 0x80(%rsp), %rdi
callq 0xf1ac
movq (%r14), %rax
movslq 0x94(%rax), %rsi
leaq 0x30(%rsp), %rdi
callq 0xf1ac
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
xorl %eax, %eax
movq %rax, 0xa0(%rsp)
movq %rax, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x44f0
movl %r12d, 0x2c(%rsp)
xorl %r15d, %r15d
leaq 0x60(%rsp), %r13
leaq 0x90(%rsp), %r12
movq %rbx, %rdi
callq 0x4130
cmpl $-0x1, %eax
je 0x17d2d
movq 0xf8(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4600
movq %r12, %rdi
movq %r13, %rsi
callq 0xa63a
incq %r15
jmp 0x17ce9
movq 0x1228c(%rip), %rdi     # 0x29fc0
leaq 0x7ba7(%rip), %rsi      # 0x1f8e2
movl $0x2a, %edx
callq 0x4350
movq 0x12274(%rip), %rdi     # 0x29fc0
movq %r15, %rsi
callq 0x42c0
movq %rax, %rbx
leaq 0x7b30(%rip), %rsi      # 0x1f88e
movl $0x1, %edx
movq %rax, %rdi
callq 0x4350
movq %rbx, %rdi
callq 0x4170
leaq 0x1(%r15), %rsi
movq (%r14), %rax
movslq 0x94(%rax), %rdx
leaq 0xb0(%rsp), %rdi
callq 0xdf88
leaq 0xb0(%rsp), %rsi
leaq 0x300(%rsp), %rdx
movq %r14, %rdi
callq 0x1691e
leaq 0xd0(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq 0x12223(%rip), %rdi     # 0x29ff0
leaq 0x7b4a(%rip), %rsi      # 0x1f91e
movl $0x25, %edx
callq 0x4350
movq 0x1220b(%rip), %rdi     # 0x29ff0
callq 0x4170
leaq 0x80(%rsp), %r13
leaq 0xc8(%rsp), %rdi
callq 0x1ba34
leaq 0x30(%rsp), %rdi
callq 0xf1e8
movq 0x10(%r14), %rdi
movq 0x60(%r14), %r8
movl $0x110, %eax            # imm = 0x110
addq %rax, %r8
movq 0x121b8(%rip), %rsi     # 0x29fd8
leaq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0x8716
movq (%r14), %rax
movq 0x10(%r14), %rdi
movl 0xb4(%rax), %edx
leaq 0x10(%rsp), %rsi
callq 0x82ec
movq %r13, %rdi
callq 0xf1e8
movq 0x10(%rsp), %rbp
cmpq 0x18(%rsp), %rbp
je 0x17ecc
movq %rbp, %rbx
negq %rbx
movq 0x20(%r14), %rsi
movslq (%rbp), %rdx
movq %r13, %rdi
callq 0xf302
addq $0x4, %rbp
addq $-0x4, %rbx
cmpq 0x18(%rsp), %rbp
jne 0x17e60
movq 0x10(%rsp), %rax
cmpq %rax, %rbp
je 0x17ecc
addq %rbx, %rax
negq %rax
sarq $0x2, %rax
movq %rax, %xmm0
punpckldq 0x6a70(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x6a78(%rip), %xmm0     # 0x1e920
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x6a3c(%rip), %xmm0     # 0x1e8f8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %r13, %rdi
callq 0xf238
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
movss 0x72ac(%rip), %xmm0     # 0x1f188
callq 0xf2ae
movq 0x10(%r14), %rdi
movq 0x60(%r14), %r8
movl $0x110, %eax            # imm = 0x110
addq %rax, %r8
movq 0x120e0(%rip), %rsi     # 0x29fd8
leaq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0x8716
movq (%r14), %rax
movq 0x10(%r14), %rdi
movl 0xb4(%rax), %edx
leaq 0x10(%rsp), %rsi
callq 0x82ec
movq %r13, %rdi
callq 0xf1e8
movq 0x10(%rsp), %rbx
cmpq 0x18(%rsp), %rbx
je 0x17fa3
movq %rbx, %rbp
negq %rbp
movq 0x20(%r14), %rsi
movslq (%rbx), %rdx
movq %r13, %rdi
callq 0xf302
addq $0x4, %rbx
addq $-0x4, %rbp
cmpq 0x18(%rsp), %rbx
jne 0x17f38
movq 0x10(%rsp), %rax
cmpq %rax, %rbx
je 0x17fa3
addq %rbp, %rax
negq %rax
sarq $0x2, %rax
movq %rax, %xmm0
punpckldq 0x6999(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x69a1(%rip), %xmm0     # 0x1e920
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x6965(%rip), %xmm0     # 0x1e8f8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %r13, %rdi
callq 0xf238
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
movss 0x776d(%rip), %xmm0     # 0x1f720
callq 0xf2ae
movq 0x10(%r14), %rdi
movq 0x60(%r14), %r8
movl $0x110, %eax            # imm = 0x110
addq %rax, %r8
movq 0x12009(%rip), %rsi     # 0x29fd8
leaq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0x8716
movq (%r14), %rax
movq 0x10(%r14), %rdi
movl 0xb4(%rax), %edx
leaq 0x10(%rsp), %rsi
callq 0x82ec
movq %r13, %rdi
callq 0xf1e8
movq 0x10(%rsp), %rbx
cmpq 0x18(%rsp), %rbx
je 0x1807a
movq %rbx, %rbp
negq %rbp
movq 0x20(%r14), %rsi
movslq (%rbx), %rdx
movq %r13, %rdi
callq 0xf302
addq $0x4, %rbx
addq $-0x4, %rbp
cmpq 0x18(%rsp), %rbx
jne 0x1800f
movq 0x10(%rsp), %rax
cmpq %rax, %rbx
je 0x1807a
addq %rbp, %rax
negq %rax
sarq $0x2, %rax
movq %rax, %xmm0
punpckldq 0x68c2(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x68ca(%rip), %xmm0     # 0x1e920
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x688e(%rip), %xmm0     # 0x1e8f8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %r13, %rdi
callq 0xf238
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
movss 0x70fe(%rip), %xmm0     # 0x1f188
callq 0xf2ae
movq %r12, (%rsp)
movq %r14, %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movl 0x2c(%rsp), %ecx
leaq 0xc8(%rsp), %r8
movq %r15, %r9
callq 0x16e06
movl $0x25, %edx
movq 0x11f2d(%rip), %rdi     # 0x29ff0
leaq 0x7854(%rip), %rsi      # 0x1f91e
callq 0x4350
movq 0x11f1a(%rip), %rcx     # 0x29ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq 0x11efc(%rip), %rdi     # 0x29ff0
callq 0x4040
movq %rax, %rdi
callq 0x4200
jmp 0x17df2
jmp 0x1810c
jmp 0x1810c
jmp 0x1810c
movq %rax, %rbx
leaq 0x70(%rsp), %rbp
jmp 0x18119
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x1a262
jmp 0x1812b
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xe05a
jmp 0x18141
jmp 0x1813e
jmp 0x1813e
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x40c0
jmp 0x18153
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1816a
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18181
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
leaq 0x90(%rsp), %rdi
callq 0xa678
leaq 0x30(%rsp), %rdi
callq 0xf1d6
jmp 0x1819d
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xf1d6
jmp 0x181af
movq %rax, %rbx
leaq 0x300(%rsp), %rdi
callq 0x40c0
jmp 0x181c1
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %rbp, %rdi
je 0x181d8
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x45b0