// File: /workspace/github_cpp_makefile_star2_O1/epfml[P]sent2vec/src/fasttext.cc
// Function: fasttext::FastText::cbowCWNgrams(fasttext::Model&, float, std::vector<int, std::allocator<int>>&)
void FastText::cbowCWNgrams(Model& model, real lr, std::vector<int32_t>& line){
  if (line.size() <= 1) return;
  std::vector<int32_t> subsLine, sidx2lidx;
  subsLine.reserve(line.size());
  sidx2lidx.reserve(line.size());
  std::uniform_real_distribution<> uniformSub(0, 1);
  for (int32_t i=0; i < line.size(); ++i) {
    if (uniformSub(model.rng) > dict_->getPDiscard(line[i]) || dict_->getTokenCount(line[i]) < args_->minCountLabel) {
      continue;
    }
    subsLine.push_back(line[i]);
    sidx2lidx.push_back(i);
  }
  std::vector<int32_t> bow;
  std::uniform_int_distribution<> uniform(1, args_->ws);
  for (int32_t w = 0; w < subsLine.size(); w++) {
    int32_t boundary = uniform(model.rng);
    bow.clear();
    for (int32_t c = -boundary; c <= boundary; c++) {
      if (c != 0 && w + c >= 0 && w + c < subsLine.size()) {
        const std::vector<int32_t>& ngrams = dict_->getNgrams(subsLine[w + c]);
        bow.insert(bow.end(), ngrams.cbegin(), ngrams.cend());
      }
    }
    int32_t start = std::max(0, w - boundary);
    int32_t end = std::min(int32_t(subsLine.size())-1, w + boundary);
    if (start == end) continue;
    int32_t buff = line[sidx2lidx[w]];
    line[sidx2lidx[w]] = 0;
    dict_->addNgrams(bow, line, sidx2lidx[start], sidx2lidx[end], args_->wordNgrams, args_->dropoutK, model.rng); // add word ngrams to bow
    line[sidx2lidx[w]] = buff;
    model.update(bow, subsLine[w], lr, args_->boostNgrams, dict_->nwords(), dict_->nwords() + args_->bucket);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movss %xmm0, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq 0x8(%rdx), %rsi
subq (%rdx), %rsi
sarq $0x2, %rsi
cmpq $0x2, %rsi
jb 0x146ed
movq %rdx, %rbx
movq %rdi, %r15
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
callq 0x19762
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x2, %rsi
leaq 0x40(%rsp), %rdi
callq 0x19762
movl $0x0, (%rsp)
movq 0x8(%rbx), %rax
cmpq (%rbx), %rax
je 0x144d0
movq 0x58(%rsp), %rax
leaq 0x110(%rax), %r12
leaq 0x20(%rsp), %r13
leaq 0x40(%rsp), %rbp
movq %rsp, %r14
movq %r12, %rdi
callq 0xc464
movsd %xmm0, 0x38(%rsp)
movq 0x10(%r15), %rdi
movslq (%rsp), %rax
movq (%rbx), %rcx
movl (%rcx,%rax,4), %esi
callq 0x7010
cvtss2sd %xmm0, %xmm0
movsd 0x38(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x144b2
movq 0x10(%r15), %rdi
movslq (%rsp), %rax
movq (%rbx), %rcx
movl (%rcx,%rax,4), %esi
callq 0x6fb6
movq (%r15), %rcx
movslq 0xac(%rcx), %rcx
cmpq %rcx, %rax
jl 0x144b2
movslq (%rsp), %rdx
shlq $0x2, %rdx
addq (%rbx), %rdx
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x14483
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x1448b
movq %r13, %rdi
callq 0xaf28
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x144a7
movl (%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x144b2
movq %rbp, %rdi
movq %r14, %rdx
callq 0xaf28
movslq (%rsp), %rax
incq %rax
movl %eax, (%rsp)
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
sarq $0x2, %rcx
cmpq %rax, %rcx
ja 0x1440a
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq (%r15), %rax
movl 0x98(%rax), %eax
movl $0x1, 0x70(%rsp)
movl %eax, 0x74(%rsp)
movq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x146a9
movq 0x58(%rsp), %rax
addq $0x110, %rax            # imm = 0x110
movq %rax, 0x38(%rsp)
xorl %r12d, %r12d
movq %rbx, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rdi, %rdx
callq 0xc2dc
movl %eax, %r14d
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x14542
movq %rax, 0x8(%rsp)
testl %r14d, %r14d
js 0x145a1
leal 0x1(,%r14,2), %r13d
movl %r12d, %ebp
subl %r14d, %ebp
xorl %ebx, %ebx
cmpl %ebx, %r14d
je 0x1459a
movl %ebp, %eax
addl %ebx, %eax
js 0x1459a
movl %eax, %eax
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0x1459a
movq 0x10(%r15), %rdi
movl (%rcx,%rax,4), %esi
callq 0x66b6
movq 0x8(%rsp), %rsi
movq (%rax), %rdx
movq 0x8(%rax), %rcx
movq %rsp, %rdi
callq 0x1a3ec
incl %ebx
cmpl %ebx, %r13d
jne 0x14557
movl %r12d, %eax
subl %r14d, %eax
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
movq 0x28(%rsp), %rcx
subq 0x20(%rsp), %rcx
shrq $0x2, %rcx
decl %ecx
addl %r12d, %r14d
cmpl %ecx, %r14d
cmovgel %ecx, %r14d
cmpl %r14d, %eax
je 0x1468f
movq 0x40(%rsp), %r8
movslq (%r8,%r12,4), %rcx
movq 0x68(%rsp), %rdx
movq (%rdx), %rsi
movl (%rsi,%rcx,4), %ebx
movl $0x0, (%rsi,%rcx,4)
movq (%r15), %rsi
movq 0x10(%r15), %rdi
movl %eax, %eax
movl (%r8,%rax,4), %ecx
movslq %r14d, %rax
movl (%r8,%rax,4), %r8d
movl 0x9c(%rsi), %eax
movl 0xb4(%rsi), %r9d
movq %rsp, %rsi
pushq 0x38(%rsp)
pushq %rax
callq 0x7f08
addq $0x10, %rsp
movq 0x40(%rsp), %rax
movslq (%rax,%r12,4), %rax
movq 0x68(%rsp), %rcx
movq (%rcx), %rcx
movl %ebx, (%rcx,%rax,4)
movq 0x20(%rsp), %rax
movl (%rax,%r12,4), %r14d
movq (%r15), %rax
movq 0x10(%r15), %rdi
cvtsd2ss 0x88(%rax), %xmm0
movss %xmm0, 0x64(%rsp)
callq 0x66a8
movl %eax, %r13d
movq 0x10(%r15), %rdi
callq 0x66a8
movq (%r15), %rcx
addl 0xc4(%rcx), %eax
movq 0x58(%rsp), %rdi
movq %rsp, %rsi
movl %r14d, %edx
movss 0x60(%rsp), %xmm0
movss 0x64(%rsp), %xmm1
movl %r13d, %ecx
movl %eax, %r8d
callq 0x10954
incq %r12
movq 0x28(%rsp), %rax
subq 0x20(%rsp), %rax
sarq $0x2, %rax
cmpq %r12, %rax
ja 0x1451d
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x146bf
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x146d6
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x146ed
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14702
jmp 0x14709
jmp 0x14709
movq %rax, %rbx
jmp 0x14722
jmp 0x14709
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x14722
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x14739
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x14750
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x45b0