// File: /workspace/github_c_makefile_star2_O2/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 0xed431
movq %rsi, %r12
testq %rsi, %rsi
je 0xed431
testl %edx, %edx
je 0xed431
movq %rdi, %r14
movl (%rdi), %edi
shlq $0x3, %rdi
movq %rdx, %rbx
leaq 0x235f82(%rip), %r13    # 0x3231a3
movq %r13, %rsi
movl $0x1a2, %edx            # imm = 0x1A2
callq 0x93160
movq %rax, %r15
movl (%r14), %edi
movq %rbx, 0x10(%rsp)
movl %ebx, %ebx
imulq %rbx, %rdi
shlq $0x3, %rdi
movq %r13, %rsi
movl $0x1a2, %edx            # imm = 0x1A2
callq 0x93160
movq %rax, (%r15)
movl (%r14), %eax
pushq $0x1
popq %rcx
movq %rbx, 0x8(%rsp)
leaq (,%rbx,8), %rdx
cmpq %rax, %rcx
jae 0xed27c
movq -0x8(%r15,%rcx,8), %rsi
addq %rdx, %rsi
movq %rsi, (%r15,%rcx,8)
incq %rcx
jmp 0xed266
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xed2b4
movl (%r12), %edx
cmpl 0x4(%r14), %edx
jae 0xed3cb
movq 0x8(%r14), %rsi
movq 0x18(%r14), %rdi
movsd (%rsi,%rcx,8), %xmm0
movq (%rdi,%rcx,8), %rsi
addsd (%rsi,%rdx,8), %xmm0
movq (%r15,%rcx,8), %rdx
movsd %xmm0, (%rdx)
incq %rcx
jmp 0xed27e
pushq $0x1
popq %r13
cmpq 0x8(%rsp), %r13
je 0xed357
movl (%r12,%r13,4), %ecx
cmpl 0x4(%r14), %ecx
jae 0xed3f9
xorl %ebp, %ebp
movl %eax, %ecx
cmpq %rcx, %rbp
jae 0xed34f
movq 0x18(%r14), %rcx
movq (%rcx,%rbp,8), %rcx
movl (%r12,%r13,4), %edx
movsd (%rcx,%rdx,8), %xmm0
movq (%r15,%rbp,8), %rcx
movsd %xmm0, (%rcx,%r13,8)
movq (%r15), %rcx
movsd -0x8(%rcx,%r13,8), %xmm0
movq 0x10(%r14), %rcx
movq (%rcx), %rcx
addsd (%rcx,%rbp,8), %xmm0
pushq $0x1
popq %rbx
movl %eax, %ecx
cmpq %rcx, %rbx
jae 0xed33a
movq (%r15,%rbx,8), %rax
movsd -0x8(%rax,%r13,8), %xmm1
movq 0x10(%r14), %rax
movq (%rax,%rbx,8), %rax
addsd (%rax,%rbp,8), %xmm1
callq 0x954cc
incq %rbx
movl (%r14), %eax
jmp 0xed30e
movq (%r15,%rbp,8), %rcx
addsd (%rcx,%r13,8), %xmm0
movsd %xmm0, (%rcx,%r13,8)
incq %rbp
jmp 0xed2d3
incq %r13
jmp 0xed2b8
movq (%r15), %rcx
movq 0x10(%rsp), %r12
decl %r12d
movsd (%rcx,%r12,8), %xmm0
pushq $0x1
popq %rbx
movl %eax, %eax
cmpq %rax, %rbx
jae 0xed389
movq (%r15,%rbx,8), %rax
movsd (%rax,%r12,8), %xmm1
callq 0x954cc
incq %rbx
movl (%r14), %eax
jmp 0xed36b
movq (%r15), %rdi
leaq 0x235e10(%rip), %rbx    # 0x3231a3
movq %rbx, %rsi
movl $0x1ae, %edx            # imm = 0x1AE
movsd %xmm0, 0x8(%rsp)
callq 0x936f9
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1ae, %edx            # imm = 0x1AE
callq 0x936f9
movsd 0x8(%rsp), %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x34ab96(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7c37(%rip), %rsi    # 0x2e5013
leaq 0x23657c(%rip), %rdx    # 0x32395f
leaq 0x23655f(%rip), %rcx    # 0x323949
leaq 0x235db2(%rip), %r8     # 0x3231a3
movl $0x185, %r9d            # imm = 0x185
jmp 0xed425
movq 0x34ab68(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7c09(%rip), %rsi    # 0x2e5013
leaq 0x236571(%rip), %rdx    # 0x323982
leaq 0x236531(%rip), %rcx    # 0x323949
leaq 0x235d84(%rip), %r8     # 0x3231a3
movl $0x18b, %r9d            # imm = 0x18B
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x34ab30(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7bd1(%rip), %rsi    # 0x2e5013
leaq 0x235f73(%rip), %rdx    # 0x3233bc
leaq 0x235f91(%rip), %rcx    # 0x3233e1
leaq 0x235d4c(%rip), %r8     # 0x3231a3
movl $0x1a1, %r9d            # imm = 0x1A1
jmp 0xed425