// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/shu-genomediff.c
// Function: gt_genomediff_calculate_div_from_avg
int gt_genomediff_calculate_div_from_avg(double **avgshu,
                                         const GtGenomediffArguments *arguments,
                                         GtShuUnitFileInfo *unit_info,
                                         GtLogger *logger,
                                         GtTimer *timer,
                                         GtError *err)
{
  int had_err = 0;
  const GtAlphabet *alphabet;
  double *gc_content = NULL;
  GtUword i_idx, j_idx;
  GtUword *genome_lengths = NULL;

  genome_lengths = genomediff_calculate_genome_lengths(unit_info);

  /*get alphabet and check if alphabet is dna, which is presumed for
    gc-calculation*/
  alphabet = gt_encseq_alphabet(unit_info->encseq);
  if (!gt_alphabet_is_dna(alphabet)) {
    gt_error_set(err,"error: sequences need to be dna to calculate gc!");
    had_err = -1;
  }

  if (!had_err && timer != NULL)
    gt_timer_show_progress(timer, "calculate gc", stdout);
  if (!had_err) {
    gc_content = genomediff_calculate_gc(genome_lengths, unit_info, err);
    if (gc_content == NULL)
      had_err = -1;
  }

    /* calculation of divergence */
  if (!had_err) {
    genomediff_calculate_div(unit_info, avgshu, gc_content, genome_lengths,
                             arguments, timer);

    if (gt_logger_enabled(logger)) {
      gt_logger_log(logger, "table of divergences");
      genomediff_print_table(avgshu, unit_info);
    }
  }

  if (!had_err && timer != NULL)
    gt_timer_show_progress(timer, "calculate kr", stdout);

  if (!had_err) {
    gt_logger_log(logger, "# Table of Kr");
    printf(""GT_WU"\n", unit_info->num_of_genomes);
    for (i_idx = 0; i_idx < unit_info->num_of_genomes; i_idx++) {
      printf("%s\t", gt_str_array_get(unit_info->genome_names, i_idx));
      for (j_idx = 0; j_idx < unit_info->num_of_genomes; j_idx++) {
        if ( i_idx == j_idx )
          printf("%.6f\t",0.0);
        else
          printf("%f\t", gt_calculateKr(avgshu[i_idx][j_idx]));
      }
      printf("\n");
    }
  }
  gt_free(gc_content);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %r12
movq %r8, %r13
movq %rcx, (%rsp)
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq %rdx, %rdi
callq 0x1fdbcc
movq %rax, %rbp
movq 0x28(%rbx), %rdi
callq 0xebcd9
movq %rax, %rdi
callq 0xd1749
testb %al, %al
je 0x1fdb84
testq %r13, %r13
je 0x1fda5b
movq 0x2bb48f(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x1be00a(%rip), %rsi    # 0x3bba5d
movq %r13, %rdi
callq 0x11cc90
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x1fdd15
testq %rax, %rax
je 0x1fdb9f
movq %rax, %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbp, %rcx
movq %r15, %r8
movq %r13, %r9
callq 0x1fdee7
movq (%rsp), %r15
movq %r15, %rdi
callq 0x103eac
testb %al, %al
je 0x1fdab5
leaq 0x1bdfca(%rip), %rsi    # 0x3bba6a
movq %r15, %rdi
xorl %eax, %eax
callq 0x103fe1
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1fe094
testq %r13, %r13
je 0x1fdad3
movq 0x2bb417(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x1bdfb4(%rip), %rsi    # 0x3bba7f
movq %r13, %rdi
callq 0x11cc90
leaq 0x1bdfb2(%rip), %rsi    # 0x3bba8c
xorl %ebp, %ebp
movq %r15, %rdi
xorl %eax, %eax
callq 0x103fe1
movq (%rbx), %rsi
leaq 0x152f38(%rip), %rdi    # 0x350a28
xorl %eax, %eax
callq 0x17070
cmpq $0x0, (%rbx)
je 0x1fdba7
movq %r12, (%rsp)
leaq 0x1bdf8e(%rip), %r13    # 0x3bba9a
leaq 0x1bdf8d(%rip), %rbp    # 0x3bbaa0
xorl %r15d, %r15d
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x11bfb3
leaq 0x15817b(%rip), %rdi    # 0x355ca4
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
cmpq $0x0, (%rbx)
je 0x1fdb6a
xorl %r12d, %r12d
cmpq %r12, %r15
jne 0x1fdb49
xorps %xmm0, %xmm0
movq %r13, %rdi
jmp 0x1fdb5b
movq (%r14,%r15,8), %rax
movsd (%rax,%r12,8), %xmm0
callq 0x32b74e
movq %rbp, %rdi
movb $0x1, %al
callq 0x17070
incq %r12
cmpq (%rbx), %r12
jb 0x1fdb3c
movl $0xa, %edi
callq 0x17a20
incq %r15
cmpq (%rbx), %r15
jb 0x1fdb16
xorl %ebp, %ebp
movq (%rsp), %r12
jmp 0x1fdba7
leaq 0x1bdea1(%rip), %rsi    # 0x3bba2c
movq %r12, %rdi
xorl %r12d, %r12d
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1fdba7
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r12d, %r12d
leaq 0x1bddd3(%rip), %rsi    # 0x3bb981
movq %r12, %rdi
movl $0x1ae, %edx            # imm = 0x1AE
callq 0x1045eb
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq