// File: /workspace/github_cpp_makefile_star2_O3/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, -0x68(%rbp)
movq %rsi, %r13
movq %rdi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
movq 0x18(%rsi), %r14
addq $0x8, %r13
cmpq %r13, %r14
movq %rdx, -0x40(%rbp)
je 0x1ea83
movl %ecx, -0x38(%rbp)
leaq -0x60(%rbp), %r15
leaq 0x20(%r14), %rsi
movq %r15, %rdi
callq 0x7f60
movq %r14, %rdi
callq 0x4410
movq %rax, %r14
cmpq %r13, %rax
jne 0x1e9ff
movq -0x60(%rbp), %r13
movq -0x58(%rbp), %r14
cmpq %r14, %r13
je 0x1ea7a
leaq 0x20(%r13), %rax
cmpq %r14, %rax
je 0x1ea7a
movl $0x20, %r15d
callq 0x40d0
cltq
movq %r15, %rcx
sarq $0x5, %rcx
incq %rcx
cqto
idivq %rcx
shlq $0x5, %rdx
cmpq %rdx, %r15
je 0x1ea65
leaq (%r15,%r13), %rdi
addq %r13, %rdx
movq %rdx, %rsi
callq 0x42a0
leaq (%r15,%r13), %rax
addq $0x20, %rax
addq $0x20, %r15
cmpq %r14, %rax
jne 0x1ea37
movq -0x60(%rbp), %r13
movq -0x40(%rbp), %rdx
movl -0x38(%rbp), %ecx
jmp 0x1ea86
xorl %r13d, %r13d
cmpq -0x58(%rbp), %r13
je 0x1eb4f
leaq 0x8(%rdx), %r15
movq -0x68(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movl %ecx, %eax
movq %rax, -0x70(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %r14
movq 0x8(%r13), %rax
cmpb $0x1, 0x8(%r12)
jne 0x1eafa
testq %rax, %rax
je 0x1eafe
movq (%r13), %rdx
xorl %esi, %esi
xorl %ecx, %ecx
movb (%rdx,%rsi), %r8b
movl $0x1, %edi
testb %r8b, %r8b
jns 0x1eaef
movl $0x4, %edi
cmpb $-0x11, %r8b
ja 0x1eaef
cmpb $-0x20, %r8b
movl $0x2, %edi
sbbl $-0x1, %edi
addl %edi, %esi
incl %ecx
cmpq %rsi, %rax
ja 0x1eaca
jmp 0x1eb00
movl %eax, %ecx
jmp 0x1eb00
xorl %ecx, %ecx
cmpl %ebx, %ecx
jb 0x1eb3f
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x2125c
cmpq %r15, %rax
jne 0x1eb3f
movq -0x68(%rbp), %rdi
movq %r13, %rsi
callq 0x10c22
cmpq -0x38(%rbp), %rax
jne 0x1eb3f
movq %r14, %rdi
movq %r13, %rsi
callq 0x13fba
incl -0x2c(%rbp)
movq -0x70(%rbp), %rax
cmpq %rax, 0x28(%r14)
jae 0x1eb56
addq $0x20, %r13
cmpq -0x58(%rbp), %r13
jne 0x1eab1
jmp 0x1eb56
movl $0x0, -0x2c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x5d4e
movl -0x2c(%rbp), %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1eb77
jmp 0x1eb77
jmp 0x1eb77
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x5d4e
movq %rbx, %rdi
callq 0x4650
nop