// File: epfml[P]sent2vec/src/fasttext.cc
// Function: fasttext::FastText::loadModelWithSharedMemory(std::istream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
void FastText::loadModelWithSharedMemory(std::istream& in,
                                         const std::string& filename,
                                         const int timeout_sec) {
  std::string shmem_name = "s2v_" + basename(filename) + "_input_matrix";

  args_ = std::make_shared<Args>();
  args_->load(in);

  dict_ = std::make_shared<Dictionary>(args_);
  dict_->load(in);

  in.read((char*) &quant_, sizeof(bool));

  input_ = ShmemMatrix::load(in, shmem_name, timeout_sec);

  in.read((char*) &args_->qout, sizeof(bool));

  output_ = std::make_shared<Matrix>();
  in.read((char*) &(output_->m_), sizeof(int64_t));
  in.read((char*) &(output_->n_), sizeof(int64_t));

  model_ = std::make_shared<Model>(input_, output_, args_, 0);

  if (args_->model == model_name::sup) {
    model_->setTargetCounts(dict_->getCounts(entry_type::label));
  } else {
    model_->setTargetCounts(dict_->getCounts(entry_type::word));
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x29fa0
movq -0x120(%rbp), %rdx
leaq 0x1a119(%rip), %rsi     # 0x437e0
leaq -0x60(%rbp), %rdi
callq 0x34120
jmp 0x296d2
leaq 0x1a10c(%rip), %rdx     # 0x437e5
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x33c70
jmp 0x296e8
leaq -0x60(%rbp), %rdi
callq 0x58d8
leaq -0x80(%rbp), %rdi
callq 0x58d8
leaq -0xa0(%rbp), %rdi
callq 0x33b10
jmp 0x29708
movq -0x128(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movq %rsi, -0x130(%rbp)
callq 0x33b80
movq -0x130(%rbp), %rdi
callq 0xe540
movq -0x128(%rbp), %rdi
callq 0xea70
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x7c80
jmp 0x29748
movq -0x128(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x33bb0
jmp 0x2975d
movq -0x128(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0x138(%rbp)
leaq -0xb0(%rbp), %rsi
movq %rsi, -0x140(%rbp)
callq 0x33c20
movq -0x140(%rbp), %rdi
callq 0x33c50
movq -0x138(%rbp), %rdi
callq 0x33af0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb370
jmp 0x297a8
movq -0x128(%rbp), %rsi
movq -0x10(%rbp), %rdi
subq $-0x80, %rsi
movl $0x1, %edx
callq 0x5540
jmp 0x297c3
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %ecx
leaq -0xc0(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x1edf0
jmp 0x297dc
movq -0x128(%rbp), %rdi
addq $0x20, %rdi
leaq -0xc0(%rbp), %rsi
movq %rsi, -0x150(%rbp)
callq 0x34170
movq -0x150(%rbp), %rdi
callq 0x341a0
movq -0x128(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
callq 0xea70
movq -0x148(%rbp), %rdi
movq %rax, %rsi
addq $0x12c, %rsi            # imm = 0x12C
movl $0x1, %edx
callq 0x5540
jmp 0x2983a
leaq -0xd0(%rbp), %rdi
callq 0x33eb0
jmp 0x29848
movq -0x128(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x160(%rbp)
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x168(%rbp)
callq 0x33f20
movq -0x168(%rbp), %rdi
callq 0x23bb0
movq -0x160(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
callq 0x23990
movq -0x158(%rbp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
movl $0x8, %edx
callq 0x5540
jmp 0x298aa
movq -0x128(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
addq $0x30, %rdi
callq 0x23990
movq -0x170(%rbp), %rdi
movq %rax, %rsi
addq $0x10, %rsi
movl $0x8, %edx
callq 0x5540
jmp 0x298df
movq -0x128(%rbp), %rcx
movq %rcx, %rsi
addq $0x20, %rsi
movq %rcx, %rdx
addq $0x30, %rdx
movl $0x0, -0xe4(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe4(%rbp), %r8
callq 0x33ff0
jmp 0x29913
movq -0x128(%rbp), %rdi
addq $0x60, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x34080
leaq -0xe0(%rbp), %rdi
callq 0x340b0
movq -0x128(%rbp), %rdi
callq 0xea70
cmpl $0x3, 0xc0(%rax)
jne 0x29a29
movq -0x128(%rbp), %rdi
addq $0x60, %rdi
callq 0x340d0
movq -0x128(%rbp), %rdi
movq %rax, -0x178(%rbp)
addq $0x10, %rdi
callq 0x33af0
movq %rax, %rsi
leaq -0x100(%rbp), %rdi
movl $0x1, %edx
callq 0xa150
jmp 0x2998c
movq -0x178(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x231c0
jmp 0x299a1
leaq -0x100(%rbp), %rdi
callq 0xf080
jmp 0x29aa6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x299e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x58d8
leaq -0x80(%rbp), %rdi
callq 0x58d8
jmp 0x29ac1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x29ab8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0xf080
jmp 0x29ab8
movq -0x128(%rbp), %rdi
addq $0x60, %rdi
callq 0x340d0
movq -0x128(%rbp), %rdi
movq %rax, -0x180(%rbp)
addq $0x10, %rdi
callq 0x33af0
movq %rax, %rsi
leaq -0x118(%rbp), %rdi
xorl %edx, %edx
callq 0xa150
jmp 0x29a63
movq -0x180(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x231c0
jmp 0x29a78
leaq -0x118(%rbp), %rdi
callq 0xf080
jmp 0x29aa6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0xf080
jmp 0x29ab8
leaq -0x40(%rbp), %rdi
callq 0x58d8
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x58d8
movq -0x88(%rbp), %rdi
callq 0x57a0
nopl (%rax)