// File: epfml[P]Bi-Sent2Vec/src/dictionary.cc
// Function: fasttext::Dictionary::prune(std::vector<int, std::allocator<int>>&)
void Dictionary::prune(std::vector<int32_t>& idx) {
  std::vector<int32_t> words, ngrams;
  for (auto it = idx.cbegin(); it != idx.cend(); ++it) {
    if (*it < nwords_) {words.push_back(*it);}
    else {ngrams.push_back(*it);}
  }
  std::sort(words.begin(), words.end());
  idx = words;

  if (ngrams.size() != 0) {
    int32_t j = 0;
    for (const auto ngram : ngrams) {
      pruneidx_[ngram - nwords_] = j;
      j++;
    }
    idx.insert(idx.end(), ngrams.begin(), ngrams.end());
  }
  pruneidx_size_ = pruneidx_.size();

  std::fill(word2int_.begin(), word2int_.end(), -1);

  int32_t j = 0;
  for (int32_t i = 0; i < words_.size(); i++) {
    if (getType(i) == entry_type::label || (j < words.size() && words[j] == i)) {
      words_[j] = words_[i];
      word2int_[find(words_[j].word)] = j;
      j++;
    }
  }
  nwords_ = words.size();
  size_ = nwords_ +  nlabels_;
  words_.erase(words_.begin() + size_, words_.end());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xe440
leaq -0x40(%rbp), %rdi
callq 0xe440
movq -0x10(%rbp), %rdi
callq 0xf370
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf3e0
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xf3a0
testb $0x1, %al
jne 0xb2fd
jmp 0xb379
leaq -0x48(%rbp), %rdi
callq 0xf410
movq -0x118(%rbp), %rcx
movl (%rax), %eax
cmpl 0x5c(%rcx), %eax
jge 0xb350
leaq -0x48(%rbp), %rdi
callq 0xf410
movq %rax, %rsi
leaq -0x28(%rbp), %rdi
callq 0xe5d0
jmp 0xb32b
jmp 0xb369
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xe530
leaq -0x28(%rbp), %rdi
callq 0xe530
jmp 0xb7d4
leaq -0x48(%rbp), %rdi
callq 0xf410
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0xe5d0
jmp 0xb367
jmp 0xb369
jmp 0xb36b
leaq -0x48(%rbp), %rdi
callq 0xf430
jmp 0xb2dd
leaq -0x28(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0xea10
movq -0x120(%rbp), %rdi
movq %rax, -0x68(%rbp)
callq 0xea40
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0xf450
jmp 0xb3ac
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xf490
jmp 0xb3bb
leaq -0x40(%rbp), %rdi
callq 0xed50
cmpq $0x0, %rax
je 0xb51c
movl $0x0, -0x74(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0xea10
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
callq 0xea40
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xf6e0
testb $0x1, %al
jne 0xb416
jmp 0xb490
leaq -0x88(%rbp), %rdi
callq 0xf720
movq -0x118(%rbp), %rcx
movl (%rax), %eax
movl %eax, -0x94(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x12c(%rbp)
movq %rcx, %rdi
addq $0x78, %rdi
movl -0x94(%rbp), %eax
movl 0x5c(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0xf740
movq %rax, -0x128(%rbp)
jmp 0xb467
movq -0x128(%rbp), %rax
movl -0x12c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xf770
jmp 0xb3fd
movq -0x10(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0xea40
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0xf840
leaq -0x40(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0xea10
movq -0x148(%rbp), %rdi
movq %rax, -0xb0(%rbp)
callq 0xea40
movq -0x140(%rbp), %rdi
movq %rax, -0xb8(%rbp)
movq -0xa0(%rbp), %rsi
movq -0xb0(%rbp), %rdx
movq -0xb8(%rbp), %rcx
callq 0xf790
movq %rax, -0x138(%rbp)
jmp 0xb50e
movq -0x138(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x118(%rbp), %rdi
addq $0x78, %rdi
callq 0xf880
movq -0x118(%rbp), %rdi
movq %rax, 0x70(%rdi)
addq $0x10, %rdi
movq %rdi, -0x150(%rbp)
callq 0xea10
movq -0x150(%rbp), %rdi
movq %rax, -0xc8(%rbp)
callq 0xea40
movq %rax, -0xd0(%rbp)
movl $0xffffffff, -0xd4(%rbp) # imm = 0xFFFFFFFF
movq -0xc8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
leaq -0xd4(%rbp), %rdx
callq 0xe9d0
jmp 0xb587
movl $0x0, -0xd8(%rbp)
movl $0x0, -0xdc(%rbp)
movq -0x118(%rbp), %rdi
movslq -0xdc(%rbp), %rax
movq %rax, -0x158(%rbp)
addq $0x28, %rdi
callq 0xeaf0
movq %rax, %rcx
movq -0x158(%rbp), %rax
cmpq %rcx, %rax
jae 0xb6f9
movq -0x118(%rbp), %rdi
movl -0xdc(%rbp), %esi
callq 0x8d50
cmpb $0x1, %al
je 0xb62a
movslq -0xd8(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0x160(%rbp), %rax
cmpq %rcx, %rax
jae 0xb6e3
movslq -0xd8(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xe240
movl (%rax), %eax
cmpl -0xdc(%rbp), %eax
jne 0xb6e3
movq -0x118(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0x170(%rbp)
movslq -0xdc(%rbp), %rsi
callq 0xe330
movq -0x170(%rbp), %rdi
movq %rax, -0x168(%rbp)
movslq -0xd8(%rbp), %rsi
callq 0xe330
movq -0x168(%rbp), %rsi
movq %rax, %rdi
callq 0xf8a0
jmp 0xb673
movq -0x118(%rbp), %rdi
movl -0xd8(%rbp), %eax
movl %eax, -0x184(%rbp)
movq %rdi, %rcx
addq $0x10, %rcx
movq %rcx, -0x180(%rbp)
addq $0x28, %rdi
movslq %eax, %rsi
callq 0xe330
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0x8070
movl %eax, -0x174(%rbp)
jmp 0xb6b7
movq -0x180(%rbp), %rdi
movl -0x174(%rbp), %eax
movslq %eax, %rsi
callq 0xe240
movl -0x184(%rbp), %ecx
movl %ecx, (%rax)
movl -0xd8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd8(%rbp)
jmp 0xb6e5
movl -0xdc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xdc(%rbp)
jmp 0xb59b
leaq -0x28(%rbp), %rdi
callq 0xed50
movq -0x118(%rbp), %rdi
movl %eax, 0x5c(%rdi)
movl 0x5c(%rdi), %eax
movl 0x60(%rdi), %ecx
addl %ecx, %eax
movl %eax, 0x58(%rdi)
addq $0x28, %rdi
movq %rdi, -0x198(%rbp)
callq 0xe880
movq %rax, %rcx
movq -0x118(%rbp), %rax
movq %rcx, -0xf8(%rbp)
movslq 0x58(%rax), %rsi
leaq -0xf8(%rbp), %rdi
callq 0xf900
movq %rax, -0xf0(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xe970
movq -0x198(%rbp), %rdi
callq 0xe8b0
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xe970
movq -0x198(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0x100(%rbp), %rdx
callq 0xe8e0
movq %rax, -0x190(%rbp)
jmp 0xb7ab
movq -0x190(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xe530
leaq -0x28(%rbp), %rdi
callq 0xe530
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x57a0
nopl (%rax)