// File: /workspace/github_cpp_makefile_star2_O1/epfml[P]sent2vec/src/fasttext.cc
// Function: fasttext::FastText::train(std::shared_ptr<fasttext::Args>)
void FastText::train(std::shared_ptr<Args> args) {
  args_ = args;
  dict_ = std::make_shared<Dictionary>(args_);
  if (args_->input == "-") {
    // manage expectations
    std::cerr << "Cannot use stdin for training!" << std::endl;
    exit(EXIT_FAILURE);
  }
  std::ifstream ifs(args_->input);
  if (!ifs.is_open()) {
    std::cerr << "Input file cannot be opened!" << std::endl;
    exit(EXIT_FAILURE);
  }
  dict_->readFromFile(ifs);
  ifs.close();

  if (args_->pretrainedVectors.size() != 0) {
    loadVectors(args_->pretrainedVectors);
  } else {
    input_ = std::make_shared<Matrix>(dict_->nwords()+args_->bucket+args_->bucketChar, args_->dim);
    input_->uniform(1.0 / args_->dim);
  }

  if (args_->model == model_name::sup) {
    output_ = std::make_shared<Matrix>(dict_->nlabels(), args_->dim);
  } else {
    output_ = std::make_shared<Matrix>(dict_->nwords(), args_->dim);
  }
  output_->zero();

  start = clock();
  tokenCount = 0;
  if (args_->thread > 1) {
    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();
    }
  } else {
    trainThread(0);
  }
  model_ = std::make_shared<Model>(input_, output_, args_, 0);

  saveModel();
  if (args_->model != model_name::sup && args_->model != model_name::sent2vec && args_->model != model_name::cbowCWNgrams) {
    saveVectors();
    if (args_->saveOutput > 0) {
      saveOutput();
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdi, %rbx
movq (%rsi), %rax
movq %rax, (%rdi)
addq $0x8, %rdi
addq $0x8, %rsi
callq 0x111bc
leaq 0x68(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x60(%rsp), %r14
leaq 0x10(%rsp), %rdx
movq %r14, %rsi
movq %rbx, %rcx
callq 0x19b44
movaps (%r14), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, (%r14)
movq 0x18(%rbx), %rdi
movups %xmm0, 0x10(%rbx)
testq %rdi, %rdi
je 0x18bca
callq 0xaa70
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x18bd9
callq 0xaa70
movq (%rbx), %rdi
leaq 0x7058(%rip), %rsi      # 0x1fc3b
callq 0x40e0
testl %eax, %eax
je 0x18f73
movq (%rbx), %rsi
leaq 0x60(%rsp), %rdi
movl $0x8, %edx
callq 0x44f0
leaq 0xd8(%rsp), %rdi
callq 0x40b0
testb %al, %al
je 0x18f98
movq 0x10(%rbx), %rdi
leaq 0x60(%rsp), %rsi
callq 0x72f0
leaq 0x60(%rsp), %rdi
callq 0x4090
movq (%rbx), %rax
movq 0x110(%rax), %rdx
testq %rdx, %rdx
je 0x18c88
leaq 0x50(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x108(%rax), %rsi
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0xaae0
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x18206
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x18d24
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4300
jmp 0x18d24
movq 0x10(%rbx), %rdi
callq 0x66a8
movq (%rbx), %r8
addl 0xc4(%r8), %eax
addl 0xc8(%r8), %eax
leaq 0x30(%rsp), %rcx
movl %eax, (%rcx)
addq $0x94, %r8
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x1b396
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x28(%rbx), %rdi
movups %xmm0, 0x20(%rbx)
testq %rdi, %rdi
je 0x18ceb
callq 0xaa70
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x18cfa
callq 0xaa70
movq (%rbx), %rax
movq 0x20(%rbx), %rdi
xorps %xmm0, %xmm0
cvtsi2sdl 0x94(%rax), %xmm0
movsd 0x5c4c(%rip), %xmm1     # 0x1e960
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
callq 0xe010
movq (%rbx), %rax
cmpl $0x3, 0xc0(%rax)
jne 0x18d67
movq 0x10(%rbx), %rdi
callq 0x66ac
leaq 0x30(%rsp), %rcx
movl %eax, (%rcx)
movl $0x94, %r8d
addq (%rbx), %r8
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x1b396
jmp 0x18d9c
movq 0x10(%rbx), %rdi
callq 0x66a8
leaq 0x30(%rsp), %rcx
movl %eax, (%rcx)
movl $0x94, %r8d
addq (%rbx), %r8
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x1b396
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x38(%rbx), %rdi
movups %xmm0, 0x30(%rbx)
testq %rdi, %rdi
je 0x18dbb
callq 0xaa70
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x18dca
callq 0xaa70
movq 0x30(%rbx), %rdi
callq 0xdff2
callq 0x41e0
movq %rax, 0x78(%rbx)
xorl %eax, %eax
xchgq %rax, 0x70(%rbx)
movq (%rbx), %rax
cmpl $0x2, 0xd4(%rax)
jl 0x18ea8
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rbx), %rax
cmpl $0x0, 0xd4(%rax)
jle 0x18e8e
xorl %r13d, %r13d
leaq 0x10ee7(%rip), %rbp     # 0x29d00
leaq 0x38(%rsp), %r14
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r12
movq $0x0, 0x38(%rsp)
movl $0x18, %edi
callq 0x42f0
movq %rbp, (%rax)
movq %rbx, 0x8(%rax)
movl %r13d, 0x10(%rax)
movq %rax, 0x30(%rsp)
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x42b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x18e68
movq (%rdi), %rax
callq *0x8(%rax)
movq %r12, %rdi
movq %r14, %rsi
callq 0x1a136
cmpq $0x0, 0x38(%rsp)
jne 0x1900f
incl %r13d
movq (%rbx), %rax
cmpl 0xd4(%rax), %r13d
jl 0x18e28
movq 0x10(%rsp), %r14
cmpq 0x18(%rsp), %r14
je 0x18eb4
movq %r14, %rdi
callq 0x4570
addq $0x8, %r14
jmp 0x18e93
movq %rbx, %rdi
xorl %esi, %esi
callq 0x17bd2
jmp 0x18ebe
leaq 0x10(%rsp), %rdi
callq 0x19726
leaq 0x30(%rbx), %r8
leaq 0x20(%rbx), %rcx
leaq 0x30(%rsp), %rax
movl $0x0, (%rax)
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %rax, (%rsp)
leaq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %r9
callq 0x19eb0
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x68(%rbx), %rdi
movups %xmm0, 0x60(%rbx)
testq %rdi, %rdi
je 0x18f13
callq 0xaa70
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x18f22
callq 0xaa70
movq %rbx, %rdi
callq 0x127d6
movq (%rbx), %rax
movl 0xc0(%rax), %eax
addl $-0x3, %eax
cmpl $0x3, %eax
jb 0x18f57
movq %rbx, %rdi
callq 0x11f02
movq (%rbx), %rax
cmpl $0x0, 0x128(%rax)
jle 0x18f57
movq %rbx, %rdi
callq 0x121bc
leaq 0x60(%rsp), %rdi
callq 0x40c0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11076(%rip), %rdi     # 0x29ff0
leaq 0x6cbc(%rip), %rsi      # 0x1fc3d
callq 0x42e0
movq %rax, %rdi
callq 0x4170
movl $0x1, %edi
callq 0x4380
movq 0x11051(%rip), %rdi     # 0x29ff0
leaq 0x6cb6(%rip), %rsi      # 0x1fc5c
movl $0x1c, %edx
callq 0x4350
movq 0x11039(%rip), %rdi     # 0x29ff0
callq 0x4170
jmp 0x18f8e
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x19021
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4300
jmp 0x19021
jmp 0x18fe2
jmp 0x18fe2
jmp 0x18fe2
jmp 0x18fe2
movq %rax, %rbx
jmp 0x19021
jmp 0x19014
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x18ffc
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x30(%rsp)
jmp 0x19017
cmpq $0x0, 0x38(%rsp)
je 0x19014
callq 0x40d0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x19726
leaq 0x60(%rsp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x45b0
nop