// File: /workspace/github_cpp_makefile_star2_O2/aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::init_candidates_num_contexts(unsigned int, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 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>>>, 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, 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::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>>>&, 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&)
int
Bigrams::init_candidates_num_contexts(unsigned int n_candidates,
                                      const transitions_t &transitions,
                                      const map<string, flt_type> &unigram_stats,
                                      map<string, flt_type> &candidates,
                                      const set<string> &stoplist)
{
    vector<pair<string, flt_type> > sorted_stats;
    Unigrams::sort_vocab(unigram_stats, sorted_stats, false);

    map<string, flt_type> ctxt_estimate;
    for (auto srcit = transitions.begin(); srcit != transitions.end(); ++srcit) {
        ctxt_estimate[srcit->first] += srcit->second.size();
        for (auto tgtit = srcit->second.begin(); tgtit != srcit->second.end(); ++tgtit)
            ctxt_estimate[tgtit->first] += 1;
    }

    for (auto ssit = sorted_stats.begin(); ssit != sorted_stats.end(); ++ssit)
        ssit->second = ctxt_estimate[ssit->first];
    stable_sort(sorted_stats.begin(), sorted_stats.end(), ascending_sort);

    for (auto it = sorted_stats.begin(); it != sorted_stats.end(); ++it) {
        if (stoplist.find(it->first) != stoplist.end()) continue;
        candidates[it->first] = 0.0;
        if (candidates.size() >= n_candidates) break;
    }

    return candidates.size();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, -0x38(%rbp)
movq %rcx, %r14
movq %rsi, %rbx
movl %edi, -0x2c(%rbp)
xorpd %xmm0, %xmm0
leaq -0x50(%rbp), %rsi
movapd %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
movq %rdx, %rdi
xorl %edx, %edx
callq 0x1bfa0
leaq -0x80(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq 0x18(%rbx), %r13
addq $0x8, %rbx
leaq -0x88(%rbp), %r15
movq %rbx, -0x58(%rbp)
cmpq %rbx, %r13
je 0x20ed7
movq %r14, %r12
leaq 0x20(%r13), %rsi
movq 0x68(%r13), %rbx
movq %r15, %rdi
callq 0x18d90
movq %rbx, %xmm0
punpckldq 0x29d2(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x29da(%rip), %xmm0     # 0x23850
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd (%rax), %xmm1
movsd %xmm1, (%rax)
movq 0x58(%r13), %rbx
leaq 0x48(%r13), %r14
cmpq %r14, %rbx
je 0x20ec0
leaq 0x20(%rbx), %rsi
movq %r15, %rdi
callq 0x18d90
movsd (%rax), %xmm0
addsd 0x28e9(%rip), %xmm0     # 0x23798
movsd %xmm0, (%rax)
movq %rbx, %rdi
callq 0x43b0
movq %rax, %rbx
jmp 0x20e92
movq %r13, %rdi
callq 0x43b0
movq %rax, %r13
movq %r12, %r14
movq -0x58(%rbp), %rbx
jmp 0x20e45
movq -0x50(%rbp), %rbx
leaq -0x88(%rbp), %r15
movq -0x48(%rbp), %rsi
cmpq %rsi, %rbx
je 0x20f05
movq %r15, %rdi
movq %rbx, %rsi
callq 0x18d90
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rbx)
addq $0x28, %rbx
jmp 0x20ee2
movq -0x50(%rbp), %rdi
leaq -0x5511(%rip), %rdx     # 0x1b9ff
callq 0x21c16
movq -0x50(%rbp), %r15
movq -0x38(%rbp), %rax
leaq 0x8(%rax), %r12
movl -0x2c(%rbp), %r13d
cmpq -0x48(%rbp), %r15
je 0x20f5a
movq -0x38(%rbp), %rdi
movq %r15, %rsi
callq 0xf572
cmpq %r12, %rax
jne 0x20f54
movq %r14, %rdi
movq %r15, %rsi
callq 0x18d90
andq $0x0, (%rax)
movq 0x28(%r14), %rbx
cmpq %r13, %rbx
jae 0x20f5e
addq $0x28, %r15
jmp 0x20f25
movq 0x28(%r14), %rbx
leaq -0x88(%rbp), %rdi
callq 0x543e
leaq -0x50(%rbp), %rdi
callq 0x1d9d2
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x20f93
movq %rax, %rbx
jmp 0x20fa2
jmp 0x20f93
jmp 0x20f93
jmp 0x20f93
jmp 0x20f93
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x543e
leaq -0x50(%rbp), %rdi
callq 0x1d9d2
movq %rbx, %rdi
callq 0x45f0
nop