// File: /workspace/github_cpp_makefile_star2_O1/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, %ebp
movq %rdi, %rbx
movq (%rdi), %rsi
leaq 0x1c0(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x44f0
movq %r14, %rdi
callq 0x11b94
movslq %ebp, %rcx
imulq %rcx, %rax
movq (%rbx), %rcx
movslq 0xd4(%rcx), %rcx
cqto
idivq %rcx
leaq 0x1c0(%rsp), %rdi
movq %rax, %rsi
callq 0x11bad
movq 0x20(%rbx), %rax
movq %rax, 0x60(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x18144
movq 0x11e82(%rip), %rcx     # 0x29fb8
cmpb $0x0, (%rcx)
je 0x18140
incl 0x8(%rax)
jmp 0x18144
lock
incl 0x8(%rax)
movq 0x30(%rbx), %rax
movq %rax, 0x50(%rsp)
movq 0x38(%rbx), %rax
movq %rax, 0x58(%rsp)
testq %rax, %rax
je 0x18170
movq 0x11e56(%rip), %rcx     # 0x29fb8
cmpb $0x0, (%rcx)
je 0x1816c
incl 0x8(%rax)
jmp 0x18170
lock
incl 0x8(%rax)
movq (%rbx), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x48(%rsp)
testq %rax, %rax
je 0x1819b
movq 0x11e2b(%rip), %rcx     # 0x29fb8
cmpb $0x0, (%rcx)
je 0x18197
incl 0x8(%rax)
jmp 0x1819b
lock
incl 0x8(%rax)
leaq 0xa0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movl %ebp, %r8d
callq 0xf458
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x181c9
callq 0xa86c
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x181d8
callq 0xa86c
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x181e7
callq 0xa86c
movq 0x10(%rbx), %rsi
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x7afe
leaq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x10888
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18220
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rbx), %rdi
callq 0x6558
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 0x18514
leaq 0x20(%rbx), %rax
movq %rax, 0x90(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, 0x88(%rsp)
xorl %r12d, %r12d
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 0x6632(%rip), %xmm1     # 0x1e8f0
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 0x86f4
movl %eax, %r13d
xorps %xmm0, %xmm0
cvtsd2ss 0x98(%rsp), %xmm0
movq (%rbx), %rax
movl 0xc0(%rax), %eax
cmpl $0x1, %eax
je 0x18347
cmpl $0x2, %eax
je 0x18330
cmpl $0x4, %eax
jne 0x1835c
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x149c0
jmp 0x1835c
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1438e
jmp 0x1835c
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x14856
movslq %r13d, %rax
addq %rax, %r12
movq (%rbx), %rax
movslq 0x90(%rax), %rax
cmpq %rax, %r12
jle 0x183a7
lock
addq %r12, 0x70(%rbx)
testl %ebp, %ebp
jne 0x183a4
movq (%rbx), %rax
cmpl $0x2, 0x100(%rax)
jl 0x183a4
leaq 0xa0(%rsp), %rdi
callq 0x10da2
movaps %xmm0, %xmm1
movq %rbx, %rdi
movss 0x8(%rsp), %xmm0
callq 0x13abc
xorl %r12d, %r12d
testl %ebp, %ebp
jne 0x184f9
movq (%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2ssl 0xb8(%rax), %xmm0
mulss 0x8(%rsp), %xmm0
cvttss2si %xmm0, %eax
cmpl %eax, %r15d
je 0x184f9
leaq 0xa0(%rsp), %rdi
callq 0x10da2
movaps %xmm0, %xmm1
movq %rbx, %rdi
movss 0x8(%rsp), %xmm0
callq 0x13abc
movq 0x11bfb(%rip), %rcx     # 0x29ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq 0x11bdd(%rip), %rdi     # 0x29ff0
callq 0x4040
movq %rax, %rdi
callq 0x4200
movl $0x1e, %edx
movq 0x11bc4(%rip), %rdi     # 0x29ff0
leaq 0x7501(%rip), %rsi      # 0x1f934
callq 0x4350
incl %r15d
movq 0x11bae(%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 0x1a752
movaps 0x30(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x30(%rsp)
movq 0x68(%rbx), %rdi
movups %xmm0, 0x60(%rbx)
testq %rdi, %rdi
je 0x184d4
callq 0xa86c
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x184e3
callq 0xa86c
movq %rbx, %rdi
movl %r15d, %esi
callq 0x12d08
movq %rbx, %rdi
movl %r15d, %esi
callq 0x11fe8
movq 0x70(%rbx), %rcx
movq (%rbx), %rax
movslq 0xa0(%rax), %rdx
imulq %r14, %rdx
cmpq %rdx, %rcx
jl 0x1827f
testl %ebp, %ebp
jne 0x18570
cmpl $0x0, 0x100(%rax)
jle 0x18570
leaq 0xa0(%rsp), %rdi
callq 0x10da2
movaps %xmm0, %xmm1
movss 0x6c37(%rip), %xmm0     # 0x1f170
movq %rbx, %rdi
callq 0x13abc
movq 0x11aa8(%rip), %rdi     # 0x29ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq 0x11a8d(%rip), %rdi     # 0x29ff0
callq 0x4040
movq %rax, %rdi
callq 0x4200
leaq 0x1c0(%rsp), %rdi
callq 0x4090
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x18597
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x185ae
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
leaq 0xa0(%rsp), %rdi
callq 0xf768
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 0x185e1
movq %rax, %rbx
jmp 0x1863e
movq %rax, %rbx
jmp 0x18655
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x185f8
callq 0xa86c
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x18607
callq 0xa86c
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x18662
callq 0xa86c
jmp 0x18662
movq %rax, %rbx
jmp 0x18662
jmp 0x18621
jmp 0x18621
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1863e
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18655
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
leaq 0xa0(%rsp), %rdi
callq 0xf768
leaq 0x1c0(%rsp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x45b0
nop