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

  gt_assert(shulensums != NULL);
  gt_assert(unit_info != NULL);

  genome_lengths =
    genomediff_calculate_genome_lengths(unit_info);

  if (timer != NULL)
    gt_timer_show_progress(timer, "calculate avg shulen", stdout);

  gt_array2dim_calloc(div,
                      unit_info->num_of_genomes,
                      unit_info->num_of_genomes);

  for (i_idx = 0; i_idx < unit_info->num_of_genomes; i_idx++) {
    GtUword length_i;
    length_i = genome_lengths[i_idx];

    for (j_idx = 0; j_idx < unit_info->num_of_genomes; j_idx++) {
      div[i_idx][j_idx] = pcktable ?
                            ((double) shulensums[i_idx][j_idx]) / length_i :
                            ((double) shulensums[j_idx][i_idx]) / length_i;
    }
  }
  if (gt_logger_enabled(logger)) {
    gt_logger_log(logger, "table of avg shulens");
    genomediff_print_table(div, 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, div, gc_content, genome_lengths,
                             arguments, timer);

    if (gt_logger_enabled(logger)) {
      gt_logger_log(logger, "table of divergences");
      genomediff_print_table(div, 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(div[i_idx][j_idx]));
      }
      printf("\n");
    }
  }

  gt_free(genome_lengths);
  gt_free(gc_content);
  if (div != NULL)
    gt_array2dim_delete(div);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x1b1d3b
