// File: /workspace/github_cpp_makefile_star2_O2/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 $0x88, %rsp
movss %xmm0, 0x2c(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x8(%rdx), %rsi
subq (%rdx), %rsi
sarq $0x2, %rsi
cmpq $0x2, %rsi
jb 0x1188c
movq %rdx, %rbx
movq %rdi, %r15
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
callq 0x15910
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x2, %rsi
leaq 0x50(%rsp), %rdi
callq 0x15910
xorps %xmm0, %xmm0
movhps 0x8344(%rip), %xmm0     # xmm0 = xmm0[0,1],mem[0,1]
leaq 0x70(%rsp), %r14
movaps %xmm0, (%r14)
movq 0x48(%rsp), %rax
addq $0x110, %rax            # imm = 0x110
movq %rax, 0x20(%rsp)
xorl %eax, %eax
leaq 0x30(%rsp), %r12
leaq 0x50(%rsp), %rbp
movq %rsp, %r13
movl %eax, (%rsp)
cltq
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
sarq $0x2, %rcx
cmpq %rax, %rcx
jbe 0x116d5
movq %r14, %rdi
movq 0x20(%rsp), %rsi
callq 0x8b92
movsd %xmm0, 0x18(%rsp)
movq 0x10(%r15), %rdi
movslq (%rsp), %rax
movq (%rbx), %rcx
movl (%rcx,%rax,4), %esi
callq 0x6664
cvtss2sd %xmm0, %xmm0
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x116cb
movq 0x10(%r15), %rdi
movslq (%rsp), %rax
movq (%rbx), %rcx
movl (%rcx,%rax,4), %esi
callq 0x660a
movq (%r15), %rcx
movslq 0xac(%rcx), %rcx
cmpq %rcx, %rax
jl 0x116cb
movslq (%rsp), %rsi
shlq $0x2, %rsi
addq (%rbx), %rsi
movq %r12, %rdi
callq 0x89ae
movq %rbp, %rdi
movq %r13, %rsi
callq 0x89ae
movl (%rsp), %eax
incl %eax
jmp 0x1163c
xorps %xmm0, %xmm0
movq %rsp, %r13
andq $0x0, 0x10(%r13)
movaps %xmm0, (%r13)
movq (%r15), %rax
movl 0x98(%rax), %eax
leaq 0x68(%rsp), %rcx
movl $0x1, (%rcx)
movl %eax, 0x4(%rcx)
xorl %r12d, %r12d
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
sarq $0x2, %rax
cmpq %r12, %rax
jbe 0x11870
leaq 0x68(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x8b16
movl %eax, %r14d
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x11738
movq %rax, 0x8(%rsp)
movl %r14d, %ebp
negl %ebp
cmpl %r14d, %ebp
jg 0x11789
testl %ebp, %ebp
je 0x11785
movl %r12d, %eax
addl %ebp, %eax
js 0x11785
movl %eax, %eax
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0x11785
movq 0x10(%r15), %rdi
movl (%rcx,%rax,4), %esi
callq 0x5f9e
movq 0x8(%rsp), %rsi
movq (%rax), %rdx
movq 0x8(%rax), %rcx
movq %r13, %rdi
callq 0x158f0
incl %ebp
jmp 0x1173d
movl %r12d, %eax
subl %r14d, %eax
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
movq 0x38(%rsp), %rcx
subq 0x30(%rsp), %rcx
shrq $0x2, %rcx
decl %ecx
addl %r12d, %r14d
cmpl %ecx, %r14d
cmovgel %ecx, %r14d
cmpl %r14d, %eax
je 0x11868
movq 0x50(%rsp), %rdx
movslq (%rdx,%r12,4), %rcx
movq (%rbx), %rsi
movl (%rsi,%rcx,4), %ebp
andl $0x0, (%rsi,%rcx,4)
movq (%r15), %rsi
movq 0x10(%r15), %rdi
movl %eax, %eax
movl (%rdx,%rax,4), %ecx
movslq %r14d, %rax
movl (%rdx,%rax,4), %r8d
movl 0x9c(%rsi), %eax
movl 0xb4(%rsi), %r9d
movq %r13, %rsi
movq %rbx, %rdx
pushq 0x20(%rsp)
pushq %rax
callq 0x7174
popq %rax
popq %rcx
movq 0x50(%rsp), %rax
movslq (%rax,%r12,4), %rax
movq (%rbx), %rcx
movl %ebp, (%rcx,%rax,4)
movq 0x30(%rsp), %rax
movl (%rax,%r12,4), %r14d
movq (%r15), %rax
movq 0x10(%r15), %rdi
cvtsd2ss 0x88(%rax), %xmm0
movss %xmm0, 0x18(%rsp)
callq 0x5f90
movl %eax, %ebp
movq 0x10(%r15), %rdi
callq 0x5f90
movq (%r15), %rcx
addl 0xc4(%rcx), %eax
movq 0x48(%rsp), %rdi
movq %r13, %rsi
movl %r14d, %edx
movss 0x2c(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
movl %ebp, %ecx
movl %eax, %r8d
callq 0xe57e
incq %r12
jmp 0x116ff
movq %rsp, %rdi
callq 0x8df8
leaq 0x50(%rsp), %rdi
callq 0x8df8
leaq 0x30(%rsp), %rdi
callq 0x8df8
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x118a4
jmp 0x118ab
jmp 0x118ab
movq %rax, %rbx
jmp 0x118b6
jmp 0x118ab
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8df8
leaq 0x50(%rsp), %rdi
callq 0x8df8
leaq 0x30(%rsp), %rdi
callq 0x8df8
movq %rbx, %rdi
callq 0x45d0