// File: /workspace/github_cpp_makefile_star2_O1/epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::loadOutputVectors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void FastText::loadOutputVectors(std::string filename) {
  std::ifstream in(filename);
  std::vector<std::string> words;
  std::shared_ptr<Matrix> mat; // temp. matrix for pretrained vectors
  int64_t n, dim;
  real x;
  if (!in.is_open()) {
    std::cerr << "Pretrained vectors file cannot be opened!" << std::endl;
    exit(EXIT_FAILURE);
  }
  in >> n >> dim;
  if (dim != args_->dim) {
    std::cerr << "Dimension of pretrained vectors does not match -dim option"
              << std::endl;
    exit(EXIT_FAILURE);
  }
  mat = std::make_shared<Matrix>(n, dim);
  for (size_t i = 0; i < n; i++) {
    std::string word;
    in >> word;
    if (dict_->getId(word) != -1){
      words.push_back(word);
      dict_->add(word);

      for (size_t j = 0; j < dim; j++) {
        in >> mat->data_[(words.size() -1) * dim + j];
      }

    }
    else{
      for (size_t j = 0; j < dim; j++) {
        in >> x;
      }
    }
  }
  in.close();

  output_ = std::make_shared<Matrix>(dict_->nwords(), args_->dim);
  output_->uniform(0.0 / args_->dim);

  for (size_t i = 0; i < words.size(); i++) {
    int32_t idx = dict_->getId(words[i]);

    if (idx < 0 || idx >= dict_->nwords()) continue;
    for (size_t j = 0; j < dim; j++) {
      output_->data_[idx * dim + j] = mat->data_[i * dim + j];
    }
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdi, %rbx
leaq 0x80(%rsp), %rdi
movl $0x8, %edx
callq 0x44f0
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x40b0
testb %al, %al
je 0x18e1b
movq $0x0, 0x8(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x4310
movq $0x0, 0x8(%rsp)
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x4310
movq (%rbx), %rax
movslq 0x94(%rax), %rax
cmpq %rax, 0x10(%rsp)
jne 0x18e53
leaq 0x28(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x20(%rsp), %rsi
leaq 0x5c(%rsp), %rdx
leaq 0x50(%rsp), %rcx
leaq 0x10(%rsp), %r8
callq 0x1bbb8
movq %rbx, 0x48(%rsp)
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x18ba3
callq 0xa86c
cmpq $0x0, 0x50(%rsp)
je 0x18cb3
leaq 0x30(%rsp), %r12
xorl %ebp, %ebp
leaq 0x80(%rsp), %r15
leaq 0x7c(%rsp), %r13
movq %r12, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq %r15, %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x43d0
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rdi
movq %r14, %rsi
callq 0x6720
cmpl $-0x1, %eax
je 0x18c69
leaq 0x60(%rsp), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0xa616
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rdi
movq %r14, %rsi
callq 0x641a
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x18c89
xorl %r14d, %r14d
xorl %r12d, %r12d
movq 0x68(%rsp), %rsi
subq 0x60(%rsp), %rsi
sarq $0x5, %rsi
decq %rsi
imulq %rax, %rsi
shlq $0x2, %rsi
addq (%rbx), %rsi
addq %r14, %rsi
movq %r15, %rdi
callq 0x4670
incq %r12
movq 0x10(%rsp), %rax
addq $0x4, %r14
cmpq %rax, %r12
jb 0x18c2f
jmp 0x18c89
cmpq $0x0, 0x10(%rsp)
je 0x18c89
xorl %r14d, %r14d
movq %r15, %rdi
movq %r13, %rsi
callq 0x4670
incq %r14
cmpq 0x10(%rsp), %r14
jb 0x18c74
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %r12
cmpq %r12, %rdi
je 0x18ca5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4300
incq %rbp
cmpq 0x50(%rsp), %rbp
jb 0x18bc3
leaq 0x80(%rsp), %rdi
callq 0x4090
movq 0x48(%rsp), %r14
movq 0x10(%r14), %rdi
callq 0x6550
leaq 0x5c(%rsp), %rcx
movl %eax, (%rcx)
movl $0x94, %r8d
addq (%r14), %r8
leaq 0x28(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x20(%rsp), %rsi
leaq 0x1f(%rsp), %rdx
callq 0x1bc38
movaps 0x20(%rsp), %xmm0
xorpd %xmm1, %xmm1
movapd %xmm1, 0x20(%rsp)
movq 0x38(%r14), %rdi
movups %xmm0, 0x30(%r14)
testq %rdi, %rdi
je 0x18d1c
callq 0xa86c
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x18d2b
callq 0xa86c
movq (%r14), %rax
movq 0x30(%r14), %rdi
xorps %xmm0, %xmm0
cvtsi2sdl 0x94(%rax), %xmm0
xorpd %xmm1, %xmm1
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
callq 0xde0c
movq 0x60(%rsp), %rax
cmpq %rax, 0x68(%rsp)
je 0x18de3
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x10(%r14), %rdi
movq %r12, %rsi
shlq $0x5, %rsi
addq %rax, %rsi
callq 0x6720
movl %eax, %ebp
testl %eax, %eax
js 0x18dc6
movq 0x10(%r14), %rdi
callq 0x6550
cmpl %eax, %ebp
jge 0x18dc6
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x18dc6
movq 0x30(%r14), %rdx
movl %ebp, %ecx
imulq %rax, %rcx
shlq $0x2, %rcx
addq (%rdx), %rcx
movq %rax, %rdx
imulq %r15, %rdx
addq (%rbx), %rdx
xorl %esi, %esi
movss (%rdx,%rsi,4), %xmm0
movss %xmm0, (%rcx,%rsi,4)
incq %rsi
cmpq %rsi, %rax
jne 0x18db4
incq %r12
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x4, %r15
cmpq %rcx, %r12
jb 0x18d67
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x18df2
callq 0xa86c
leaq 0x60(%rsp), %rdi
callq 0xa654
leaq 0x80(%rsp), %rdi
callq 0x40c0
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x0, 0x8(%rsp)
movq 0x111c5(%rip), %rdi     # 0x29ff0
leaq 0x6b21(%rip), %rsi      # 0x1f953
movl $0x29, %edx
callq 0x4350
movq $0x0, 0x8(%rsp)
movq 0x111a4(%rip), %rdi     # 0x29ff0
callq 0x4170
jmp 0x18e89
movq $0x0, 0x8(%rsp)
movq 0x1118d(%rip), %rdi     # 0x29ff0
leaq 0x6b13(%rip), %rsi      # 0x1f97d
movl $0x3a, %edx
callq 0x4350
movq $0x0, 0x8(%rsp)
movq 0x1116c(%rip), %rdi     # 0x29ff0
callq 0x4170
movl $0x1, %edi
callq 0x4380
movq %rax, %r14
movq $0x0, 0x8(%rsp)
jmp 0x18ed0
jmp 0x18ea5
jmp 0x18ea5
movq %rax, %r14
jmp 0x18ed0
movq %rax, %r14
jmp 0x18eb9
jmp 0x18eb1
movq %rax, %r14
leaq 0x30(%rsp), %r12
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x18ed0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4300
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x18edf
callq 0xa86c
leaq 0x60(%rsp), %rdi
callq 0xa654
leaq 0x80(%rsp), %rdi
callq 0x40c0
movq %r14, %rdi
callq 0x45b0