// File: /workspace/github_cpp_makefile_star2_O2/aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::disable_string(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::__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>>, 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>>, 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>>>>>>&)
flt_type
Bigrams::disable_string(const transitions_t &reverse_transitions,
                        const string &text,
                        const map<string, flt_type> &unigram_stats,
                        transitions_t &transitions,
                        transitions_t &changes)
{
    changes.clear();
    flt_type total_ll_diff = 0.0;

    for (auto it = transitions[text].begin(); it != transitions[text].begin(); ++it) {
        changes[text][it->first] = it->second;
        it->second = SMALL_LP;
    }

    for (auto contit = reverse_transitions.at(text).begin(); contit != reverse_transitions.at(text).end(); ++contit) {

        changes[contit->first][text] = transitions[contit->first][text];
        flt_type renormalizer = sub_log_domain_probs(0, transitions[contit->first][text]);
        flt_type ll_diff = 0.0;

        for (auto it = transitions[contit->first].begin(); it != transitions[contit->first].end(); ++it) {
            if (it->first != text) {
                flt_type count = unigram_stats.at(contit->first) * exp(it->second);
                changes[contit->first][it->first] = it->second;
                ll_diff -= count * it->second;
                it->second -= renormalizer;
                ll_diff += count * it->second;
            }
        }

        changes[contit->first][text] = transitions[contit->first][text];
        transitions[contit->first][text] = SMALL_LP;

        total_ll_diff += ll_diff;
    }

    return total_ll_diff;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r14
movq %rdx, -0x60(%rbp)
movq %rsi, %r12
movq %rdi, -0x50(%rbp)
movq %r8, -0x40(%rbp)
movq %r8, %rdi
callq 0x1a3dc
movq %r14, %rdi
movq %r12, %rsi
callq 0x19048
movq 0x18(%rax), %r15
movabsq $-0x3fa7000000000000, %r13 # imm = 0xC059000000000000
movq %r14, %rdi
movq %r12, %rsi
callq 0x19048
cmpq 0x18(%rax), %r15
je 0x207b1
leaq 0x20(%r15), %rbx
movsd 0x40(%r15), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x19048
movq %rax, %rdi
movq %rbx, %rsi
callq 0x18d90
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %r13, 0x40(%r15)
movq %r15, %rdi
callq 0x4270
movq %rax, %r15
jmp 0x20760
movq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x190b2
movq 0x18(%rax), %rbx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x190b2
addq $0x8, %rax
cmpq %rax, %rbx
je 0x209b0
movq %rbx, -0x58(%rbp)
leaq 0x20(%rbx), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x19048
movq %rax, %rdi
movq %r12, %rsi
callq 0x18d90
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x19048
movq %rax, %rdi
movq %r12, %rsi
callq 0x18d90
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %r14, %rdi
movq %r13, %rsi
callq 0x19048
movq %rax, %rdi
movq %r12, %rsi
callq 0x18d90
movsd (%rax), %xmm0
callq 0x209c4
movsd %xmm0, -0x68(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x19048
movq 0x18(%rax), %r15
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x19048
addq $0x8, %rax
cmpq %rax, %r15
je 0x2092e
leaq 0x20(%r15), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xea17
testb %al, %al
je 0x2091e
movq -0x60(%rbp), %rdi
movq %r13, %rsi
callq 0x19102
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x40(%r15), %xmm0
callq 0x4600
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x40(%r15), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x19048
movq %rax, %rdi
movq %rbx, %rsi
callq 0x18d90
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd 0x40(%r15), %xmm0
movsd -0x38(%rbp), %xmm3
movapd %xmm3, %xmm1
mulsd %xmm0, %xmm1
movsd -0x30(%rbp), %xmm2
subsd %xmm1, %xmm2
subsd -0x68(%rbp), %xmm0
movsd %xmm0, 0x40(%r15)
mulsd %xmm3, %xmm0
addsd %xmm0, %xmm2
movsd %xmm2, -0x30(%rbp)
movq %r15, %rdi
callq 0x4270
movq %rax, %r15
jmp 0x20866
movq %r14, %rdi
movq %r13, %rsi
callq 0x19048
movq %rax, %rdi
movq %r12, %rsi
callq 0x18d90
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x19048
movq %rax, %rdi
movq %r12, %rsi
callq 0x18d90
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %r14, %rdi
movq %r13, %rsi
callq 0x19048
movq %rax, %rdi
movq %r12, %rsi
callq 0x18d90
movabsq $-0x3fa7000000000000, %rcx # imm = 0xC059000000000000
movq %rcx, (%rax)
movsd -0x48(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x58(%rbp), %rdi
callq 0x43b0
movq %rax, %rbx
jmp 0x207ca
movsd -0x48(%rbp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq