// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/hmm.c
// Function: gt_hmm_backward
double gt_hmm_backward(const GtHMM* hmm, const unsigned int *emissions,
                    unsigned int num_of_emissions)
{
  unsigned int i;
  double **b, P;

  gt_assert(hmm && emissions && num_of_emissions);
  gt_array2dim_malloc(b, hmm->num_of_states, num_of_emissions);

  /* XXX: we do not need the full table here, the last column would suffice */
  compute_backward_table(b, hmm, emissions, num_of_emissions);

  /* compute P(x) */
  P = hmm->initial_state_prob[0] + hmm->emission_prob[0][emissions[0]] +
      b[0][0];
  for (i = 1; i < hmm->num_of_states; i++) {
    /* XXX: replace the logsum() call with a tabulated version */
    P = gt_logsum(P, hmm->initial_state_prob[i] +
                     hmm->emission_prob[i][emissions[0]] + b[i][0]);
  }

  gt_array2dim_delete(b);
  return P;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x15190a
movq %rsi, %rbx
testq %rsi, %rsi
je 0x15190a
movl %edx, %ebp
testl %edx, %edx
je 0x15190a
movq %rdi, %r14
movl (%rdi), %edi
shlq $0x3, %rdi
leaq 0x231677(%rip), %r12    # 0x382d9b
movq %r12, %rsi
movl $0x1da, %edx            # imm = 0x1DA
callq 0x104226
movq %rax, %r15
movl (%r14), %edi
movl %ebp, %r13d
imulq %r13, %rdi
shlq $0x3, %rdi
movq %r12, %rsi
movl $0x1da, %edx            # imm = 0x1DA
callq 0x104226
movq %rax, (%r15)
movl (%r14), %eax
cmpq $0x2, %rax
jb 0x15177d
leaq (,%r13,8), %rcx
movq (%r15), %rdx
addq %rcx, %rdx
movl $0x1, %esi
movq %rdx, (%r15,%rsi,8)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %rax
jne 0x15176e
testl %eax, %eax
je 0x151798
xorl %ecx, %ecx
movq (%r15,%rcx,8), %rdx
movq $0x0, -0x8(%rdx,%r13,8)
incq %rcx
cmpq %rcx, %rax
jne 0x151783
addl $-0x2, %ebp
js 0x151865
movl %eax, %ecx
movl %ebp, %edx
movq %rdx, (%rsp)
movl (%rbx,%rdx,4), %edx
cmpl 0x4(%r14), %edx
jae 0x151905
testl %ecx, %ecx
je 0x151854
movq (%rsp), %rcx
leal 0x1(%rcx), %r13d
xorl %ebp, %ebp
movq 0x10(%r14), %rcx
movq 0x18(%r14), %rdx
movq (%rcx,%rbp,8), %rcx
movsd (%rcx), %xmm0
movq (%rdx), %rcx
movl (%rbx,%r13,4), %edx
addsd (%rcx,%rdx,8), %xmm0
movq (%r15), %rcx
addsd (%rcx,%r13,8), %xmm0
cmpl $0x2, %eax
jb 0x151835
movl $0x1, %r12d
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
movq (%rax,%rbp,8), %rax
movsd (%rax,%r12,8), %xmm1
movq (%rcx,%r12,8), %rax
movl (%rbx,%r13,4), %ecx
addsd (%rax,%rcx,8), %xmm1
movq (%r15,%r12,8), %rax
addsd (%rax,%r13,8), %xmm1
callq 0x105ae4
incq %r12
movl (%r14), %edx
movl %edx, %eax
cmpq %rdx, %r12
jb 0x1517f8
jmp 0x151837
movl %eax, %edx
movq (%r15,%rbp,8), %rcx
movq (%rsp), %rsi
movsd %xmm0, (%rcx,%rsi,8)
incq %rbp
movl %eax, %ecx
cmpq %rdx, %rbp
jb 0x1517c8
jmp 0x151856
xorl %ecx, %ecx
movq (%rsp), %rdx
leal -0x1(%rdx), %ebp
testl %edx, %edx
jg 0x1517a3
movq 0x8(%r14), %rcx
movq 0x18(%r14), %rdx
movsd (%rcx), %xmm0
movq (%rdx), %rcx
movl (%rbx), %edx
addsd (%rcx,%rdx,8), %xmm0
movq (%r15), %rdi
addsd (%rdi), %xmm0
cmpl $0x2, %eax
jb 0x1518c8
movl $0x1, %r12d
movq 0x8(%r14), %rax
movq 0x18(%r14), %rcx
movsd (%rax,%r12,8), %xmm1
movq (%rcx,%r12,8), %rax
movl (%rbx), %ecx
addsd (%rax,%rcx,8), %xmm1
movq (%r15,%r12,8), %rax
addsd (%rax), %xmm1
callq 0x105ae4
incq %r12
movl (%r14), %eax
cmpq %rax, %r12
jb 0x15188d
movsd %xmm0, (%rsp)
movq (%r15), %rdi
jmp 0x1518cd
movsd %xmm0, (%rsp)
leaq 0x2314c7(%rip), %rbx    # 0x382d9b
movq %rbx, %rsi
movl $0x1e8, %edx            # imm = 0x1E8
callq 0x1045eb
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1e8, %edx            # imm = 0x1E8
callq 0x1045eb
movsd (%rsp), %xmm0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x48294
callq 0x4825b