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

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

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

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

  gt_array2dim_delete(f);
  return P;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x159044
movq %rsi, %r12
testq %rsi, %rsi
je 0x159044
movl %edx, %ebx
testl %edx, %edx
je 0x159044
movq %rdi, %r14
movl (%rdi), %edi
shlq $0x3, %rdi
leaq 0x2332ee(%rip), %r13    # 0x38c15b
movq %r13, %rsi
movl $0x1a2, %edx            # imm = 0x1A2
callq 0x1092b2
movq %rax, %r15
movl (%r14), %edi
movl %ebx, %ecx
movq %rcx, 0x8(%rsp)
imulq %rcx, %rdi
shlq $0x3, %rdi
movq %r13, %rsi
movl $0x1a2, %edx            # imm = 0x1A2
callq 0x1092b2
movq %rax, (%r15)
movl (%r14), %eax
cmpq $0x2, %rax
jb 0x158ecf
movq 0x8(%rsp), %rcx
leaq (,%rcx,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 0x158ec0
testq %rax, %rax
je 0x158f0c
movl (%r12), %ecx
cmpl 0x4(%r14), %ecx
jae 0x159049
movq 0x8(%r14), %rdx
movq 0x18(%r14), %rsi
xorl %edi, %edi
movsd (%rdx,%rdi,8), %xmm0
movq (%rsi,%rdi,8), %r8
addsd (%r8,%rcx,8), %xmm0
movq (%r15,%rdi,8), %r8
movsd %xmm0, (%r8)
incq %rdi
cmpq %rdi, %rax
jne 0x158eec
movq %rbx, 0x10(%rsp)
cmpl $0x2, %ebx
jb 0x158fc7
movl $0x1, %r13d
movl (%r12,%r13,4), %eax
cmpl 0x4(%r14), %eax
jae 0x15903f
cmpl $0x0, (%r14)
je 0x158fb9
xorl %ebx, %ebx
movq 0x18(%r14), %rax
movq (%rax,%rbx,8), %rax
movl (%r12,%r13,4), %ecx
movsd (%rax,%rcx,8), %xmm0
movq (%r15,%rbx,8), %rax
movsd %xmm0, (%rax,%r13,8)
movq (%r15), %rax
movsd -0x8(%rax,%r13,8), %xmm0
movq 0x10(%r14), %rax
movq (%rax), %rax
addsd (%rax,%rbx,8), %xmm0
cmpl $0x2, (%r14)
jb 0x158f9e
movl $0x1, %ebp
movq (%r15,%rbp,8), %rax
movsd -0x8(%rax,%r13,8), %xmm1
movq 0x10(%r14), %rax
movq (%rax,%rbp,8), %rax
addsd (%rax,%rbx,8), %xmm1
callq 0x10aba0
incq %rbp
movl (%r14), %eax
cmpq %rax, %rbp
jb 0x158f76
movq (%r15,%rbx,8), %rax
addsd (%rax,%r13,8), %xmm0
movsd %xmm0, (%rax,%r13,8)
incq %rbx
movl (%r14), %eax
cmpq %rax, %rbx
jb 0x158f3a
incq %r13
cmpq 0x8(%rsp), %r13
jne 0x158f20
movq (%r15), %rax
movq 0x10(%rsp), %r12
decl %r12d
movsd (%rax,%r12,8), %xmm0
cmpl $0x2, (%r14)
jb 0x158ffd
movl $0x1, %ebx
movq (%r15,%rbx,8), %rax
movsd (%rax,%r12,8), %xmm1
callq 0x10aba0
incq %rbx
movl (%r14), %eax
cmpq %rax, %rbx
jb 0x158fe3
movsd %xmm0, 0x8(%rsp)
movq (%r15), %rdi
leaq 0x23314e(%rip), %rbx    # 0x38c15b
movq %rbx, %rsi
movl $0x1ae, %edx            # imm = 0x1AE
callq 0x109670
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1ae, %edx            # imm = 0x1AE
callq 0x109670
movsd 0x8(%rsp), %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x49096
callq 0x49024
callq 0x4905d