// File: /workspace/github_c_makefile_star2_O3/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 0x1fdedd
movq %rsi, %r13
testq %rsi, %rsi
je 0x1fdee2
movq %rdi, %rbx
movq 0x28(%r13), %rdi
callq 0x1fd37c
testq %rax, %rax
je 0x1fdebe
movq %rax, %r15
movq %rbx, 0x10(%rsp)
movq (%r13), %rdi
leaq 0x1bdc21(%rip), %rbx    # 0x3bb981
movl $0x8, %esi
movq %rbx, %rdx
movl $0x88, %ecx
callq 0x10436a
movq %rax, 0x8(%rsp)
movq (%r13), %rdi
movl $0x8, %esi
movq %rbx, %rdx
movl $0x8a, %ecx
callq 0x10436a
movq %rax, %r12
movq 0x28(%r13), %rdi
callq 0xe7bac
testq %rax, %rax
je 0x1fdde9
movq %rax, %rbp
xorl %ebx, %ebx
movq 0x28(%r13), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xeb6ee
movq %r14, %rdi
movq %rax, %rsi
callq 0xf6438
movq 0x20(%r13), %rcx
testq %rcx, %rcx
je 0x1fddca
movq (%rcx,%rax,8), %rax
movq (%r15,%rbx,8), %rcx
testq %rcx, %rcx
je 0x1fdde1
addq (%r12,%rax,8), %rcx
jb 0x1fded3
movq %rcx, (%r12,%rax,8)
incq %rbx
cmpq %rbx, %rbp
jne 0x1fdda3
cmpq $0x0, (%r13)
movq 0x8(%rsp), %r14
je 0x1fde95
leaq 0x1bdd32(%rip), %rbx    # 0x3bbb32
xorl %ebp, %ebp
movq (%r12,%rbp,8), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x103d72
incq %rbp
movq (%r13), %rax
cmpq %rax, %rbp
jb 0x1fde02
testq %rax, %rax
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r14
je 0x1fde95
xorl %ecx, %ecx
movq 0x149aa8(%rip), %xmm0   # 0x3478e0
movapd 0x149ab0(%rip), %xmm1   # 0x3478f0
movq (%r12,%rcx,8), %rsi
movq (%rdi,%rcx,8), %rdx
cmpq %rdx, %rsi
ja 0x1fded8
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
cmpq %rcx, %rax
jne 0x1fde40
leaq 0x1bdae5(%rip), %rbx    # 0x3bb981
movq %r15, %rdi
movq %rbx, %rsi
movl $0xa4, %edx
callq 0x1045eb
movq %r12, %rdi
movq %rbx, %rsi
movl $0xa5, %edx
callq 0x1045eb
jmp 0x1fdec1
xorl %r14d, %r14d
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7eb2c
callq 0x7eb59
callq 0x7ebc9
callq 0x7eb92