// File: /workspace/github_cpp_makefile_star2_O2/aalto-speech[P]ftk/src/Unigrams.cc
// Function: Unigrams::init_candidates_by_random(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_by_random(const map<string, flt_type> &vocab,
                                    set<string> &candidates,
                                    unsigned int n_candidates,
                                    const set<string> &stoplist,
                                    unsigned int min_length)
{
    vector<string> shuffled_vocab;
    for (auto it = vocab.cbegin(); it != vocab.cend(); ++it)
        shuffled_vocab.push_back(it->first);
    random_shuffle(shuffled_vocab.begin(), shuffled_vocab.end());

    int selected_candidates = 0;
    for (auto it = shuffled_vocab.begin(); it != shuffled_vocab.end(); ++it) {
        const string &subword = *it;
        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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %ebx
movq %r8, -0x40(%rbp)
movl %ecx, -0x2c(%rbp)
movq %rdx, -0x38(%rbp)
movq %rsi, %r14
movq %rdi, %r12
leaq -0x60(%rbp), %r13
andq $0x0, 0x10(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, (%r13)
movq 0x18(%rsi), %r15
addq $0x8, %r14
cmpq %r14, %r15
je 0x1cb54
leaq 0x20(%r15), %rsi
movq %r13, %rdi
callq 0x719e
movq %r15, %rdi
callq 0x43b0
movq %rax, %r15
jmp 0x1cb36
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1da69
movq -0x60(%rbp), %r14
movq -0x38(%rbp), %rax
leaq 0x8(%rax), %r15
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x70(%rbp)
movl -0x2c(%rbp), %eax
movq %rax, -0x68(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %r13
cmpq -0x58(%rbp), %r14
je 0x1cbe4
movzbl 0x8(%r12), %esi
movq %r14, %rdi
callq 0x1bb8e
cmpl %ebx, %eax
jb 0x1cbde
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x1edee
cmpq %r15, %rax
jne 0x1cbde
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0xf572
cmpq -0x70(%rbp), %rax
jne 0x1cbde
movq %r13, %rdi
movq %r14, %rsi
callq 0x123ba
incl -0x2c(%rbp)
movq -0x68(%rbp), %rax
cmpq %rax, 0x28(%r13)
jae 0x1cbe4
addq $0x20, %r14
jmp 0x1cb8b
leaq -0x60(%rbp), %rdi
callq 0x54b6
movl -0x2c(%rbp), %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1cc07
jmp 0x1cc07
jmp 0x1cc07
jmp 0x1cc07
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x54b6
movq %rbx, %rdi
callq 0x45f0
nop