// File: /workspace/github_c_makefile_star2_O3/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 0x1516e0
movq %rsi, %r12
testq %rsi, %rsi
je 0x1516e0
testl %edx, %edx
je 0x1516e0
movq %rdi, %r14
movl (%rdi), %edi
shlq $0x3, %rdi
movq %rdx, %rbx
leaq 0x2318ae(%rip), %r13    # 0x382d9b
movq %r13, %rsi
movl $0x1a2, %edx            # imm = 0x1A2
callq 0x104226
movq %rax, %r15
movl (%r14), %edi
movq %rbx, 0x10(%rsp)
movl %ebx, %ecx
movq %rcx, 0x8(%rsp)
imulq %rcx, %rdi
shlq $0x3, %rdi
movq %r13, %rsi
movl $0x1a2, %edx            # imm = 0x1A2
callq 0x104226
movq %rax, (%r15)
movl (%r14), %eax
cmpq $0x2, %rax
jb 0x151554
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 0x151545
testl %eax, %eax
movq 0x10(%rsp), %r9
je 0x151595
movl (%r12), %ecx
cmpl 0x4(%r14), %ecx
jae 0x1516e5
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 0x151575
cmpl $0x2, %r9d
jb 0x15165c
movl $0x1, %r13d
movl %eax, %edx
movl (%r12,%r13,4), %ecx
cmpl 0x4(%r14), %ecx
jae 0x1516db
testl %edx, %edx
je 0x15164c
xorl %ebx, %ebx
movq 0x18(%r14), %rcx
movq (%rcx,%rbx,8), %rcx
movl (%r12,%r13,4), %edx
movsd (%rcx,%rdx,8), %xmm1
movq (%r15,%rbx,8), %rdx
movsd %xmm1, (%rdx,%r13,8)
movq (%r15), %rcx
movsd -0x8(%rcx,%r13,8), %xmm0
movq 0x10(%r14), %rcx
movq (%rcx), %rcx
addsd (%rcx,%rbx,8), %xmm0
cmpl $0x2, %eax
jb 0x151630
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 0x105ae4
incq %rbp
movl (%r14), %ecx
cmpq %rcx, %rbp
jb 0x1515fa
movq (%r15,%rbx,8), %rdx
movsd (%rdx,%r13,8), %xmm1
movl %ecx, %eax
jmp 0x151632
movl %eax, %ecx
addsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%r13,8)
incq %rbx
movl %eax, %edx
cmpq %rcx, %rbx
jb 0x1515bf
jmp 0x15164e
xorl %edx, %edx
incq %r13
cmpq 0x8(%rsp), %r13
jne 0x1515a7
movq (%r15), %rdi
movq 0x10(%rsp), %r12
decl %r12d
movsd (%rdi,%r12,8), %xmm0
cmpl $0x2, %eax
jb 0x15169c
movl $0x1, %ebx
movq (%r15,%rbx,8), %rax
movsd (%rax,%r12,8), %xmm1
callq 0x105ae4
incq %rbx
movl (%r14), %eax
cmpq %rax, %rbx
jb 0x151677
movsd %xmm0, 0x8(%rsp)
movq (%r15), %rdi
jmp 0x1516a2
movsd %xmm0, 0x8(%rsp)
leaq 0x2316f2(%rip), %rbx    # 0x382d9b
movq %rbx, %rsi
movl $0x1ae, %edx            # imm = 0x1AE
callq 0x1045eb
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1ae, %edx            # imm = 0x1AE
callq 0x1045eb
movsd 0x8(%rsp), %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x48222
callq 0x481b0
callq 0x481e9