// File: /workspace/github_cpp_makefile_star2_O2/epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::trainThread(int)
void FastText::trainThread(int32_t threadId) {
  std::ifstream ifs(args_->input);
  utils::seek(ifs, threadId * utils::size(ifs) / args_->thread);
  int32_t currCheckPoint = 0;
  Model model(input_, output_, args_, threadId);
  model.setTargetCounts(dict_->getCounts(entry_type::word));

  const int64_t ntokens = dict_->ntokens();
  int64_t localTokenCount = 0;
  std::vector<int32_t> line, labels;
  while (tokenCount < args_->epoch * ntokens) {
    real progress = real(tokenCount) / (args_->epoch * ntokens);
    real lr = args_->lr * (1.0 - progress);
    localTokenCount += dict_->getLine(ifs, line, labels, model.rng);
    if (args_->model == model_name::bisent2vec) {
      bisent2vec(model, lr, line);
    } else if (args_->model == model_name::cbow) {
      cbow(model, lr, line);
    } else if (args_->model == model_name::transgram) {
      transgram(model, lr, line);
    }
    if (localTokenCount > args_->lrUpdateRate) {
      tokenCount += localTokenCount;
      localTokenCount = 0;
      if (threadId == 0 && args_->verbose > 1) {
        printInfo(progress, model.getLoss());
      }
    }
    if (threadId == 0 && currCheckPoint != (int)(progress*args_->numCheckPoints)) {
      currCheckPoint++;
      printInfo(progress, model.getLoss());
      std::cerr << std::endl;
      std::cerr<<"Saving Model ----- Checkpoint "<< currCheckPoint<< std::endl;
      model_ = std::make_shared<Model>(input_, output_, args_, 0);
      saveModel(currCheckPoint);
      saveVectors(currCheckPoint);
    }
  }
  if (threadId == 0 && args_->verbose > 0) {
    printInfo(1.0, model.getLoss());
    std::cerr << std::endl;
  }
  ifs.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rsi
leaq 0x1e0(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x4520
movq %r14, %rdi
callq 0xf8f4
movslq %ebp, %rcx
imulq %rcx, %rax
movq (%rbx), %rcx
movslq 0xd4(%rcx), %rcx
cqto
idivq %rcx
leaq 0x1e0(%rsp), %rdi
movq %rax, %rsi
callq 0xf90b
leaq 0x20(%rbx), %rsi
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movq %rsi, 0x50(%rsp)
callq 0x15e92
leaq 0x30(%rbx), %rsi
leaq 0x70(%rsp), %r15
movq %r15, %rdi
movq %rsi, 0x48(%rsp)
callq 0x15e92
leaq 0x60(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x8b26
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl %ebp, %r8d
callq 0xd4c4
leaq 0x68(%rsp), %rdi
callq 0x8b66
leaq 0x78(%rsp), %rdi
callq 0x8b66
leaq 0x88(%rsp), %rdi
callq 0x8b66
movq 0x10(%rbx), %rsi
leaq 0x20(%rsp), %rdi
xorl %edx, %edx
callq 0x6dfe
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xe4ca
leaq 0x20(%rsp), %rdi
callq 0x9a28
movq 0x10(%rbx), %rdi
callq 0x5e3c
movq %rax, %r12
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r13
movaps %xmm0, (%r13)
andq $0x0, 0x10(%r13)
leaq 0x90(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x60(%rbx), %rax
movq %rax, 0x40(%rsp)
movq $0x0, 0x10(%rsp)
xorl %r14d, %r14d
movq 0x70(%rbx), %rcx
movq (%rbx), %rax
movslq 0xa0(%rax), %rdx
imulq %r12, %rdx
cmpq %rdx, %rcx
jge 0x145b2
movq 0x70(%rbx), %rax
cvtsi2ss %rax, %xmm1
movq (%rbx), %rax
movslq 0xa0(%rax), %rcx
imulq %r12, %rcx
cvtsi2ss %rcx, %xmm0
movq 0x10(%rbx), %rdi
divss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
cvtss2sd %xmm1, %xmm0
movsd 0x64fd(%rip), %xmm1     # 0x1a8e8
subsd %xmm0, %xmm1
mulsd 0x80(%rax), %xmm1
movsd %xmm1, 0x58(%rsp)
leaq 0x1e0(%rsp), %rsi
movq %r13, %rdx
leaq 0x90(%rsp), %rcx
leaq 0x1d0(%rsp), %r8
callq 0x7650
movl %eax, %r15d
cvtsd2ss 0x58(%rsp), %xmm0
movq (%rbx), %rax
movl 0xc0(%rax), %eax
cmpl $0x1, %eax
je 0x14468
cmpl $0x2, %eax
je 0x14453
cmpl $0x4, %eax
jne 0x1447b
movq %rbx, %rdi
leaq 0xc0(%rsp), %rsi
movq %r13, %rdx
callq 0x117fa
jmp 0x1447b
movq %rbx, %rdi
leaq 0xc0(%rsp), %rsi
movq %r13, %rdx
callq 0x11374
jmp 0x1447b
movq %rbx, %rdi
leaq 0xc0(%rsp), %rsi
movq %r13, %rdx
callq 0x116c6
movslq %r15d, %rax
addq %rax, %r14
movq (%rbx), %rax
movslq 0x90(%rax), %rcx
cmpq %rcx, %r14
jle 0x144d5
lock
addq %r14, 0x70(%rbx)
movl $0x0, %r14d
testl %ebp, %ebp
jne 0x1439a
movq (%rbx), %rax
cmpl $0x2, 0x100(%rax)
jl 0x144d0
leaq 0xc0(%rsp), %rdi
callq 0xe902
movaps %xmm0, %xmm1
movq %rbx, %rdi
movss 0xc(%rsp), %xmm0
callq 0x10c22
movq (%rbx), %rax
xorl %r14d, %r14d
jmp 0x144dd
testl %ebp, %ebp
jne 0x1439a
cvtsi2ssl 0xb8(%rax), %xmm0
mulss 0xc(%rsp), %xmm0
cvttss2si %xmm0, %eax
cmpl %eax, 0x10(%rsp)
je 0x1439a
leaq 0xc0(%rsp), %rdi
callq 0xe902
movaps %xmm0, %xmm1
movq %rbx, %rdi
movss 0xc(%rsp), %xmm0
callq 0x10c22
movq 0x13ad2(%rip), %rdi     # 0x27ff0
callq 0x4190
movq 0x13ac6(%rip), %rdi     # 0x27ff0
leaq 0x740b(%rip), %rsi      # 0x1b93c
callq 0x4330
movq 0x10(%rsp), %rsi
incl %esi
movq %rax, %rdi
movq %rsi, 0x10(%rsp)
callq 0x45b0
movq %rax, %rdi
callq 0x4190
andl $0x0, 0x1c(%rsp)
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rbx, %rcx
leaq 0x1c(%rsp), %r8
callq 0x15bfb
movq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x168a8
leaq 0xb8(%rsp), %rdi
callq 0x8b66
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x10470
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0xfc42
jmp 0x1439a
testl %ebp, %ebp
jne 0x145eb
cmpl $0x0, 0x100(%rax)
jle 0x145eb
leaq 0xc0(%rsp), %rdi
callq 0xe902
movaps %xmm0, %xmm1
movss 0x6b99(%rip), %xmm0     # 0x1b170
movq %rbx, %rdi
callq 0x10c22
movq 0x13a0a(%rip), %rdi     # 0x27ff0
callq 0x4190
leaq 0x1e0(%rsp), %rdi
callq 0x40a0
leaq 0x90(%rsp), %rdi
callq 0x8c0e
leaq 0x20(%rsp), %rdi
callq 0x8c0e
leaq 0xc0(%rsp), %rdi
callq 0xd7b4
leaq 0x1e0(%rsp), %rdi
callq 0x40e0
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14682
jmp 0x1464e
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x9a28
jmp 0x1469c
movq %rax, %rbx
jmp 0x1469c
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x8b66
leaq 0x78(%rsp), %rdi
callq 0x8b66
leaq 0x88(%rsp), %rdi
callq 0x8b66
jmp 0x146a9
jmp 0x14682
movq %rax, %rbx
jmp 0x146a9
jmp 0x14682
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x8c0e
leaq 0x20(%rsp), %rdi
callq 0x8c0e
leaq 0xc0(%rsp), %rdi
callq 0xd7b4
leaq 0x1e0(%rsp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x45d0