// File: /workspace/github_cpp_makefile_star2_O3/epfml[P]Bi-Sent2Vec/src/dictionary.cc
// Function: fasttext::Dictionary::addNgrams(std::vector<int, std::allocator<int>>&, int, int, std::linear_congruential_engine<unsigned long, 48271ul, 0ul, 2147483647ul>&) const
void Dictionary::addNgrams(std::vector<int32_t>& line, int32_t n, int32_t k, std::minstd_rand& rng) const {
  int32_t num_discarded = 0;
  int32_t line_size = line.size();
  std::vector<bool> discard;
  discard.resize(line_size, false);
  std::uniform_int_distribution<> uniform(0, line_size - 1);
  while (num_discarded < k && line_size - num_discarded > 2) {
    int32_t token_to_discard = uniform(rng);
    if (!discard[token_to_discard]) {
      discard[token_to_discard] = true;
      num_discarded++;
    }
  }
  for (int32_t i = 0; i < line_size; i++) {
    if (discard[i]) continue;
    uint64_t h = line[i];
    for (int32_t j = i + 1; j < line_size && j < i + n; j++) {
      if (discard[j]) break;
      h = h * 116049371 + line[j];
      line.push_back(nwords_ + (h % args_->bucket));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, %r12
movl %ecx, %ebp
movq %rdx, 0x28(%rsp)
movq %rsi, %r14
movq %rdi, 0x38(%rsp)
movq 0x8(%rsi), %rbx
subq (%rsi), %rbx
shrq $0x2, %rbx
xorl %eax, %eax
leaq 0x40(%rsp), %rdi
movq %rax, (%rdi)
movl %eax, 0x8(%rdi)
movq %rax, 0x10(%rdi)
movl %eax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movslq %ebx, %rsi
xorl %edx, %edx
callq 0xa744
movq %rbx, 0x8(%rsp)
leal -0x1(%rbx), %eax
movl $0x0, 0x30(%rsp)
movl %eax, 0x34(%rsp)
testl %ebp, %ebp
jle 0x8197
cmpl $0x3, 0x8(%rsp)
jl 0x8197
xorl %ebx, %ebx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
leaq 0x30(%rsp), %r13
leaq 0x3f(%rax), %r15
movq %r13, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xc07c
movslq %eax, %r8
leal 0x3f(%r8), %ecx
testl %r8d, %r8d
cmovnsl %r8d, %ecx
sarl $0x6, %ecx
movslq %ecx, %rdx
shlq $0x3, %rdx
addq 0x40(%rsp), %rdx
movq %r8, %rcx
andq %r15, %rcx
xorl %esi, %esi
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
cmpq %rdi, %rcx
setbe %sil
movl $0x1, %edi
movl %eax, %ecx
shlq %cl, %rdi
movq -0x8(%rdx,%rsi,8), %rax
btq %r8, %rax
jb 0x8187
leaq -0x8(,%rsi,8), %rcx
orq %rdi, %rax
movq %rax, (%rdx,%rcx)
incl %ebx
cmpl %ebp, %ebx
jge 0x8197
movq 0x8(%rsp), %rax
subl %ebx, %eax
cmpl $0x2, %eax
jg 0x811d
movq 0x8(%rsp), %rsi
testl %esi, %esi
jle 0x82a0
movl %esi, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movl $0x1, %r15d
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movl %ecx, %ebp
movq %rdi, 0x18(%rsp)
cmpl %esi, %ebp
movl %esi, %ebx
cmovll %ebp, %ebx
movq 0x40(%rsp), %rcx
movl %eax, %edx
shrl $0x6, %edx
movq (%rcx,%rdx,8), %rcx
btq %rax, %rcx
jae 0x81e6
incq %rax
movq %rax, %rdx
jmp 0x828f
movq 0x28(%rsp), %rcx
addl %eax, %ecx
cmpl %ecx, %esi
cmovll %esi, %ecx
leaq 0x1(%rax), %rdx
movslq %ecx, %rcx
cmpq %rcx, %rdx
jge 0x828f
movq %rdx, 0x20(%rsp)
movq (%r14), %rcx
movslq (%rcx,%rax,4), %r13
movq %r15, %r12
movq 0x40(%rsp), %rax
movl %r12d, %ecx
shrl $0x6, %ecx
movq (%rax,%rcx,8), %rax
btq %r12, %rax
jb 0x8280
imulq $0x6eac5db, %r13, %rax  # imm = 0x6EAC5DB
movq (%r14), %rcx
movslq (%rcx,%r12,4), %r13
addq %rax, %r13
movq 0x38(%rsp), %rsi
movq (%rsi), %rax
movslq 0xc4(%rax), %rcx
movq %r13, %rax
xorl %edx, %edx
divq %rcx
addl 0x5c(%rsi), %edx
movl %edx, 0x14(%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x826b
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r14)
jmp 0x8278
movq %r14, %rdi
leaq 0x14(%rsp), %rdx
callq 0xb082
incq %r12
cmpq %r12, %rbx
jne 0x8211
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rdx
incq %r15
incl %ebp
movq %rdx, %rax
cmpq %rdi, %rdx
jne 0x81c0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x82b7
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x82ca
jmp 0x82ca
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x82e4
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x45b0