// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/EM.cc
// Function: forward_backward(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&, FactorGraph&, 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::vector<double, std::allocator<double>>&)
flt_type forward_backward(const transitions_t &transitions,
                          FactorGraph &text,
                          transitions_t &stats,
                          vector<flt_type> &post_scores)
{
    if (text.nodes.size() == 0) return MIN_FLOAT;
    stats.clear();

    vector<flt_type> fw(text.nodes.size(), MIN_FLOAT);
    vector<flt_type> bw(text.nodes.size(), MIN_FLOAT);
    fw[0] = 0.0; bw[text.nodes.size()-1] = 0.0;

    forward(transitions, text, fw);
    backward(text, fw, bw, stats);

    post_scores.clear();
    post_scores.resize(text.text.size());
    for (unsigned int i=1; i<text.nodes.size()-1; i++) {
        int idx = int(text.nodes[i].start_pos) + int(text.nodes[i].len) - 1;
        if (post_scores[idx] == 0.0) post_scores[idx] = bw[i];
        else post_scores[idx] = add_log_domain_probs(post_scores[idx], bw[i]);
    }

    return fw.back();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq 0x48(%rsi), %rax
cmpq 0x40(%rsi), %rax
je 0x184ae
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, -0x40(%rbp)
movq %rdx, -0x60(%rbp)
movq %rdx, %rdi
callq 0x1c43c
movq 0x48(%r14), %rsi
subq 0x40(%r14), %rsi
sarq $0x3, %rsi
movabsq $0x6db6db6db6db6db7, %r12 # imm = 0x6DB6DB6DB6DB6DB7
imulq %r12, %rsi
movabsq $-0x10000000000001, %r15 # imm = 0xFFEFFFFFFFFFFFFF
leaq -0x58(%rbp), %rdx
movq %r15, (%rdx)
leaq -0x80(%rbp), %rdi
leaq -0x68(%rbp), %r13
movq %r13, %rcx
callq 0x1b134
movq 0x48(%r14), %rsi
subq 0x40(%r14), %rsi
sarq $0x3, %rsi
imulq %r12, %rsi
movq %r15, (%r13)
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rdx
leaq -0x29(%rbp), %rcx
callq 0x1b134
leaq -0x80(%rbp), %rdx
movq (%rdx), %rax
xorl %ecx, %ecx
movq %rcx, (%rax)
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
movq -0x58(%rbp), %rsi
imulq %r12, %rax
movq %rcx, -0x8(%rsi,%rax)
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x17d10
leaq -0x80(%rbp), %rsi
leaq -0x58(%rbp), %rdx
movq %r14, %rdi
movq -0x60(%rbp), %rcx
callq 0x17f51
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x18387
movq %rax, 0x8(%rbx)
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x1b4d4
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
addq $-0x3, %rdx
cmpq $-0x3, %rdx
ja 0x18478
movq (%rbx), %rdx
movl $0x1, %esi
movl $0x2, %r15d
xorpd %xmm0, %xmm0
imulq $0x38, %rsi, %rdi
movzwl (%rax,%rdi), %r8d
movzbl 0x2(%rax,%rdi), %edi
leaq (%r8,%rdi), %r9
leaq (%r8,%rdi), %r13
decq %r13
movsd -0x8(%rdx,%r9,8), %xmm1
ucomisd %xmm0, %xmm1
movq -0x58(%rbp), %rdi
movsd (%rdi,%rsi,8), %xmm2
jne 0x18402
jp 0x18402
movsd %xmm2, (%rdx,%r13,8)
jmp 0x18458
movapd %xmm1, %xmm3
subsd %xmm2, %xmm3
movapd %xmm3, %xmm0
xorpd 0xe40a(%rip), %xmm0     # 0x26820
movapd %xmm0, %xmm4
cmpltsd %xmm3, %xmm4
andpd %xmm4, %xmm1
andnpd %xmm2, %xmm4
orpd %xmm1, %xmm4
movapd %xmm4, -0x40(%rbp)
minsd %xmm3, %xmm0
callq 0x4660
callq 0x46e0
addsd -0x40(%rbp), %xmm0
movq (%rbx), %rdx
movsd %xmm0, (%rdx,%r13,8)
xorpd %xmm0, %xmm0
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
movl %r15d, %esi
movq %rcx, %rdi
subq %rax, %rdi
sarq $0x3, %rdi
imulq %r12, %rdi
decq %rdi
incl %r15d
cmpq %rsi, %rdi
ja 0x183c9
movq -0x78(%rbp), %rax
movsd -0x8(%rax), %xmm0
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
movsd %xmm0, -0x40(%rbp)
je 0x18499
callq 0x4350
movsd -0x40(%rbp), %xmm0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x184b6
callq 0x4350
movsd -0x40(%rbp), %xmm0
jmp 0x184b6
movsd 0xe34a(%rip), %xmm0     # 0x26800
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x184db
movq %rax, %rbx
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x184db
callq 0x4350
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x184e9
callq 0x4350
movq %rbx, %rdi
callq 0x4650