// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/tools/gt_genomediff.c
// Function: gt_genomediff_runner
static int gt_genomediff_runner(int argc, const char **argv,
                                int parsed_args, void *tool_arguments,
                                GtError *err)
{
  bool mirrored = false;
  int had_err = 0,
      i;
  GtEncseq              *encseq = NULL;
  GtGenomediffArguments *arguments = tool_arguments;
  GtLogger              *logger;
  GtShuUnitFileInfo     *unit_info = NULL;
  GtTimer               *timer = NULL;

  gt_error_check(err);
  gt_assert(arguments);

  logger = gt_logger_new(arguments->verbose,
                         GT_LOGGER_DEFLT_PREFIX,
                         stdout);
  gt_assert(logger);

  for (i = parsed_args; i < argc; i++) {
    gt_str_array_add_cstr(arguments->filenames, argv[i]);
  }

  if (gt_showtime_enabled()) {
    timer = gt_timer_new_with_progress_description("start");
    gt_timer_start(timer);
    gt_assert(timer);
  }

  if (arguments->with_units) {
    gt_logger_log(logger, "unitfile option set, filename is %s\n",
                  gt_str_get(arguments->unitfile));
  }

  if (timer != NULL)
    gt_timer_show_progress(timer, "start shu search", stdout);

  if (gt_str_array_size(arguments->filenames) > 1UL) {
    GtEncseqEncoder *ee = gt_encseq_encoder_new();
    gt_encseq_encoder_set_timer(ee, timer);
    gt_encseq_encoder_set_logger(ee, logger);
    /* kr only makes sense for dna, so we can check this already with ee */
    gt_encseq_encoder_set_input_dna(ee);
    had_err = gt_encseq_encoder_encode(ee, arguments->filenames,
                                       gt_str_get(arguments->indexname), err);
    gt_encseq_encoder_delete(ee);
  }
  else {
    gt_str_append_str(arguments->indexname,
                      gt_str_array_get_str(arguments->filenames, 0));
    if (arguments->with_esa || arguments->with_pck) {
      GtStr *current_line = gt_str_new();
      FILE *prj_fp;
      const char *buffer;
      char **elements = NULL;

      prj_fp = gt_fa_fopen_with_suffix(gt_str_get(arguments->indexname),
                                       GT_PROJECTFILESUFFIX,"rb",err);
      if (prj_fp == NULL)
        had_err = -1;
      while (!had_err && gt_str_read_next_line(current_line, prj_fp) != EOF) {
        buffer = gt_str_get(current_line);
        if (elements != NULL) {
          gt_free(elements[0]);
          gt_free(elements[1]);
        }
        gt_free(elements);
        elements = gt_cstr_split(buffer, '=');
        gt_log_log("%s", elements[0]);
        if (strcmp("mirrored", elements[0]) == 0) {
          gt_log_log("%s", elements[1]);
          if (strcmp("1", elements[1]) == 0) {
            mirrored = true;
            gt_log_log("sequences are treated as mirrored");
          }
        }
        gt_str_reset(current_line);
      }
      gt_str_delete(current_line);
      if (elements != NULL) {
        gt_free(elements[0]);
        gt_free(elements[1]);
      }
      gt_free(elements);
      gt_fa_xfclose(prj_fp);
    }
  }

  if (!had_err) {
    GtEncseqLoader *el = gt_encseq_loader_new_from_options(arguments->loadopts,
                                                           err);
    if (mirrored)
      gt_encseq_loader_mirror(el);
    encseq =
      gt_encseq_loader_load(el, gt_str_get(arguments->indexname), err);
    gt_encseq_loader_delete(el);
  }
  if (encseq == NULL)
    had_err = -1;
  if (!had_err) {
    unit_info = gt_shu_unit_info_new(encseq);
    if (arguments->with_units)
      had_err = gt_shu_unit_file_info_read(arguments->unitfile, unit_info,
                                           logger, err);
  }

  if (!had_err) {
    uint64_t **shusums = NULL;
    if (arguments->with_esa || arguments->with_pck) {
      shusums = gt_genomediff_shulen_sum(arguments, unit_info,
                                         logger, timer, err);
      if (shusums == NULL)
        had_err = -1;
    }
    else {
      const bool doesa = true;
      GenomediffInfo gd_info;
      Suffixeratoroptions sopts;
      sopts.beverbose = arguments->verbose;
      sopts.indexname = arguments->indexname;
      sopts.db = NULL;
      sopts.encopts = NULL;
      sopts.genomediff = true;
      sopts.inputindex = arguments->indexname;
      sopts.loadopts = arguments->loadopts;
      sopts.showprogress = false;
      sopts.idxopts = arguments->idxopts;

      gt_assert(unit_info != NULL);
      gt_array2dim_calloc(shusums, unit_info->num_of_genomes,
                          unit_info->num_of_genomes);
      gd_info.shulensums = shusums;
      gd_info.unit_info = unit_info;
      had_err = gt_runsuffixerator(doesa, &sopts, &gd_info, logger, err);
    }
    if (!had_err && shusums != NULL) {
      had_err = gt_genomediff_kr_calc(shusums, arguments, unit_info,
                                      arguments->with_pck, logger, timer, err);
      gt_array2dim_delete(shusums);
    }
  }

  if (timer != NULL) {
    gt_timer_show_progress_final(timer, stdout);
    gt_timer_delete(timer);
  }
  gt_logger_delete(logger);
  gt_encseq_delete(encseq);
  gt_shu_unit_info_delete(unit_info);

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, %r12
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %rbx
movl %edi, %r14d
testq %r8, %r8
je 0xa9d7b
movq %r12, %rdi
callq 0xfcc32
testb %al, %al
jne 0xaa336
movq %r12, 0x10(%rsp)
testq %r15, %r15
je 0xaa32c
movzbl 0x1(%r15), %edi
movq 0x40f143(%rip), %r13    # 0x4b8ed8
movq (%r13), %rdx
leaq 0x29cb34(%rip), %rsi    # 0x3468d4
callq 0x103e40
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0xaa331
cmpl %r14d, %ebp
jge 0xa9dd3
movslq %ebp, %r12
movslq %r14d, %r14
movq 0x68(%r15), %rdi
movq (%rbx,%r12,8), %rsi
callq 0x11bee9
incq %r12
cmpq %r12, %r14
jne 0xa9dbe
callq 0x119160
testb %al, %al
je 0xa9e02
leaq 0x2f83ae(%rip), %rdi    # 0x3a2191
callq 0x11c986
movq %rax, %r14
movq %rax, %rdi
callq 0x11c9e3
testq %r14, %r14
movq 0x20(%rsp), %r12
jne 0xa9e0a
callq 0x1b5e5
xorl %r14d, %r14d
movq 0x20(%rsp), %r12
cmpb $0x1, 0x4(%r15)
jne 0xa9e2e
movq 0x60(%r15), %rdi
callq 0x11b0a1
leaq 0x2a363f(%rip), %rsi    # 0x34d460
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x103fe1
testq %r14, %r14
je 0xa9e46
movq (%r13), %rdx
leaq 0x2a3ad2(%rip), %rsi    # 0x34d910
movq %r14, %rdi
callq 0x11cc90
movq 0x68(%r15), %rdi
callq 0x11c131
cmpq $0x1, %rax
movq %r14, 0x28(%rsp)
jbe 0xa9eba
callq 0xefd9d
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0xf01c0
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf02fc
movq %rbx, %rdi
callq 0xf0063
movq 0x50(%r15), %rdi
movq 0x68(%r15), %r14
callq 0x11b0a1
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq 0x10(%rsp), %r14
movq %r14, %rcx
callq 0xf030c
movl %eax, %ebp
movq %rbx, %rdi
callq 0xf018f
testl %ebp, %ebp
jne 0xaa162
jmp 0xaa051
movq 0x50(%r15), %rbx
movq 0x68(%r15), %rdi
xorl %esi, %esi
callq 0x11bfee
movq %rbx, %rdi
movq %rax, %rsi
callq 0x11adc1
cmpb $0x0, 0x2(%r15)
movq 0x10(%rsp), %r14
jne 0xa9eeb
cmpb $0x0, 0x3(%r15)
je 0xaa051
callq 0x11ac6c
movq %rax, %rbp
movq 0x50(%r15), %rdi
callq 0x11b0a1
leaq 0x2a3a1e(%rip), %rsi    # 0x34d921
leaq 0x2fb813(%rip), %rdx    # 0x3a571d
leaq 0x2a3655(%rip), %rcx    # 0x34d566
movq %rax, %rdi
movl $0x12d, %r8d            # imm = 0x12D
movq %r14, %r9
callq 0xfcf97
movq %rax, %r13
testq %rax, %rax
je 0xaa065
movq %r15, 0x30(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x11b1ff
cmpl $-0x1, %eax
je 0xaa073
movq $0x0, 0x18(%rsp)
leaq 0x2a360f(%rip), %r15    # 0x34d566
leaq 0x31eb4b(%rip), %r14    # 0x3c8aa9
xorl %ebx, %ebx
movq %rbp, 0x38(%rsp)
movq %r13, %r12
movq %r14, %r13
movq %rbp, %rdi
callq 0x11b0a1
movq %rax, %r14
testq %rbx, %rbx
je 0xa9f9c
movq (%rbx), %rdi
movq %r15, %rsi
movl $0x133, %edx            # imm = 0x133
callq 0x1045eb
movq 0x8(%rbx), %rdi
movq %r15, %rsi
movl $0x134, %edx            # imm = 0x134
callq 0x1045eb
movq %rbx, %rdi
movq %r15, %rbp
movq %r15, %rsi
movl $0x136, %edx            # imm = 0x136
callq 0x1045eb
movq %r14, %rdi
movl $0x3d, %esi
callq 0xe4168
movq %rax, %rbx
movq (%rax), %rsi
movq %r13, %r14
movq %r13, %rdi
xorl %eax, %eax
callq 0x103d72
movq (%rbx), %rsi
leaq 0x2a3966(%rip), %rdi    # 0x34d93f
callq 0x17a40
testl %eax, %eax
je 0xa9fef
movq %r12, %r13
movq %rbp, %r15
movq 0x38(%rsp), %rbp
jmp 0xaa033
movq 0x8(%rbx), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x103d72
movq 0x8(%rbx), %rcx
movzbl (%rcx), %eax
subl $0x31, %eax
movq %r12, %r13
jne 0xaa010
movzbl 0x1(%rcx), %eax
negl %eax
movq %rbp, %r15
testl %eax, %eax
movq 0x38(%rsp), %rbp
jne 0xaa033
leaq 0x2a3901(%rip), %rdi    # 0x34d926
xorl %eax, %eax
callq 0x103d72
movb $0x1, %al
movq %rax, 0x18(%rsp)
movq %rbp, %rdi
callq 0x11b132
movq %rbp, %rdi
movq %r13, %rsi
callq 0x11b1ff
cmpl $-0x1, %eax
jne 0xa9f65
jmp 0xaa07e
movq 0x38(%r15), %rdi
movq %r14, %rsi
callq 0xf2311
movq %rax, %rbx
jmp 0xaa10d
movq %rbp, %rdi
callq 0x11bdbf
xorl %ebp, %ebp
xorl %ebx, %ebx
jmp 0xaa0c6
movq $0x0, 0x18(%rsp)
xorl %ebx, %ebx
movq %rbp, %rdi
callq 0x11bdbf
testq %rbx, %rbx
movq 0x20(%rsp), %r12
je 0xaa0ba
movq (%rbx), %rdi
leaq 0x2a34cc(%rip), %r14    # 0x34d566
movq %r14, %rsi
movl $0x144, %edx            # imm = 0x144
callq 0x1045eb
movq 0x8(%rbx), %rdi
movq %r14, %rsi
movl $0x145, %edx            # imm = 0x145
callq 0x1045eb
jmp 0xaa0bc
xorl %ebx, %ebx
movq 0x18(%rsp), %rbp
movq 0x30(%rsp), %r15
leaq 0x2a3499(%rip), %rsi    # 0x34d566
movq %rbx, %rdi
movl $0x147, %edx            # imm = 0x147
callq 0x1045eb
movq %r13, %rdi
callq 0xfd09a
testq %r13, %r13
je 0xaa1a6
movq 0x38(%r15), %rdi
movq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0xf2311
movq %rax, %rbx
testb $0x1, %bpl
je 0xaa10d
movq %rbx, %rdi
callq 0xf237b
movq 0x50(%r15), %rdi
callq 0x11b0a1
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xef129
movq %rax, %rbp
movq %rbx, %rdi
callq 0xefbe3
testq %rbp, %rbp
je 0xaa162
movq %rbp, %rdi
callq 0x1fe855
movq %rax, %r13
cmpb $0x1, 0x4(%r15)
jne 0xaa16c
movq 0x60(%r15), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
callq 0x1fe498
testl %eax, %eax
je 0xaa16c
movl %eax, %ebx
jmp 0xaa1b0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
jmp 0xaa1ae
cmpb $0x0, 0x2(%r15)
jne 0xaa17e
cmpb $0x1, 0x3(%r15)
jne 0xaa200
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq 0x28(%rsp), %rcx
movq 0x10(%rsp), %r8
callq 0x1fd6e0
movq %rax, %r14
xorl %ebx, %ebx
cmpq $0x1, %rax
sbbl %ebx, %ebx
jmp 0xaa2c9
xorl %r13d, %r13d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movq 0x28(%rsp), %r14
testq %r14, %r14
je 0xaa1d4
movq 0x40ed17(%rip), %rax    # 0x4b8ed8
movq (%rax), %rsi
movq %r14, %rdi
callq 0x11cf39
movq %r14, %rdi
callq 0x11d054
movq %r12, %rdi
callq 0x1040e0
movq %rbp, %rdi
callq 0xea375
movq %r13, %rdi
callq 0x1fe810
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb 0x1(%r15), %al
movb %al, 0x40(%rsp)
movq 0x50(%r15), %rax
movq %rax, 0x60(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x70(%rsp)
movq %rcx, 0x48(%rsp)
movq %rax, 0x68(%rsp)
movw $0x100, 0x41(%rsp)      # imm = 0x100
movups 0x38(%r15), %xmm0
movups %xmm0, 0x50(%rsp)
testq %r13, %r13
je 0xaa33b
movq (%r13), %rdi
shlq $0x3, %rdi
leaq 0x2a331b(%rip), %rbx    # 0x34d566
movq %rbx, %rsi
movl $0x176, %edx            # imm = 0x176
callq 0x104226
movq %rax, %r14
movq (%r13), %rdi
imulq %rdi, %rdi
movl $0x8, %esi
movq %rbx, %rdx
movl $0x176, %ecx            # imm = 0x176
callq 0x10436a
movq %rax, (%r14)
movq (%r13), %rax
cmpq $0x2, %rax
jb 0xaa2a4
leaq (,%rax,8), %rcx
movq (%r14), %rdx
addq %rcx, %rdx
movl $0x1, %esi
movq %rdx, (%r14,%rsi,8)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %rax
jne 0xaa295
leaq 0x78(%rsp), %rdx
movq %r14, 0x8(%rdx)
movq %r13, (%rdx)
leaq 0x40(%rsp), %rsi
movl $0x1, %edi
movq %r12, %rcx
movq 0x10(%rsp), %r8
callq 0x1f0370
movl %eax, %ebx
testl %ebx, %ebx
jne 0xaa1b0
testq %r14, %r14
je 0xaa1b0
movzbl 0x3(%r15), %ecx
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %r8
movq 0x28(%rsp), %r9
callq 0x1fe12f
movl %eax, %ebx
movq (%r14), %rdi
leaq 0x2a325c(%rip), %r15    # 0x34d566
movq %r15, %rsi
movl $0x17e, %edx            # imm = 0x17E
callq 0x1045eb
movq %r14, %rdi
movq %r15, %rsi
movl $0x17e, %edx            # imm = 0x17E
callq 0x1045eb
jmp 0xaa1b0
callq 0x1b657
callq 0x1b61e
callq 0x1b573
callq 0x1b5ac