// File: /workspace/github_c_makefile_star2_O1/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 0x207bbb
movq %rdx, %rbx
testq %rdx, %rdx
je 0x207bc0
movq %r9, %r15
movl %ecx, %ebp
movq %rdi, %r12
movq %rsi, 0x18(%rsp)
movq %r8, 0x20(%rsp)
movq %rbx, %rdi
callq 0x2072d3
movq %rax, %r14
testq %r15, %r15
je 0x207881
movq 0x2bc679(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1bd8b1(%rip), %rsi    # 0x3c512a
movq %r15, %rdi
callq 0x1229c8
movq %r15, 0x10(%rsp)
movq (%rbx), %rdi
shlq $0x3, %rdi
leaq 0x1bd75d(%rip), %r13    # 0x3c4ff1
movq %r13, %rsi
movl $0x1cc, %edx            # imm = 0x1CC
callq 0x1092b2
movq %rax, %r15
movq (%rbx), %rdi
imulq %rdi, %rdi
movl $0x8, %esi
movq %r13, %rdx
movl $0x1cc, %ecx            # imm = 0x1CC
callq 0x1093ef
movq %rax, (%r15)
movq (%rbx), %rax
cmpq $0x2, %rax
jb 0x2078eb
leaq (,%rax,8), %rcx
movq (%r15), %rdx
addq %rcx, %rdx
movl $0x1, %esi
movq %rdx, (%r15,%rsi,8)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %rax
jne 0x2078dc
testq %rax, %rax
movq 0x20(%rsp), %r13
je 0x20796d
xorl %ecx, %ecx
movsd 0x148fe1(%rip), %xmm0   # 0x3508e0
movapd 0x148fe9(%rip), %xmm1   # 0x3508f0
movq (%r15,%rcx,8), %rdx
movsd (%r14,%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 0x207926
incq %rcx
cmpq %rax, %rcx
jne 0x207907
movq %r13, %rdi
callq 0x108f3c
testb %al, %al
je 0x207995
leaq 0x1bd7bf(%rip), %rsi    # 0x3c513f
movq %r13, %rdi
xorl %eax, %eax
callq 0x10906e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x207788
movq 0x28(%rbx), %rdi
callq 0xf02da
movq %rax, %rdi
callq 0xd3c75
movl %eax, %ebp
testb %al, %al
jne 0x2079bf
movq 0x60(%rsp), %rdi
leaq 0x1bd6e4(%rip), %rsi    # 0x3c509c
xorl %eax, %eax
callq 0x1019cf
cmpq $0x0, 0x10(%rsp)
sete %al
movl %ebp, %ecx
xorb $0x1, %cl
orb %al, %cl
jne 0x2079ec
movq 0x2bc510(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1bd6eb(%rip), %rsi    # 0x3c50cd
movq 0x10(%rsp), %rdi
callq 0x1229c8
testb %bpl, %bpl
je 0x207a13
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20741c
testq %rax, %rax
je 0x207a26
movq %rax, 0x8(%rsp)
movb $0x1, %r12b
movl $0x0, 0x4(%rsp)
jmp 0x207a3a
movq $0x0, 0x8(%rsp)
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
jmp 0x207a37
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
testb %r12b, %r12b
je 0x207a84
movq %rbx, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movq %r14, %rcx
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
callq 0x2075e7
movq %r13, %rdi
callq 0x108f3c
testb %al, %al
je 0x207a84
leaq 0x1bd66b(%rip), %rsi    # 0x3c50da
movq %r13, %rdi
xorl %eax, %eax
callq 0x10906e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x207788
movq %r14, 0x18(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
sete %al
movl %r12d, %ecx
xorb $0x1, %cl
orb %al, %cl
jne 0x207ab4
movq 0x2bc443(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1bd640(%rip), %rsi    # 0x3c50ef
callq 0x1229c8
testb %r12b, %r12b
je 0x207b5d
leaq 0x1bd638(%rip), %rsi    # 0x3c50fc
movq %r13, %rdi
xorl %eax, %eax
callq 0x10906e
movq (%rbx), %rsi
leaq 0x151f8b(%rip), %rdi    # 0x359a63
xorl %eax, %eax
callq 0x17070
cmpq $0x0, (%rbx)
je 0x207b5d
leaq 0x1bd61e(%rip), %r13    # 0x3c510a
leaq 0x1bd61d(%rip), %rbp    # 0x3c5110
xorl %r12d, %r12d
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0x121cfa
leaq 0x1571c7(%rip), %rdi    # 0x35ecd0
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
cmpq $0x0, (%rbx)
je 0x207b4b
xorl %r14d, %r14d
cmpq %r14, %r12
jne 0x207b2a
xorpd %xmm0, %xmm0
movq %r13, %rdi
jmp 0x207b3c
movq (%r15,%r12,8), %rax
movsd (%rax,%r14,8), %xmm0
callq 0x336320
movq %rbp, %rdi
movb $0x1, %al
callq 0x17070
incq %r14
cmpq (%rbx), %r14
jb 0x207b1c
movl $0xa, %edi
callq 0x17a20
incq %r12
cmpq (%rbx), %r12
jb 0x207af6
leaq 0x1bd48d(%rip), %rbx    # 0x3c4ff1
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movl $0x20a, %edx            # imm = 0x20A
callq 0x109670
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movl $0x20b, %edx            # imm = 0x20B
callq 0x109670
movq (%r15), %rdi
movq %rbx, %rsi
movl $0x20d, %edx            # imm = 0x20D
callq 0x109670
movq %r15, %rdi
movq %rbx, %rsi
movl $0x20d, %edx            # imm = 0x20D
callq 0x109670
movl 0x4(%rsp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x80a43
callq 0x80a0a
nopl (%rax)