// File: /workspace/github_c_makefile_star2_O3/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 0xbdd02
movq %r15, %rdi
callq 0xfcc32
testb %al, %al
jne 0xbe369
testq %rbx, %rbx
je 0xbe35f
cmpl %ebp, %r14d
jl 0xbe364
jle 0xbdd29
leaq 0x292274(%rip), %rsi    # 0x34ff91
movq %r15, %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0xbdd8e
movq 0x10(%rbx), %rdi
callq 0x11b0ca
testq %rax, %rax
je 0xbde2c
callq 0xef0cd
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x11b0a1
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0xef129
movq %rax, %r12
testq %rax, %rax
je 0xbdd7e
movq %r12, %rdi
callq 0xe7b9c
movq %rax, %rdi
movl $0x1, %esi
movq %r15, %rdx
callq 0x1f34c7
testl %eax, %eax
je 0xbdda6
movq %r12, %rdi
callq 0xea375
movq %r14, %rdi
callq 0xefbe3
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0xebcd9
movq %rax, %rdi
callq 0xd1749
testb %al, %al
jne 0xbddd8
movl 0x38(%rbx), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0xbddd8
leaq 0x297c96(%rip), %rsi    # 0x355a62
movq %r15, %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0xbdd7e
movzbl 0x4(%rbx), %edi
callq 0xbe37d
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 0x1f128e
movq %rax, %rbp
movq %r13, %rdi
callq 0xbe402
leaq 0x297a41(%rip), %rsi    # 0x355850
movq %rbp, %rdi
movl $0x15d, %edx            # imm = 0x15D
callq 0x1045eb
movq %r12, %rdi
callq 0xea375
movq %r14, %rdi
callq 0xefbe3
movq 0x18(%rbx), %rdi
callq 0x11b0ca
testq %rax, %rax
jne 0xbde4c
movq 0x20(%rbx), %rdi
callq 0x11b0ca
testq %rax, %rax
je 0xbdf78
movq 0x18(%rbx), %rdi
callq 0x11b0ca
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
movq 0x18(%rbx,%rcx,8), %rdi
callq 0x11b0a1
movq %rax, %rbp
cmpb $0x1, 0x5(%rbx)
jne 0xbde8e
leaq 0x2979d9(%rip), %rdx    # 0x355850
leaq 0x10(%rsp), %rsi
movq %rbp, %rdi
movl $0x16e, %ecx            # imm = 0x16E
movq %r15, %r8
callq 0xfd6db
jmp 0xbdeaa
leaq 0x2979bb(%rip), %rdx    # 0x355850
leaq 0x10(%rsp), %rsi
movq %rbp, %rdi
movl $0x171, %ecx            # imm = 0x171
movq %r15, %r8
callq 0xfda81
movq %rax, %r14
testq %rax, %rax
je 0xbdecd
movq 0x20(%rbx), %rdi
callq 0x11b0ca
testq %rax, %rax
je 0xbded8
cmpb $0x1, 0x6(%rbx)
jne 0xbdedd
callq 0xd0ece
jmp 0xbdeec
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xbe333
xorl %r12d, %r12d
jmp 0xbdf1b
cmpb $0x1, 0x7(%rbx)
jne 0xbdf88
callq 0xd0fdd
movq %rax, %r13
testq %rax, %rax
je 0xbe36e
movq 0x10(%rsp), %rsi
movq %r14, %rdi
movq %r13, %rdx
movq %r15, %rcx
callq 0x18a8d5
movq %rax, %r12
movq %r13, %rdi
callq 0xd0e1c
testq %r12, %r12
je 0xbdf80
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1f34c7
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0xbe32b
movzbl 0x4(%rbx), %edi
callq 0xbe37d
movq %rax, %r13
movq 0x18(%rbx), %rdi
callq 0x11b0ca
testq %rax, %rax
movq %r13, 0x20(%rsp)
je 0xbdfb6
movq 0x10(%rsp), %rsi
movzbl (%rbx), %edx
movzbl 0x1(%rbx), %ecx
movq (%r13), %r9
movq 0x8(%r13), %r8
movq %r14, %rdi
callq 0x1f33d5
jmp 0xbe016
xorl %r13d, %r13d
jmp 0xbdd94
xorl %r12d, %r12d
jmp 0xbe10b
movq 0x30(%rbx), %rdi
callq 0x11b0ca
testq %rax, %rax
je 0xbe080
movq 0x30(%rbx), %rdi
callq 0x11b0a1
movq %rax, %rdi
movq %r15, %rsi
callq 0xd1957
movq %rax, %r13
jmp 0xbe0c4
movq 0x20(%rbx), %rdi
callq 0x11b0ca
testq %r12, %r12
je 0xbe373
testq %rax, %rax
je 0xbe373
movl 0x38(%rbx), %esi
testl %esi, %esi
je 0xbdfff
xorl %eax, %eax
cmpl $0x1, %esi
je 0xbdfe6
cmpl $0x3, %esi
je 0xbdfe6
movb $0x1, %al
addl $-0x4, %esi
xorl %edx, %edx
cmpl $-0x2, %esi
setb %dl
movzbl %al, %esi
movq %r12, %rdi
callq 0x18ad23
movl 0x38(%rbx), %esi
movzbl (%rbx), %edx
movzbl 0x1(%rbx), %ecx
movq (%r13), %r9
movq 0x8(%r13), %r8
movq %r12, %rdi
callq 0x1f3288
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
cmpb $0x1, 0x8(%rbx)
jne 0xbe159
movq %rbp, %rdi
callq 0xd3e84
leaq 0x2c9141(%rip), %rsi    # 0x387178
leaq 0x297aa3(%rip), %rdx    # 0x355ae1
leaq 0x29780b(%rip), %rcx    # 0x355850
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movl $0x1b7, %r8d            # imm = 0x1B7
movq %r15, %r9
callq 0xfcf97
testq %rax, %rax
je 0xbe116
movq %rax, %r13
testq %r12, %r12
je 0xbe11e
movq %r12, %rdi
callq 0x18ac02
movq %rax, %rdx
jmp 0xbe123
callq 0x11be10
movq %rax, %r12
movq 0x20(%rbx), %rdi
callq 0x11b0ca
testq %rax, %rax
je 0xbe378
movq 0x20(%rbx), %rdi
callq 0x11b0a1
movq %r12, %rdi
movq %rax, %rsi
callq 0x11bee9
movq %r12, %rdi
movq %r15, %rsi
callq 0xd0c4a
movq %rax, %r13
movq %r12, %rdi
callq 0x11c144
testq %r13, %r13
je 0xbe0f9
movq %r13, %rdi
callq 0xd1749
testb %al, %al
jne 0xbdef8
movl 0x38(%rbx), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0xbdef8
leaq 0x297973(%rip), %rsi    # 0x355a62
movq %r15, %rdi
xorl %eax, %eax
callq 0xfcb67
movq %r13, %rdi
callq 0xd0e1c
xorl %r12d, %r12d
xorl %edi, %edi
callq 0xd0e1c
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xbe32b
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xbe143
movq 0x10(%rsp), %rdx
incq %rdx
movl $0x4, %esi
movq 0x18(%rsp), %rdi
movq %r13, %rcx
callq 0x11f89c
movq %r13, %rdi
callq 0xfd018
xorl %r13d, %r13d
leaq 0x297706(%rip), %rsi    # 0x355850
movq 0x8(%rsp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
callq 0x1045eb
cmpb $0x1, 0x9(%rbx)
jne 0xbe1f9
movq %rbp, %rdi
callq 0xd3e84
movq %rax, %rbp
leaq 0x29796f(%rip), %rsi    # 0x355ae4
leaq 0x297965(%rip), %rdx    # 0x355ae1
leaq 0x2976cd(%rip), %rcx    # 0x355850
movq %rax, %rdi
movl $0x1ce, %r8d            # imm = 0x1CE
movq %r15, %r9
callq 0xfcf97
testq %rax, %rax
je 0xbe1c0
movq %rax, %r15
testq %r12, %r12
je 0xbe1c8
movq %r12, %rdi
callq 0x18ac02
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x18abec
movq 0x8(%rsp), %rdx
movq %rax, %rdi
jmp 0xbe1d0
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xbe1e5
movq 0x10(%rsp), %rdx
movq %r14, %rdi
movl $0x1, %esi
movq %r15, %rcx
callq 0x11f89c
movq %r15, %rdi
callq 0xfd018
leaq 0x297664(%rip), %rsi    # 0x355850
movq %rbp, %rdi
movl $0x1e3, %edx            # imm = 0x1E3
callq 0x1045eb
testl %r13d, %r13d
jne 0xbe30b
cmpb $0x1, 0x2(%rbx)
jne 0xbe30b
movq $0x0, 0x28(%rsp)
movq 0x18(%rbx), %rdi
callq 0x11b0ca
testq %rax, %rax
movq %rax, 0x30(%rsp)
je 0xbe234
movq 0x10(%rsp), %rbp
movq %rbp, 0x8(%rsp)
jmp 0xbe24f
movq %r12, %rdi
callq 0x18ac02
movq %rax, %rbp
movq %r12, %rdi
callq 0x18ac40
movq %rbp, 0x8(%rsp)
subq %rax, %rbp
movq 0x20(%rsp), %r15
cmpq $0x0, (%r15)
je 0xbe280
movq 0x8(%r15), %rdi
callq 0x103eac
testb %al, %al
je 0xbe280
movq (%r15), %rdi
movq 0x3fac67(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x29786e(%rip), %rsi    # 0x355ae9
callq 0x11cc90
cmpb $0x1, 0x3(%rbx)
jne 0xbe2ad
xorl %edx, %edx
cmpq $0x0, 0x30(%rsp)
sete %dl
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rcx
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
callq 0x1ed187
jmp 0xbe2d8
xorl %ecx, %ecx
cmpq $0x0, 0x30(%rsp)
sete %cl
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
leaq 0x28(%rsp), %rsi
xorl %edi, %edi
movq %r14, %rdx
movq %rbp, %r8
movq 0x8(%rsp), %r9
callq 0x1ed31a
movq %rax, %r15
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x28(%rsp), %rdx
leaq 0x29780b(%rip), %rsi    # 0x355afb
xorl %eax, %eax
callq 0x103fe1
leaq 0x297552(%rip), %rsi    # 0x355850
movq %r15, %rdi
movl $0x20e, %edx            # imm = 0x20E
callq 0x1045eb
leaq 0x29753e(%rip), %rsi    # 0x355850
movq 0x18(%rsp), %rdi
movl $0x210, %edx            # imm = 0x210
callq 0x1045eb
movq 0x20(%rsp), %rdi
callq 0xbe402
movq %r12, %rdi
callq 0x18a71c
cmpb $0x1, 0x5(%rbx)
jne 0xbe346
movq %r14, %rdi
callq 0xfdc54
jmp 0xbdd94
leaq 0x297503(%rip), %rsi    # 0x355850
movq %r14, %rdi
movl $0x21a, %edx            # imm = 0x21A
callq 0x1045eb
jmp 0xbdd94
callq 0x1e495
callq 0x1e45c
callq 0x1e378
callq 0x1e3ea
callq 0x1e423
callq 0x1e3b1