movq %rdx, %r15
testq %rdx, %rdx
je 0x1b1d69
movq %r9, %r14
movl %ecx, %ebp
movq %rdi, %r12
movq %rsi, 0x8(%rsp)
movq %r8, 0x20(%rsp)
movq %r15, %rdi
callq 0x1b1434
movq %rax, %rbx
testq %r14, %r14
je 0x1b1a56
movq 0x28646c(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1aa4be(%rip), %rsi    # 0x35bf0c
movq %r14, %rdi
callq 0xaf86f
movq %r14, 0x10(%rsp)
movq (%r15), %rdi
shlq $0x3, %rdi
leaq 0x1aa36a(%rip), %r13    # 0x35bdd3
movq %r13, %rsi
movl $0x1cc, %edx            # imm = 0x1CC
callq 0x93160
movq %rax, %r14
movq (%r15), %rdi
imulq %rdi, %rdi
pushq $0x8
popq %rsi
movq %r13, %rdx
movl $0x1cc, %ecx            # imm = 0x1CC
callq 0x9334a
movq %rax, (%r14)
movq (%r15), %rax
pushq $0x1
popq %rcx
leaq (,%rax,8), %rdx
movq 0x20(%rsp), %r13
cmpq %rax, %rcx
jae 0x1b1abc
movq -0x8(%r14,%rcx,8), %rsi
addq %rdx, %rsi
movq %rsi, (%r14,%rcx,8)
incq %rcx
jmp 0x1b1aa6
xorl %ecx, %ecx
movsd 0x135e1a(%rip), %xmm0   # 0x2e78e0
movapd 0x135e22(%rip), %xmm1   # 0x2e78f0
cmpq %rax, %rcx
je 0x1b1b37
movq (%r14,%rcx,8), %rdx
movsd (%rbx,%rcx,8), %xmm3
unpcklps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
subpd %xmm1, %xmm3
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
addsd %xmm3, %xmm2
xorl %esi, %esi
cmpq %rsi, %rax
je 0x1b1b32
testb %bpl, %bpl
movq %rsi, %rdi
cmovneq %rcx, %rdi
movq %rcx, %r8
cmovneq %rsi, %r8
movq (%r12,%rdi,8), %rdi
movsd (%rdi,%r8,8), %xmm3
unpcklps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
subpd %xmm1, %xmm3
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
addsd %xmm3, %xmm4
divsd %xmm2, %xmm4
movsd %xmm4, (%rdx,%rsi,8)
incq %rsi
jmp 0x1b1af1
incq %rcx
jmp 0x1b1ace
movq %r13, %rdi
callq 0x92c18
testb %al, %al
je 0x1b1b5f
leaq 0x1aa3d7(%rip), %rsi    # 0x35bf21
movq %r13, %rdi
xorl %eax, %eax
callq 0x92e71
movq %r14, %rdi
movq %r15, %rsi
callq 0x1b196c
movq 0x28(%r15), %rdi
callq 0x754dd
movq %rax, %rdi
callq 0x5741b
testb %al, %al
je 0x1b1cb0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1b1b98
movq 0x286327(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1aa31c(%rip), %rsi    # 0x35beaf
callq 0xaf86f
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1b156b
testq %rax, %rax
je 0x1b1cdb
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
callq 0x1b17ce
movq %r13, %rdi
callq 0x92c18
testb %al, %al
je 0x1b1bf2
leaq 0x1aa2df(%rip), %rsi    # 0x35bebc
movq %r13, %rdi
xorl %eax, %eax
callq 0x92e71
movq %r14, %rdi
movq %r15, %rsi
callq 0x1b196c
movq %r12, 0x18(%rsp)
movq %rbx, 0x8(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1b1c1c
movq 0x2862a3(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1aa2ba(%rip), %rsi    # 0x35bed1
callq 0xaf86f
leaq 0x1aa2bb(%rip), %rsi    # 0x35bede
movq %r13, %rdi
xorl %eax, %eax
callq 0x92e71
movq (%r15), %rsi
leaq 0x13ee04(%rip), %rdi    # 0x2f0a3b
xorl %eax, %eax
callq 0x17070
leaq 0x1aa2a7(%rip), %r13    # 0x35beec
leaq 0x1aa2a6(%rip), %rbp    # 0x35bef2
xorl %r12d, %r12d
cmpq (%r15), %r12
jae 0x1b1ccc
movq 0x10(%r15), %rdi
movq %r12, %rsi
callq 0xae386
leaq 0x14404d(%rip), %rdi    # 0x2f5cb4
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
xorl %ebx, %ebx
cmpq (%r15), %rbx
jae 0x1b1ca3
cmpq %rbx, %r12
jne 0x1b1c86
xorpd %xmm0, %xmm0
movq %r13, %rdi
jmp 0x1b1c97
movq (%r14,%r12,8), %rax
movsd (%rax,%rbx,8), %xmm0
callq 0x2cd0eb
movq %rbp, %rdi
movb $0x1, %al
callq 0x17070
incq %rbx
jmp 0x1b1c73
pushq $0xa
popq %rdi
callq 0x179c0
incq %r12
jmp 0x1b1c4f
leaq 0x1aa1c7(%rip), %rsi    # 0x35be7e
xorl %r12d, %r12d
movq 0x60(%rsp), %rdi
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %r13
jmp 0x1b1ce2
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %r12
xorl %r13d, %r13d
jmp 0x1b1ce2
pushq $-0x1
popq %r13
xorl %r12d, %r12d
leaq 0x1aa0ea(%rip), %r15    # 0x35bdd3
movq %rbx, %rdi
movq %r15, %rsi
movl $0x20a, %edx            # imm = 0x20A
callq 0x936f9
movq %r12, %rdi
movq %r15, %rsi
movl $0x20b, %edx            # imm = 0x20B
callq 0x936f9
movq (%r14), %rdi
movq %r15, %rsi
movl $0x20d, %edx            # imm = 0x20D
callq 0x936f9
movq %r14, %rdi
movq %r15, %rsi
movl $0x20d, %edx            # imm = 0x20D
callq 0x936f9
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x286226(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1332c7(%rip), %rsi    # 0x2e5013
leaq 0x1aa0fe(%rip), %rdx    # 0x35be51
leaq 0x1aa19c(%rip), %rcx    # 0x35bef6
leaq 0x1aa072(%rip), %r8     # 0x35bdd3
movl $0x1c1, %r9d            # imm = 0x1C1
jmp 0x1b1d95
movq 0x2861f8(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x133299(%rip), %rsi    # 0x2e5013
leaq 0x13b71a(%rip), %rdx    # 0x2ed49b
leaq 0x1aa16e(%rip), %rcx    # 0x35bef6
leaq 0x1aa044(%rip), %r8     # 0x35bdd3
movl $0x1c2, %r9d            # imm = 0x1C2
xorl %eax, %eax
callq 0x17a50
callq 0x17390
nopl (%rax)