// File: 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>>>>>>&)
flt_type forward_backward(const transitions_t &transitions,
                          FactorGraph &text,
                          transitions_t &stats)
{
    if (text.nodes.size() == 0) return MIN_FLOAT;

    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);

    return fw.back();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
callq 0x23a90
cmpq $0x0, %rax
jne 0x42d50
callq 0x47bf0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x42eed
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
callq 0x23a90
movq %rax, -0x90(%rbp)
callq 0x47bf0
movaps 0x23a20(%rip), %xmm1    # 0x66790
pxor %xmm1, %xmm0
movlpd %xmm0, -0x40(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x48220
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rcx
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x48240
jmp 0x42da6
leaq -0x41(%rbp), %rdi
callq 0x482c0
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
callq 0x23a90
movq %rax, -0xa0(%rbp)
callq 0x47bf0
movaps 0x239c1(%rip), %xmm1    # 0x66790
pxor %xmm1, %xmm0
movlpd %xmm0, -0x78(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x48220
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rcx
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x48240
jmp 0x42e05
leaq -0x79(%rbp), %rdi
callq 0x482c0
xorl %eax, %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x47eb0
movq $0x0, (%rax)
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
callq 0x23a90
movq %rax, %rsi
decq %rsi
leaq -0x70(%rbp), %rdi
callq 0x47eb0
movq -0xa8(%rbp), %rdx
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x42640
jmp 0x42e62
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rcx
leaq -0x38(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x42980
jmp 0x42e79
leaq -0x38(%rbp), %rdi
callq 0x482e0
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x48320
leaq -0x38(%rbp), %rdi
callq 0x48320
jmp 0x42eed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x482c0
jmp 0x42efb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x482c0
jmp 0x42ee2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x48320
leaq -0x38(%rbp), %rdi
callq 0x48320
jmp 0x42efb
movsd -0x8(%rbp), %xmm0
addq $0xb0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x46e0
nopw %cs:(%rax,%rax)