// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/Unigrams.cc
// Function: Unigrams::init_candidates_by_usage(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::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, double)
int
Unigrams::init_candidates_by_usage(const map<string, flt_type> &words,
                                   const map<string, flt_type> &vocab,
                                   set<string> &candidates,
                                   unsigned int n_candidates,
                                   const set<string> &stoplist,
                                   unsigned int min_length,
                                   flt_type max_usage)
{
    map<string, flt_type> words_type = words;
    for (auto it = words_type.begin(); it != words_type.end(); ++it)
        it->second = 1.0;

    map<string, flt_type> type_occ;
    resegment_words(words_type, vocab, type_occ);

    vector<pair<string, flt_type> > sorted_occ;
    sort_vocab(type_occ, sorted_occ, false);

    int selected_candidates = 0;
    for (auto it = sorted_occ.cbegin(); it != sorted_occ.cend(); ++it) {
        const string &subword = it->first;
        if (it->second > max_usage) break;
        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 $0xc8, %rsp
movsd %xmm0, -0x60(%rbp)
movq %r9, -0x38(%rbp)
movl %r8d, -0x30(%rbp)
movq %rcx, %r14
movq %rdx, %r12
movq %rdi, %r15
leaq -0xc0(%rbp), %r13
movq %r13, %rdi
callq 0x201fa
movq 0x18(%r13), %rax
leaq -0xb8(%rbp), %rbx
cmpq %rbx, %rax
je 0x1ec4a
movabsq $0x3ff0000000000000, %r13 # imm = 0x3FF0000000000000
movq %r13, 0x40(%rax)
movq %rax, %rdi
callq 0x4280
cmpq %rbx, %rax
jne 0x1ec39
leaq -0x88(%rbp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq -0xe8(%rbp), %rax
xorpd %xmm0, %xmm0
movapd %xmm0, -0x8(%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq -0xc0(%rbp), %rsi
leaq -0x90(%rbp), %rcx
leaq -0xf0(%rbp), %r8
movq %r15, %rdi
movq %r12, %rdx
callq 0x1dfac
leaq -0xf0(%rbp), %rdi
callq 0x5c7a
leaq -0x50(%rbp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq -0x90(%rbp), %rdi
xorl %r12d, %r12d
xorl %edx, %edx
callq 0x1dc30
movq -0x50(%rbp), %r13
cmpq -0x48(%rbp), %r13
je 0x1edae
leaq 0x8(%r14), %rbx
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x58(%rbp)
movl -0x30(%rbp), %eax
movq %rax, -0x30(%rbp)
xorl %r12d, %r12d
movsd 0x20(%r13), %xmm0
ucomisd -0x60(%rbp), %xmm0
ja 0x1edae
movq 0x8(%r13), %rax
cmpb $0x1, 0x8(%r15)
jne 0x1ed5b
testq %rax, %rax
je 0x1ed5f
movq (%r13), %rdx
xorl %esi, %esi
xorl %ecx, %ecx
movb (%rdx,%rsi), %r8b
movl $0x1, %edi
testb %r8b, %r8b
jns 0x1ed50
movl $0x4, %edi
cmpb $-0x11, %r8b
ja 0x1ed50
cmpb $-0x20, %r8b
movl $0x2, %edi
sbbl $-0x1, %edi
addl %edi, %esi
incl %ecx
cmpq %rsi, %rax
ja 0x1ed2b
jmp 0x1ed61
movl %eax, %ecx
jmp 0x1ed61
xorl %ecx, %ecx
cmpl 0x10(%rbp), %ecx
jb 0x1eda0
movq %r14, %rdi
movq %r13, %rsi
callq 0x2125c
cmpq %rbx, %rax
jne 0x1eda0
movq -0x38(%rbp), %rdi
movq %r13, %rsi
callq 0x10c22
cmpq -0x58(%rbp), %rax
jne 0x1eda0
movq %r14, %rdi
movq %r13, %rsi
callq 0x13fba
incl %r12d
movq -0x30(%rbp), %rax
cmpq %rax, 0x28(%r14)
jae 0x1edae
addq $0x28, %r13
cmpq -0x48(%rbp), %r13
jne 0x1ed02
leaq -0x50(%rbp), %rdi
callq 0x1fbf4
leaq -0x90(%rbp), %rdi
callq 0x5ce4
leaq -0xc0(%rbp), %rdi
callq 0x5ce4
movl %r12d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1edfb
jmp 0x1edfb
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x5c7a
jmp 0x1ee07
jmp 0x1edfb
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1fbf4
leaq -0x90(%rbp), %rdi
callq 0x5ce4
leaq -0xc0(%rbp), %rdi
callq 0x5ce4
movq %rbx, %rdi
callq 0x4650
nop