// File: epfml[P]Bi-Sent2Vec/src/dictionary.cc
// Function: fasttext::Dictionary::addNgrams(std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, int, int, int, int, std::linear_congruential_engine<unsigned long, 48271ul, 0ul, 2147483647ul>&)
void Dictionary::addNgrams(std::vector<int32_t>& out, std::vector<int32_t>& line, int32_t start, int32_t end, int32_t n, int32_t k, std::minstd_rand& rng) {
  int32_t num_discarded = 0;
  int32_t line_size = end - start;
  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 = start; i <= end; i++) {
    if (discard[i - start]) continue;
    uint64_t h = line[i];
    for (int32_t j = i + 1; j <= end && j < i + n; j++) {
      if (discard[j - start]) break;
      h = h * 116049371 + line[j];
      out.push_back(nwords_ + (h % args_->bucket));
    }
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0xedd0
movq -0xd8(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
xorl %edx, %edx
callq 0xedf0
jmp 0xa14a
movl -0x2c(%rbp), %edx
decl %edx
leaq -0x6c(%rbp), %rdi
xorl %esi, %esi
callq 0xef10
jmp 0xa15c
jmp 0xa15e
movl -0x28(%rbp), %ecx
xorl %eax, %eax
cmpl 0x10(%rbp), %ecx
movb %al, -0xe1(%rbp)
jge 0xa180
movl -0x2c(%rbp), %eax
subl -0x28(%rbp), %eax
cmpl $0x2, %eax
setg %al
movb %al, -0xe1(%rbp)
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0xa18f
jmp 0xa265
movq 0x18(%rbp), %rsi
leaq -0x6c(%rbp), %rdi
callq 0xef40
movl %eax, -0xe8(%rbp)
jmp 0xa1a4
movl -0xe8(%rbp), %eax
movl %eax, -0x70(%rbp)
movslq -0x70(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xef70
movq %rdx, -0xf8(%rbp)
movq %rax, -0xf0(%rbp)
jmp 0xa1ca
movq -0xf8(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movq %rax, -0x78(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xefd0
xorb $-0x1, %al
testb $0x1, %al
jne 0xa1f1
jmp 0xa260
movslq -0x70(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xef70
movq %rdx, -0x108(%rbp)
movq %rax, -0x100(%rbp)
jmp 0xa20e
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movq %rax, -0x88(%rbp)
leaq -0x90(%rbp), %rdi
movl $0x1, %esi
callq 0xf000
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xa260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xf050
jmp 0xa479
jmp 0xa15e
movl -0x1c(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0xa467
movl -0x94(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
leaq -0x58(%rbp), %rdi
callq 0xef70
movq %rdx, -0x118(%rbp)
movq %rax, -0x110(%rbp)
jmp 0xa2a4
movq -0x118(%rbp), %rax
movq -0x110(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movq %rax, -0xa0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xefd0
testb $0x1, %al
jne 0xa2d2
jmp 0xa2d7
jmp 0xa453
movq -0x18(%rbp), %rdi
movslq -0x94(%rbp), %rsi
callq 0xe240
movslq (%rax), %rax
movq %rax, -0xb0(%rbp)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %ecx
xorl %eax, %eax
cmpl -0x20(%rbp), %ecx
movb %al, -0x119(%rbp)
jg 0xa32d
movl -0xb4(%rbp), %eax
movl -0x94(%rbp), %ecx
addl -0x24(%rbp), %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x119(%rbp)
movb -0x119(%rbp), %al
testb $0x1, %al
jne 0xa33c
jmp 0xa451
movl -0xb4(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
leaq -0x58(%rbp), %rdi
callq 0xef70
movq %rdx, -0x130(%rbp)
movq %rax, -0x128(%rbp)
jmp 0xa363
movq -0x130(%rbp), %rax
movq -0x128(%rbp), %rcx
movq %rcx, -0xc8(%rbp)
movq %rax, -0xc0(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0xefd0
testb $0x1, %al
jne 0xa391
jmp 0xa396
jmp 0xa451
movq -0xb0(%rbp), %rax
imulq $0x6eac5db, %rax, %rax  # imm = 0x6EAC5DB
movq %rax, -0x150(%rbp)
movq -0x18(%rbp), %rdi
movslq -0xb4(%rbp), %rsi
callq 0xe240
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movq -0x150(%rbp), %rax
movslq (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
movl 0x5c(%rdi), %eax
movl %eax, -0x134(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x140(%rbp)
callq 0xe6e0
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movq -0x140(%rbp), %rax
movslq 0xc4(%rcx), %rcx
xorl %edx, %edx
divq %rcx
movl -0x134(%rbp), %eax
movl %edx, %ecx
addl %ecx, %eax
movl %eax, -0xcc(%rbp)
leaq -0xcc(%rbp), %rsi
callq 0xe6b0
jmp 0xa43b
jmp 0xa43d
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0xa300
jmp 0xa453
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0xa26e
leaq -0x58(%rbp), %rdi
callq 0xf050
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x57a0
nopw %cs:(%rax,%rax)