// File: 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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x48490
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x48700
movq %rax, %rdi
callq 0x58790
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x48700
movq %rax, %rdi
callq 0x58790
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x48c30
testb $0x1, %al
jne 0x5f395
jmp 0x5f401
leaq -0x38(%rbp), %rdi
callq 0x587c0
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x48700
movq %rax, -0x88(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x587c0
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x47db0
movsd -0x80(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x38(%rbp), %rdi
callq 0x587c0
movsd 0x739a(%rip), %xmm0     # 0x66788
movsd %xmm0, 0x20(%rax)
leaq -0x38(%rbp), %rdi
callq 0x4bba0
jmp 0x5f369
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x487e0
movq %rax, %rdi
callq 0x1b450
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x487e0
movq %rax, %rdi
callq 0x1b480
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1b290
testb $0x1, %al
jne 0x5f449
jmp 0x5f7de
movq -0x20(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x47db0
movsd (%rax), %xmm0
movsd %xmm0, -0xa0(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x47db0
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x47db0
movsd (%rax), %xmm1
xorps %xmm0, %xmm0
callq 0x5f7f0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, %rdi
callq 0x58790
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, %rdi
callq 0x48c90
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x48c30
testb $0x1, %al
jne 0x5f57b
jmp 0x5f710
leaq -0x68(%rbp), %rdi
callq 0x587c0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x24420
testb $0x1, %al
jne 0x5f599
jmp 0x5f700
movq -0x18(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0x48880
movsd (%rax), %xmm0
movsd %xmm0, -0xf0(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x587c0
movsd 0x20(%rax), %xmm0
callq 0x4710
movaps %xmm0, %xmm1
movsd -0xf0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x587c0
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0xd8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, -0xe0(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x587c0
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
callq 0x47db0
movsd -0xd8(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x587c0
movsd -0xd0(%rbp), %xmm0
movsd 0x20(%rax), %xmm2
movsd -0x60(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x587c0
movsd -0xc8(%rbp), %xmm1
movsd 0x20(%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rax)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x587c0
movsd -0xc0(%rbp), %xmm0
movsd 0x20(%rax), %xmm2
movsd -0x60(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x5f702
leaq -0x68(%rbp), %rdi
callq 0x4bba0
jmp 0x5f536
movq -0x20(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x47db0
movsd (%rax), %xmm0
movsd %xmm0, -0x108(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0x110(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x47db0
movsd -0x108(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b2f0
movq -0x100(%rbp), %rdi
movq %rax, %rsi
callq 0x48700
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x47db0
movsd 0x6fcb(%rip), %xmm0     # 0x66788
movsd %xmm0, (%rax)
movsd -0x60(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1b320
jmp 0x5f41a
movsd -0x30(%rbp), %xmm0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax)