// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/shu-divergence.c
// Function: gt_divergence
double gt_divergence(double E, /* relative error for divergence calculation */
                   double T, /* absolute error for exp shulen*/
                   double M, /* minimum for logarithm */
                   double threshold, /* abs error for divergence */
                   double shulen,
                   GtUword subjectLength,
                   double gc,
                   double *ln_n_fac,
                   GtUword n_s)
{
  double p, q,
         du, dl, dm, d, exp_shulen;
  double *s1;
  s1 = gt_calloc((size_t) n_s + 1, sizeof (double));

  p = gc / 2;
  q = (1.0 - gc) / 2.0;
  du = 0.0;
  dl = 1.0 - (2 * p * p + 2 * q * q);  /* dl < 0.75 */

  while (gt_double_smaller_double(threshold, (dl - du) / 2.0)) {
    dm = (du + dl) / 2.0;
    exp_shulen = expShulen(T, M, dm, p, subjectLength, ln_n_fac, s1, n_s);
    if (gt_double_smaller_double(shulen, exp_shulen))
      du = dm;
    else
      dl = dm;
    /* test the relative error between du and dl; if it is smaller than some
     * threshold, then break !! */
    if (fabs (dl - du) / dl <= E)
      break;
  }
  d = (du + dl) / 2.0;
  gt_free(s1);
  return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r12
movq %rsi, %r14
movsd %xmm5, 0x8(%rsp)
movq %rdi, %r15
movsd %xmm4, 0x80(%rsp)
movsd %xmm3, 0x88(%rsp)
movsd %xmm2, 0xa0(%rsp)
movsd %xmm1, 0x98(%rsp)
movsd %xmm0, 0x78(%rsp)
leaq 0x1(%rdx), %rdi
leaq 0xba8ff(%rip), %rdx     # 0x3e5ac0
movl $0x8, %esi
movl $0x95, %ecx
callq 0x10436a
movq %rax, 0x30(%rsp)
movsd 0x2ac6b(%rip), %xmm3    # 0x355e48
movsd 0x1b043(%rip), %xmm4    # 0x346228
movapd %xmm4, %xmm0
movsd 0x8(%rsp), %xmm5
subsd %xmm5, %xmm0
mulsd %xmm3, %xmm5
mulsd %xmm3, %xmm0
movapd %xmm5, %xmm1
addsd %xmm5, %xmm1
movapd %xmm0, %xmm2
addsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm5, %xmm1
addsd %xmm2, %xmm1
movapd %xmm4, %xmm2
subsd %xmm1, %xmm2
movq %r15, %xmm0
punpckldq 0x1c6b4(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movsd %xmm5, 0x8(%rsp)
subsd %xmm5, %xmm3
movsd %xmm3, 0x58(%rsp)
subpd 0x1c6ac(%rip), %xmm0    # 0x3478f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0xf0(%rsp)
xorpd %xmm3, %xmm3
movq %r12, 0x90(%rsp)
movsd %xmm3, 0x28(%rsp)
movsd %xmm2, (%rsp)
movapd %xmm2, %xmm1
subsd %xmm3, %xmm1
movsd 0x2abc8(%rip), %xmm0    # 0x355e48
mulsd %xmm0, %xmm1
movsd 0x88(%rsp), %xmm0
callq 0x105c97
testb %al, %al
je 0x32b681
movsd (%rsp), %xmm0
addsd 0x28(%rsp), %xmm0
mulsd 0x2ab9b(%rip), %xmm0    # 0x355e48
movsd %xmm0, 0x20(%rsp)
xorpd %xmm1, %xmm1
cmpq $0x2, %r15
jb 0x32b630
movsd 0x1af5f(%rip), %xmm0    # 0x346228
subsd 0x20(%rsp), %xmm0
xorl %ebx, %ebx
movl $0x1, %r13d
movl $0x2, %ebp
movsd %xmm0, 0xa8(%rsp)
xorpd %xmm2, %xmm2
movsd %xmm2, 0x48(%rsp)
movsd %xmm0, 0x50(%rsp)
movsd %xmm1, 0xb0(%rsp)
movsd 0x1af22(%rip), %xmm0    # 0x346228
subsd 0x50(%rsp), %xmm0
movq %r13, %xmm1
movdqa %xmm1, 0xd0(%rsp)
testl %ebx, %ebx
jne 0x32b570
cmpq %r12, %r13
ja 0x32b6cf
movq 0x30(%rsp), %rax
movsd (%rax,%r13,8), %xmm1
xorl %ebx, %ebx
ucomisd 0x40a50(%rip), %xmm1    # 0x36bd90
jne 0x32b56c
jp 0x32b56c
movsd %xmm0, 0x38(%rsp)
movapd 0xd0(%rsp), %xmm0
unpcklps 0x1c57e(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1c586(%rip), %xmm0    # 0x3478f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0xe0(%rsp)
xorpd %xmm1, %xmm1
movq %r13, %rax
xorl %ebx, %ebx
movq %r13, %r12
movsd %xmm1, 0xc8(%rsp)
xorpd %xmm0, %xmm0
subq $0x1, %r12
jb 0x32b3b0
movsd (%r14,%r13,8), %xmm0
subsd (%r14,%rbx,8), %xmm0
subsd (%r14,%rax,8), %xmm0
movsd %xmm0, 0x40(%rsp)
movaps 0xe0(%rsp), %xmm0
callq 0x17700
movsd %xmm0, 0xc0(%rsp)
movq %rbx, %xmm0
punpckldq 0x1c507(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1c50f(%rip), %xmm0    # 0x3478f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x60(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x17d90
movsd %xmm0, 0x10(%rsp)
movapd 0xe0(%rsp), %xmm1
subsd 0x60(%rsp), %xmm1
movapd %xmm1, 0x100(%rsp)
movsd 0x58(%rsp), %xmm0
callq 0x17d90
movsd %xmm0, 0xb8(%rsp)
movsd 0x8(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
callq 0x17d90
movsd %xmm0, 0x60(%rsp)
movsd 0x58(%rsp), %xmm0
movaps 0x100(%rsp), %xmm1
callq 0x17d90
movsd 0x10(%rsp), %xmm1
mulsd 0xc0(%rsp), %xmm1
mulsd 0xb8(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
mulsd 0x60(%rsp), %xmm0
movsd 0x1ada3(%rip), %xmm1    # 0x346228
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movapd 0xf0(%rsp), %xmm1
callq 0x17d90
mulsd 0x10(%rsp), %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x32b4ad
jnp 0x32b51b
ucomisd 0xa0(%rsp), %xmm0
jae 0x32b4ed
addsd 0x1ad68(%rip), %xmm0    # 0x346228
callq 0x17610
addsd 0x40(%rsp), %xmm0
callq 0x17e30
movsd %xmm0, 0x10(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0x17e30
movsd 0x10(%rsp), %xmm2
subsd %xmm0, %xmm2
jmp 0x32b51b
callq 0x17610
xorpd %xmm2, %xmm2
movsd 0x42412(%rip), %xmm1    # 0x36d910
ucomisd %xmm0, %xmm1
jae 0x32b51b
movsd 0x40(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x17e30
movapd %xmm0, %xmm2
movsd 0xc8(%rsp), %xmm1
addsd %xmm2, %xmm1
ucomisd 0x1acf8(%rip), %xmm1    # 0x346228
jae 0x32b546
incq %rbx
movq %r12, %rax
cmpq $-0x1, %r12
jne 0x32b38b
xorl %ebx, %ebx
jmp 0x32b553
movl $0x1, %ebx
movsd 0x1acd5(%rip), %xmm1    # 0x346228
movq 0x30(%rsp), %rax
movsd %xmm1, (%rax,%r13,8)
movq 0x90(%rsp), %r12
movsd 0x38(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movapd %xmm0, %xmm2
subsd 0x48(%rsp), %xmm2
movapd 0xd0(%rsp), %xmm1
unpcklps 0x1c350(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1c358(%rip), %xmm1    # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, 0x10(%rsp)
callq 0x105bb7
testb %al, %al
jne 0x32b5d2
xorpd %xmm1, %xmm1
movapd 0x10(%rsp), %xmm0
callq 0x105d16
testb %al, %al
je 0x32b6ca
movsd 0xb0(%rsp), %xmm1
movapd 0x10(%rsp), %xmm2
addsd %xmm2, %xmm1
ucomisd 0x1ac3b(%rip), %xmm1    # 0x346228
jb 0x32b602
divsd %xmm1, %xmm2
movsd 0x98(%rsp), %xmm0
ucomisd %xmm2, %xmm0
jae 0x32b630
movsd 0x50(%rsp), %xmm0
mulsd 0xa8(%rsp), %xmm0
incq %r13
leaq 0x1(%rbp), %rax
movsd 0x38(%rsp), %xmm2
movsd %xmm2, 0x48(%rsp)
cmpq %r15, %rbp
movq %rax, %rbp
jne 0x32b2ef
movsd 0x80(%rsp), %xmm0
callq 0x105c97
testb %al, %al
jne 0x32b650
movsd 0x20(%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
jmp 0x32b65b
movsd 0x20(%rsp), %xmm3
movsd (%rsp), %xmm2
movapd %xmm2, %xmm0
subsd %xmm3, %xmm0
andpd 0x40735(%rip), %xmm0    # 0x36bda0
divsd %xmm2, %xmm0
movsd 0x78(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x32b265
jmp 0x32b68c
movsd (%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
addsd %xmm3, %xmm2
mulsd 0x2a7b0(%rip), %xmm2    # 0x355e48
movsd %xmm2, (%rsp)
leaq 0xba41c(%rip), %rsi     # 0x3e5ac0
movq 0x30(%rsp), %rdi
movl $0xa9, %edx
callq 0x1045eb
movsd (%rsp), %xmm0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x958c2
callq 0x958f9