// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x88, %rsp
movsd %xmm0, 0x80(%rsp)
movsd %xmm1, 0x78(%rsp)
movsd %xmm2, 0x70(%rsp)
movsd %xmm3, 0x68(%rsp)
movsd %xmm4, 0x60(%rsp)
movq %rdi, 0x58(%rsp)
movsd %xmm5, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq 0x40(%rsp), %rdi
addq $0x1, %rdi
movl $0x8, %esi
leaq 0xd44b6(%rip), %rdx     # 0x5bb4a8
movl $0x95, %ecx
callq 0xe83c0
movq %rax, (%rsp)
movsd 0x50(%rsp), %xmm0
movsd 0x31d52(%rip), %xmm1    # 0x518d60
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x30220(%rip), %xmm0    # 0x517240
subsd 0x50(%rsp), %xmm0
movsd 0x31d32(%rip), %xmm1    # 0x518d60
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x31d17(%rip), %xmm1    # 0x518d60
mulsd 0x38(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x31d03(%rip), %xmm0    # 0x518d60
mulsd 0x30(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x301c7(%rip), %xmm0    # 0x517240
subsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x68(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
subsd 0x28(%rsp), %xmm1
movsd 0x31cc3(%rip), %xmm2    # 0x518d60
divsd %xmm2, %xmm1
callq 0xec2f0
testb $0x1, %al
jne 0x4e70af
jmp 0x4e7167
movsd 0x28(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd 0x31c9d(%rip), %xmm1    # 0x518d60
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x78(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
movq 0x58(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq (%rsp), %rdx
movq 0x40(%rsp), %rcx
callq 0x4e71b0
movsd %xmm0, 0x8(%rsp)
movsd 0x60(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0xec2f0
testb $0x1, %al
jne 0x4e711a
jmp 0x4e7128
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0x4e7134
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm1
subsd 0x28(%rsp), %xmm1
movaps 0x56309(%rip), %xmm0    # 0x53d450
pand %xmm0, %xmm1
divsd 0x20(%rsp), %xmm1
movsd 0x80(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x4e7162
jmp 0x4e7167
jmp 0x4e7083
movsd 0x28(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd 0x31be5(%rip), %xmm1    # 0x518d60
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movq (%rsp), %rdi
leaq 0xd4318(%rip), %rsi     # 0x5bb4a8
movl $0xa9, %edx
callq 0xe88c0
movsd 0x10(%rsp), %xmm0
addq $0x88, %rsp
retq
nopl (%rax,%rax)