// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/shu-genomediff.c
// Function: genomediff_calculate_div
static void genomediff_calculate_div(GtShuUnitFileInfo *unit_info,
                                     double **div, double *gc_content,
                                     GtUword *genome_lengths,
                                     const GtGenomediffArguments *arguments,
                                     GtTimer *timer)
{
  double query_gc,
         query_shulen,
         *ln_n_fac;
  GtUword subject_len,
                i_idx, j_idx,
                subject, query;

  if (timer != NULL)
    gt_timer_show_progress(timer, "pre calculate ln_n_fac", stdout);

  ln_n_fac = gt_get_ln_n_fac(arguments->max_ln_n_fac);
  if (timer != NULL)
    gt_timer_show_progress(timer, "calculate divergence", stdout);
  for (i_idx = 0; i_idx < unit_info->num_of_genomes; i_idx++) {
    for (j_idx = i_idx+1; j_idx < unit_info->num_of_genomes; j_idx++) {
      /* query is the one with smaller avg shulen */
      if (gt_double_smaller_double(div[i_idx][j_idx], div[j_idx][i_idx])) {
        subject = j_idx;
        query = i_idx;
      }
      else if (gt_double_smaller_double(div[j_idx][i_idx], div[i_idx][j_idx])) {
          subject = i_idx;
          query = j_idx;
      }
      /* if avg shulen is equal, choose query with gc content farther from .5 */
      else {
        if (gt_double_smaller_double(fabs(gc_content[i_idx]-0.5),
                                     fabs(gc_content[j_idx]-0.5))) {
          subject = i_idx;
          query = j_idx;
        }
        else {
          subject = j_idx;
          query = i_idx;
        }
      }
      query_gc = gc_content[query];
      query_shulen = div[query][subject];
      subject_len = genome_lengths[subject];

      div[i_idx][j_idx] = gt_divergence(arguments->divergence_rel_err,
                                        arguments->divergence_abs_err,
                                        arguments->divergence_m,
                                        arguments->divergence_threshold,
                                        query_shulen,
                                        subject_len,
                                        query_gc,
                                        ln_n_fac,
                                        arguments->max_ln_n_fac);
      div[j_idx][i_idx] = div[i_idx][j_idx];
    }
  }
  gt_free(ln_n_fac);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r14
movq %r8, %rbx
movq %rcx, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, (%rsp)
testq %r9, %r9
je 0x1b180f
movq 0x2866b3(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1aa7c6(%rip), %rsi    # 0x35bfcd
movq %r14, %rdi
callq 0xaf86f
movq 0x10(%rbx), %rdi
callq 0x2cd07b
movq %rax, %rbp
testq %r14, %r14
je 0x1b1839
movq 0x286689(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1aa7b3(%rip), %rsi    # 0x35bfe4
movq %r14, %rdi
callq 0xaf86f
movq (%rsp), %rax
movq (%rax), %rax
xorl %r14d, %r14d
cmpq %rax, %r14
jae 0x1b194a
leaq 0x1(%r14), %r13
movq %r13, 0x8(%rsp)
cmpq %rax, %r13
jae 0x1b1940
movq (%r12,%r14,8), %rax
movsd (%rax,%r13,8), %xmm0
movq (%r12,%r13,8), %rax
movsd (%rax,%r14,8), %xmm1
callq 0x955e2
movq %r13, %rcx
movq %r14, %rdx
testb %al, %al
jne 0x1b18e5
movq (%r12,%r13,8), %rax
movsd (%rax,%r14,8), %xmm0
movq (%r12,%r14,8), %rax
movsd (%rax,%r13,8), %xmm1
callq 0x955e2
movq %r14, %rcx
movq %r13, %rdx
testb %al, %al
jne 0x1b18e5
movsd (%r15,%r14,8), %xmm0
movsd 0x15a476(%rip), %xmm2   # 0x30bd28
addsd %xmm2, %xmm0
movapd 0x15a492(%rip), %xmm3   # 0x30bd50
andpd %xmm3, %xmm0
movsd (%r15,%r13,8), %xmm1
addsd %xmm2, %xmm1
andpd %xmm3, %xmm1
callq 0x955e2
movq %r14, %rcx
movq %r13, %rdx
testb %al, %al
jne 0x1b18e5
movq %r13, %rcx
movq %r14, %rdx
movsd (%r15,%rdx,8), %xmm5
movq (%r12,%rdx,8), %rax
movsd (%rax,%rcx,8), %xmm4
movq 0x10(%rsp), %rax
movq (%rax,%rcx,8), %rdi
movsd 0x28(%rbx), %xmm0
movsd 0x18(%rbx), %xmm1
movsd 0x20(%rbx), %xmm2
movsd 0x30(%rbx), %xmm3
movq 0x10(%rbx), %rdx
movq %rbp, %rsi
callq 0x2ccaa4
movq (%r12,%r14,8), %rax
movsd %xmm0, (%rax,%r13,8)
movq (%r12,%r13,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r13
movq (%rsp), %rax
movq (%rax), %rax
jmp 0x1b1855
movq 0x8(%rsp), %r14
jmp 0x1b1843
leaq 0x1aa482(%rip), %rsi    # 0x35bdd3
movq %rbp, %rdi
movl $0xe3, %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x936f9