// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
testq %rdi, %rdi
je 0x1fe48d
movq %rdx, %r15
testq %rdx, %rdx
je 0x1fe492
movq %r9, %r14
movl %ecx, %ebp
movq %rdi, %r12
movq %rsi, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq %r15, %rdi
callq 0x1fdbcc
movq %rax, %rbx
testq %r14, %r14
je 0x1fe18d
movq 0x2bad5d(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x1bd935(%rip), %rsi    # 0x3bbaba
movq %r14, %rdi
callq 0x11cc90
movq %r14, (%rsp)
movq (%r15), %rdi
shlq $0x3, %rdi
leaq 0x1bd7e2(%rip), %r13    # 0x3bb981
movq %r13, %rsi
movl $0x1cc, %edx            # imm = 0x1CC
callq 0x104226
movq %rax, %r14
movq (%r15), %rdi
imulq %rdi, %rdi
movl $0x8, %esi
movq %r13, %rdx
movl $0x1cc, %ecx            # imm = 0x1CC
callq 0x10436a
movq %rax, (%r14)
movq (%r15), %rax
cmpq $0x2, %rax
jb 0x1fe1fd
leaq (,%rax,8), %rcx
movq (%r14), %rdx
addq %rcx, %rdx
movl $0x1, %esi
movq 0x8(%rsp), %r13
movq %rdx, (%r14,%rsi,8)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %rax
jne 0x1fe1ec
jmp 0x1fe207
testq %rax, %rax
movq 0x8(%rsp), %r13
je 0x1fe27e
xorl %ecx, %ecx
movsd 0x1496cf(%rip), %xmm0   # 0x3478e0
movapd 0x1496d7(%rip), %xmm1   # 0x3478f0
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
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
cmpq %rsi, %rax
jne 0x1fe237
incq %rcx
cmpq %rax, %rcx
jne 0x1fe219
movq %r13, %rdi
callq 0x103eac
testb %al, %al
je 0x1fe2a6
leaq 0x1bd83e(%rip), %rsi    # 0x3bbacf
movq %r13, %rdi
xorl %eax, %eax
callq 0x103fe1
movq %r14, %rdi
movq %r15, %rsi
callq 0x1fe094
movq 0x28(%r15), %rdi
callq 0xebcd9
movq %rax, %rdi
callq 0xd1749
testb %al, %al
je 0x1fe410
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1fe2de
movq 0x2bac09(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x1bd784(%rip), %rsi    # 0x3bba5d
callq 0x11cc90
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1fdd15
testq %rax, %rax
je 0x1fe42d
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
movq 0x10(%rsp), %r8
movq (%rsp), %r9
callq 0x1fdee7
movq %r13, %rdi
callq 0x103eac
testb %al, %al
je 0x1fe337
leaq 0x1bd748(%rip), %rsi    # 0x3bba6a
movq %r13, %rdi
xorl %eax, %eax
callq 0x103fe1
movq %r14, %rdi
movq %r15, %rsi
callq 0x1fe094
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1fe356
movq 0x2bab91(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x1bd72e(%rip), %rsi    # 0x3bba7f
callq 0x11cc90
leaq 0x1bd72f(%rip), %rsi    # 0x3bba8c
xorl %ebp, %ebp
movq %r13, %rdi
xorl %eax, %eax
callq 0x103fe1
movq (%r15), %rsi
leaq 0x1526b5(%rip), %rdi    # 0x350a28
xorl %eax, %eax
callq 0x17070
cmpq $0x0, (%r15)
je 0x1fe435
movq %r12, 0x8(%rsp)
movq %rbx, (%rsp)
leaq 0x1bd706(%rip), %r13    # 0x3bba9a
leaq 0x1bd705(%rip), %rbp    # 0x3bbaa0
xorl %r12d, %r12d
movq 0x10(%r15), %rdi
movq %r12, %rsi
callq 0x11bfb3
leaq 0x1578f3(%rip), %rdi    # 0x355ca4
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
cmpq $0x0, (%r15)
je 0x1fe3f1
xorl %ebx, %ebx
cmpq %rbx, %r12
jne 0x1fe3d1
xorpd %xmm0, %xmm0
movq %r13, %rdi
jmp 0x1fe3e2
movq (%r14,%r12,8), %rax
movsd (%rax,%rbx,8), %xmm0
callq 0x32b74e
movq %rbp, %rdi
movb $0x1, %al
callq 0x17070
incq %rbx
cmpq (%r15), %rbx
jb 0x1fe3c3
movl $0xa, %edi
callq 0x17a20
incq %r12
cmpq (%r15), %r12
jb 0x1fe39e
xorl %ebp, %ebp
movq (%rsp), %rbx
movq 0x8(%rsp), %r12
jmp 0x1fe435
movq 0x50(%rsp), %rdi
leaq 0x1bd610(%rip), %rsi    # 0x3bba2c
xorl %r12d, %r12d
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1fe435
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r12d, %r12d
leaq 0x1bd545(%rip), %r15    # 0x3bb981
movq %rbx, %rdi
movq %r15, %rsi
movl $0x20a, %edx            # imm = 0x20A
callq 0x1045eb
movq %r12, %rdi
movq %r15, %rsi
movl $0x20b, %edx            # imm = 0x20B
callq 0x1045eb
movq (%r14), %rdi
movq %r15, %rsi
movl $0x20d, %edx            # imm = 0x20D
callq 0x1045eb
movq %r14, %rdi
movq %r15, %rsi
movl $0x20d, %edx            # imm = 0x20D
callq 0x1045eb
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7ec39
callq 0x7ec00
nop