// File: /workspace/github_cpp_makefile_star2_O1/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 0x185e3
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, -0x40(%rbp)
movq %rdx, -0x60(%rbp)
movq %rdx, %rdi
callq 0x1c532
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 0x1b220
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 0x1b220
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 0x17e65
leaq -0x80(%rbp), %rsi
leaq -0x58(%rbp), %rdx
movq %r14, %rdi
movq -0x60(%rbp), %rcx
callq 0x1808e
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x184c4
movq %rax, 0x8(%rbx)
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x1b5b6
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r12, %rcx
addq $-0x3, %rcx
cmpq $-0x3, %rcx
ja 0x185ad
movl $0x1, %ecx
movl $0x2, %r15d
xorpd %xmm0, %xmm0
imulq $0x38, %rcx, %rdx
movzwl (%rax,%rdx), %esi
movzbl 0x2(%rax,%rdx), %eax
leaq (%rsi,%rax), %rdx
leaq (%rsi,%rax), %r13
decq %r13
movq (%rbx), %rax
movsd -0x8(%rax,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
movq -0x58(%rbp), %rdx
movsd (%rdx,%rcx,8), %xmm2
jne 0x1853a
jp 0x1853a
movsd %xmm2, (%rax,%r13,8)
jmp 0x18588
movapd %xmm1, %xmm3
subsd %xmm2, %xmm3
movapd %xmm3, %xmm0
xorpd 0xe2d2(%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), %rax
movsd %xmm0, (%rax,%r13,8)
xorpd %xmm0, %xmm0
movl %r15d, %ecx
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
decq %rdx
incl %r15d
cmpq %rcx, %rdx
ja 0x18500
movq -0x78(%rbp), %rax
movsd -0x8(%rax), %xmm0
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
movsd %xmm0, -0x40(%rbp)
je 0x185ce
callq 0x4350
movsd -0x40(%rbp), %xmm0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x185eb
callq 0x4350
movsd -0x40(%rbp), %xmm0
jmp 0x185eb
movsd 0xe215(%rip), %xmm0     # 0x26800
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x18610
movq %rax, %rbx
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x18610
callq 0x4350
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x1861e
callq 0x4350
movq %rbx, %rdi
callq 0x4650