// File: /workspace/github_c_makefile_star2_O1/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 $0x128, %rsp            # imm = 0x128
movq %rdx, %r12
movq %rsi, %r14
movsd %xmm5, 0x8(%rsp)
movq %rdi, %rbp
movsd %xmm4, 0x78(%rsp)
movsd %xmm3, 0x80(%rsp)
movsd %xmm2, 0xb0(%rsp)
movsd %xmm1, 0xa0(%rsp)
movsd %xmm0, 0x70(%rsp)
leaq 0x1(%rdx), %rdi
leaq 0xb9546(%rip), %rdx     # 0x3ef2b8
movl $0x8, %esi
movl $0x95, %ecx
callq 0x1093ef
movq %rax, 0x30(%rsp)
movsd 0x290ea(%rip), %xmm3    # 0x35ee78
movsd 0x19492(%rip), %xmm4    # 0x34f228
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 %rbp, %xmm0
punpckldq 0x1ab03(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1ab0b(%rip), %xmm0    # 0x3508f0
movsd %xmm5, 0x8(%rsp)
subsd %xmm5, %xmm3
movsd %xmm3, 0x48(%rsp)
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x100(%rsp)
leaq 0x8(%r14), %rax
movq %rax, 0x68(%rsp)
xorpd %xmm3, %xmm3
movq %r12, 0x90(%rsp)
movq %rbp, 0x88(%rsp)
movsd %xmm3, 0x28(%rsp)
movsd %xmm2, (%rsp)
movapd %xmm2, %xmm1
subsd %xmm3, %xmm1
movsd 0x29036(%rip), %xmm0    # 0x35ee78
mulsd %xmm0, %xmm1
movsd 0x80(%rsp), %xmm0
callq 0x10ad54
testb %al, %al
je 0x336253
movsd (%rsp), %xmm0
addsd 0x28(%rsp), %xmm0
mulsd 0x29009(%rip), %xmm0    # 0x35ee78
movsd %xmm0, 0x20(%rsp)
xorpd %xmm2, %xmm2
cmpq $0x2, %rbp
movsd 0x193a3(%rip), %xmm1    # 0x34f228
jb 0x3361fd
movapd %xmm1, %xmm0
subsd 0x20(%rsp), %xmm0
xorl %r13d, %r13d
movl $0x1, %ebx
movq 0x68(%rsp), %r15
movsd %xmm0, 0xa8(%rsp)
xorpd %xmm3, %xmm3
subsd %xmm0, %xmm1
movq %rbx, %xmm4
testl %r13d, %r13d
movsd %xmm2, 0xc0(%rsp)
movsd %xmm0, 0xb8(%rsp)
jne 0x33614d
cmpq %r12, %rbx
ja 0x3362a1
movq 0x30(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
ucomisd 0x3f0f2(%rip), %xmm0    # 0x374fe0
jne 0x336149
jp 0x336149
movsd %xmm3, 0x98(%rsp)
movsd %xmm1, 0x38(%rsp)
movdqa %xmm4, 0xf0(%rsp)
movdqa %xmm4, %xmm0
punpckldq 0x1a9c2(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1a9ca(%rip), %xmm0    # 0x3508f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0xe0(%rsp)
xorpd %xmm1, %xmm1
movq %r15, %r12
xorl %ebp, %ebp
movsd %xmm1, 0xd8(%rsp)
xorpd %xmm0, %xmm0
cmpq %rbp, %rbx
je 0x335f68
movsd (%r14,%rbx,8), %xmm0
subsd (%r14,%rbp,8), %xmm0
subsd (%r12), %xmm0
movsd %xmm0, 0x40(%rsp)
movaps 0xe0(%rsp), %xmm0
callq 0x17700
movsd %xmm0, 0xd0(%rsp)
movq %rbp, %xmm0
punpckldq 0x1a94f(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1a957(%rip), %xmm0    # 0x3508f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x17d90
movsd %xmm0, 0x10(%rsp)
movapd 0xe0(%rsp), %xmm1
subsd 0x50(%rsp), %xmm1
movapd %xmm1, 0x110(%rsp)
movsd 0x48(%rsp), %xmm0
callq 0x17d90
movsd %xmm0, 0xc8(%rsp)
movsd 0x8(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
callq 0x17d90
movsd %xmm0, 0x50(%rsp)
movsd 0x48(%rsp), %xmm0
movaps 0x110(%rsp), %xmm1
callq 0x17d90
movsd 0x10(%rsp), %xmm1
mulsd 0xd0(%rsp), %xmm1
mulsd 0xc8(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
mulsd 0x50(%rsp), %xmm0
movsd 0x191eb(%rip), %xmm1    # 0x34f228
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movapd 0x100(%rsp), %xmm1
callq 0x17d90
mulsd 0x10(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x336065
jnp 0x3360d3
ucomisd 0xb0(%rsp), %xmm0
jae 0x3360a5
addsd 0x191b0(%rip), %xmm0    # 0x34f228
callq 0x17610
addsd 0x40(%rsp), %xmm0
callq 0x17e30
movsd %xmm0, 0x10(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0x17e30
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
jmp 0x3360d3
callq 0x17610
movsd 0x40aae(%rip), %xmm1    # 0x376b60
ucomisd %xmm0, %xmm1
xorpd %xmm1, %xmm1
jae 0x3360d3
movsd 0x40(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x17e30
movapd %xmm0, %xmm1
movsd 0xd8(%rsp), %xmm2
addsd %xmm1, %xmm2
movsd 0x19140(%rip), %xmm1    # 0x34f228
ucomisd %xmm1, %xmm2
movl $0x1, %eax
cmovael %eax, %r13d
movapd %xmm1, %xmm0
minsd %xmm2, %xmm0
cmpq %rbx, %rbp
jae 0x336117
incq %rbp
addq $-0x8, %r12
ucomisd %xmm1, %xmm2
movapd %xmm0, %xmm1
jb 0x335f44
movq 0x30(%rsp), %rax
movsd %xmm0, (%rax,%rbx,8)
movq 0x90(%rsp), %r12
movq 0x88(%rsp), %rbp
movsd 0x38(%rsp), %xmm1
movsd 0x98(%rsp), %xmm3
movdqa 0xf0(%rsp), %xmm4
mulsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
subsd %xmm3, %xmm1
punpckldq 0x1a781(%rip), %xmm4 # xmm4 = xmm4[0],mem[0],xmm4[1],mem[1]
subpd 0x1a789(%rip), %xmm4    # 0x3508f0
movapd %xmm4, %xmm0
unpckhpd %xmm4, %xmm0            # xmm0 = xmm0[1],xmm4[1]
addsd %xmm4, %xmm0
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, 0x10(%rsp)
callq 0x10ac6f
testb %al, %al
jne 0x3361a1
xorpd %xmm1, %xmm1
movapd 0x10(%rsp), %xmm0
callq 0x10adc8
testb %al, %al
je 0x33629c
movsd 0xc0(%rsp), %xmm2
movapd 0x10(%rsp), %xmm3
addsd %xmm3, %xmm2
movsd 0x1906c(%rip), %xmm1    # 0x34f228
ucomisd %xmm1, %xmm2
jb 0x3361d5
divsd %xmm2, %xmm3
movsd 0xa0(%rsp), %xmm0
ucomisd %xmm3, %xmm0
jae 0x3361fd
movsd 0xb8(%rsp), %xmm0
mulsd 0xa8(%rsp), %xmm0
incq %rbx
addq $0x8, %r15
movsd 0x38(%rsp), %xmm3
cmpq %rbp, %rbx
jne 0x335eaf
movsd 0x78(%rsp), %xmm0
movapd %xmm2, %xmm1
callq 0x10ad54
testb %al, %al
jne 0x33621e
movsd 0x20(%rsp), %xmm2
movsd 0x28(%rsp), %xmm1
jmp 0x336229
movsd 0x20(%rsp), %xmm1
movsd (%rsp), %xmm2
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
andpd 0x3edb7(%rip), %xmm0    # 0x374ff0
divsd %xmm2, %xmm0
movapd %xmm1, %xmm3
movsd 0x70(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x335e27
jmp 0x33625e
movsd (%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
addsd %xmm3, %xmm2
mulsd 0x28c0e(%rip), %xmm2    # 0x35ee78
movsd %xmm2, (%rsp)
leaq 0xb9042(%rip), %rsi     # 0x3ef2b8
movq 0x30(%rsp), %rdi
movl $0xa9, %edx
callq 0x109670
movsd (%rsp), %xmm0
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x97929
callq 0x97960