// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %r8, %r12
movq %rcx, %r14
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r15
andq $0x0, 0x20(%rsp)
testq %r8, %r8
je 0x1b0e38
movq %r12, %rdi
callq 0x89eb7
testb %al, %al
jne 0x1b11ac
testq %rbx, %rbx
je 0x1b117b
cmpb $0x1, 0x2(%r15)
pushq $-0x1
popq %r13
movq %r14, 0x18(%rsp)
movq %rbp, 0x30(%rsp)
jne 0x1b0edd
testq %r14, %r14
je 0x1b0e78
movq 0x28704a(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1aaf7e(%rip), %rsi    # 0x35bdee
movq %r14, %rdi
callq 0xaf86f
movq 0x68(%r15), %rdi
movq $0x0, 0x8(%rsp)
xorl %esi, %esi
callq 0xae386
movzbl (%r15), %edx
movq %rax, %rdi
movl $0x87, %esi
movq %rbp, %rcx
movq %r12, %r8
callq 0x1516ac
movq %rax, 0x20(%rsp)
movl $0x0, %edi
movl $0x0, %r14d
testq %rax, %rax
je 0x1b1062
movq %rax, %rbp
movq %rax, %rdi
callq 0x151c21
movq %rax, %r13
movq $0x0, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
jmp 0x1b0f67
cmpb $0x0, 0x3(%r15)
je 0x1b11dd
testq %r14, %r14
je 0x1b0f06
movq 0x286fbc(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1aaf1e(%rip), %rsi    # 0x35be1c
movq %r14, %rdi
callq 0xaf86f
movq 0x68(%r15), %rdi
movq $0x0, 0x8(%rsp)
xorl %esi, %esi
callq 0xae386
movl 0x8(%r15), %r9d
pushq $0x1
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
movl %edx, %r8d
pushq %r12
pushq %rbp
callq 0x15fd30
addq $0x10, %rsp
movl $0x0, %edi
movl $0x0, %r14d
testq %rax, %rax
je 0x1b1062
movq %rax, %rbp
movq %rax, %rdi
callq 0x15fcad
movq %rax, %r13
movq $0x0, 0x8(%rsp)
movq %rbp, 0x10(%rsp)
movq (%rbx), %rdi
shlq $0x3, %rdi
leaq 0x1aae5e(%rip), %rbp    # 0x35bdd3
movq %rbp, %rsi
movl $0x120, %edx            # imm = 0x120
callq 0x93160
movq %rax, %r14
movq (%rbx), %rdi
imulq %rdi, %rdi
pushq $0x8
popq %rsi
movq %rbp, %rdx
movl $0x120, %ecx            # imm = 0x120
callq 0x9334a
movq %rax, (%r14)
movq (%rbx), %rax
pushq $0x1
popq %rcx
leaq (,%rax,8), %rdx
cmpq %rax, %rcx
jae 0x1b0fc3
movq -0x8(%r14,%rcx,8), %rsi
addq %rdx, %rsi
movq %rsi, (%r14,%rcx,8)
incq %rcx
jmp 0x1b0fad
cmpb $0x1, 0x2(%r15)
jne 0x1b1002
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1b0fea
movq 0x286ed5(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1aae49(%rip), %rsi    # 0x35be2e
callq 0xaf86f
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
movq %r12, %r8
callq 0x152ce4
jmp 0x1b105a
movq 0x28(%rbx), %rdi
callq 0x754dd
movq %rax, %rdi
callq 0x56c8e
movl %eax, %ebp
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x160aa3
movq %rax, 0x28(%rsp)
movq %r13, %rdi
callq 0x160a60
testq %rax, %rax
je 0x1b1239
movl %ebp, %ecx
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq 0x28(%rsp), %r8
movq 0x18(%rsp), %r9
pushq %r12
pushq 0x38(%rsp)
callq 0x2cbcdc
popq %rcx
popq %rdx
movl %eax, %r13d
movq 0x10(%rsp), %rdi
cmpb $0x1, 0x2(%r15)
jne 0x1b107d
cmpq $0x0, 0x8(%rsp)
je 0x1b1082
leaq 0x20(%rsp), %rdi
callq 0x1517e5
jmp 0x1b1082
callq 0x15fc68
testl %r13d, %r13d
je 0x1b10ca
leaq 0x15b49f(%rip), %rdi    # 0x30c52d
xorl %eax, %eax
callq 0x92a82
testq %r14, %r14
je 0x1b10ae
movq (%r14), %rdi
leaq 0x1aad2f(%rip), %rsi    # 0x35bdd3
movl $0x14a, %edx            # imm = 0x14A
callq 0x936f9
leaq 0x1aad1e(%rip), %rsi    # 0x35bdd3
movq %r14, %rdi
movl $0x14a, %edx            # imm = 0x14A
callq 0x936f9
xorl %r14d, %r14d
jmp 0x1b1169
testq %r14, %r14
je 0x1b120b
leaq 0x1aad8a(%rip), %rdi    # 0x35be64
xorl %eax, %eax
callq 0x92a82
callq 0x92a76
testb %al, %al
je 0x1b1169
movq 0x286e77(%rip), %r12    # 0x437f68
pushq $0x30
popq %rbp
xorl %r15d, %r15d
cmpq (%rbx), %r15
jae 0x1b1169
movq (%r12), %r13
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0xae386
movq %r13, %rdi
leaq 0x1aad5d(%rip), %rsi    # 0x35be73
movq %rax, %rdx
xorl %eax, %eax
callq 0x17a50
xorl %r13d, %r13d
cmpq (%rbx), %r13
jae 0x1b1158
movq (%r12), %rsi
cmpq %r13, %r15
jne 0x1b113d
movl %ebp, %edi
callq 0x17930
incq %r13
jmp 0x1b1123
movq (%r14,%r15,8), %rax
movq (%rax,%r13,8), %rdx
movq %rsi, %rdi
leaq 0x19aa59(%rip), %rsi    # 0x34bba8
xorl %eax, %eax
callq 0x17a50
jmp 0x1b1138
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0x17930
incq %r15
jmp 0x1b10f7
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x286de6(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x133e87(%rip), %rsi    # 0x2e5013
leaq 0x13c308(%rip), %rdx    # 0x2ed49b
leaq 0x1aac20(%rip), %rcx    # 0x35bdba
leaq 0x1aac32(%rip), %r8     # 0x35bdd3
movl $0xf4, %r9d
jmp 0x1b1265
movq 0x286db5(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x133e56(%rip), %rsi    # 0x2e5013
leaq 0x133ffb(%rip), %rdx    # 0x2e51bf
leaq 0x1aabef(%rip), %rcx    # 0x35bdba
leaq 0x1aac01(%rip), %r8     # 0x35bdd3
movl $0xf3, %r9d
jmp 0x1b1265
movq 0x286d84(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x133e25(%rip), %rsi    # 0x2e5013
leaq 0x1aac13(%rip), %rdx    # 0x35be08
leaq 0x1aabbe(%rip), %rcx    # 0x35bdba
leaq 0x1aabd0(%rip), %r8     # 0x35bdd3
movl $0x109, %r9d            # imm = 0x109
jmp 0x1b1265
movq 0x286d56(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x133df7(%rip), %rsi    # 0x2e5013
leaq 0x1aac2e(%rip), %rdx    # 0x35be51
leaq 0x1aab90(%rip), %rcx    # 0x35bdba
leaq 0x1aaba2(%rip), %r8     # 0x35bdd3
movl $0x14e, %r9d            # imm = 0x14E
jmp 0x1b1265
movq 0x286d28(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x133dc9(%rip), %rsi    # 0x2e5013
leaq 0x1aabeb(%rip), %rdx    # 0x35be3c
leaq 0x1aab62(%rip), %rcx    # 0x35bdba
leaq 0x1aab74(%rip), %r8     # 0x35bdd3
movl $0x133, %r9d            # imm = 0x133
xorl %eax, %eax
callq 0x17a50
callq 0x17390