// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movl %esi, %ebp
movq %rdi, %r14
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x300(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x4520
movq (%r14), %rax
movslq 0x94(%rax), %rsi
leaq 0x60(%rsp), %rdi
callq 0xd03c
movq (%r14), %rax
movslq 0x94(%rax), %rsi
leaq 0x30(%rsp), %rdi
callq 0xd03c
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
leaq 0xf8(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x4520
xorl %r15d, %r15d
leaq 0xf8(%rsp), %rbx
leaq 0xa8(%rsp), %r13
leaq 0x70(%rsp), %r12
movq %rbx, %rdi
callq 0x4130
cmpl $-0x1, %eax
je 0x13e2e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4090
movq %r12, %rdi
movq %r13, %rsi
callq 0x87e2
incq %r15
jmp 0x13e06
movq 0x1418b(%rip), %rdi     # 0x27fc0
leaq 0x7a9e(%rip), %rsi      # 0x1b8da
callq 0x4330
movq %rax, %rdi
movq %r15, %rsi
callq 0x4320
leaq 0x7a33(%rip), %rsi      # 0x1b886
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4190
leaq 0x1(%r15), %rsi
movq (%r14), %rax
movslq 0x94(%rax), %rdx
leaq 0x90(%rsp), %rdi
callq 0xbdec
leaq 0x90(%rsp), %rsi
leaq 0x300(%rsp), %rdx
movq %r14, %rdi
callq 0x12f6e
leaq 0xd0(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq 0x14136(%rip), %rdi     # 0x27ff0
leaq 0x7a55(%rip), %rsi      # 0x1b916
callq 0x4330
movq %rax, %rdi
callq 0x4190
movl %ebp, 0x2c(%rsp)
leaq 0x60(%rsp), %rbx
leaq 0xc8(%rsp), %rdi
callq 0x17964
leaq 0x30(%rsp), %rdi
callq 0xd078
movq 0x10(%r14), %rdi
movq 0x60(%r14), %r8
movl $0x110, %eax            # imm = 0x110
addq %rax, %r8
movq 0x140d3(%rip), %rsi     # 0x27fd8
leaq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0x7650
movq (%r14), %rax
movq 0x10(%r14), %rdi
movl 0xb4(%rax), %edx
leaq 0x10(%rsp), %rsi
callq 0x7364
movq %rbx, %rdi
callq 0xd078
movq 0x10(%rsp), %rbp
movq %rbp, %r13
negq %r13
cmpq 0x18(%rsp), %rbp
je 0x13f5f
movq 0x20(%r14), %rsi
movslq (%rbp), %rdx
movq %rbx, %rdi
callq 0xd19e
addq $0x4, %rbp
addq $-0x4, %r13
jmp 0x13f3e
movq 0x10(%rsp), %rax
cmpq %rax, %rbp
je 0x13fac
addq %r13, %rax
negq %rax
sarq $0x2, %rax
movq %rax, %xmm0
punpckldq 0x6990(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x6998(%rip), %xmm0     # 0x1a920
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x694c(%rip), %xmm0     # 0x1a8e8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %rbx, %rdi
callq 0xd0cc
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movss 0x71b4(%rip), %xmm0     # 0x1b170
callq 0xd148
movq 0x10(%r14), %rdi
movq 0x60(%r14), %r8
movl $0x110, %eax            # imm = 0x110
addq %rax, %r8
movq 0x14000(%rip), %rsi     # 0x27fd8
leaq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0x7650
movq (%r14), %rax
movq 0x10(%r14), %rdi
movl 0xb4(%rax), %edx
leaq 0x10(%rsp), %rsi
callq 0x7364
movq %rbx, %rdi
callq 0xd078
movq 0x10(%rsp), %r13
movq %r13, %rbp
negq %rbp
cmpq 0x18(%rsp), %r13
je 0x14032
movq 0x20(%r14), %rsi
movslq (%r13), %rdx
movq %rbx, %rdi
callq 0xd19e
addq $0x4, %r13
addq $-0x4, %rbp
jmp 0x14011
movq 0x10(%rsp), %rax
cmpq %rax, %r13
je 0x1407f
addq %rbp, %rax
negq %rax
sarq $0x2, %rax
movq %rax, %xmm0
punpckldq 0x68bd(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x68c5(%rip), %xmm0     # 0x1a920
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x6879(%rip), %xmm0     # 0x1a8e8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %rbx, %rdi
callq 0xd0cc
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movss 0x7689(%rip), %xmm0     # 0x1b718
callq 0xd148
movq 0x10(%r14), %rdi
movq 0x60(%r14), %r8
movl $0x110, %eax            # imm = 0x110
addq %rax, %r8
movq 0x13f2d(%rip), %rsi     # 0x27fd8
leaq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0x7650
movq (%r14), %rax
movq 0x10(%r14), %rdi
movl 0xb4(%rax), %edx
leaq 0x10(%rsp), %rsi
callq 0x7364
movq %rbx, %rdi
callq 0xd078
movq 0x10(%rsp), %r13
movq %r13, %rbp
negq %rbp
cmpq 0x18(%rsp), %r13
je 0x14105
movq 0x20(%r14), %rsi
movslq (%r13), %rdx
movq %rbx, %rdi
callq 0xd19e
addq $0x4, %r13
addq $-0x4, %rbp
jmp 0x140e4
movq 0x10(%rsp), %rax
cmpq %rax, %r13
je 0x14152
addq %rbp, %rax
negq %rax
sarq $0x2, %rax
movq %rax, %xmm0
punpckldq 0x67ea(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x67f2(%rip), %xmm0     # 0x1a920
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x67a6(%rip), %xmm0     # 0x1a8e8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq %rbx, %rdi
callq 0xd0cc
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movss 0x700e(%rip), %xmm0     # 0x1b170
callq 0xd148
movq %r12, (%rsp)
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movl 0x2c(%rsp), %ecx
leaq 0xc8(%rsp), %r8
movq %r15, %r9
callq 0x13344
movq 0x13e5a(%rip), %rdi     # 0x27ff0
leaq 0x7779(%rip), %rsi      # 0x1b916
callq 0x4330
movq %rax, %rdi
callq 0x4190
jmp 0x13ed7
jmp 0x141b7
jmp 0x141b7
jmp 0x141b7
jmp 0x141b7
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x15ea6
jmp 0x141cc
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0xbed2
jmp 0x141e2
jmp 0x141df
jmp 0x141df
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x40e0
jmp 0x141f4
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x8c0e
leaq 0x10(%rsp), %rdi
callq 0x8c0e
leaq 0x70(%rsp), %rdi
callq 0x880e
leaq 0x30(%rsp), %rdi
callq 0xd066
jmp 0x14221
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0xd066
jmp 0x14230
movq %rax, %rbx
leaq 0x300(%rsp), %rdi
callq 0x40e0
jmp 0x14242
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x46c8
movq %rbx, %rdi
callq 0x45d0
nop