// File: /workspace/github_cpp_makefile_star2_O3/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), %edx
leal -0x1(%rdx), %ecx
movslq %ecx, %rsi
movq (%r12), %rax
leaq (%rsi,%rsi,2), %rsi
movq 0x8(%rax,%rsi,8), %rdi
cmpq (%rax,%rsi,8), %rdi
sete %sil
testl %edx, %edx
setle %dl
orb %sil, %dl
jne 0x17369
movq %r8, %r14
movl %ecx, %r13d
movsd 0xf622(%rip), %xmm2     # 0x26810
leaq (,%r13,2), %rbx
addq %r13, %rbx
movq (%rax,%rbx,8), %r15
cmpq 0x8(%rax,%rbx,8), %r15
je 0x17359
movslq %r13d, %rax
movq %rax, -0x60(%rbp)
movq %r13, -0x58(%rbp)
movq (%r14), %rax
movsd (%rax,%r13,8), %xmm3
ucomisd %xmm2, %xmm3
jne 0x17228
jnp 0x17346
movq -0x68(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r13,8), %xmm1
ucomisd %xmm2, %xmm1
jne 0x17241
jnp 0x17346
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 0x1b036
movsd -0x40(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x172b8
callq 0x4350
movslq (%r15), %rax
cmpq $-0x1, %rax
movsd 0xf549(%rip), %xmm2     # 0x26810
movq %rbx, %r12
movq %r14, %rbx
movq %r13, %r14
movq -0x58(%rbp), %r13
je 0x17346
movq (%r14), %rcx
movsd (%rcx,%rax,8), %xmm1
ucomisd %xmm2, %xmm1
jne 0x172e6
jnp 0x1733c
movapd %xmm1, %xmm2
movapd -0x80(%rbp), %xmm3
subsd %xmm3, %xmm2
movapd %xmm2, %xmm0
xorpd 0xf521(%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 0xf4e1(%rip), %xmm2     # 0x26810
addsd -0x40(%rbp), %xmm0
movslq (%r15), %rax
movq (%r14), %rcx
jmp 0x17341
movapd -0x80(%rbp), %xmm0
movsd %xmm0, (%rcx,%rax,8)
addq $0x10, %r15
movq (%r12), %rax
cmpq 0x8(%rax,%rbx,8), %r15
jne 0x17213
leaq -0x1(%r13), %rcx
testq %r13, %r13
movq %rcx, %r13
jg 0x171ee
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 0x17393
callq 0x4350
movq %rbx, %rdi
callq 0x4650