// File: 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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rdi
callq 0xed50
movl %eax, -0x28(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0xedd0
movq -0xd0(%rbp), %rdi
movslq -0x28(%rbp), %rsi
xorl %edx, %edx
callq 0xedf0
jmp 0xa4ef
movl -0x28(%rbp), %edx
decl %edx
leaq -0x64(%rbp), %rdi
xorl %esi, %esi
callq 0xef10
jmp 0xa501
jmp 0xa503
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x18(%rbp), %ecx
movb %al, -0xd9(%rbp)
jge 0xa525
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
cmpl $0x2, %eax
setg %al
movb %al, -0xd9(%rbp)
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0xa534
jmp 0xa607
movq -0x20(%rbp), %rsi
leaq -0x64(%rbp), %rdi
callq 0xef40
movl %eax, -0xe0(%rbp)
jmp 0xa549
movl -0xe0(%rbp), %eax
movl %eax, -0x68(%rbp)
movslq -0x68(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xef70
movq %rdx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
jmp 0xa56f
movq -0xf0(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq %rcx, -0x78(%rbp)
movq %rax, -0x70(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xefd0
xorb $-0x1, %al
testb $0x1, %al
jne 0xa596
jmp 0xa602
movslq -0x68(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xef70
movq %rdx, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
jmp 0xa5b3
movq -0x100(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq %rax, -0x80(%rbp)
leaq -0x88(%rbp), %rdi
movl $0x1, %esi
callq 0xf000
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xa602
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xf050
jmp 0xa80e
jmp 0xa503
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0xa7fc
movslq -0x8c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xef70
movq %rdx, -0x110(%rbp)
movq %rax, -0x108(%rbp)
jmp 0xa640
movq -0x110(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movq %rax, -0x98(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xefd0
testb $0x1, %al
jne 0xa66e
jmp 0xa673
jmp 0xa7e8
movq -0x10(%rbp), %rdi
movslq -0x8c(%rbp), %rsi
callq 0xe240
movslq (%rax), %rax
movq %rax, -0xa8(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %ecx
xorl %eax, %eax
cmpl -0x28(%rbp), %ecx
movb %al, -0x111(%rbp)
jge 0xa6c9
movl -0xac(%rbp), %eax
movl -0x8c(%rbp), %ecx
addl -0x14(%rbp), %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x111(%rbp)
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0xa6d8
jmp 0xa7e6
movslq -0xac(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xef70
movq %rdx, -0x128(%rbp)
movq %rax, -0x120(%rbp)
jmp 0xa6f8
movq -0x128(%rbp), %rax
movq -0x120(%rbp), %rcx
movq %rcx, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xefd0
testb $0x1, %al
jne 0xa726
jmp 0xa72b
jmp 0xa7e6
movq -0xa8(%rbp), %rax
imulq $0x6eac5db, %rax, %rax  # imm = 0x6EAC5DB
movq %rax, -0x148(%rbp)
movq -0x10(%rbp), %rdi
movslq -0xac(%rbp), %rsi
callq 0xe240
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movq -0x148(%rbp), %rax
movslq (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movl 0x5c(%rdi), %eax
movl %eax, -0x12c(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x138(%rbp)
callq 0xe6e0
movq -0x140(%rbp), %rdi
movq %rax, %rcx
movq -0x138(%rbp), %rax
movslq 0xc4(%rcx), %rcx
xorl %edx, %edx
divq %rcx
movl -0x12c(%rbp), %eax
movl %edx, %ecx
addl %ecx, %eax
movl %eax, -0xc4(%rbp)
leaq -0xc4(%rbp), %rsi
callq 0xe6b0
jmp 0xa7d0
jmp 0xa7d2
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0xa69c
jmp 0xa7e8
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0xa611
leaq -0x50(%rbp), %rdi
callq 0xf050
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x57a0
nopw (%rax,%rax)