// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/tools/gt_sain.c
// Function: gt_sain_runner
static int gt_sain_runner(int argc, GT_UNUSED const char **argv,
                          int parsed_args, void *tool_arguments, GtError *err)
{
  GtSainArguments *arguments = tool_arguments;
  int had_err = 0;

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

  gt_assert (argc >= parsed_args);
  if (parsed_args < argc)
  {
    gt_error_set(err,"superfluous arguments");
    had_err = -1;
  } else
  {
    GtUsainindextype *suftab = NULL;

    if (gt_str_length(arguments->encseqfile) > 0)
    {
      GtEncseqLoader *el = gt_encseq_loader_new();
      GtEncseq *encseq
        = gt_encseq_loader_load(el,gt_str_get(arguments->encseqfile),err);
      if (encseq == NULL)
      {
        had_err = -1;
      } else
      {
        if (gt_sain_checkmaxsequencelength(gt_encseq_total_length(encseq),true,
                                           err)
                       != 0)
        {
          had_err = -1;
        } else
        {
          if (!gt_alphabet_is_dna(gt_encseq_alphabet(encseq)) &&
              (arguments->readmode == GT_READMODE_COMPL ||
               arguments->readmode == GT_READMODE_REVCOMPL))
          {
            gt_error_set(err,"option -dir cpl and -dir rcl is only "
                             "possible for DNA sequences");
            had_err = -1;
          }
        }
        if (!had_err)
        {
          GtSainTimerandLogger *tl
            = gt_sain_timer_logger_new(arguments->verbose);
          suftab = gt_sain_encseq_sortsuffixes(encseq,
                                               arguments->readmode,
                                               arguments->icheck,
                                               arguments->fcheck,
                                               tl->logger,
                                               tl->timer);
          gt_sain_timer_logger_delete(tl);
          gt_free(suftab);
        }
      }
      gt_encseq_delete(encseq);
      gt_encseq_loader_delete(el);
    }
    if (!had_err && (gt_str_length(arguments->plainseqfile) > 0 ||
                     gt_str_length(arguments->fastafile) > 0))
    {
      GtUchar *filecontents;
      size_t len;
      const char *inputfile = gt_str_length(arguments->plainseqfile) > 0
                                ? gt_str_get(arguments->plainseqfile)
                                : gt_str_get(arguments->fastafile);

      if (arguments->dommap)
      {
        filecontents = gt_fa_mmap_read (inputfile,&len,err);
      } else
      {
        filecontents = gt_fa_heap_read (inputfile,&len,err);
      }
      if (filecontents == NULL)
      {
        had_err = -1;
      } else
      {
        GtBareEncseq *bare_encseq = NULL;

        if (!had_err)
        {
          if (gt_str_length(arguments->fastafile) > 0)
          {
            GtAlphabet *alphabet = gt_sain_getalphabet(arguments,err);

            if (alphabet == NULL)
            {
              had_err = -1;
            } else
            {
              bare_encseq = gt_bare_encseq_parse_new(filecontents,len,alphabet,
                                                     err);
              if (bare_encseq == NULL)
              {
                had_err = -1;
              }
            }
            gt_alphabet_delete(alphabet);
          }
        }
        if (!had_err &&
            gt_sain_checkmaxsequencelength((GtUword) len,false,err) != 0)
        {
          had_err = -1;
        }
        if (!had_err)
        {
          GtSainTimerandLogger *tl
            = gt_sain_timer_logger_new(arguments->verbose);
          if (gt_str_length(arguments->plainseqfile) > 0)
          {
            suftab = gt_sain_plain_sortsuffixes(filecontents,
                                                (GtUword) len,
                                                arguments->icheck,
                                                arguments->fcheck,
                                                tl->logger,
                                                tl->timer);
          } else
          {
            gt_assert(gt_str_length(arguments->fastafile) > 0 &&
                      bare_encseq != NULL);
            if (arguments->readmode != GT_READMODE_FORWARD)
            {
              bare_encseq_convert(bare_encseq,
                                  GT_ISDIRREVERSE(arguments->readmode)
                                    ? false : true,
                                  GT_ISDIRCOMPLEMENT(arguments->readmode)
                                    ? false : true);
            }
            suftab = gt_sain_bare_encseq_sortsuffixes(bare_encseq,
                                                      arguments->readmode,
                                                      arguments->icheck,
                                                      arguments->fcheck,
                                                      tl->logger,
                                                      tl->timer);
          }
          if (arguments->suftabout)
          {
            char *inputfile_basename = gt_basename(inputfile);
            FILE *fpout = gt_fa_fopen_with_suffix(inputfile_basename,
                                                  ".suf","wb",err);
            if (fpout == NULL)
            {
              had_err = -1;
            } else
            {
              GtUword totallength;
              if (bare_encseq != NULL)
              {
                totallength = gt_bare_encseq_total_length(bare_encseq);
              } else
              {
                totallength = len;
              }
              gt_xfwrite(suftab,sizeof *suftab,totallength+1,fpout);
              gt_fa_fclose(fpout);
            }
            gt_free(inputfile_basename);
          }
          if (arguments->tistabout)
          {
            char *inputfile_basename = gt_basename(inputfile);
            FILE *fpout = gt_fa_fopen_with_suffix(inputfile_basename,
                                                  ".tis","wb",err);
            if (fpout == NULL)
            {
              had_err = -1;
            } else
            {
              GtUword totallength;
              const GtUchar *sequence;

              if (bare_encseq != NULL)
              {
                totallength = gt_bare_encseq_total_length(bare_encseq);
                sequence = gt_bare_encseq_sequence(bare_encseq);
              } else
              {
                totallength = len;
                sequence = filecontents;
              }
              gt_xfwrite(sequence,sizeof *sequence,totallength,fpout);
              gt_fa_fclose(fpout);
            }
            gt_free(inputfile_basename);
          }
          if (!had_err && arguments->outlcptab)
          {
            unsigned int *lcptab;
            GtUword maxlcp = 0, partwidth, totallength;
            bool withspecial;

            if (gt_str_length(arguments->plainseqfile) > 0)
            {
              withspecial = false;
              totallength = (GtUword) len;
              partwidth = totallength;
            } else
            {
              withspecial = true;
              totallength = gt_bare_encseq_total_length(bare_encseq);
              partwidth = totallength -
                          gt_bare_encseq_specialcharacters(bare_encseq);
            }
            if (tl->timer != NULL && gt_logger_enabled(tl->logger))
            {
              gt_timer_show_progress(tl->timer,"compute lcp-value",stdout);
            }
            if (arguments->lcpkasai)
            {
              lcptab = gt_plain_lcp13_kasai(&maxlcp,
                                            filecontents,
                                            withspecial,
                                            partwidth,
                                            totallength,
                                            suftab);
            } else
            {
              lcptab = gt_plain_lcp_phialgorithm(false,
                                                 &maxlcp,
                                                 filecontents,
                                                 withspecial,
                                                 partwidth,
                                                 totallength,
                                                 suftab);
            }
            gt_logger_log(tl->logger,"maxlcp="GT_WU,maxlcp);
            gt_free(lcptab);
          }
          gt_free(suftab);
          gt_sain_timer_logger_delete(tl);
        }
        gt_bare_encseq_delete(bare_encseq);
      }
      if (arguments->dommap)
      {
        gt_fa_xmunmap(filecontents);
      } else
      {
        gt_free(filecontents);
      }
    }
  }
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %r15
movq %rcx, %rbx
movl %edx, %ebp
movl %edi, %r14d
testq %r8, %r8
je 0x416f1
movq %r15, %rdi
callq 0x89eb7
testb %al, %al
jne 0x41d9d
testq %rbx, %rbx
je 0x41d41
cmpl %ebp, %r14d
jl 0x41d6f
pushq $-0x1
popq %rbp
jle 0x4171e
leaq 0x2ae88a(%rip), %rsi    # 0x2eff99
movq %r15, %rdi
xorl %eax, %eax
callq 0x89dbb
jmp 0x41d30
movq 0x10(%rbx), %rdi
callq 0xad289
testq %rax, %rax
je 0x4180c
callq 0x791cd
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0xad1fa
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x7921d
movq %rax, %r12
testq %rax, %rax
je 0x41771
movq %r12, %rdi
callq 0x7055e
pushq $0x1
popq %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x1a5088
testl %eax, %eax
je 0x41786
movq %r12, %rdi
callq 0x735fd
movq %r14, %rdi
callq 0x79f01
jmp 0x41d30
movq %r12, %rdi
callq 0x754dd
movq %rax, %rdi
callq 0x5741b
testb %al, %al
jne 0x417b8
movl 0x38(%rbx), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x417b8
leaq 0x2b42c6(%rip), %rsi    # 0x2f5a72
movq %r15, %rdi
xorl %eax, %eax
callq 0x89dbb
jmp 0x41771
movzbl 0x4(%rbx), %edi
callq 0x41e62
movq %rax, %r13
movl 0x38(%rbx), %esi
movzbl (%rbx), %edx
movzbl 0x1(%rbx), %ecx
movq (%rax), %r9
movq 0x8(%rax), %r8
movq %r12, %rdi
callq 0x1a27fa
movq %rax, %rbp
movq %r13, %rdi
callq 0x41ee2
leaq 0x2b4071(%rip), %rsi    # 0x2f5860
movq %rbp, %rdi
movl $0x15d, %edx            # imm = 0x15D
callq 0x936f9
movq %r12, %rdi
callq 0x735fd
movq %r14, %rdi
callq 0x79f01
movq 0x18(%rbx), %rdi
callq 0xad289
testq %rax, %rax
jne 0x4182c
movq 0x20(%rbx), %rdi
callq 0xad289
testq %rax, %rax
je 0x41932
movq 0x18(%rbx), %rdi
callq 0xad289
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
movq 0x18(%rbx,%rcx,8), %rdi
callq 0xad1fa
movq %rax, %r13
cmpb $0x1, 0x5(%rbx)
jne 0x4186e
leaq 0x2b4009(%rip), %rdx    # 0x2f5860
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
movl $0x16e, %ecx            # imm = 0x16E
movq %r15, %r8
callq 0x8b049
jmp 0x4188a
leaq 0x2b3feb(%rip), %rdx    # 0x2f5860
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
movl $0x171, %ecx            # imm = 0x171
movq %r15, %r8
callq 0x8b6c2
movq %rax, %r14
testq %rax, %rax
je 0x418b2
movq 0x20(%rbx), %rdi
callq 0xad289
testq %rax, %rax
je 0x418ba
cmpb $0x1, 0x6(%rbx)
movq %r13, 0x8(%rsp)
jne 0x418bf
callq 0x56967
jmp 0x418ce
pushq $-0x1
popq %rbp
jmp 0x41d0c
xorl %r12d, %r12d
jmp 0x4190c
cmpb $0x1, 0x7(%rbx)
jne 0x41979
callq 0x56a5d
movq %rax, %rbp
testq %rax, %rax
je 0x41dd5
movq 0x10(%rsp), %rsi
movq %r14, %rdi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x13395f
movq %rax, %r13
testq %rax, %rax
setne %r12b
movq %rbp, %rdi
callq 0x568b5
testb %r12b, %r12b
je 0x41927
movq %r13, %r12
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1a5088
testl %eax, %eax
je 0x41939
pushq $-0x1
popq %rbp
jmp 0x41d04
pushq $-0x1
popq %rbp
movq %r13, %r12
jmp 0x41d04
xorl %ebp, %ebp
jmp 0x41d30
movzbl 0x4(%rbx), %edi
callq 0x41e62
movq %rax, %rbp
movq 0x18(%rbx), %rdi
callq 0xad289
testq %rax, %rax
movq %rbp, 0x28(%rsp)
je 0x419a7
movq 0x10(%rsp), %rsi
movzbl (%rbx), %edx
movzbl 0x1(%rbx), %ecx
movq (%rbp), %r9
movq 0x8(%rbp), %r8
movq %r14, %rdi
callq 0x1a4f9d
jmp 0x41a07
movq 0x30(%rbx), %rdi
callq 0xad289
testq %rax, %rax
je 0x41a70
movq 0x30(%rbx), %rdi
callq 0xad1fa
movq %rax, %rdi
movq %r15, %rsi
callq 0x5773d
movq %rax, %rbp
jmp 0x41ab4
movq 0x20(%rbx), %rdi
callq 0xad289
testq %r12, %r12
je 0x41e03
testq %rax, %rax
je 0x41e03
movl 0x38(%rbx), %esi
testl %esi, %esi
je 0x419f0
xorl %eax, %eax
cmpl $0x1, %esi
je 0x419d7
cmpl $0x3, %esi
je 0x419d7
movb $0x1, %al
addl $-0x4, %esi
xorl %edx, %edx
cmpl $-0x2, %esi
setb %dl
movzbl %al, %esi
movq %r12, %rdi
callq 0x133fbb
movl 0x38(%rbx), %esi
movzbl (%rbx), %edx
movzbl 0x1(%rbx), %ecx
movq (%rbp), %r9
movq 0x8(%rbp), %r8
movq %r12, %rdi
callq 0x1a4e59
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
cmpb $0x1, 0x8(%rbx)
jne 0x41b3b
movq %r13, %rdi
callq 0x5a384
leaq 0x2e5b46(%rip), %rsi    # 0x32756d
leaq 0x2b40c3(%rip), %rdx    # 0x2f5af1
leaq 0x2b3e2b(%rip), %rcx    # 0x2f5860
movq %rax, 0x20(%rsp)
movq %rax, %rdi
movl $0x1b7, %r8d            # imm = 0x1B7
movq %r15, %r9
callq 0x8a449
testq %rax, %rax
je 0x41afe
movq %rax, %rbp
testq %r12, %r12
je 0x41b03
movq %r12, %rdi
callq 0x133da4
movq %rax, %rdx
jmp 0x41b08
callq 0xae154
movq %rax, %r12
movq 0x20(%rbx), %rdi
callq 0xad289
testq %rax, %rax
je 0x41e31
movq 0x20(%rbx), %rdi
callq 0xad1fa
movq %r12, %rdi
movq %rax, %rsi
callq 0xae22f
movq %r12, %rdi
movq %r15, %rsi
callq 0x5674e
movq %rax, %rbp
movq %r12, %rdi
callq 0xae662
testq %rbp, %rbp
je 0x41ae9
movq %rbp, %rdi
callq 0x5741b
testb %al, %al
jne 0x418da
movl 0x38(%rbx), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x418da
leaq 0x2b3f93(%rip), %rsi    # 0x2f5a72
movq %r15, %rdi
xorl %eax, %eax
callq 0x89dbb
movq %rbp, %rdi
callq 0x568b5
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r12d, %r12d
jmp 0x418f7
pushq $-0x1
popq %rbp
jmp 0x41b25
movq 0x10(%rsp), %rdx
incq %rdx
pushq $0x4
popq %rsi
movq 0x18(%rsp), %rdi
movq %rbp, %rcx
callq 0xb302c
movq %rbp, %rdi
callq 0x8a4fd
xorl %ebp, %ebp
leaq 0x2b3d34(%rip), %rsi    # 0x2f5860
movq 0x20(%rsp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
callq 0x936f9
cmpb $0x1, 0x9(%rbx)
jne 0x41bd6
movq %r13, %rdi
callq 0x5a384
movq %rax, %r13
leaq 0x2b3f9d(%rip), %rsi    # 0x2f5af4
leaq 0x2b3f93(%rip), %rdx    # 0x2f5af1
leaq 0x2b3cfb(%rip), %rcx    # 0x2f5860
movq %rax, %rdi
movl $0x1ce, %r8d            # imm = 0x1CE
movq %r15, %r9
callq 0x8a449
testq %rax, %rax
je 0x41ba2
movq %rax, %r15
testq %r12, %r12
je 0x41ba7
movq %r12, %rdi
callq 0x133da4
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x133d5b
movq 0x8(%rsp), %rdx
movq %rax, %rdi
jmp 0x41baf
pushq $-0x1
popq %rbp
jmp 0x41bc2
movq 0x10(%rsp), %rdx
movq %r14, %rdi
pushq $0x1
popq %rsi
movq %r15, %rcx
callq 0xb302c
movq %r15, %rdi
callq 0x8a4fd
leaq 0x2b3c97(%rip), %rsi    # 0x2f5860
movq %r13, %rdi
movl $0x1e3, %edx            # imm = 0x1E3
callq 0x936f9
testl %ebp, %ebp
jne 0x41ce4
cmpb $0x1, 0x2(%rbx)
jne 0x41ce4
andq $0x0, 0x30(%rsp)
movq 0x18(%rbx), %rdi
callq 0xad289
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x41c0d
movq 0x10(%rsp), %r13
movq %r13, 0x8(%rsp)
jmp 0x41c28
movq %r12, %rdi
callq 0x133da4
movq %rax, %r13
movq %r12, %rdi
callq 0x133e7b
movq %r13, 0x8(%rsp)
subq %rax, %r13
movq 0x28(%rsp), %r15
cmpq $0x0, (%r15)
je 0x41c59
movq 0x8(%r15), %rdi
callq 0x92c18
testb %al, %al
je 0x41c59
movq (%r15), %rdi
movq 0x3f6266(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x2b3ea5(%rip), %rsi    # 0x2f5af9
callq 0xaf86f
cmpb $0x1, 0x3(%rbx)
jne 0x41c86
xorl %edx, %edx
cmpq $0x0, 0x20(%rsp)
sete %dl
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rcx
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
callq 0x19d93f
jmp 0x41cb1
xorl %ecx, %ecx
cmpq $0x0, 0x20(%rsp)
sete %cl
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %rsi
xorl %edi, %edi
movq %r14, %rdx
movq %r13, %r8
movq 0x8(%rsp), %r9
callq 0x19db09
movq %rax, %r15
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x30(%rsp), %rdx
leaq 0x2b3e42(%rip), %rsi    # 0x2f5b0b
xorl %eax, %eax
callq 0x92e71
leaq 0x2b3b89(%rip), %rsi    # 0x2f5860
movq %r15, %rdi
movl $0x20e, %edx            # imm = 0x20E
callq 0x936f9
leaq 0x2b3b75(%rip), %rsi    # 0x2f5860
movq 0x18(%rsp), %rdi
movl $0x210, %edx            # imm = 0x210
callq 0x936f9
movq 0x28(%rsp), %rdi
callq 0x41ee2
movq %r12, %rdi
callq 0x13371c
cmpb $0x1, 0x5(%rbx)
jne 0x41d1c
movq %r14, %rdi
callq 0x8b9fa
jmp 0x41d30
leaq 0x2b3b3d(%rip), %rsi    # 0x2f5860
movq %r14, %rdi
movl $0x21a, %edx            # imm = 0x21A
callq 0x936f9
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3f6220(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2a32c1(%rip), %rsi    # 0x2e5013
leaq 0x2a4513(%rip), %rdx    # 0x2e626c
leaq 0x2b3cef(%rip), %rcx    # 0x2f5a4f
leaq 0x2b3af9(%rip), %r8     # 0x2f5860
movl $0x12d, %r9d            # imm = 0x12D
jmp 0x41dc9
movq 0x3f61f2(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2a3293(%rip), %rsi    # 0x2e5013
leaq 0x2b3cd7(%rip), %rdx    # 0x2f5a5e
leaq 0x2b3cc1(%rip), %rcx    # 0x2f5a4f
leaq 0x2b3acb(%rip), %r8     # 0x2f5860
movl $0x12f, %r9d            # imm = 0x12F
jmp 0x41dc9
movq 0x3f61c4(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2a3265(%rip), %rsi    # 0x2e5013
leaq 0x2a340a(%rip), %rdx    # 0x2e51bf
leaq 0x2b3c93(%rip), %rcx    # 0x2f5a4f
leaq 0x2b3a9d(%rip), %r8     # 0x2f5860
movl $0x12c, %r9d            # imm = 0x12C
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x3f618c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2a322d(%rip), %rsi    # 0x2e5013
leaq 0x3021cc(%rip), %rdx    # 0x343fb9
leaq 0x2b3d6c(%rip), %rcx    # 0x2f5b60
leaq 0x2b3a65(%rip), %r8     # 0x2f5860
movl $0x122, %r9d            # imm = 0x122
jmp 0x41dc9
movq 0x3f615e(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2a31ff(%rip), %rsi    # 0x2e5013
leaq 0x2b3c97(%rip), %rdx    # 0x2f5ab2
leaq 0x2b3c2d(%rip), %rcx    # 0x2f5a4f
leaq 0x2b3a37(%rip), %r8     # 0x2f5860
movl $0x1a3, %r9d            # imm = 0x1A3
jmp 0x41dc9
movq 0x3f6130(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2a31d1(%rip), %rsi    # 0x2e5013
leaq 0x2b3cef(%rip), %rdx    # 0x2f5b38
leaq 0x2b3d10(%rip), %rcx    # 0x2f5b60
leaq 0x2b3a09(%rip), %r8     # 0x2f5860
movl $0x108, %r9d            # imm = 0x108
jmp 0x41dc9