// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/hmm.c
// Function: gt_hmm_rmsd
double gt_hmm_rmsd(const GtHMM *hmm_a, const GtHMM* hmm_b)
{
  unsigned int i, j;
  double difference = 0.0, rmsd = 0.0, a_prob, b_prob;
  gt_assert(hmm_a && hmm_b);
  gt_assert(hmm_a->num_of_states == hmm_b->num_of_states);
  gt_assert(hmm_a->num_of_symbols == hmm_b->num_of_symbols);
  gt_assert(gt_hmm_is_valid(hmm_a));
  gt_assert(gt_hmm_is_valid(hmm_b));
  /* add transitions probabilities */
  for (i = 0; i < hmm_a->num_of_states; i++) {
    for (j = 0; j < hmm_a->num_of_states; j++) {
      a_prob = gt_hmm_get_transition_probability(hmm_a,i,j);
      b_prob = gt_hmm_get_transition_probability(hmm_b,i,j);

      if (gt_double_equals_double(a_prob, b_prob))
        difference = 0.0;
      else
        difference = a_prob - b_prob;
      rmsd += difference * difference;
    }
  }
  /* add emission probabilities */
  for (i = 0; i < hmm_a->num_of_states; i++) {
    for (j = 0; j < hmm_a->num_of_symbols; j++) {
      a_prob = gt_hmm_get_emission_probability(hmm_a,i,j);
      b_prob = gt_hmm_get_emission_probability(hmm_b,i,j);

      if (gt_double_equals_double(a_prob, b_prob))
        difference = 0.0;
      else
        difference = a_prob - b_prob;
      rmsd += difference * difference;
    }
  }
  return sqrt(rmsd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x159547
movq %rsi, %rbx
testq %rsi, %rsi
je 0x159547
movq %rdi, %r14
movl (%rdi), %eax
cmpl (%rbx), %eax
jne 0x15954c
movl 0x4(%r14), %eax
cmpl 0x4(%rbx), %eax
jne 0x159551
movq %r14, %rdi
callq 0x1587b0
testb %al, %al
je 0x159556
movq %rbx, %rdi
callq 0x1587b0
testb %al, %al
je 0x15955b
cmpl $0x0, (%r14)
je 0x15949f
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
cmpl $0x0, (%r14)
je 0x159496
xorl %r15d, %r15d
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x158608
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x158608
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x10ac6f
xorpd %xmm1, %xmm1
testb %al, %al
jne 0x159480
movsd (%rsp), %xmm1
subsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
incl %r15d
cmpl (%r14), %r15d
jb 0x159434
incl %ebp
cmpl (%r14), %ebp
jb 0x15942b
jmp 0x1594a3
xorpd %xmm0, %xmm0
cmpl $0x0, (%r14)
je 0x15951f
xorl %ebp, %ebp
cmpl $0x0, 0x4(%r14)
je 0x159518
xorl %r15d, %r15d
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x15875c
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x15875c
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x10ac6f
xorpd %xmm1, %xmm1
testb %al, %al
jne 0x159501
movsd (%rsp), %xmm1
subsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
incl %r15d
cmpl 0x4(%r14), %r15d
jb 0x1594b5
incl %ebp
cmpl (%r14), %ebp
jb 0x1594ab
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x159538
sqrtsd %xmm0, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x175e0
callq 0x4917a
callq 0x491b3
callq 0x491ec
callq 0x49225
callq 0x4925e