// File: aalto-speech[P]ftk/src/EM.cc
// Function: forward(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::vector<double, std::allocator<double>>&)
void forward(const transitions_t &transitions,
             FactorGraph &text,
             vector<flt_type> &fw)
{
    for (unsigned int i=0; i<text.nodes.size(); i++) {

        if (fw[i] == MIN_FLOAT) continue;

        FactorGraph::Node &node = text.nodes[i];
        for (auto arc = node.outgoing.begin(); arc != node.outgoing.end(); ++arc) {

            int tgt_node = (**arc).target_node;
            try {
                (**arc).cost = transitions.at(text.get_factor(node)).at(text.get_factor(tgt_node));
            }
            catch (std::out_of_range &oor) {
                (**arc).cost = SMALL_LP;
            }

            flt_type cost = fw[i] + (**arc).cost;
            if (fw[tgt_node] == MIN_FLOAT) fw[tgt_node] = cost;
            else fw[tgt_node] = add_log_domain_probs(fw[tgt_node], cost);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0x23a90
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x4296a
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x47eb0
movsd (%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
callq 0x47bf0
movaps %xmm0, %xmm1
movsd -0xb0(%rbp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
ucomisd %xmm1, %xmm0
jne 0x426d6
jp 0x426d6
jmp 0x4295c
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x23ae0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x24310
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x24340
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x245f0
testb $0x1, %al
jne 0x42724
jmp 0x4295a
leaq -0x30(%rbp), %rdi
callq 0x24630
movq (%rax), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x24450
jmp 0x42755
movq -0xb8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x487e0
movq %rax, -0xc0(%rbp)
jmp 0x4276e
movq -0x10(%rbp), %rsi
movl -0x3c(%rbp), %edx
leaq -0x90(%rbp), %rdi
callq 0x24510
jmp 0x42783
movq -0xc0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x48880
movq %rax, -0xc8(%rbp)
jmp 0x4279f
movq -0xc8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xd0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x24630
movsd -0xd0(%rbp), %xmm0
movq (%rax), %rax
movsd %xmm0, 0x8(%rax)
leaq -0x90(%rbp), %rdi
callq 0x4828
leaq -0x60(%rbp), %rdi
callq 0x4828
jmp 0x4285d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x4281f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x42816
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4828
leaq -0x60(%rbp), %rdi
callq 0x4828
movl -0x6c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x42973
movq -0x68(%rbp), %rdi
callq 0x4180
movq %rax, -0x98(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x24630
movq (%rax), %rax
movsd 0x23f35(%rip), %xmm0    # 0x66788
movsd %xmm0, 0x8(%rax)
callq 0x4660
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x47eb0
movsd (%rax), %xmm0
movsd %xmm0, -0xe0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x24630
movsd -0xe0(%rbp), %xmm0
movq (%rax), %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x47eb0
movsd (%rax), %xmm0
movsd %xmm0, -0xd8(%rbp)
callq 0x47bf0
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4290b
jp 0x4290b
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x47eb0
movsd -0xe8(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x4294a
movq -0x18(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x47eb0
movsd (%rax), %xmm0
movsd -0xa0(%rbp), %xmm1
callq 0x412e0
movsd %xmm0, -0xf0(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x47eb0
movsd -0xf0(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x4294c
leaq -0x30(%rbp), %rdi
callq 0x24650
jmp 0x426fd
jmp 0x4295c
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x4265e
addq $0xf0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x46e0
nopl (%rax)