// File: /workspace/github_c_makefile_star2_O3/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 %r8, %rbx
movq %rcx, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, 0x8(%rsp)
testq %r9, %r9
je 0x1fdf49
movq %r9, %r13
movq 0x2bafc1(%rip), %r14    # 0x4b8ed8
movq (%r14), %rdx
leaq 0x1bdc5a(%rip), %rsi    # 0x3bbb7b
movq %r9, %rdi
callq 0x11cc90
movq 0x10(%rbx), %rdi
callq 0x32b6d4
movq %rax, %rbp
movq (%r14), %rdx
leaq 0x1bdc53(%rip), %rsi    # 0x3bbb92
movq %r13, %rdi
callq 0x11cc90
jmp 0x1fdf55
movq 0x10(%rbx), %rdi
callq 0x32b6d4
movq %rax, %rbp
movq 0x8(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x1fe072
xorl %r14d, %r14d
leaq 0x1(%r14), %rcx
movq %rcx, (%rsp)
cmpq %rax, %rcx
jae 0x1fe065
movq (%r12,%r14,8), %rcx
movq (%rsp), %r13
movsd (%rcx,%r13,8), %xmm0
movq (%r12,%r13,8), %rax
movsd (%rax,%r14,8), %xmm1
callq 0x105c97
movq %r13, %rcx
movq %r14, %rdx
testb %al, %al
jne 0x1fe005
movq (%r12,%r13,8), %rax
movsd (%rax,%r14,8), %xmm0
movq (%r12,%r14,8), %rax
movsd (%rax,%r13,8), %xmm1
callq 0x105c97
movq %r14, %rcx
movq %r13, %rdx
testb %al, %al
jne 0x1fe005
movsd (%r15,%r14,8), %xmm0
movsd 0x1bd98e(%rip), %xmm2   # 0x3bb960
addsd %xmm2, %xmm0
movapd 0x16ddc2(%rip), %xmm3   # 0x36bda0
andpd %xmm3, %xmm0
movsd (%r15,%r13,8), %xmm1
addsd %xmm2, %xmm1
andpd %xmm3, %xmm1
callq 0x105c97
movq %r14, %rcx
movq %r13, %rdx
testb %al, %al
jne 0x1fe005
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 0x32b16c
movq (%r12,%r14,8), %rcx
movsd %xmm0, (%rcx,%r13,8)
movq (%r12,%r13,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r13
movq 0x8(%rsp), %rax
movq (%rax), %rax
cmpq %rax, %r13
jb 0x1fdf82
movq (%rsp), %r14
cmpq %rax, %r14
jb 0x1fdf69
leaq 0x1bd908(%rip), %rsi    # 0x3bb981
movq %rbp, %rdi
movl $0xe3, %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1045eb