// File: /workspace/github_c_makefile_star2_O2/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 0xed9bb
movq %rsi, %rbx
testq %rsi, %rsi
je 0xed9bb
movq %rdi, %r14
movl (%rdi), %eax
cmpl (%rbx), %eax
jne 0xed9ec
movl 0x4(%r14), %eax
cmpl 0x4(%rbx), %eax
jne 0xeda1d
movq %r14, %rdi
callq 0xeca3c
testb %al, %al
je 0xeda4b
movq %rbx, %rdi
callq 0xeca3c
testb %al, %al
je 0xeda79
movl (%r14), %eax
xorpd %xmm0, %xmm0
xorl %ebp, %ebp
cmpl %eax, %ebp
jae 0xed91e
xorl %r15d, %r15d
cmpl %eax, %r15d
jae 0xed91a
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0xec77b
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0xec77b
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x955a5
xorpd %xmm1, %xmm1
testb %al, %al
jne 0xed904
movsd (%rsp), %xmm1
subsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
incl %r15d
movl (%r14), %eax
jmp 0xed8b3
incl %ebp
jmp 0xed8ac
xorl %ebp, %ebp
cmpl %eax, %ebp
jae 0xed993
xorl %r15d, %r15d
cmpl 0x4(%r14), %r15d
jae 0xed98c
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0xec95e
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0xec95e
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x955a5
xorpd %xmm1, %xmm1
testb %al, %al
jne 0xed979
movsd (%rsp), %xmm1
subsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
incl %r15d
jmp 0xed927
incl %ebp
movl (%r14), %eax
jmp 0xed920
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xed9ac
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 0x175b0
movq 0x34a5a6(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7647(%rip), %rsi    # 0x2e5013
leaq 0x235a39(%rip), %rdx    # 0x32340c
leaq 0x235a41(%rip), %rcx    # 0x32341b
leaq 0x2357c2(%rip), %r8     # 0x3231a3
movl $0x21b, %r9d            # imm = 0x21B
jmp 0xedaa5
movq 0x34a575(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7616(%rip), %rsi    # 0x2e5013
leaq 0x235a23(%rip), %rdx    # 0x323427
leaq 0x235a10(%rip), %rcx    # 0x32341b
leaq 0x235791(%rip), %r8     # 0x3231a3
movl $0x21c, %r9d            # imm = 0x21C
jmp 0xedaa5
movq 0x34a544(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f75e5(%rip), %rsi    # 0x2e5013
leaq 0x235a1f(%rip), %rdx    # 0x323454
leaq 0x2359df(%rip), %rcx    # 0x32341b
leaq 0x235760(%rip), %r8     # 0x3231a3
movl $0x21d, %r9d            # imm = 0x21D
jmp 0xedaa5
movq 0x34a516(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f75b7(%rip), %rsi    # 0x2e5013
leaq 0x235a20(%rip), %rdx    # 0x323483
leaq 0x2359b1(%rip), %rcx    # 0x32341b
leaq 0x235732(%rip), %r8     # 0x3231a3
movl $0x21e, %r9d            # imm = 0x21E
jmp 0xedaa5
movq 0x34a4e8(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7589(%rip), %rsi    # 0x2e5013
leaq 0x235a09(%rip), %rdx    # 0x32349a
leaq 0x235983(%rip), %rcx    # 0x32341b
leaq 0x235704(%rip), %r8     # 0x3231a3
movl $0x21f, %r9d            # imm = 0x21F
xorl %eax, %eax
callq 0x17a50
callq 0x17390