// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
testq %rdi, %rdi
je 0xed68d
movq %rsi, %rbx
testq %rsi, %rsi
je 0xed68d
movl %edx, %r12d
testl %edx, %edx
je 0xed68d
movq %rdi, %r14
movl (%rdi), %edi
shlq $0x3, %rdi
leaq 0x235d06(%rip), %r13    # 0x3231a3
movq %r13, %rsi
movl $0x1da, %edx            # imm = 0x1DA
callq 0x93160
movq %rax, %r15
movl (%r14), %edi
movq %r12, %rbp
movl %r12d, %r12d
imulq %r12, %rdi
shlq $0x3, %rdi
movq %r13, %rsi
movl $0x1da, %edx            # imm = 0x1DA
callq 0x93160
movq %rax, (%r15)
movl (%r14), %eax
pushq $0x1
popq %rcx
leaq (,%r12,8), %rdx
cmpq %rax, %rcx
jae 0xed4f2
movq -0x8(%r15,%rcx,8), %rsi
addq %rdx, %rsi
movq %rsi, (%r15,%rcx,8)
incq %rcx
jmp 0xed4dc
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xed508
movq (%r15,%rcx,8), %rdx
andq $0x0, -0x8(%rdx,%r12,8)
incq %rcx
jmp 0xed4f4
addl $-0x2, %ebp
testl %ebp, %ebp
js 0xed5bd
movl %ebp, %ecx
movq %rcx, 0x8(%rsp)
movl (%rbx,%rcx,4), %ecx
cmpl 0x4(%r14), %ecx
jae 0xed655
movq %rbp, 0x10(%rsp)
leal 0x1(%rbp), %r12d
xorl %r13d, %r13d
movl %eax, %ecx
cmpq %rcx, %r13
jae 0xed5b1
movq 0x10(%r14), %rcx
movq 0x18(%r14), %rdx
movq (%rcx,%r13,8), %rcx
movsd (%rcx), %xmm0
movq (%rdx), %rcx
movl (%rbx,%r12,4), %edx
addsd (%rcx,%rdx,8), %xmm0
movq (%r15), %rcx
addsd (%rcx,%r12,8), %xmm0
pushq $0x1
popq %rbp
movl %eax, %ecx
cmpq %rcx, %rbp
jae 0xed59e
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
movq (%rax,%r13,8), %rax
movsd (%rax,%rbp,8), %xmm1
movq (%rcx,%rbp,8), %rax
movl (%rbx,%r12,4), %ecx
addsd (%rax,%rcx,8), %xmm1
movq (%r15,%rbp,8), %rax
addsd (%rax,%r12,8), %xmm1
callq 0x954cc
incq %rbp
movl (%r14), %eax
jmp 0xed562
movq (%r15,%r13,8), %rcx
movq 0x8(%rsp), %rdx
movsd %xmm0, (%rcx,%rdx,8)
incq %r13
jmp 0xed533
movq 0x10(%rsp), %rbp
decl %ebp
jmp 0xed50b
movq 0x8(%r14), %rcx
movq 0x18(%r14), %rdx
movsd (%rcx), %xmm0
movq (%rdx), %rcx
movl (%rbx), %edx
addsd (%rcx,%rdx,8), %xmm0
movq (%r15), %rcx
addsd (%rcx), %xmm0
pushq $0x1
popq %r12
movl %eax, %eax
cmpq %rax, %r12
jae 0xed613
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 0x954cc
incq %r12
movl (%r14), %eax
jmp 0xed5de
movq (%r15), %rdi
leaq 0x235b86(%rip), %rbx    # 0x3231a3
movq %rbx, %rsi
movl $0x1e8, %edx            # imm = 0x1E8
movsd %xmm0, 0x8(%rsp)
callq 0x936f9
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1e8, %edx            # imm = 0x1E8
callq 0x936f9
movsd 0x8(%rsp), %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x34a90c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f79ad(%rip), %rsi    # 0x2e5013
leaq 0x236315(%rip), %rdx    # 0x323982
leaq 0x236336(%rip), %rcx    # 0x3239aa
leaq 0x235b28(%rip), %r8     # 0x3231a3
movl $0x1c2, %r9d            # imm = 0x1C2
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x34a8d4(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7975(%rip), %rsi    # 0x2e5013
leaq 0x235d17(%rip), %rdx    # 0x3233bc
leaq 0x235d44(%rip), %rcx    # 0x3233f0
leaq 0x235af0(%rip), %r8     # 0x3231a3
movl $0x1d9, %r9d            # imm = 0x1D9
jmp 0xed681