// File: /workspace/github_cpp_makefile_star2_O2/epfml[P]sent2vec/src/fasttext.cc
// Function: fasttext::FastText::savedDictTrain(std::shared_ptr<fasttext::Args>)
void FastText::savedDictTrain(std::shared_ptr<Args> args) {
  loadDict(args_->dict);
  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_->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 $0x258, %rsp            # imm = 0x258
movq %rdi, %rbx
movq (%rdi), %rsi
addq $0x60, %rsi
callq 0x1012a
movq (%rbx), %rdi
leaq 0x632f(%rip), %rsi      # 0x1ac43
callq 0x5cfb
testb %al, %al
jne 0x14bc8
movq (%rbx), %rsi
leaq 0x50(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x4520
leaq 0xc8(%rsp), %rdi
callq 0x40c0
testb %al, %al
je 0x14beb
movq 0x10(%rbx), %rdi
leaq 0x50(%rsp), %rsi
callq 0x684c
leaq 0x50(%rsp), %rdi
callq 0x40a0
movq (%rbx), %rsi
cmpq $0x0, 0x110(%rsi)
je 0x14995
addq $0x108, %rsi            # imm = 0x108
leaq 0x30(%rsp), %rdi
callq 0x4460
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x14602
leaq 0x30(%rsp), %rdi
callq 0x46c8
jmp 0x149fb
movq 0x10(%rbx), %rdi
callq 0x5f90
movq (%rbx), %rdx
addl 0xc4(%rdx), %eax
leaq 0x8(%rsp), %rsi
movl %eax, (%rsi)
addq $0x94, %rdx
leaq 0x10(%rsp), %rdi
callq 0x15a3e
leaq 0x20(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x16130
leaq 0x18(%rsp), %rdi
callq 0x8d50
movq (%rbx), %rax
movq 0x20(%rbx), %rdi
cvtsi2sdl 0x94(%rax), %xmm0
movsd 0x4f6a(%rip), %xmm1     # 0x19958
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
callq 0xc0e6
movq (%rbx), %rax
cmpl $0x3, 0xc0(%rax)
jne 0x14a2b
movq 0x10(%rbx), %rdi
callq 0x5f94
leaq 0x8(%rsp), %rsi
movl %eax, (%rsi)
movl $0x94, %edx
addq (%rbx), %rdx
leaq 0x10(%rsp), %rdi
callq 0x15a3e
jmp 0x14a4d
movq 0x10(%rbx), %rdi
callq 0x5f90
leaq 0x8(%rsp), %rsi
movl %eax, (%rsi)
movl $0x94, %edx
addq (%rbx), %rdx
leaq 0x10(%rsp), %rdi
callq 0x15a3e
leaq 0x30(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x16130
leaq 0x18(%rsp), %rdi
callq 0x8d50
movq 0x30(%rbx), %rdi
callq 0xc0c8
callq 0x4220
movq %rax, 0x78(%rbx)
xorl %eax, %eax
xchgq %rax, 0x70(%rbx)
xorl %ebp, %ebp
movq (%rbx), %rax
movl 0xd4(%rax), %eax
cmpl $0x2, %eax
jl 0x14b11
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq 0x12227(%rip), %r15     # 0x26cd0
leaq 0x28(%rsp), %r12
leaq 0x8(%rsp), %r13
cmpl %eax, %ebp
jge 0x14b1d
andq $0x0, 0x28(%rsp)
pushq $0x18
popq %rdi
callq 0x4340
movq %r15, (%rax)
movq %rbx, 0x8(%rax)
movl %ebp, 0x10(%rax)
movq %rax, 0x8(%rsp)
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x4300
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x14af1
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, %rdi
movq %r12, %rsi
callq 0x16728
movq %r12, %rdi
callq 0x15878
incl %ebp
movq (%rbx), %rax
movl 0xd4(%rax), %eax
jmp 0x14ab3
movq %rbx, %rdi
xorl %esi, %esi
callq 0x14136
jmp 0x14b41
movq 0x10(%rsp), %r14
cmpq 0x18(%rsp), %r14
je 0x14b37
movq %r14, %rdi
callq 0x45a0
addq $0x8, %r14
jmp 0x14b22
leaq 0x10(%rsp), %rdi
callq 0x15886
leaq 0x30(%rbx), %rdx
leaq 0x20(%rbx), %rsi
leaq 0x8(%rsp), %r8
andl $0x0, (%r8)
leaq 0x10(%rsp), %rdi
movq %rbx, %rcx
callq 0x15807
leaq 0x60(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1654a
leaq 0x18(%rsp), %rdi
callq 0x8d50
movq %rbx, %rdi
callq 0x10254
movq (%rbx), %rax
movl 0xc0(%rax), %eax
addl $-0x3, %eax
cmpl $0x3, %eax
jb 0x14bac
movq %rbx, %rdi
callq 0xfc3a
movq (%rbx), %rax
cmpl $0x0, 0x128(%rax)
jle 0x14bac
movq %rbx, %rdi
callq 0xfdfa
leaq 0x50(%rsp), %rdi
callq 0x40e0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x12421(%rip), %rdi     # 0x26ff0
leaq 0x606f(%rip), %rsi      # 0x1ac45
callq 0x4330
movq %rax, %rdi
callq 0x4190
pushq $0x1
popq %rdi
callq 0x43b0
movq 0x123fe(%rip), %rdi     # 0x26ff0
leaq 0x606b(%rip), %rsi      # 0x1ac64
callq 0x4330
movq %rax, %rdi
callq 0x4190
jmp 0x14be3
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x46c8
jmp 0x14c57
jmp 0x14c1f
jmp 0x14c1f
jmp 0x14c1f
jmp 0x14c1f
movq %rax, %rbx
jmp 0x14c57
jmp 0x14c4a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x15878
jmp 0x14c4d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x14c4d
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x14c4d
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x15886
leaq 0x50(%rsp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x45d0
nop