// File: epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::precomputeSentenceVectors(fasttext::Matrix&, std::basic_ifstream<char, std::char_traits<char>>&)
void FastText::precomputeSentenceVectors(Matrix& sentenceVectors,std::ifstream& in) {
  Vector vec(args_->dim);
  sentenceVectors.zero();
  std::cerr << "Pre-computing sentence vectors...";
  std::vector<int32_t> line;
  std::vector<int32_t> labels;
  int32_t i = 0;
  while (i < sentenceVectors.m_) {

    dict_->getLine(in, line, labels, model_->rng);
    dict_->addNgrams(line, args_->wordNgrams);

    vec.zero();
    for (auto it = line.cbegin(); it != line.cend(); ++it) {
      vec.addRow(*input_, *it);
    }
    if (!line.empty()) {
      vec.mul(1.0 / line.size());
    }
    real norm = vec.norm();
    if(norm != 0)
        sentenceVectors.addRow(vec, i, 1.0 / norm);
    i++;
  }
  std::cerr << " done." << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0xe6e0
movslq 0x94(%rax), %rsi
leaq -0x28(%rbp), %rdi
callq 0x20c00
movq -0x10(%rbp), %rdi
callq 0x1dfc0
jmp 0x2de72
movq 0x31177(%rip), %rdi     # 0x5eff0
leaq 0x159a7(%rip), %rsi     # 0x43827
callq 0x5420
jmp 0x2de87
leaq -0x50(%rbp), %rdi
callq 0xe440
leaq -0x68(%rbp), %rdi
callq 0xe440
movl $0x0, -0x6c(%rbp)
movslq -0x6c(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x2e0c4
movq -0x90(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0x90(%rbp), %rdi
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
addq $0x60, %rdi
callq 0x34630
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq %rax, %r8
addq $0x110, %r8             # imm = 0x110
leaq -0x50(%rbp), %rdx
leaq -0x68(%rbp), %rcx
callq 0xac80
jmp 0x2df0b
movq -0x90(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0x90(%rbp), %rdi
movq %rax, -0xa8(%rbp)
callq 0xe6e0
movq -0xa8(%rbp), %rdi
movl 0xb4(%rax), %edx
leaq -0x50(%rbp), %rsi
callq 0xa820
jmp 0x2df46
leaq -0x28(%rbp), %rdi
callq 0x20cb0
jmp 0x2df51
leaq -0x50(%rbp), %rdi
callq 0xf370
movq %rax, -0x78(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xf3e0
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xf3a0
testb $0x1, %al
jne 0x2df7e
jmp 0x2dff4
movq -0x90(%rbp), %rdi
addq $0x20, %rdi
callq 0x23880
movq %rax, -0xb0(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xf410
movq -0xb0(%rbp), %rsi
movslq (%rax), %rdx
leaq -0x28(%rbp), %rdi
callq 0x20f30
jmp 0x2dfb3
jmp 0x2dfb5
leaq -0x78(%rbp), %rdi
callq 0xf430
jmp 0x2df5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2e119
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xe530
leaq -0x50(%rbp), %rdi
callq 0xe530
jmp 0x2e119
leaq -0x50(%rbp), %rdi
callq 0x34ec0
testb $0x1, %al
jne 0x2e04e
leaq -0x50(%rbp), %rdi
callq 0xed50
movq %rax, %xmm1
movaps 0x148da(%rip), %xmm0    # 0x428f0
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x148de(%rip), %xmm0    # 0x42900
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x1487f(%rip), %xmm0    # 0x428b8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0x28(%rbp), %rdi
callq 0x20d80
jmp 0x2e04c
jmp 0x2e04e
leaq -0x28(%rbp), %rdi
callq 0x20d00
movss %xmm0, -0xb4(%rbp)
jmp 0x2e061
movss -0xb4(%rbp), %xmm0
movss %xmm0, -0x84(%rbp)
movss -0x84(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x2e085
jp 0x2e085
jmp 0x2e0b6
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rdx
movss -0x84(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x14817(%rip), %xmm0    # 0x428b8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0x28(%rbp), %rsi
callq 0x1e1f0
jmp 0x2e0b4
jmp 0x2e0b6
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2dea0
movq 0x30f25(%rip), %rdi     # 0x5eff0
leaq 0x1574e(%rip), %rsi     # 0x43820
callq 0x5420
movq %rax, -0xc0(%rbp)
jmp 0x2e0e0
movq -0xc0(%rbp), %rdi
movq 0x30ea2(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2e0f5
leaq -0x68(%rbp), %rdi
callq 0xe530
leaq -0x50(%rbp), %rdi
callq 0xe530
leaq -0x28(%rbp), %rdi
callq 0x20c60
addq $0xc0, %rsp
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x20c60
movq -0x30(%rbp), %rdi
callq 0x57a0
nopl (%rax,%rax)