// File: /workspace/github_cpp_makefile_star2_O2/epfml[P]sent2vec/src/fasttext.cc
// Function: fasttext::FastText::loadVectors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void FastText::loadVectors(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;
  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;
    words.push_back(word);
    dict_->add(word);
    for (size_t j = 0; j < dim; j++) {
      in >> mat->data_[i * dim + j];
    }
  }
  in.close();

  dict_->threshold(1, 0);
  input_ = std::make_shared<Matrix>(dict_->nwords()+args_->bucket, args_->dim);
  input_->uniform(1.0 / args_->dim);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdi, %rbx
leaq 0x70(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x4520
andq $0x0, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x10(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x40c0
testb %al, %al
je 0x1486a
leaq 0x70(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4360
movq %rsp, %rsi
movq %rax, %rdi
callq 0x4360
movq (%rbx), %rax
movslq 0x94(%rax), %rax
cmpq %rax, (%rsp)
jne 0x14887
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
callq 0x15a1d
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %r13
movq %r13, %rsi
callq 0x16130
leaq 0x28(%rsp), %rdi
callq 0x8d50
xorl %ebp, %ebp
leaq 0x70(%rsp), %r15
xorl %r14d, %r14d
movq %rbx, 0x60(%rsp)
cmpq 0x8(%rsp), %r14
jae 0x14741
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
andq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x4400
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0x89cc
movq 0x10(%rbx), %rdi
movq %r13, %rsi
callq 0x5eb2
xorl %r12d, %r12d
xorl %ebx, %ebx
movq (%rsp), %rsi
cmpq %rsi, %rbx
jae 0x14728
movq 0x10(%rsp), %rax
imulq %rbp, %rsi
addq (%rax), %rsi
addq %r12, %rsi
movq %r15, %rdi
callq 0x46b0
incq %rbx
addq $0x4, %r12
jmp 0x146ff
movq %r13, %rdi
callq 0x46c8
incq %r14
addq $0x4, %rbp
movq 0x60(%rsp), %rbx
jmp 0x146b6
leaq 0x70(%rsp), %rdi
callq 0x40a0
movq 0x10(%rbx), %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x6b5e
movq 0x10(%rbx), %rdi
callq 0x5f90
movq (%rbx), %rdx
addl 0xc4(%rdx), %eax
leaq 0x6c(%rsp), %rsi
movl %eax, (%rsi)
addq $0x94, %rdx
leaq 0x20(%rsp), %rdi
callq 0x15a3e
leaq 0x20(%rbx), %r14
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x16130
leaq 0x28(%rsp), %rdi
callq 0x8d50
movq (%rbx), %rax
movq 0x20(%rbx), %rdi
cvtsi2sdl 0x94(%rax), %xmm0
movsd 0x51a3(%rip), %xmm1     # 0x19958
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
callq 0xc0e6
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq 0x8(%rsp), %r12
jae 0x1483a
movq 0x10(%rbx), %rdi
movq %r12, %rsi
shlq $0x5, %rsi
addq 0x40(%rsp), %rsi
callq 0x60ba
movl %eax, %ebp
testl %eax, %eax
js 0x14831
movq 0x10(%rbx), %rdi
callq 0x5f90
cmpl %eax, %ebp
jge 0x14831
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%r14), %rdx
movl %ebp, %esi
imulq %rax, %rsi
movq %rax, %rdi
imulq %r15, %rdi
subq $0x1, %rax
jb 0x14831
movq (%rcx), %r8
movss (%r8,%rdi), %xmm0
movq (%rdx), %r8
movss %xmm0, (%r8,%rsi,4)
incq %rsi
addq $0x4, %rdi
jmp 0x14810
incq %r12
addq $0x4, %r15
jmp 0x147c8
leaq 0x18(%rsp), %rdi
callq 0x8d50
leaq 0x40(%rsp), %rdi
callq 0x89f8
leaq 0x70(%rsp), %rdi
callq 0x40e0
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1277f(%rip), %rdi     # 0x26ff0
leaq 0x6366(%rip), %rsi      # 0x1abde
callq 0x4330
movq %rax, %rdi
callq 0x4190
jmp 0x148a2
movq 0x12762(%rip), %rdi     # 0x26ff0
leaq 0x6373(%rip), %rsi      # 0x1ac08
callq 0x4330
movq %rax, %rdi
callq 0x4190
pushq $0x1
popq %rdi
callq 0x43b0
jmp 0x148b0
jmp 0x148b0
jmp 0x148b0
movq %rax, %rbx
jmp 0x148c4
jmp 0x148b7
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x46c8
leaq 0x18(%rsp), %rdi
callq 0x8d50
leaq 0x40(%rsp), %rdi
callq 0x89f8
leaq 0x70(%rsp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x45d0