// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq %rcx, %r14
movq %rdx, -0x48(%rbp)
movq %rsi, %rcx
movq %rdi, -0x38(%rbp)
leaq -0xe0(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0xe8(%rbp), %rsi
pushq $0x1
popq %rdx
movq %rcx, -0x40(%rbp)
movq %rcx, %rdi
callq 0x20c4c
leaq -0xb0(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0xb8(%rbp), %rsi
movq %r14, %rdi
callq 0x20686
movq 0x18(%rbx), %r15
addq $0x8, %rbx
movzbl %r12b, %eax
movl %eax, -0x2c(%rbp)
cmpq %rbx, %r15
je 0x2118a
andl $0x0, -0x80(%rbp)
andq $0x0, -0x78(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x70(%rbp)
movq %rax, -0x68(%rbp)
andq $0x0, -0x60(%rbp)
leaq 0x20(%r15), %r12
leaq -0xe8(%rbp), %rdi
movq %r12, %rsi
callq 0x212be
leaq -0x118(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x1de1a
movq -0x38(%rbp), %rdi
movq %r13, %rsi
movq -0x40(%rbp), %rdx
movl -0x2c(%rbp), %ecx
callq 0x17f60
movsd %xmm0, -0x58(%rbp)
leaq -0xb8(%rbp), %rdi
movq %r12, %rsi
movq -0x48(%rbp), %rdx
movq %r14, %rcx
leaq -0x88(%rbp), %r8
callq 0x2071c
movsd %xmm0, -0x50(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x118(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl -0x2c(%rbp), %ecx
callq 0x17f60
subsd -0x58(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x40(%r15)
movq %r14, %rdi
leaq -0x88(%rbp), %rsi
callq 0x20bbc
cmpb $0x0, 0x10(%rbp)
je 0x21162
movq %rbx, %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x21204
movq 0x28(%rax), %rbx
leaq -0xb8(%rbp), %rdi
movq %r12, %rsi
callq 0x21204
addl 0x28(%rax), %ebx
movsd 0x40(%r15), %xmm0
cvtsi2sd %ebx, %xmm1
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm1
cmpltsd 0x22f3(%rip), %xmm0     # 0x23440
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movlpd %xmm0, 0x40(%r15)
movq %r13, %rbx
leaq -0x118(%rbp), %rdi
callq 0x53c6
leaq -0x88(%rbp), %rdi
callq 0x19564
movq %r15, %rdi
callq 0x4270
movq %rax, %r15
jmp 0x21048
leaq -0xb8(%rbp), %rdi
callq 0x19564
leaq -0xe8(%rbp), %rdi
callq 0x2130e
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x211e4
movq %rax, %rbx
jmp 0x211f0
jmp 0x211c4
jmp 0x211c4
jmp 0x211c4
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x53c6
jmp 0x211d8
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x19564
leaq -0xb8(%rbp), %rdi
callq 0x19564
leaq -0xe8(%rbp), %rdi
callq 0x2130e
movq %rbx, %rdi
callq 0x45f0