// File: /workspace/github_cpp_makefile_star2_O1/aalto-speech[P]ftk/src/EM.cc
// Function: backward(StringSet const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::vector<Token, std::allocator<Token>>, std::allocator<std::vector<Token, std::allocator<Token>>>> 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>>, 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 StringSet &vocab,
              const string &text,
              const vector<vector<Token> > &search,
              const vector<flt_type> &fw,
              vector<flt_type> &bw,
              map<string, flt_type> &stats)
{
    int len = text.length();
    if (search[len-1].size() == 0) return;

    // Backward
    for (int i=len-1; i>=0; i--) {
        for (auto tok = search[i].cbegin(); tok != search[i].cend(); ++tok) {
            flt_type normalized = tok->cost - fw[i] + bw[i];
            if (bw[i] != SMALL_LP && fw[i] != SMALL_LP) {
                stats[text.substr(tok->source+1, i-tok->source)] += exp(normalized);
                if (tok->source == -1) continue;
                if (bw[tok->source] != SMALL_LP) bw[tok->source] = add_log_domain_probs(bw[tok->source], normalized);
                else bw[tok->source] = normalized;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, -0x50(%rbp)
movq %rcx, -0x68(%rbp)
movq %rdx, %r12
movq %rsi, -0x48(%rbp)
movl 0x8(%rsi), %ecx
leal -0x1(%rcx), %eax
movslq %eax, %rdx
movq (%r12), %rsi
leaq (%rdx,%rdx,2), %rdx
movq 0x8(%rsi,%rdx,8), %rdi
cmpq (%rsi,%rdx,8), %rdi
sete %dl
testl %ecx, %ecx
setle %cl
orb %dl, %cl
jne 0x174d3
movq %r8, %r14
movl %eax, %r13d
movsd 0xf4bc(%rip), %xmm2     # 0x26810
movq (%r12), %rax
leaq (,%r13,2), %rbx
addq %r13, %rbx
movq (%rax,%rbx,8), %r15
cmpq 0x8(%rax,%rbx,8), %r15
je 0x174c3
movslq %r13d, %rax
movq %rax, -0x60(%rbp)
movq %r13, -0x58(%rbp)
movq (%r14), %rax
movsd (%rax,%r13,8), %xmm3
ucomisd %xmm2, %xmm3
jne 0x17392
jnp 0x174b0
movq -0x68(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r13,8), %xmm1
ucomisd %xmm2, %xmm1
jne 0x173ab
jnp 0x174b0
movq %r14, %r13
movq %rbx, %r14
movq %r12, %rbx
movsd 0x8(%r15), %xmm0
subsd %xmm1, %xmm0
addsd %xmm3, %xmm0
movapd %xmm0, -0x80(%rbp)
callq 0x4660
movsd %xmm0, -0x40(%rbp)
movslq (%r15), %rdx
movq -0x60(%rbp), %rcx
subq %rdx, %rcx
incq %rdx
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
movq -0x48(%rbp), %rsi
callq 0x43b0
movq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x1b10e
movsd -0x40(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x17422
callq 0x4350
movslq (%r15), %rax
cmpq $-0x1, %rax
movsd 0xf3df(%rip), %xmm2     # 0x26810
movq %rbx, %r12
movq %r14, %rbx
movq %r13, %r14
movq -0x58(%rbp), %r13
je 0x174b0
movq (%r14), %rcx
movsd (%rcx,%rax,8), %xmm1
ucomisd %xmm2, %xmm1
jne 0x17450
jnp 0x174a6
movapd %xmm1, %xmm2
movapd -0x80(%rbp), %xmm3
subsd %xmm3, %xmm2
movapd %xmm2, %xmm0
xorpd 0xf3b7(%rip), %xmm0     # 0x26820
movapd %xmm0, %xmm4
cmpltsd %xmm2, %xmm4
andpd %xmm4, %xmm1
andnpd %xmm3, %xmm4
orpd %xmm1, %xmm4
movapd %xmm4, -0x40(%rbp)
minsd %xmm2, %xmm0
callq 0x4660
callq 0x46e0
movsd 0xf377(%rip), %xmm2     # 0x26810
addsd -0x40(%rbp), %xmm0
movslq (%r15), %rax
movq (%r14), %rcx
jmp 0x174ab
movapd -0x80(%rbp), %xmm0
movsd %xmm0, (%rcx,%rax,8)
addq $0x10, %r15
movq (%r12), %rax
cmpq 0x8(%rax,%rbx,8), %r15
jne 0x1737d
leaq -0x1(%r13), %rax
testq %r13, %r13
movq %rax, %r13
jg 0x17354
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x174fd
callq 0x4350
movq %rbx, %rdi
callq 0x4650