// File: /workspace/github_c_makefile_star2_O1/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 0xbfc92
movq %r15, %rdi
callq 0x101a9a
testb %al, %al
jne 0xc0338
testq %rbx, %rbx
je 0xc032e
cmpl %ebp, %r14d
jl 0xc0333
jle 0xbfcb9
leaq 0x299314(%rip), %rsi    # 0x358fc1
movq %r15, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0xbfd1e
movq 0x10(%rbx), %rdi
callq 0x120d4c
testq %rax, %rax
je 0xbfdba
callq 0xf36ef
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x120d23
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0xf374b
movq %rax, %r12
testq %rax, %rax
je 0xbfd0e
movq %r12, %rdi
callq 0xec1d8
movq %rax, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x1fcc1c
testl %eax, %eax
je 0xbfd34
movq %r12, %rdi
callq 0xee90c
movq %r14, %rdi
callq 0xf424d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0xf02da
movq %rax, %rdi
callq 0xd3c75
testb %al, %al
jne 0xbfd66
movl 0x38(%rbx), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0xbfd66
leaq 0x29ed34(%rip), %rsi    # 0x35ea8e
movq %r15, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0xbfd0e
movzbl 0x4(%rbx), %edi
callq 0xc0347
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 0x1faa3e
movq %rax, %rbp
movq %r13, %rdi
callq 0xc03c9
leaq 0x29eae3(%rip), %rsi    # 0x35e880
movq %rbp, %rdi
movl $0x15d, %edx            # imm = 0x15D
callq 0x109670
movq %r12, %rdi
callq 0xee90c
movq %r14, %rdi
callq 0xf424d
movq 0x18(%rbx), %rdi
callq 0x120d4c
testq %rax, %rax
jne 0xbfdda
movq 0x20(%rbx), %rdi
callq 0x120d4c
testq %rax, %rax
je 0xbfec7
movq 0x18(%rbx), %rdi
callq 0x120d4c
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
movq 0x18(%rbx,%rcx,8), %rdi
callq 0x120d23
movq %rax, %r13
cmpb $0x1, 0x5(%rbx)
jne 0xbfe1c
leaq 0x29ea7b(%rip), %rdx    # 0x35e880
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
movl $0x16e, %ecx            # imm = 0x16E
movq %r15, %r8
callq 0x102572
jmp 0xbfe38
leaq 0x29ea5d(%rip), %rdx    # 0x35e880
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
movl $0x171, %ecx            # imm = 0x171
movq %r15, %r8
callq 0x102933
movq %rax, %r14
testq %rax, %rax
je 0xbfe63
movq 0x20(%rbx), %rdi
callq 0x120d4c
testq %rax, %rax
movq %r13, 0x8(%rsp)
je 0xbfe6d
cmpb $0x1, 0x6(%rbx)
jne 0xbfe75
movb $0x1, %r12b
callq 0xd340f
jmp 0xbfe87
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xc0302
movb $0x1, %r12b
xorl %r13d, %r13d
jmp 0xbfedc
cmpb $0x1, 0x7(%rbx)
jne 0xbff52
movb $0x1, %r12b
callq 0xd3528
movq %rax, %rbp
testb %r12b, %r12b
je 0xbfe99
testq %rbp, %rbp
jne 0xbfea3
callq 0x1e73b
movq %rbp, %rdi
callq 0xd335d
xorl %ebp, %ebp
testq %rbp, %rbp
je 0xbfece
movq 0x10(%rsp), %rsi
movq %r14, %rdi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x192f1d
movq %rax, %r13
testq %rax, %rax
setne %r12b
jmp 0xbfed4
xorl %ebp, %ebp
jmp 0xbfd23
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %rbp, %rdi
callq 0xd335d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %r12b, %r12b
je 0xbff4a
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1fcc1c
testl %eax, %eax
movq %r13, %r12
jne 0xc02fa
movzbl 0x4(%rbx), %edi
callq 0xc0347
movq %rax, %rbp
movq 0x18(%rbx), %rdi
callq 0x120d4c
testq %rax, %rax
movq %rbp, 0x28(%rsp)
je 0xbff80
movq 0x10(%rsp), %rsi
movzbl (%rbx), %edx
movzbl 0x1(%rbx), %ecx
movq (%rbp), %r9
movq 0x8(%rbp), %r8
movq %r14, %rdi
callq 0x1fcb2a
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %r13
jmp 0xbffea
movq %r13, %r12
jmp 0xc02fa
movq 0x30(%rbx), %rdi
callq 0x120d4c
testq %rax, %rax
je 0xc0051
movq 0x30(%rbx), %rdi
callq 0x120d23
movq %rax, %rdi
movq %r15, %rsi
callq 0xd3e83
movq %rax, %rbp
jmp 0xc0095
movq 0x20(%rbx), %rdi
callq 0x120d4c
testq %r12, %r12
movq 0x8(%rsp), %r13
je 0xc033d
testq %rax, %rax
je 0xc033d
movl 0x38(%rbx), %eax
testl %eax, %eax
je 0xbffcb
xorl %ecx, %ecx
cmpl $0x1, %eax
je 0xbffb5
cmpl $0x3, %eax
je 0xbffb5
movb $0x1, %cl
addl $-0x4, %eax
xorl %edx, %edx
cmpl $-0x2, %eax
setb %dl
movzbl %cl, %esi
movq %r12, %rdi
callq 0x19338c
movl 0x38(%rbx), %esi
movzbl (%rbx), %edx
movzbl 0x1(%rbx), %ecx
movq (%rbp), %r9
movq 0x8(%rbp), %r8
movq %r12, %rdi
callq 0x1fc9dd
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
cmpb $0x1, 0x8(%rbx)
jne 0xc0123
movq %r14, 0x20(%rsp)
movq %r13, %rdi
callq 0xd6450
leaq 0x2d0547(%rip), %rsi    # 0x390551
leaq 0x29eafc(%rip), %rdx    # 0x35eb0d
leaq 0x29e868(%rip), %rcx    # 0x35e880
movq %rax, %r14
movq %rax, %rdi
movl $0x1b7, %r8d            # imm = 0x1B7
movq %r15, %r9
callq 0x101dff
testq %rax, %rax
je 0xc00df
movq %rax, %rbp
testq %r12, %r12
je 0xc00e6
movq %r12, %rdi
callq 0x19326b
movq %rax, %rdx
jmp 0xc00eb
callq 0x121b54
movq %rax, %r12
movq 0x20(%rbx), %rdi
callq 0x120d4c
testq %rax, %rax
je 0xc0342
movq 0x20(%rbx), %rdi
callq 0x120d23
movq %r12, %rdi
movq %rax, %rsi
callq 0x121c30
movq %r12, %rdi
movq %r15, %rsi
callq 0xd3212
movq %rax, %rbp
movq %r12, %rdi
callq 0x121e8b
testq %rbp, %rbp
je 0xc00d5
movq %rbp, %rdi
callq 0xd3c75
movb $0x1, %r12b
testb %al, %al
jne 0xbfe8a
movl 0x38(%rbx), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0xbfe8a
leaq 0x29e9cb(%rip), %rsi    # 0x35ea8e
xorl %r12d, %r12d
movq %r15, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0xbfe8a
xorl %ebp, %ebp
xorl %r12d, %r12d
jmp 0xbfe8a
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xc010a
movq 0x10(%rsp), %rdx
incq %rdx
movl $0x4, %esi
movq 0x18(%rsp), %rdi
movq %rbp, %rcx
callq 0x125658
movq %rbp, %rdi
callq 0x101e80
xorl %ebp, %ebp
leaq 0x29e76f(%rip), %rsi    # 0x35e880
movq %r14, %rdi
movl $0x1c8, %edx            # imm = 0x1C8
callq 0x109670
movq 0x20(%rsp), %r14
cmpb $0x1, 0x9(%rbx)
jne 0xc01c2
movq %r13, %rdi
callq 0xd6450
movq %rax, %r13
leaq 0x29e9d1(%rip), %rsi    # 0x35eb10
leaq 0x29e9c7(%rip), %rdx    # 0x35eb0d
leaq 0x29e733(%rip), %rcx    # 0x35e880
movq %rax, %rdi
movl $0x1ce, %r8d            # imm = 0x1CE
movq %r15, %r9
callq 0x101dff
testq %rax, %rax
je 0xc018a
movq %rax, %r15
testq %r12, %r12
je 0xc0191
movq %r12, %rdi
callq 0x19326b
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x193255
movq 0x8(%rsp), %rdx
movq %rax, %rdi
jmp 0xc0199
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xc01ae
movq 0x10(%rsp), %rdx
movq %r14, %rdi
movl $0x1, %esi
movq %r15, %rcx
callq 0x125658
movq %r15, %rdi
callq 0x101e80
leaq 0x29e6cb(%rip), %rsi    # 0x35e880
movq %r13, %rdi
movl $0x1e3, %edx            # imm = 0x1E3
callq 0x109670
testl %ebp, %ebp
jne 0xc02da
cmpb $0x1, 0x2(%rbx)
jne 0xc02da
movq $0x0, 0x30(%rsp)
movq 0x18(%rbx), %rdi
callq 0x120d4c
movq %rax, %r15
testq %rax, %rax
movq %r14, 0x20(%rsp)
je 0xc01ff
movq 0x10(%rsp), %r13
movq %r13, 0x8(%rsp)
jmp 0xc021a
movq %r12, %rdi
callq 0x19326b
movq %rax, %r13
movq %r12, %rdi
callq 0x1932a9
movq %r13, 0x8(%rsp)
subq %rax, %r13
movq 0x28(%rsp), %r14
cmpq $0x0, (%r14)
je 0xc024b
movq 0x8(%r14), %rdi
callq 0x108f3c
testb %al, %al
je 0xc024b
movq (%r14), %rdi
movq 0x403cac(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x29e8cf(%rip), %rsi    # 0x35eb15
callq 0x1229c8
cmpb $0x1, 0x3(%rbx)
jne 0xc027a
xorl %edx, %edx
testq %r15, %r15
sete %dl
leaq 0x30(%rsp), %rdi
movq 0x20(%rsp), %r14
movq %r14, %rsi
movq %r13, %rcx
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
callq 0x1f6983
jmp 0xc02a7
xorl %ecx, %ecx
testq %r15, %r15
sete %cl
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %rsi
xorl %edi, %edi
movq 0x20(%rsp), %r14
movq %r14, %rdx
movq %r13, %r8
movq 0x8(%rsp), %r9
callq 0x1f6aec
movq %rax, %r15
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x30(%rsp), %rdx
leaq 0x29e868(%rip), %rsi    # 0x35eb27
xorl %eax, %eax
callq 0x10906e
leaq 0x29e5b3(%rip), %rsi    # 0x35e880
movq %r15, %rdi
movl $0x20e, %edx            # imm = 0x20E
callq 0x109670
leaq 0x29e59f(%rip), %rsi    # 0x35e880
movq 0x18(%rsp), %rdi
movl $0x210, %edx            # imm = 0x210
callq 0x109670
movq 0x28(%rsp), %rdi
callq 0xc03c9
movq %r12, %rdi
callq 0x192d4c
cmpb $0x1, 0x5(%rbx)
jne 0xc0315
movq %r14, %rdi
callq 0x102b12
jmp 0xbfd23
leaq 0x29e564(%rip), %rsi    # 0x35e880
movq %r14, %rdi
movl $0x21a, %edx            # imm = 0x21A
callq 0x109670
jmp 0xbfd23
callq 0x1e7e6
callq 0x1e7ad
callq 0x1e6c9
callq 0x1e774
callq 0x1e702