// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/shu-genomediff.c
// Function: gt_genomediff_shulen_sum
uint64_t **gt_genomediff_shulen_sum(const GtGenomediffArguments *arguments,
                                    GtShuUnitFileInfo *unit_info,
                                    GtLogger *logger,
                                    GtTimer *timer,
                                    GtError *err)
{
  int had_err = 0;
  GtUword i_idx, j_idx;
  uint64_t **shulensums = NULL;
  const GtEncseq *encseq = NULL;
  Genericindex *generic_index_subject = NULL;
  Sequentialsuffixarrayreader *ssar = NULL;

  gt_error_check(err);
  gt_assert(unit_info != NULL);

  /* prepare index */
  if (arguments->with_esa) {
    if (timer != NULL)
      gt_timer_show_progress(timer, "load sequential sa reader", stdout);

    ssar = gt_newSequentialsuffixarrayreaderfromfile(
                                    gt_str_array_get(arguments->filenames, 0),
                                    SARR_LCPTAB | SARR_SUFTAB | SARR_ESQTAB |
                                      SARR_SSPTAB,
                                    arguments->scanfile,
                                    logger, err);
    if (ssar == NULL)
      had_err = -1;

    if (!had_err) {
      encseq = gt_encseqSequentialsuffixarrayreader(ssar);
    }
  }
  else {
    gt_assert(arguments->with_pck);

    if (timer != NULL)
      gt_timer_show_progress(timer, "map generic index", stdout);

    generic_index_subject =
      genericindex_new(gt_str_array_get(arguments->filenames, 0),
                       false, true, false, true,
                       arguments->user_max_depth,
                       logger, err);
    if (generic_index_subject == NULL) {
      had_err = -1;
    }
    /*get num of genomes from unitfile or encseq and allocate shulen-matrix*/
    if (!had_err) {
      encseq = genericindex_getencseq(generic_index_subject);
    }
  }

  /*calculate sums of shulens*/
  if (!had_err) {
    gt_array2dim_calloc(shulensums,
                        unit_info->num_of_genomes,
                        unit_info->num_of_genomes);

    if (arguments->with_esa) {
      if (timer != NULL)
        gt_timer_show_progress(timer, "dfs esa index", stdout);

      had_err = gt_multiesa2shulengthdist(ssar, encseq, shulensums,
                                          unit_info, err);
    }
    else {
      const FMindex *subjectindex = NULL;
      GtUword num_of_chars,
                    total_length;
      const GtAlphabet *alphabet = gt_encseq_alphabet(unit_info->encseq);

      num_of_chars = (GtUword) gt_alphabet_num_of_chars(alphabet);
      total_length = genericindex_get_totallength(generic_index_subject);

      subjectindex = genericindex_get_packedindex(generic_index_subject);
      gt_assert(subjectindex != NULL);

      had_err = gt_pck_calculate_shulen(subjectindex,
                                        unit_info,
                                        shulensums,
                                        num_of_chars,
                                        total_length,
                                        timer,
                                        logger,
                                        err);
    }
  }

  if (arguments->with_esa) {
    if (ssar != NULL)
      gt_freeSequentialsuffixarrayreader(&ssar);
  }
  else
    genericindex_delete(generic_index_subject);

  if (had_err) {
    gt_log_log("foo");
    if (shulensums != NULL)
      gt_array2dim_delete(shulensums);
    shulensums = NULL;
  }
  else {
    gt_assert(shulensums != NULL);
    gt_log_log("sum of shulens");
    if (gt_log_enabled()) {
      for (i_idx = 0; i_idx < unit_info->num_of_genomes; i_idx++) {
        fprintf(stderr, "debug: %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)
            fprintf(stderr, "0");
          else
            fprintf(stderr, Formatuint64_t"\t",
                    PRINTuint64_tcast(shulensums[i_idx][j_idx]));
        }
        fprintf(stderr, "\n");
      }
    }
  }
  return shulensums;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r14
movq $0x0, 0x10(%rsp)
testq %r8, %r8
je 0x206df3
movq %r15, %rdi
callq 0x101a9a
testb %al, %al
jne 0x2070bd
testq %rbx, %rbx
je 0x2070b8
cmpb $0x1, 0x2(%r14)
jne 0x206e68
testq %r12, %r12
je 0x206e21
movq 0x2bd0d9(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1be1f3(%rip), %rsi    # 0x3c500c
movq %r12, %rdi
callq 0x1229c8
movq 0x68(%r14), %rdi
xorl %esi, %esi
callq 0x121cfa
movzbl (%r14), %edx
movq %rax, %rdi
movl $0x87, %esi
movq %rbp, %rcx
movq %r15, %r8
callq 0x1ae094
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x206ed7
movq %rax, %rdi
callq 0x1ae549
movq %rax, 0x8(%rsp)
movb $0x1, %al
xorl %r13d, %r13d
jmp 0x206ef0
cmpb $0x0, 0x3(%r14)
je 0x2070c2
testq %r12, %r12
je 0x206e91
movq 0x2bd069(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1be1b1(%rip), %rsi    # 0x3c503a
movq %r12, %rdi
callq 0x1229c8
movq 0x68(%r14), %rdi
xorl %esi, %esi
callq 0x121cfa
movl 0x8(%r14), %r9d
movq %rax, %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
pushq %r15
pushq %rbp
callq 0x1bae8e
addq $0x10, %rsp
movq %rax, %r13
testq %rax, %rax
je 0x206ee5
movq %r13, %rdi
callq 0x1bae6d
movq %rax, 0x8(%rsp)
movb $0x1, %al
jmp 0x206ef0
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
jmp 0x206eee
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
testb %al, %al
je 0x206fab
movq %rbp, 0x20(%rsp)
movq %r12, 0x18(%rsp)
movq (%rbx), %rdi
shlq $0x3, %rdi
leaq 0x1be0e1(%rip), %r12    # 0x3c4ff1
movq %r12, %rsi
movl $0x120, %edx            # imm = 0x120
callq 0x1092b2
movq %rax, %rbp
movq (%rbx), %rdi
imulq %rdi, %rdi
movl $0x8, %esi
movq %r12, %rdx
movl $0x120, %ecx            # imm = 0x120
callq 0x1093ef
movq %rax, (%rbp)
movq (%rbx), %rax
cmpq $0x2, %rax
jb 0x206f6a
leaq (,%rax,8), %rcx
movq (%rbp), %rdx
addq %rcx, %rdx
movl $0x1, %esi
movq %rdx, (%rbp,%rsi,8)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %rax
jne 0x206f5a
cmpb $0x1, 0x2(%r14)
jne 0x206fb5
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x206f91
movq 0x2bcf66(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1be0c0(%rip), %rsi    # 0x3c504c
callq 0x1229c8
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x1af441
jmp 0x20700c
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
jmp 0x20700f
movq 0x28(%rbx), %rdi
callq 0xf02da
movq %rax, %rdi
callq 0xd3713
movl %eax, %r12d
movq %r13, %rdi
callq 0x1bba3e
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x1bba2e
testq %rax, %rax
je 0x2070cc
movl %r12d, %ecx
movq %rax, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
pushq %r15
pushq 0x28(%rsp)
callq 0x33503c
addq $0x10, %rsp
movl %eax, %r15d
cmpb $0x1, 0x2(%r14)
jne 0x20702a
cmpq $0x0, 0x10(%rsp)
je 0x207032
leaq 0x10(%rsp), %rdi
callq 0x1ae1ac
jmp 0x207032
movq %r13, %rdi
callq 0x1bae24
testl %r15d, %r15d
je 0x207077
leaq 0x16e45f(%rip), %rdi    # 0x37549d
xorl %eax, %eax
callq 0x108e02
testq %rbp, %rbp
je 0x20705f
movq (%rbp), %rdi
leaq 0x1bdf9c(%rip), %rsi    # 0x3c4ff1
movl $0x14a, %edx            # imm = 0x14A
callq 0x109670
leaq 0x1bdf8b(%rip), %rsi    # 0x3c4ff1
movq %rbp, %rdi
movl $0x14a, %edx            # imm = 0x14A
callq 0x109670
xorl %ebp, %ebp
jmp 0x207099
testq %rbp, %rbp
je 0x2070c7
leaq 0x1bdfff(%rip), %rdi    # 0x3c5082
xorl %eax, %eax
callq 0x108e02
callq 0x108df6
testb %al, %al
je 0x207099
cmpq $0x0, (%rbx)
jne 0x2070ab
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x80820
jmp 0x207099
callq 0x808fd
callq 0x80775
callq 0x807ae
callq 0x808c4
callq 0x807e7