// File: /workspace/github_cpp_makefile_star2_O1/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 $0xd8, %rsp
movsd %xmm0, -0x70(%rbp)
movq %r9, -0x40(%rbp)
movl %r8d, -0x38(%rbp)
movq %rcx, %r14
movq %rdx, %r12
movq %rdi, %r15
leaq -0xd0(%rbp), %r13
movq %r13, %rdi
callq 0x20386
movq 0x18(%r13), %rax
leaq -0xc8(%rbp), %rbx
cmpq %rbx, %rax
je 0x1edae
movabsq $0x3ff0000000000000, %r13 # imm = 0x3FF0000000000000
movq %r13, 0x40(%rax)
movq %rax, %rdi
callq 0x4280
cmpq %rbx, %rax
jne 0x1ed9d
leaq -0x98(%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 -0xf8(%rbp), %rax
xorpd %xmm0, %xmm0
movapd %xmm0, 0x8(%rax)
movapd %xmm0, 0x18(%rax)
movapd %xmm0, -0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq -0xd0(%rbp), %rsi
leaq -0xa0(%rbp), %rcx
leaq -0x100(%rbp), %r8
movq %r15, %rdi
movq %r12, %rdx
callq 0x1e0e8
leaq -0x100(%rbp), %rdi
callq 0x5c80
leaq -0x60(%rbp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq -0xa0(%rbp), %rdi
movl $0x0, -0x2c(%rbp)
xorl %edx, %edx
callq 0x1dd68
movq -0x60(%rbp), %r13
cmpq -0x58(%rbp), %r13
je 0x1ef39
leaq 0x8(%r14), %r12
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x68(%rbp)
movl -0x38(%rbp), %eax
movq %rax, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
movsd 0x20(%r13), %xmm0
movl $0x5, %ebx
ucomisd -0x70(%rbp), %xmm0
ja 0x1ef22
movq 0x8(%r13), %rax
cmpb $0x1, 0x8(%r15)
jne 0x1eed2
testq %rax, %rax
je 0x1eed6
movq (%r13), %rdx
xorl %esi, %esi
xorl %ecx, %ecx
movb (%rdx,%rsi), %r8b
movl $0x1, %edi
testb %r8b, %r8b
jns 0x1eec7
movl $0x4, %edi
cmpb $-0x11, %r8b
ja 0x1eec7
cmpb $-0x20, %r8b
movl $0x2, %edi
sbbl $-0x1, %edi
addl %edi, %esi
incl %ecx
cmpq %rsi, %rax
ja 0x1eea2
jmp 0x1eed8
movl %eax, %ecx
jmp 0x1eed8
xorl %ecx, %ecx
movl $0x7, %ebx
cmpl 0x10(%rbp), %ecx
jb 0x1ef22
movq %r14, %rdi
movq %r13, %rsi
callq 0x21436
cmpq %r12, %rax
jne 0x1ef22
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x10d38
cmpq -0x68(%rbp), %rax
jne 0x1ef22
movq %r14, %rdi
movq %r13, %rsi
callq 0x14092
incl -0x2c(%rbp)
xorl %eax, %eax
movq -0x38(%rbp), %rcx
cmpq %rcx, 0x28(%r14)
setae %al
leal (%rax,%rax,4), %ebx
cmpl $0x7, %ebx
je 0x1ef2b
testl %ebx, %ebx
jne 0x1ef39
addq $0x28, %r13
cmpq -0x58(%rbp), %r13
jne 0x1ee74
leaq -0x60(%rbp), %rdi
callq 0x1fd8a
leaq -0xa0(%rbp), %rdi
callq 0x5cea
leaq -0xd0(%rbp), %rdi
callq 0x5cea
movl -0x2c(%rbp), %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1ef86
jmp 0x1ef86
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x5c80
jmp 0x1ef92
jmp 0x1ef86
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x1fd8a
leaq -0xa0(%rbp), %rdi
callq 0x5cea
leaq -0xd0(%rbp), %rdi
callq 0x5cea
movq %rbx, %rdi
callq 0x4650