// File: /workspace/github_cpp_makefile_star2_O2/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, -0x48(%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 0x1dfc0
movq 0x18(%r13), %rax
leaq -0xb8(%rbp), %rbx
movabsq $0x3ff0000000000000, %r13 # imm = 0x3FF0000000000000
cmpq %rbx, %rax
je 0x1ccd3
movq %r13, 0x40(%rax)
movq %rax, %rdi
callq 0x4270
jmp 0x1ccc0
leaq -0x88(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0xe8(%rbp), %rax
xorpd %xmm0, %xmm0
movapd %xmm0, -0x8(%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0xc0(%rbp), %rsi
leaq -0x90(%rbp), %rcx
leaq -0xf0(%rbp), %r8
movq %r15, %rdi
movq %r12, %rdx
callq 0x1c264
leaq -0xf0(%rbp), %rdi
callq 0x53c6
leaq -0x60(%rbp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
leaq -0x90(%rbp), %rdi
xorl %r12d, %r12d
xorl %edx, %edx
callq 0x1bfa0
movq -0x60(%rbp), %r13
leaq 0x8(%r14), %rbx
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movl -0x30(%rbp), %eax
movq %rax, -0x30(%rbp)
cmpq -0x58(%rbp), %r13
je 0x1cddf
movsd 0x20(%r13), %xmm0
ucomisd -0x48(%rbp), %xmm0
ja 0x1cddf
movzbl 0x8(%r15), %esi
movq %r13, %rdi
callq 0x1bb8e
cmpl 0x10(%rbp), %eax
jb 0x1cdd9
movq %r14, %rdi
movq %r13, %rsi
callq 0x1edee
cmpq %rbx, %rax
jne 0x1cdd9
movq -0x38(%rbp), %rdi
movq %r13, %rsi
callq 0xf572
cmpq -0x40(%rbp), %rax
jne 0x1cdd9
movq %r14, %rdi
movq %r13, %rsi
callq 0x123ba
incl %r12d
movq -0x30(%rbp), %rax
cmpq %rax, 0x28(%r14)
jae 0x1cddf
addq $0x28, %r13
jmp 0x1cd7a
leaq -0x60(%rbp), %rdi
callq 0x1d9d2
leaq -0x90(%rbp), %rdi
callq 0x543e
leaq -0xc0(%rbp), %rdi
callq 0x543e
movl %r12d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1ce2c
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x53c6
jmp 0x1ce38
jmp 0x1ce2c
jmp 0x1ce2c
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x1d9d2
leaq -0x90(%rbp), %rdi
callq 0x543e
leaq -0xc0(%rbp), %rdi
callq 0x543e
movq %rbx, %rdi
callq 0x45f0