// File: /workspace/github_cpp_makefile_star2_O1/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, -0x58(%rbp)
movl %ecx, -0x2c(%rbp)
movq %rdx, -0x38(%rbp)
movq %rsi, %r14
movq %rdi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq 0x18(%rsi), %r13
addq $0x8, %r14
cmpq %r14, %r13
je 0x1eb6f
leaq -0x50(%rbp), %r15
leaq 0x20(%r13), %rsi
movq %r15, %rdi
callq 0x7f8c
movq %r13, %rdi
callq 0x4410
movq %rax, %r13
cmpq %r14, %rax
jne 0x1eb53
movq -0x50(%rbp), %r14
movq -0x48(%rbp), %r15
cmpq %r15, %r14
je 0x1ebca
leaq 0x20(%r14), %rax
cmpq %r15, %rax
je 0x1ebca
movl $0x20, %r13d
callq 0x40d0
cltq
movq %r13, %rcx
sarq $0x5, %rcx
incq %rcx
cqto
idivq %rcx
shlq $0x5, %rdx
cmpq %rdx, %r13
je 0x1ebb9
leaq (%r14,%r13), %rdi
addq %r14, %rdx
movq %rdx, %rsi
callq 0x42a0
leaq (%r14,%r13), %rax
addq $0x20, %rax
addq $0x20, %r13
cmpq %r15, %rax
jne 0x1eb8b
movq -0x50(%rbp), %r14
cmpq -0x48(%rbp), %r14
je 0x1ecb3
movq -0x38(%rbp), %rax
leaq 0x8(%rax), %r15
movq -0x58(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x68(%rbp)
movl -0x2c(%rbp), %eax
movq %rax, -0x60(%rbp)
movl $0x0, -0x2c(%rbp)
movq 0x8(%r14), %rax
cmpb $0x1, 0x8(%r12)
jne 0x1ec42
testq %rax, %rax
je 0x1ec46
movq (%r14), %rdx
xorl %esi, %esi
xorl %ecx, %ecx
movb (%rdx,%rsi), %r8b
movl $0x1, %edi
testb %r8b, %r8b
jns 0x1ec37
movl $0x4, %edi
cmpb $-0x11, %r8b
ja 0x1ec37
cmpb $-0x20, %r8b
movl $0x2, %edi
sbbl $-0x1, %edi
addl %edi, %esi
incl %ecx
cmpq %rsi, %rax
ja 0x1ec12
jmp 0x1ec48
movl %eax, %ecx
jmp 0x1ec48
xorl %ecx, %ecx
movl $0x7, %r13d
cmpl %ebx, %ecx
jb 0x1ec98
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x21436
cmpq %r15, %rax
jne 0x1ec98
movq -0x58(%rbp), %rdi
movq %r14, %rsi
callq 0x10d38
cmpq -0x68(%rbp), %rax
jne 0x1ec98
movq -0x38(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x14092
incl -0x2c(%rbp)
xorl %eax, %eax
movq -0x60(%rbp), %rcx
cmpq %rcx, 0x28(%r13)
setae %al
leal (%rax,%rax,4), %r13d
cmpl $0x7, %r13d
je 0x1eca3
testl %r13d, %r13d
jne 0x1ecba
addq $0x20, %r14
cmpq -0x48(%rbp), %r14
jne 0x1ebfa
jmp 0x1ecba
movl $0x0, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x5d54
movl -0x2c(%rbp), %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1ecdb
jmp 0x1ecdb
jmp 0x1ecdb
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x5d54
movq %rbx, %rdi
callq 0x4650
nop