// File: aalto-speech[P]ftk/src/Unigrams.cc
// Function: Unigrams::init_candidates(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, double>>> const&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, unsigned int, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, unsigned int)
int
Unigrams::init_candidates(const map<string, flt_type> &vocab,
                          set<string> &candidates,
                          unsigned int n_candidates,
                          const set<string> &stoplist,
                          unsigned int min_length)
{

    vector<pair<string, flt_type> > sorted_vocab;
    sort_vocab(vocab, sorted_vocab, false);

    int selected_candidates = 0;
    for (auto it = sorted_vocab.cbegin(); it != sorted_vocab.cend(); ++it) {
        const string &subword = it->first;
        if (get_factor_length(subword, this->utf8) < min_length) continue;
        if (candidates.find(subword) != candidates.end()) continue;
        if (stoplist.find(subword) != stoplist.end()) continue;
        candidates.insert(subword);
        selected_candidates++;
        if (candidates.size() >= n_candidates) break;
    }

    return selected_candidates;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x587e0
movq -0xa8(%rbp), %rsi
movq -0x10(%rbp), %rdi
xorl %edx, %edx
callq 0x55590
jmp 0x567b1
movl $0x0, -0x58(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x58c30
movq %rax, -0x60(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x58ca0
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x58c60
testb $0x1, %al
jne 0x567e8
jmp 0x56938
leaq -0x60(%rbp), %rdi
callq 0x58cd0
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movq %rcx, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movzbl 0x8(%rax), %esi
andl $0x1, %esi
callq 0x54dc0
movl %eax, -0xb4(%rbp)
jmp 0x56817
movl -0xb4(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x56841
jmp 0x5692a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x58850
jmp 0x56959
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x58b10
movq %rax, -0xc0(%rbp)
jmp 0x56857
movq -0xc0(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x23610
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x235b0
testb $0x1, %al
jne 0x56882
jmp 0x56887
jmp 0x5692a
movq -0x28(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x235e0
movq %rax, -0xc8(%rbp)
jmp 0x5689d
movq -0xc8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rdi
callq 0x23610
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x235b0
testb $0x1, %al
jne 0x568d4
jmp 0x568d6
jmp 0x5692a
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x31820
movb %dl, -0xd1(%rbp)
movq %rax, -0xd0(%rbp)
jmp 0x568f2
movb -0xd1(%rbp), %al
movq -0xd0(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movb %al, -0x98(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x58af0
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
jb 0x56928
jmp 0x56938
jmp 0x5692a
leaq -0x60(%rbp), %rdi
callq 0x58cf0
jmp 0x567c5
movl -0x58(%rbp), %eax
movl %eax, -0xd8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x58850
movl -0xd8(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x46e0
nopw %cs:(%rax,%rax)