// File: /workspace/github_c_makefile_star2_O1/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, %r13
testq %r9, %r9
je 0x207627
movq 0x2bc8d3(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1bdbcc(%rip), %rsi    # 0x3c51eb
movq %r14, %rdi
callq 0x1229c8
movq 0x10(%rbx), %rdi
callq 0x3362a6
movq %rax, 0x8(%rsp)
testq %r14, %r14
je 0x207653
movq 0x2bc8a7(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1bdbb7(%rip), %rsi    # 0x3c5202
movq %r14, %rdi
callq 0x1229c8
cmpq $0x0, (%r13)
je 0x207764
xorl %r14d, %r14d
leaq 0x1(%r14), %rax
movq %rax, (%rsp)
cmpq (%r13), %rax
jae 0x207756
movq (%rsp), %rbp
movq (%r12,%r14,8), %rax
movsd (%rax,%rbp,8), %xmm0
movq (%r12,%rbp,8), %rax
movsd (%rax,%r14,8), %xmm1
callq 0x10ad54
movq %rbp, %rcx
movq %r14, %rdx
testb %al, %al
jne 0x2076fc
movq (%r12,%rbp,8), %rax
movsd (%rax,%r14,8), %xmm0
movq (%r12,%r14,8), %rax
movsd (%rax,%rbp,8), %xmm1
callq 0x10ad54
movq %r14, %rcx
movq %rbp, %rdx
testb %al, %al
jne 0x2076fc
movsd (%r15,%r14,8), %xmm0
movsd 0x1bd907(%rip), %xmm2   # 0x3c4fd0
addsd %xmm2, %xmm0
movapd 0x16d91b(%rip), %xmm3   # 0x374ff0
andpd %xmm3, %xmm0
movsd (%r15,%rbp,8), %xmm1
addsd %xmm2, %xmm1
andpd %xmm3, %xmm1
callq 0x10ad54
movq %r14, %rcx
movq %rbp, %rdx
testb %al, %al
jne 0x2076fc
movq %rbp, %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 0x8(%rsp), %rsi
callq 0x335d20
movq (%r12,%r14,8), %rax
movsd %xmm0, (%rax,%rbp,8)
movq (%r12,%rbp,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %rbp
cmpq (%r13), %rbp
jb 0x207677
movq (%rsp), %r14
cmpq (%r13), %r14
jb 0x207661
leaq 0x1bd886(%rip), %rsi    # 0x3c4ff1
movq 0x8(%rsp), %rdi
movl $0xe3, %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x109670