// File: aalto-speech[P]ftk/src/EM.cc
// Function: forward_backward(StringSet const&, 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>>>&, std::vector<double, std::allocator<double>>&, bool)
flt_type forward_backward(const StringSet &vocab,
                          const string &text,
                          map<string, flt_type> &stats,
                          vector<flt_type> &bw,
                          bool utf8)
{
    int len = text.length();
    if (len == 0) return MIN_FLOAT;

    stats.clear();
    vector<vector<Token> > search(len);
    vector<flt_type> fw(len, SMALL_LP); fw[0] = 0.0;
    bw.resize(len, SMALL_LP); bw.back() = 0.0;

    forward(vocab, text, search, fw, utf8);
    backward(vocab, text, search, fw, bw, stats);

    if (search[len-1].size() == 0) return MIN_FLOAT;
    return fw.back();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
movq -0x18(%rbp), %rdi
callq 0x45e0
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x41a0b
callq 0x47bf0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x41c00
movq -0x20(%rbp), %rdi
callq 0x47d90
movslq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x48170
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x48190
jmp 0x41a48
leaq -0x49(%rbp), %rdi
callq 0x48200
movslq -0x30(%rbp), %rax
movq %rax, -0xb8(%rbp)
movabsq $-0x3fa7000000000000, %rax # imm = 0xC059000000000000
movq %rax, -0x80(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x48220
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rcx
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x48240
jmp 0x41a9a
leaq -0x81(%rbp), %rdi
callq 0x482c0
xorl %eax, %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x47eb0
movq $0x0, (%rax)
movq -0x28(%rbp), %rdi
movslq -0x30(%rbp), %rsi
movabsq $-0x3fa7000000000000, %rax # imm = 0xC059000000000000
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %rdx
callq 0x483e0
jmp 0x41ae1
movq -0x28(%rbp), %rdi
callq 0x482e0
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movzbl -0x29(%rbp), %r8d
andl $0x1, %r8d
leaq -0x48(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0x40e50
jmp 0x41b11
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %r8
movq -0x20(%rbp), %r9
leaq -0x48(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0x41370
jmp 0x41b30
movl -0x30(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x47e90
movq %rax, %rdi
callq 0x47cd0
cmpq $0x0, %rax
jne 0x41bc5
callq 0x47bf0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x8(%rbp)
movl $0x1, -0x94(%rbp)
jmp 0x41be1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x48200
jmp 0x41c0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x482c0
jmp 0x41bf5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x48320
jmp 0x41bf5
leaq -0x78(%rbp), %rdi
callq 0x482e0
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
movl $0x1, -0x94(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x48320
leaq -0x48(%rbp), %rdi
callq 0x48380
jmp 0x41c00
leaq -0x48(%rbp), %rdi
callq 0x48380
jmp 0x41c0e
movsd -0x8(%rbp), %xmm0
addq $0xc0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x46e0
nopw (%rax,%rax)