// File: /workspace/github_cpp_makefile_star2_O2/ddu1[P]polarizedtext/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);

  Model model(input_, output_, args_, threadId);
  if (args_->model == model_name::sup) {
    model.setTargetCounts(dict_->getCounts(entry_type::label));
  } else {
    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::sup) {
      dict_->addNgrams(line, args_->wordNgrams);
      supervised(model, lr, line, labels);
    } else if (args_->model == model_name::cbow) {
      cbow(model, lr, line);
    } else if (args_->model == model_name::sg) {
      skipgram(model, lr, line);
    } else if (args_->model == model_name::pwv) { // updated
      pwv(model, lr, line);
    }     
    if (localTokenCount > args_->lrUpdateRate) {
      tokenCount += localTokenCount;
      localTokenCount = 0;
      if (threadId == 0 && args_->verbose > 1) {
        printInfo(progress, model.getLoss());
      }
    }
  }
  if (threadId == 0 && args_->verbose > 0) {
    printInfo(1.0, model.getLoss());
    std::cout << std::endl;
  }
  ifs.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rsi
leaq 0x1a0(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x33c0
movq %r14, %rdi
callq 0xaa98
movslq %ebp, %rcx
imulq %rcx, %rax
movq (%rbx), %rcx
movslq 0x9c(%rcx), %rcx
cqto
idivq %rcx
leaq 0x1a0(%rsp), %rdi
movq %rax, %rsi
callq 0xaaaf
leaq 0x20(%rbx), %rsi
leaq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0xcbda
leaq 0x30(%rbx), %rsi
leaq 0x70(%rsp), %r15
movq %r15, %rdi
callq 0xcbda
leaq 0x60(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0xcc0e
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl %ebp, %r8d
callq 0x8090
leaq 0x68(%rsp), %rdi
callq 0x625c
leaq 0x78(%rsp), %rdi
callq 0x625c
leaq 0x88(%rsp), %rdi
callq 0x625c
movq (%rbx), %rax
cmpl $0x3, 0x8c(%rax)
jne 0xbeb8
movq 0x10(%rbx), %rsi
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x53d8
leaq 0x90(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x902a
jmp 0xbeda
movq 0x10(%rbx), %rsi
leaq 0x20(%rsp), %rdi
xorl %edx, %edx
callq 0x53d8
leaq 0x90(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x902a
leaq 0x20(%rsp), %rdi
callq 0x757a
movl %ebp, 0xc(%rsp)
movq 0x10(%rbx), %rdi
callq 0x483c
movq %rax, %r14
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r15
andq $0x0, 0x10(%r15)
leaq 0x40(%rsp), %rax
andq $0x0, 0x10(%rax)
movaps %xmm0, (%r15)
movaps %xmm0, (%rax)
xorl %r12d, %r12d
leaq 0x3e3c(%rip), %rbp      # 0xfd58
movq 0x50(%rbx), %rcx
movq (%rbx), %rax
movslq 0x74(%rax), %rdx
imulq %r14, %rdx
cmpq %rdx, %rcx
jge 0xc095
movq 0x50(%rbx), %rax
cvtsi2ss %rax, %xmm1
movq (%rbx), %rax
movslq 0x74(%rax), %rcx
imulq %r14, %rcx
cvtsi2ss %rcx, %xmm0
movq 0x10(%rbx), %rdi
divss %xmm0, %xmm1
movss %xmm1, 0x1c(%rsp)
cvtss2sd %xmm1, %xmm0
movsd 0x3681(%rip), %xmm1     # 0xf5e8
subsd %xmm0, %xmm1
mulsd 0x60(%rax), %xmm1
movsd %xmm1, 0x10(%rsp)
leaq 0x1a0(%rsp), %rsi
movq %r15, %rdx
leaq 0x40(%rsp), %rcx
leaq 0x198(%rsp), %r8
callq 0x5502
movl %eax, %r13d
movq (%rbx), %rax
movl 0x8c(%rax), %ecx
decl %ecx
cmpl $0x3, %ecx
ja 0xc02c
cvtsd2ss 0x10(%rsp), %xmm0
movslq (%rbp,%rcx,4), %rcx
addq %rbp, %rcx
jmpq *%rcx
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
movq %r15, %rdx
callq 0xb2b8
jmp 0xc02c
movss %xmm0, 0x10(%rsp)
movq 0x10(%rbx), %rdi
movl 0x84(%rax), %edx
movq %r15, %rsi
callq 0x5436
leaq 0x90(%rsp), %rsi
movss 0x10(%rsp), %xmm0
movq %r15, %rdx
leaq 0x40(%rsp), %rcx
callq 0xb24a
jmp 0xc02c
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
movq %r15, %rdx
callq 0xb3ea
jmp 0xc02c
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
movq %r15, %rdx
callq 0xb522
movslq %r13d, %rax
addq %rax, %r12
movq (%rbx), %rax
movslq 0x68(%rax), %rax
cmpq %rax, %r12
jle 0xbf1c
lock
addq %r12, 0x50(%rbx)
movl $0x0, %r12d
cmpl $0x0, 0xc(%rsp)
jne 0xbf1c
movq (%rbx), %rax
cmpl $0x2, 0xc8(%rax)
movl $0x0, %r12d
jl 0xbf1c
leaq 0x90(%rsp), %rdi
callq 0x9470
movapd %xmm0, %xmm1
movq %rbx, %rdi
movss 0x1c(%rsp), %xmm0
callq 0xb068
xorl %r12d, %r12d
jmp 0xbf1c
cmpl $0x0, 0xc(%rsp)
jne 0xc0d1
cmpl $0x0, 0xc8(%rax)
jle 0xc0d1
leaq 0x90(%rsp), %rdi
callq 0x9470
movaps %xmm0, %xmm1
movss 0x3a2b(%rip), %xmm0     # 0xfae8
movq %rbx, %rdi
callq 0xb068
movq 0xbefc(%rip), %rdi      # 0x17fc8
callq 0x3100
leaq 0x1a0(%rsp), %rdi
callq 0x3050
leaq 0x40(%rsp), %rdi
callq 0x626a
leaq 0x20(%rsp), %rdi
callq 0x626a
leaq 0x90(%rsp), %rdi
callq 0x8370
leaq 0x1a0(%rsp), %rdi
callq 0x3070
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc120
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x757a
jmp 0xc17c
jmp 0xc133
jmp 0xc133
movq %rax, %rbx
jmp 0xc17c
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x625c
leaq 0x78(%rsp), %rdi
callq 0x625c
leaq 0x88(%rsp), %rdi
callq 0x625c
jmp 0xc189
jmp 0xc165
movq %rax, %rbx
jmp 0xc189
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x626a
leaq 0x20(%rsp), %rdi
callq 0x626a
leaq 0x90(%rsp), %rdi
callq 0x8370
leaq 0x1a0(%rsp), %rdi
callq 0x3070
movq %rbx, %rdi
callq 0x3440