// File: /workspace/github_c_makefile_star2_O3/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 0x151bfe
movq %rsi, %rbx
testq %rsi, %rsi
je 0x151bfe
movq %rdi, %r14
movl (%rdi), %eax
cmpl (%rbx), %eax
jne 0x151c03
movl 0x4(%r14), %eax
cmpl 0x4(%rbx), %eax
jne 0x151c08
movq %r14, %rdi
callq 0x150e36
testb %al, %al
je 0x151c0d
movq %rbx, %rdi
callq 0x150e36
testb %al, %al
je 0x151c12
cmpl $0x0, (%r14)
xorpd %xmm0, %xmm0
je 0x151bd6
xorl %ebp, %ebp
xorl %r15d, %r15d
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x150ca6
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x150ca6
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x105bb7
xorpd %xmm0, %xmm0
testb %al, %al
jne 0x151b27
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
incl %r15d
movl (%r14), %eax
cmpl %eax, %r15d
jb 0x151adb
incl %ebp
cmpl %eax, %ebp
jb 0x151ad8
testl %eax, %eax
je 0x151bd6
movl 0x4(%r14), %ecx
xorl %ebp, %ebp
testl %ecx, %ecx
je 0x151bce
xorl %r15d, %r15d
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x150de1
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x150de1
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x105bb7
xorpd %xmm0, %xmm0
testb %al, %al
jne 0x151bab
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
incl %r15d
movl 0x4(%r14), %ecx
cmpl %ecx, %r15d
jb 0x151b5f
movl (%r14), %eax
jmp 0x151bd0
xorl %ecx, %ecx
incl %ebp
cmpl %eax, %ebp
jb 0x151b58
ucomisd 0x21a1b2(%rip), %xmm0   # 0x36bd90
jb 0x151bef
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 0x48306
callq 0x4833f
callq 0x48378
callq 0x483b1
callq 0x483ea