// File: /workspace/github_cpp_makefile_star2_O3/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 $0x3c8, %rsp            # imm = 0x3C8
movl %esi, %r12d
movq %rdi, %rbx
movq (%rdi), %rsi
leaq 0x1c0(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x44f0
movq %r14, %rdi
callq 0x11bcc
movslq %r12d, %rcx
imulq %rcx, %rax
movq (%rbx), %rcx
movslq 0xd4(%rcx), %rcx
cqto
idivq %rcx
leaq 0x1c0(%rsp), %rdi
movq %rax, %rsi
callq 0x11be5
movq 0x20(%rbx), %rax
movq %rax, 0x60(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x18269
movq 0x11d5d(%rip), %rcx     # 0x29fb8
cmpb $0x0, (%rcx)
je 0x18265
incl 0x8(%rax)
jmp 0x18269
lock
incl 0x8(%rax)
movq 0x30(%rbx), %rax
movq %rax, 0x50(%rsp)
movq 0x38(%rbx), %rax
movq %rax, 0x58(%rsp)
testq %rax, %rax
je 0x18295
movq 0x11d31(%rip), %rcx     # 0x29fb8
cmpb $0x0, (%rcx)
je 0x18291
incl 0x8(%rax)
jmp 0x18295
lock
incl 0x8(%rax)
movq (%rbx), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x48(%rsp)
testq %rax, %rax
je 0x182c0
movq 0x11d06(%rip), %rcx     # 0x29fb8
cmpb $0x0, (%rcx)
je 0x182bc
incl 0x8(%rax)
jmp 0x182c0
lock
incl 0x8(%rax)
leaq 0xa0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movl %r12d, %r8d
callq 0xf674
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x182ee
callq 0xa8a0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x182fd
callq 0xa8a0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x1830c
callq 0xa8a0
movq 0x10(%rbx), %rsi
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x7b4a
leaq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x108c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18345
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rbx), %rdi
callq 0x655c
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %r15d, %r15d
movq %r15, 0x20(%rsp)
movq %r15, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movq 0x70(%rbx), %rcx
movq (%rbx), %rax
movslq 0xa0(%rax), %rdx
imulq %r14, %rdx
cmpq %rdx, %rcx
jge 0x18642
leaq 0x20(%rbx), %rax
movq %rax, 0x90(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, 0x88(%rsp)
xorl %ebp, %ebp
movq 0x70(%rbx), %rax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
movq (%rbx), %rax
movslq 0xa0(%rax), %rcx
imulq %r14, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
movq 0x10(%rbx), %rdi
divss %xmm0, %xmm1
movss %xmm1, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movsd 0x6516(%rip), %xmm1     # 0x1e8f8
subsd %xmm0, %xmm1
mulsd 0x80(%rax), %xmm1
movsd %xmm1, 0x98(%rsp)
leaq 0x1c0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x70(%rsp), %rcx
leaq 0x1b0(%rsp), %r8
callq 0x8716
movl %eax, %r13d
xorps %xmm0, %xmm0
cvtsd2ss 0x98(%rsp), %xmm0
movq (%rbx), %rax
movl 0xc0(%rax), %eax
cmpl $0x1, %eax
je 0x1846b
cmpl $0x2, %eax
je 0x18454
cmpl $0x4, %eax
jne 0x18480
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x14ab4
jmp 0x18480
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x144ac
jmp 0x18480
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1494e
movslq %r13d, %rax
addq %rax, %rbp
movq (%rbx), %rax
movslq 0x90(%rax), %rcx
cmpq %rcx, %rbp
jle 0x184a6
lock
addq %rbp, 0x70(%rbx)
testl %r12d, %r12d
je 0x184b1
xorl %ebp, %ebp
jmp 0x18627
testl %r12d, %r12d
jne 0x18627
jmp 0x184e0
movq (%rbx), %rax
cmpl $0x2, 0x100(%rax)
jl 0x184de
leaq 0xa0(%rsp), %rdi
callq 0x10db4
movaps %xmm0, %xmm1
movq %rbx, %rdi
movss 0x8(%rsp), %xmm0
callq 0x13b0c
movq (%rbx), %rax
xorl %ebp, %ebp
xorps %xmm0, %xmm0
cvtsi2ssl 0xb8(%rax), %xmm0
mulss 0x8(%rsp), %xmm0
cvttss2si %xmm0, %eax
cmpl %eax, %r15d
je 0x18627
leaq 0xa0(%rsp), %rdi
callq 0x10db4
movaps %xmm0, %xmm1
movq %rbx, %rdi
movss 0x8(%rsp), %xmm0
callq 0x13b0c
movq 0x11acd(%rip), %rcx     # 0x29ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq 0x11aaf(%rip), %rdi     # 0x29ff0
callq 0x4040
movq %rax, %rdi
callq 0x4200
movl $0x1e, %edx
movq 0x11a96(%rip), %rdi     # 0x29ff0
leaq 0x73e3(%rip), %rsi      # 0x1f944
callq 0x4350
incl %r15d
movq 0x11a80(%rip), %rdi     # 0x29ff0
movl %r15d, %esi
callq 0x4580
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4200
movl $0x0, 0x2c(%rsp)
movq $0x0, 0x30(%rsp)
leaq 0x2c(%rsp), %rax
movq %rax, (%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xf(%rsp), %rdx
movq 0x90(%rsp), %rcx
movq 0x88(%rsp), %r8
movq %rbx, %r9
callq 0x1a7e2
movaps 0x30(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x30(%rsp)
movq 0x68(%rbx), %rdi
movups %xmm0, 0x60(%rbx)
testq %rdi, %rdi
je 0x18611
callq 0xa8a0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x18611
callq 0xa8a0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x12d5a
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1203c
movq 0x70(%rbx), %rcx
movq (%rbx), %rax
movslq 0xa0(%rax), %rdx
imulq %r14, %rdx
cmpq %rdx, %rcx
jl 0x183a3
testl %r12d, %r12d
jne 0x1869f
cmpl $0x0, 0x100(%rax)
jle 0x1869f
leaq 0xa0(%rsp), %rdi
callq 0x10db4
movaps %xmm0, %xmm1
movss 0x6b20(%rip), %xmm0     # 0x1f188
movq %rbx, %rdi
callq 0x13b0c
movq 0x11979(%rip), %rdi     # 0x29ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq 0x1195e(%rip), %rdi     # 0x29ff0
callq 0x4040
movq %rax, %rdi
callq 0x4200
leaq 0x1c0(%rsp), %rdi
callq 0x4090
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x186c6
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x186dd
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
leaq 0xa0(%rsp), %rdi
callq 0xf984
leaq 0x1c0(%rsp), %rdi
callq 0x40c0
addq $0x3c8, %rsp            # imm = 0x3C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x18710
movq %rax, %rbx
jmp 0x1876d
movq %rax, %rbx
jmp 0x18784
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x18727
callq 0xa8a0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x18736
callq 0xa8a0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x18791
callq 0xa8a0
jmp 0x18791
movq %rax, %rbx
jmp 0x18791
jmp 0x18750
jmp 0x18750
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1876d
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18784
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
leaq 0xa0(%rsp), %rdi
callq 0xf984
leaq 0x1c0(%rsp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x45b0