// File: /workspace/github_cpp_makefile_star2_O2/epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::quantize(std::shared_ptr<fasttext::Args>)
void FastText::quantize(std::shared_ptr<Args> qargs) {
  if (qargs->output.empty()) {
      std::cerr<<"No model provided!"<<std::endl; exit(1);
  }
  loadModel(qargs->output + ".bin");

  args_->input = qargs->input;
  args_->qout = qargs->qout;
  args_->output = qargs->output;


  if (qargs->cutoff > 0 && qargs->cutoff < input_->m_) {
    auto idx = selectEmbeddings(qargs->cutoff);
    dict_->prune(idx);
    std::shared_ptr<Matrix> ninput =
      std::make_shared<Matrix> (idx.size(), args_->dim);
    for (auto i = 0; i < idx.size(); i++) {
      for (auto j = 0; j < args_->dim; j++) {
        ninput->at(i,j) = input_->at(idx[i], j);
      }
    }
    input_ = ninput;
    if (qargs->retrain) {
      args_->epoch = qargs->epoch;
      args_->lr = qargs->lr;
      args_->thread = qargs->thread;
      args_->verbose = qargs->verbose;
      tokenCount = 0;
      std::vector<std::thread> threads;
      for (int32_t i = 0; i < args_->thread; i++) {
        threads.push_back(std::thread([=]() { trainThread(i); }));
      }
      for (auto it = threads.begin(); it != threads.end(); ++it) {
        it->join();
      }
    }
  }

  qinput_ = std::make_shared<QMatrix>(*input_, qargs->dsub, qargs->qnorm);

  if (args_->qout) {
    qoutput_ = std::make_shared<QMatrix>(*output_, 2, qargs->qnorm);
  }

  quant_ = true;
  saveModel();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r13
movq (%rsi), %rsi
cmpq $0x0, 0x48(%rsi)
je 0x1127e
movq %rdi, %rbx
addq $0x40, %rsi
leaq 0xa83d(%rip), %rdx      # 0x1b7d2
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xc742
pushq $-0x1
popq %rcx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x1066c
leaq 0x8(%rsp), %rdi
callq 0x46c8
movq (%r13), %rsi
movq (%rbx), %rdi
callq 0x41d0
movq (%r13), %rsi
movb 0x12c(%rsi), %al
movq (%rbx), %rdi
movb %al, 0x12c(%rdi)
addq $0x40, %rsi
addq $0x40, %rdi
callq 0x41d0
movq (%r13), %rcx
movq 0x130(%rcx), %rdx
testq %rdx, %rdx
je 0x111e4
movq 0x20(%rbx), %rax
cmpq 0x8(%rax), %rdx
jae 0x111e4
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x10e06
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x7a0a
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
sarq $0x2, %rax
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
movl $0x94, %edx
addq (%rbx), %rdx
leaq 0x30(%rsp), %rdi
callq 0x15c4b
leaq 0x20(%rbx), %rdi
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq (%rbx), %rdx
xorl %esi, %esi
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq %rcx, %r9
je 0x110c6
movl 0x94(%rdx), %r10d
movq (%rdi), %r11
movq 0x30(%rsp), %r14
testl %r10d, %r10d
cmovlel %esi, %r10d
xorl %r15d, %r15d
cmpq %r15, %r10
je 0x110bd
movslq (%rax,%r9,4), %r12
imulq 0x10(%r11), %r12
shlq $0x2, %r12
addq (%r11), %r12
movss (%r12,%r15,4), %xmm0
movq 0x10(%r14), %r12
imulq %r8, %r12
addq (%r14), %r12
movss %xmm0, (%r12,%r15,4)
incq %r15
jmp 0x1108c
incq %r9
addq $0x4, %r8
jmp 0x1106e
leaq 0x30(%rsp), %rsi
callq 0xeb34
movq (%r13), %rax
cmpb $0x0, 0x12d(%rax)
je 0x111cc
movq %r13, 0x60(%rsp)
movl 0xa0(%rax), %ecx
movq (%rbx), %rdx
movl %ecx, 0xa0(%rdx)
movsd 0x80(%rax), %xmm0
movsd %xmm0, 0x80(%rdx)
movl 0xd4(%rax), %ecx
movl %ecx, 0xd4(%rdx)
movl 0x100(%rax), %eax
movl %eax, 0x100(%rdx)
xorl %eax, %eax
xchgq %rax, 0x70(%rbx)
xorl %r14d, %r14d
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
leaq 0x16b12(%rip), %r12     # 0x27c50
leaq 0x28(%rsp), %r13
movq %rsp, %rbp
movq (%rbx), %rax
cmpl 0xd4(%rax), %r14d
jge 0x111a3
andq $0x0, 0x28(%rsp)
pushq $0x18
popq %rdi
callq 0x4340
movq %r12, (%rax)
movq %rbx, 0x8(%rax)
movl %r14d, 0x10(%rax)
movq %rax, (%rsp)
movq %r13, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x4300
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1118b
movq (%rdi), %rax
callq *0x8(%rax)
movq %r15, %rdi
movq %r13, %rsi
callq 0x16a86
movq %r13, %rdi
callq 0x15c6c
incl %r14d
jmp 0x11146
movq 0x40(%rsp), %r15
movq 0x60(%rsp), %r13
cmpq 0x48(%rsp), %r15
je 0x111c2
movq %r15, %rdi
callq 0x45a0
addq $0x8, %r15
jmp 0x111ad
leaq 0x40(%rsp), %rdi
callq 0x15c7a
leaq 0x38(%rsp), %rdi
callq 0x8b66
leaq 0x8(%rsp), %rdi
callq 0x8c0e
movq (%r13), %rcx
movq 0x20(%rbx), %rsi
leaq 0x138(%rcx), %rdx
addq $0x12e, %rcx            # imm = 0x12E
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x15c9b
leaq 0x40(%rbx), %rdi
movq %r15, %rsi
callq 0x16620
leaq 0x10(%rsp), %rdi
callq 0x8b66
movq (%rbx), %rax
cmpb $0x1, 0x12c(%rax)
jne 0x11260
movq 0x30(%rbx), %rsi
leaq 0x40(%rsp), %rdx
movl $0x2, (%rdx)
movl $0x12e, %ecx            # imm = 0x12E
addq (%r13), %rcx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x15cbf
leaq 0x50(%rbx), %rdi
movq %r14, %rsi
callq 0x16620
leaq 0x10(%rsp), %rdi
callq 0x8b66
movb $0x1, 0x80(%rbx)
movq %rbx, %rdi
callq 0x102f0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x16d6b(%rip), %rdi     # 0x27ff0
leaq 0xa5a2(%rip), %rsi      # 0x1b82e
callq 0x4330
movq %rax, %rdi
callq 0x4190
pushq $0x1
popq %rdi
callq 0x43b0
jmp 0x112a3
movq %rax, %rbx
jmp 0x112f3
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x46c8
jmp 0x112fd
jmp 0x112dc
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x15c6c
jmp 0x112df
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x112df
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x112df
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x15c7a
leaq 0x38(%rsp), %rdi
callq 0x8b66
leaq 0x8(%rsp), %rdi
callq 0x8c0e
movq %rbx, %rdi
callq 0x45d0
nop