// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::rank_candidate_subwords(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&, MultiStringFactorGraph 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>>, 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>>>>>>&, 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>>>&, bool, bool)
void
Bigrams::rank_candidate_subwords(const map<string, flt_type> &words,
                                 const MultiStringFactorGraph &msfg,
                                 const map<string, flt_type> &unigram_stats,
                                 transitions_t &transitions,
                                 map<string, flt_type> &candidates,
                                 bool forward_backward,
                                 bool normalize_by_bigram_count)
{
    map<string, set<string> > backpointers;
    Bigrams::get_backpointers(msfg, backpointers, 1);
    transitions_t reverse;
    Bigrams::reverse_transitions(transitions, reverse);

    for (auto it = candidates.begin(); it != candidates.end(); ++it) {
        transitions_t changes;
        set<string> words_to_resegment = backpointers.at(it->first);
        flt_type orig_score = likelihood(words, words_to_resegment, msfg, forward_backward);
        flt_type context_score = Bigrams::disable_string(reverse, it->first,
                                                         unigram_stats, transitions, changes);
        flt_type hypo_score = likelihood(words, words_to_resegment, msfg, forward_backward);
        it->second = hypo_score-orig_score + context_score;
        Bigrams::restore_string(transitions, changes);
        if (normalize_by_bigram_count) {
            int num_bigrams = transitions.at(it->first).size() + reverse.at(it->first).size();
            if (it->second < 0) it->second /= num_bigrams;
            else it->second *= num_bigrams;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %r9d, %r12d
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, -0x48(%rbp)
movq %rsi, %rdx
movq %rdi, -0x38(%rbp)
leaq -0xe0(%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), %rsi
movq %rdx, -0x40(%rbp)
movq %rdx, %rdi
movl $0x1, %edx
callq 0x23444
leaq -0xb0(%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 -0xb8(%rbp), %rsi
movq %rbx, %rdi
callq 0x22e0e
movq 0x18(%r14), %r15
addq $0x8, %r14
cmpq %r14, %r15
je 0x23a44
movzbl %r12b, %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x80(%rbp)
xorl %ecx, %ecx
movq %rcx, -0x78(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x70(%rbp)
movq %rax, -0x68(%rbp)
movq %rcx, -0x60(%rbp)
leaq 0x20(%r15), %r12
leaq -0xe8(%rbp), %rdi
movq %r12, %rsi
callq 0x23b9c
leaq -0x118(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x20038
movq -0x38(%rbp), %rdi
movq %r13, %rsi
movq -0x40(%rbp), %rdx
movl -0x2c(%rbp), %ecx
callq 0x19e52
movsd %xmm0, -0x58(%rbp)
leaq -0xb8(%rbp), %rdi
movq %r12, %rsi
movq -0x48(%rbp), %rdx
movq %rbx, %rcx
leaq -0x88(%rbp), %r8
callq 0x22eac
movsd %xmm0, -0x50(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x118(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl -0x2c(%rbp), %ecx
callq 0x19e52
subsd -0x58(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x40(%r15)
movq %rbx, %rdi
leaq -0x88(%rbp), %rsi
callq 0x233a8
cmpb $0x0, 0x10(%rbp)
je 0x23a18
movq %rbx, %rdi
movq %r14, %r13
movq %r12, %rsi
callq 0x23abe
movq 0x28(%rax), %r14
leaq -0xb8(%rbp), %rdi
movq %r12, %rsi
callq 0x23abe
addl 0x28(%rax), %r14d
movsd 0x40(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm1
cmpltsd 0x2aad(%rip), %xmm0     # 0x264b0
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movlpd %xmm0, 0x40(%r15)
movq %r13, %r14
leaq -0x118(%rbp), %rdi
callq 0x5c7a
leaq -0x88(%rbp), %rdi
callq 0x1b8ec
movq %r15, %rdi
callq 0x4280
movq %rax, %r15
cmpq %r14, %rax
jne 0x238ff
leaq -0xb8(%rbp), %rdi
callq 0x1b8ec
leaq -0xe8(%rbp), %rdi
callq 0x23bfa
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x23a9e
movq %rax, %rbx
jmp 0x23aaa
jmp 0x23a83
jmp 0x23a83
jmp 0x23a83
movq %rax, %rbx
jmp 0x23a92
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x5c7a
leaq -0x88(%rbp), %rdi
callq 0x1b8ec
leaq -0xb8(%rbp), %rdi
callq 0x1b8ec
leaq -0xe8(%rbp), %rdi
callq 0x23bfa
movq %rbx, %rdi
callq 0x4650