// File: /workspace/github_cpp_makefile_star2_O3/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 0x14811
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 0x19858
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x2, %rsi
leaq 0x40(%rsp), %rdi
callq 0x19858
movl $0x0, (%rsp)
movq 0x8(%rbx), %rax
cmpq (%rbx), %rax
je 0x145f1
movq 0x58(%rsp), %rax
leaq 0x110(%rax), %r12
leaq 0x20(%rsp), %r14
leaq 0x40(%rsp), %rbp
movq %rsp, %r13
movq %r12, %rdi
callq 0xc408
movsd %xmm0, 0x38(%rsp)
movq 0x10(%r15), %rdi
movslq (%rsp), %rax
movq (%rbx), %rcx
movl (%rcx,%rax,4), %esi
callq 0x7044
cvtss2sd %xmm0, %xmm0
movsd 0x38(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movl (%rsp), %ecx
ja 0x145d5
movslq %ecx, %rax
movq 0x10(%r15), %rdi
movq (%rbx), %rcx
movl (%rcx,%rax,4), %esi
callq 0x6fea
movq (%r15), %rcx
movslq 0xac(%rcx), %rdx
movl (%rsp), %ecx
cmpq %rdx, %rax
jl 0x145d5
movslq %ecx, %rdx
shlq $0x2, %rdx
addq (%rbx), %rdx
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x145a3
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x145ab
movq %r14, %rdi
callq 0xaf5a
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x145c7
movl (%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x145d5
movq %rbp, %rdi
movq %r13, %rdx
callq 0xaf5a
movl (%rsp), %ecx
incl %ecx
movl %ecx, (%rsp)
movslq %ecx, %rax
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
sarq $0x2, %rcx
cmpq %rax, %rcx
ja 0x14526
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 0x147e3
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 0xc280
movl %eax, %r14d
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x14663
movq %rax, 0x8(%rsp)
testl %r14d, %r14d
js 0x146c2
leal 0x1(,%r14,2), %r13d
movl %r12d, %ebp
subl %r14d, %ebp
xorl %ebx, %ebx
cmpl %ebx, %r14d
je 0x146bb
movl %ebp, %eax
addl %ebx, %eax
js 0x146bb
movl %eax, %eax
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0x146bb
movq 0x10(%r15), %rdi
movl (%rcx,%rax,4), %esi
callq 0x66ba
movq 0x8(%rsp), %rsi
movq (%rax), %rdx
movq 0x8(%rax), %rcx
movq %rsp, %rdi
callq 0x1a4ca
incl %ebx
cmpl %ebx, %r13d
jne 0x14678
movl %r12d, %eax
subl %r14d, %eax
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
movq 0x28(%rsp), %rcx
subq 0x20(%rsp), %rcx
movq %rcx, %rdx
shrq $0x2, %rdx
decl %edx
addl %r12d, %r14d
cmpl %edx, %r14d
cmovgel %edx, %r14d
cmpl %r14d, %eax
je 0x147bd
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 0x7f5c
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 0x66ac
movl %eax, %r13d
movq 0x10(%r15), %rdi
callq 0x66ac
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 0x1098c
movq 0x28(%rsp), %rcx
subq 0x20(%rsp), %rcx
incq %r12
sarq $0x2, %rcx
cmpq %r12, %rcx
ja 0x1463e
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x147e3
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x147fa
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x14811
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 0x14826
jmp 0x1482d
jmp 0x1482d
movq %rax, %rbx
jmp 0x14846
jmp 0x1482d
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x14846
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1485d
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x14874
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x45b0