// File: 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
movq %rsp, %rbp
subq $0x5e0, %rsp            # imm = 0x5E0
movq %rdx, -0x548(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x550(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5600
movq -0x548(%rbp), %rsi
leaq -0x240(%rbp), %rdi
movl $0x8, %edx
callq 0x56d0
jmp 0x2f55b
movq -0x550(%rbp), %rdi
movq $0x0, -0x258(%rbp)
callq 0xe6e0
movslq 0x94(%rax), %rsi
leaq -0x268(%rbp), %rdi
callq 0x20c00
jmp 0x2f587
movq -0x550(%rbp), %rdi
callq 0xe6e0
movslq 0x94(%rax), %rsi
leaq -0x278(%rbp), %rdi
callq 0x20c00
jmp 0x2f5a8
leaq -0x290(%rbp), %rdi
callq 0xe720
leaq -0x2a8(%rbp), %rdi
callq 0xe440
leaq -0x2c0(%rbp), %rdi
callq 0xe440
movq -0x548(%rbp), %rsi
leaq -0x4c8(%rbp), %rdi
movl $0x8, %edx
callq 0x56d0
jmp 0x2f5e6
jmp 0x2f5e8
leaq -0x4c8(%rbp), %rdi
callq 0x5190
movl %eax, -0x554(%rbp)
jmp 0x2f5fc
movl -0x554(%rbp), %eax
cmpl $-0x1, %eax
je 0x2f6b6
leaq -0x4c8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x50d0
jmp 0x2f61d
leaq -0x290(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xe640
jmp 0x2f62f
movq -0x258(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x258(%rbp)
jmp 0x2f5e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x2fdda
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x2fdce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x2fdc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x2fd92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x2fd86
movq 0x2f8fb(%rip), %rdi     # 0x5efb8
leaq 0x141ae(%rip), %rsi     # 0x43872
callq 0x5420
movq %rax, -0x560(%rbp)
jmp 0x2f6d2
movq -0x560(%rbp), %rdi
movq -0x258(%rbp), %rsi
callq 0x5810
movq %rax, -0x568(%rbp)
jmp 0x2f6ee
movq -0x568(%rbp), %rdi
leaq 0x14122(%rip), %rsi     # 0x4381e
callq 0x5420
movq %rax, -0x570(%rbp)
jmp 0x2f70a
movq -0x570(%rbp), %rdi
movq 0x2f878(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2f71f
movq -0x550(%rbp), %rdi
movq -0x258(%rbp), %rax
incq %rax
movq %rax, -0x578(%rbp)
callq 0xe6e0
movq -0x578(%rbp), %rsi
movslq 0x94(%rax), %rdx
leaq -0x4e0(%rbp), %rdi
callq 0x1de00
jmp 0x2f758
movq -0x550(%rbp), %rdi
leaq -0x4e0(%rbp), %rsi
leaq -0x240(%rbp), %rdx
callq 0x2de30
jmp 0x2f774
leaq -0x510(%rbp), %rdi
callq 0x35550
movq 0x2f869(%rip), %rdi     # 0x5eff0
leaq 0x14120(%rip), %rsi     # 0x438ae
callq 0x5420
movq %rax, -0x580(%rbp)
jmp 0x2f79c
movq -0x580(%rbp), %rdi
movq 0x2f7e6(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2f7b1
jmp 0x2f7b3
jmp 0x2f7b5
leaq -0x510(%rbp), %rdi
callq 0x35570
leaq -0x278(%rbp), %rdi
callq 0x20cb0
jmp 0x2f7cf
movq -0x550(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0x550(%rbp), %rdi
movq %rax, -0x588(%rbp)
addq $0x60, %rdi
callq 0x34630
movq -0x588(%rbp), %rdi
movq %rax, %r8
addq $0x110, %r8             # imm = 0x110
movq 0x2f7ca(%rip), %rsi     # 0x5efd8
leaq -0x2a8(%rbp), %rdx
leaq -0x2c0(%rbp), %rcx
callq 0xac80
jmp 0x2f823
movq -0x550(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0x550(%rbp), %rdi
movq %rax, -0x590(%rbp)
callq 0xe6e0
movq -0x590(%rbp), %rdi
movl 0xb4(%rax), %edx
leaq -0x2a8(%rbp), %rsi
callq 0xa820
jmp 0x2f861
leaq -0x268(%rbp), %rdi
callq 0x20cb0
jmp 0x2f86f
leaq -0x2a8(%rbp), %rdi
callq 0xf370
movq %rax, -0x518(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0xf3e0
movq %rax, -0x520(%rbp)
leaq -0x518(%rbp), %rdi
leaq -0x520(%rbp), %rsi
callq 0xf3a0
testb $0x1, %al
jne 0x2f8b1
jmp 0x2f936
movq -0x550(%rbp), %rdi
addq $0x20, %rdi
callq 0x23880
movq %rax, -0x598(%rbp)
leaq -0x518(%rbp), %rdi
callq 0xf410
movq -0x598(%rbp), %rsi
movslq (%rax), %rdx
leaq -0x268(%rbp), %rdi
callq 0x20f30
jmp 0x2f8ec
jmp 0x2f8ee
leaq -0x518(%rbp), %rdi
callq 0xf430
jmp 0x2f882
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x2fd7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x510(%rbp), %rdi
callq 0x355e0
jmp 0x2fd7a
leaq -0x2a8(%rbp), %rdi
callq 0x34ec0
testb $0x1, %al
jne 0x2f999
leaq -0x2a8(%rbp), %rdi
callq 0xed50
movq %rax, %xmm1
movaps 0x12f92(%rip), %xmm0    # 0x428f0
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x12f96(%rip), %xmm0    # 0x42900
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x12f37(%rip), %xmm0    # 0x428b8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0x268(%rbp), %rdi
callq 0x20d80
jmp 0x2f997
jmp 0x2f999
leaq -0x278(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movss 0x12f19(%rip), %xmm0    # 0x428c8
callq 0x20e80
jmp 0x2f9b6
movq -0x550(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0x550(%rbp), %rdi
movq %rax, -0x5a0(%rbp)
addq $0x60, %rdi
callq 0x34630
movq -0x5a0(%rbp), %rdi
movq %rax, %r8
addq $0x110, %r8             # imm = 0x110
movq 0x2f5e3(%rip), %rsi     # 0x5efd8
leaq -0x2a8(%rbp), %rdx
leaq -0x2c0(%rbp), %rcx
callq 0xac80
jmp 0x2fa0a
movq -0x550(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0x550(%rbp), %rdi
movq %rax, -0x5a8(%rbp)
callq 0xe6e0
movq -0x5a8(%rbp), %rdi
movl 0xb4(%rax), %edx
leaq -0x2a8(%rbp), %rsi
callq 0xa820
jmp 0x2fa48
leaq -0x268(%rbp), %rdi
callq 0x20cb0
jmp 0x2fa56
leaq -0x2a8(%rbp), %rdi
callq 0xf370
movq %rax, -0x528(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0xf3e0
movq %rax, -0x530(%rbp)
leaq -0x528(%rbp), %rdi
leaq -0x530(%rbp), %rsi
callq 0xf3a0
testb $0x1, %al
jne 0x2fa95
jmp 0x2fae0
movq -0x550(%rbp), %rdi
addq $0x20, %rdi
callq 0x23880
movq %rax, -0x5b0(%rbp)
leaq -0x528(%rbp), %rdi
callq 0xf410
movq -0x5b0(%rbp), %rsi
movslq (%rax), %rdx
leaq -0x268(%rbp), %rdi
callq 0x20f30
jmp 0x2fad0
jmp 0x2fad2
leaq -0x528(%rbp), %rdi
callq 0xf430
jmp 0x2fa69
leaq -0x2a8(%rbp), %rdi
callq 0x34ec0
testb $0x1, %al
jne 0x2fb43
leaq -0x2a8(%rbp), %rdi
callq 0xed50
movq %rax, %xmm1
movaps 0x12de8(%rip), %xmm0    # 0x428f0
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x12dec(%rip), %xmm0    # 0x42900
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x12d8d(%rip), %xmm0    # 0x428b8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0x268(%rbp), %rdi
callq 0x20d80
jmp 0x2fb41
jmp 0x2fb43
leaq -0x278(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movss 0x13b47(%rip), %xmm0    # 0x436a0
callq 0x20e80
jmp 0x2fb60
movq -0x550(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0x550(%rbp), %rdi
movq %rax, -0x5b8(%rbp)
addq $0x60, %rdi
callq 0x34630
movq -0x5b8(%rbp), %rdi
movq %rax, %r8
addq $0x110, %r8             # imm = 0x110
movq 0x2f439(%rip), %rsi     # 0x5efd8
leaq -0x2a8(%rbp), %rdx
leaq -0x2c0(%rbp), %rcx
callq 0xac80
jmp 0x2fbb4
movq -0x550(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0x550(%rbp), %rdi
movq %rax, -0x5c0(%rbp)
callq 0xe6e0
movq -0x5c0(%rbp), %rdi
movl 0xb4(%rax), %edx
leaq -0x2a8(%rbp), %rsi
callq 0xa820
jmp 0x2fbf2
leaq -0x268(%rbp), %rdi
callq 0x20cb0
jmp 0x2fc00
leaq -0x2a8(%rbp), %rdi
callq 0xf370
movq %rax, -0x538(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0xf3e0
movq %rax, -0x540(%rbp)
leaq -0x538(%rbp), %rdi
leaq -0x540(%rbp), %rsi
callq 0xf3a0
testb $0x1, %al
jne 0x2fc3f
jmp 0x2fc8a
movq -0x550(%rbp), %rdi
addq $0x20, %rdi
callq 0x23880
movq %rax, -0x5c8(%rbp)
leaq -0x538(%rbp), %rdi
callq 0xf410
movq -0x5c8(%rbp), %rsi
movslq (%rax), %rdx
leaq -0x268(%rbp), %rdi
callq 0x20f30
jmp 0x2fc7a
jmp 0x2fc7c
leaq -0x538(%rbp), %rdi
callq 0xf430
jmp 0x2fc13
leaq -0x2a8(%rbp), %rdi
callq 0x34ec0
testb $0x1, %al
jne 0x2fced
leaq -0x2a8(%rbp), %rdi
callq 0xed50
movq %rax, %xmm1
movaps 0x12c3e(%rip), %xmm0    # 0x428f0
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x12c42(%rip), %xmm0    # 0x42900
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x12be3(%rip), %xmm0    # 0x428b8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0x268(%rbp), %rdi
callq 0x20d80
jmp 0x2fceb
jmp 0x2fced
leaq -0x278(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movss 0x12bc5(%rip), %xmm0    # 0x428c8
callq 0x20e80
jmp 0x2fd0a
movq -0x550(%rbp), %rdi
movl -0xc(%rbp), %ecx
movq -0x258(%rbp), %r9
movq %rsp, %rax
leaq -0x290(%rbp), %rdx
movq %rdx, (%rax)
leaq -0x4e0(%rbp), %rsi
leaq -0x278(%rbp), %rdx
leaq -0x510(%rbp), %r8
callq 0x2e4d0
jmp 0x2fd44
movq 0x2f2a5(%rip), %rdi     # 0x5eff0
leaq 0x13b5c(%rip), %rsi     # 0x438ae
callq 0x5420
movq %rax, -0x5d0(%rbp)
jmp 0x2fd60
movq -0x5d0(%rbp), %rdi
movq 0x2f222(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2fd75
jmp 0x2f7b3
leaq -0x4e0(%rbp), %rdi
callq 0x1df90
leaq -0x4c8(%rbp), %rdi
callq 0x5130
leaq -0x2c0(%rbp), %rdi
callq 0xe530
leaq -0x2a8(%rbp), %rdi
callq 0xe530
leaq -0x290(%rbp), %rdi
callq 0xe820
leaq -0x278(%rbp), %rdi
callq 0x20c60
leaq -0x268(%rbp), %rdi
callq 0x20c60
leaq -0x240(%rbp), %rdi
callq 0x5130
leaq -0x38(%rbp), %rdi
callq 0x58d8
movq -0x248(%rbp), %rdi
callq 0x57a0
nop