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

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

        const FactorGraph::Node &node = text.nodes[i];
        string target_node_str = text.get_factor(node);

        for (auto arc = node.incoming.begin(); arc != node.incoming.end(); ++arc) {
            int src_node = (**arc).source_node;
            if (fw[src_node] == MIN_FLOAT) continue;
            flt_type curr_cost = (**arc).cost + fw[src_node] - fw[i] + bw[i];
            stats[text.get_factor(src_node)][target_node_str] += exp(curr_cost);
            if (bw[src_node] == MIN_FLOAT) bw[src_node] = curr_cost;
            else bw[src_node] = add_log_domain_probs(bw[src_node], curr_cost);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, -0x58(%rbp)
movq %rdx, %r8
movq %rsi, -0x38(%rbp)
movq 0x48(%rdi), %rax
movq %rdi, -0x40(%rbp)
subq 0x40(%rdi), %rax
pushq $0x38
popq %rcx
cqto
idivq %rcx
movl %eax, %ecx
movsd 0xd158(%rip), %xmm1     # 0x23790
movq %r8, -0x30(%rbp)
decq %rcx
testl %ecx, %ecx
jle 0x16795
movl %ecx, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movq (%r8), %rax
movsd (%rax,%r13,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x16662
jnp 0x1663c
movq %rcx, -0x50(%rbp)
movq -0x40(%rbp), %rsi
movq 0x40(%rsi), %r14
imulq $0x38, %r13, %r12
leaq (%r14,%r12), %rbx
leaq -0x80(%rbp), %rdi
movq %rbx, %rdx
callq 0xea24
movsd 0xd106(%rip), %xmm1     # 0x23790
movq -0x30(%rbp), %rdx
movq 0x8(%r14,%r12), %r14
movq -0x38(%rbp), %rsi
cmpq 0x10(%rbx), %r14
je 0x16777
movq (%r14), %rax
movzwl (%rax), %r12d
movq (%rsi), %rcx
movsd (%rcx,%r12,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x166bd
jnp 0x1676e
addsd 0x8(%rax), %xmm0
subsd (%rcx,%r13,8), %xmm0
movq (%rdx), %rax
addsd (%rax,%r13,8), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0x4600
movsd %xmm0, -0x60(%rbp)
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
movq -0x40(%rbp), %rsi
movl %r12d, %edx
callq 0xea5a
movq -0x58(%rbp), %rdi
movq %r15, %rsi
callq 0x19152
movq %rax, %rdi
leaq -0x80(%rbp), %rsi
callq 0x18d90
movsd -0x60(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
leaq -0xa0(%rbp), %rdi
callq 0x46b8
movq -0x30(%rbp), %rdx
movq (%rdx), %rax
movsd (%rax,%r12,8), %xmm0
movsd 0xd054(%rip), %xmm1     # 0x23790
ucomisd %xmm1, %xmm0
jne 0x1674b
jp 0x1674b
movsd -0x48(%rbp), %xmm0
jmp 0x16764
movsd -0x48(%rbp), %xmm1
callq 0x15a53
movsd 0xd033(%rip), %xmm1     # 0x23790
movq -0x30(%rbp), %rdx
movq (%rdx), %rax
movsd %xmm0, (%rax,%r12,8)
movq -0x38(%rbp), %rsi
addq $0x8, %r14
jmp 0x16697
leaq -0x80(%rbp), %rdi
callq 0x46b8
movsd 0xd008(%rip), %xmm1     # 0x23790
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rcx
jmp 0x1663c
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x167b8
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x46b8
leaq -0x80(%rbp), %rdi
callq 0x46b8
movq %rbx, %rdi
callq 0x45f0