// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/shu-genomediff.c
// Function: genomediff_calculate_gc
static double *genomediff_calculate_gc(GtUword *genome_lengths,
                                       GtShuUnitFileInfo *unit_info,
                                       GT_UNUSED GtError *err)
{
  GtUword file_idx = 0UL,
                genome_idx,
                idx,
                *seq_gc_content = NULL,
                num_of_seq,
                *genome_gc_content;
  double *gc_content;

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

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

  /*count gc, do not calculate ratio*/
  seq_gc_content = gt_encseq_gc_count(unit_info->encseq);

  if (seq_gc_content == NULL)
    return NULL;

  gc_content = gt_calloc((size_t)unit_info->num_of_genomes,
                         sizeof (*gc_content));
  genome_gc_content = gt_calloc((size_t)unit_info->num_of_genomes,
                                sizeof (*genome_gc_content));
  num_of_seq = gt_encseq_num_of_sequences(unit_info->encseq);

  for (idx = 0; idx < num_of_seq; idx++) {
    file_idx = gt_encseq_filenum(unit_info->encseq,
                                 gt_encseq_seqstartpos(unit_info->encseq, idx));
    if (unit_info->map_files != NULL)
      genome_idx = unit_info->map_files[file_idx];
    else
      genome_idx = file_idx;
    #ifndef S_SPLINT_S
    gt_safe_add(genome_gc_content[genome_idx],
                genome_gc_content[genome_idx],
                seq_gc_content[idx]);
    #endif
  }
  for (idx = 0; idx < unit_info->num_of_genomes; idx++) {
    gt_log_log("file/genome "GT_WU" has gc "GT_WU"",
               idx, genome_gc_content[idx]);
  }

  for (idx = 0; idx < unit_info->num_of_genomes; idx++) {
    gt_assert(genome_gc_content[idx] <= genome_lengths[idx]);
    gc_content[idx] = (double) genome_gc_content[idx] /
                      (double) genome_lengths[idx];
  }
  gt_free(seq_gc_content);
  gt_free(genome_gc_content);
  return gc_content;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x1b1775
movq %rsi, %r13
testq %rsi, %rsi
je 0x1b179f
movq %rdi, %rbx
movq 0x28(%r13), %rdi
callq 0x1b09a0
testq %rax, %rax
je 0x1b16fc
movq %rax, %r15
movq %rbx, 0x10(%rsp)
movq (%r13), %rdi
leaq 0x1aa81d(%rip), %rbx    # 0x35bdd3
pushq $0x8
popq %r12
movq %r12, %rsi
movq %rbx, %rdx
movl $0x88, %ecx
callq 0x9334a
movq %rax, 0x8(%rsp)
movq (%r13), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movl $0x8a, %ecx
callq 0x9334a
movq %rax, %r12
movq 0x28(%r13), %rdi
callq 0x705a1
movq %rax, %rbp
xorl %ebx, %ebx
cmpq %rbx, %rbp
je 0x1b163c
movq 0x28(%r13), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x74d9c
movq %r14, %rdi
movq %rax, %rsi
callq 0x81b97
movq 0x20(%r13), %rcx
testq %rcx, %rcx
je 0x1b1620
movq (%rcx,%rax,8), %rax
movq (%r15,%rbx,8), %rcx
testq %rcx, %rcx
je 0x1b1637
addq (%r12,%rax,8), %rcx
jb 0x1b1749
movq %rcx, (%r12,%rax,8)
incq %rbx
jmp 0x1b15f4
leaq 0x1aa941(%rip), %rbx    # 0x35bf84
xorl %ebp, %ebp
movq (%r13), %rax
cmpq %rax, %rbp
jae 0x1b1664
movq (%r12,%rbp,8), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x92a82
incq %rbp
jmp 0x1b1645
xorl %ecx, %ecx
movq 0x136272(%rip), %xmm0   # 0x2e78e0
movapd 0x13627a(%rip), %xmm1   # 0x2e78f0
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r14
cmpq %rcx, %rax
je 0x1b16d3
movq (%r12,%rcx,8), %rsi
movq (%rdi,%rcx,8), %rdx
cmpq %rdx, %rsi
ja 0x1b1711
movq %rsi, %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
subpd %xmm1, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
movq %rdx, %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
subpd %xmm1, %xmm2
movapd %xmm2, %xmm4
unpckhpd %xmm2, %xmm4            # xmm4 = xmm4[1],xmm2[1]
addsd %xmm2, %xmm4
divsd %xmm4, %xmm3
movsd %xmm3, (%r14,%rcx,8)
incq %rcx
jmp 0x1b1680
leaq 0x1aa6f9(%rip), %rbx    # 0x35bdd3
movq %r15, %rdi
movq %rbx, %rsi
movl $0xa4, %edx
callq 0x936f9
movq %r12, %rdi
movq %rbx, %rsi
movl $0xa5, %edx
callq 0x936f9
jmp 0x1b16ff
xorl %r14d, %r14d
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x286850(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1338f1(%rip), %rsi    # 0x2e5013
leaq 0x1aa876(%rip), %rdx    # 0x35bf9f
leaq 0x1aa83c(%rip), %rcx    # 0x35bf6c
leaq 0x1aa69c(%rip), %r8     # 0x35bdd3
movl $0xa0, %r9d
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x286818(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x151008(%rip), %rsi    # 0x302762
leaq 0x1aa672(%rip), %rdx    # 0x35bdd3
movl $0x97, %ecx
xorl %eax, %eax
callq 0x17a50
pushq $0x1
popq %rdi
callq 0x178f0
movq 0x2867ec(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x13388d(%rip), %rsi    # 0x2e5013
leaq 0x1aa7c8(%rip), %rdx    # 0x35bf55
leaq 0x1aa7d8(%rip), %rcx    # 0x35bf6c
leaq 0x1aa638(%rip), %r8     # 0x35bdd3
pushq $0x7b
jmp 0x1b17c7
movq 0x2867c2(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x133863(%rip), %rsi    # 0x2e5013
leaq 0x13bce4(%rip), %rdx    # 0x2ed49b
leaq 0x1aa7ae(%rip), %rcx    # 0x35bf6c
leaq 0x1aa60e(%rip), %r8     # 0x35bdd3
pushq $0x7c
popq %r9
jmp 0x1b173d