// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/tools/gt_encseq2spm.c
// Function: gt_encseq2spm_runner
static int gt_encseq2spm_runner(GT_UNUSED int argc,
                                GT_UNUSED const char **argv,
                                GT_UNUSED int parsed_args,
                                void *tool_arguments,
                                GtError *err)
{
  GtEncseq2spmArguments *arguments = tool_arguments;
  GtEncseqLoader *el = NULL;
  GtEncseq *encseq = NULL;
  bool haserr = false;

  gt_error_check(err);
  gt_assert(arguments);
  el = gt_encseq_loader_new();
  gt_encseq_loader_drop_description_support(el);
  gt_encseq_loader_disable_autosupport(el);
  encseq = gt_encseq_loader_load(el, gt_str_get(arguments->encseqinput),
                                 err);
  if (encseq == NULL)
  {
    haserr = true;
  }
  if (!haserr)
  {
    if (arguments->singlestrand)
    {
      gt_error_set(err,"option -singlestand is not implemented");
      haserr = true;
    } else
    {
      if (gt_encseq_mirror(encseq, err) != 0)
      {
        haserr = true;
      }
    }
  }

  if (!haserr && arguments->singlescan > 0)
  {
    GtTimer *timer = NULL;

    if (gt_showtime_enabled())
    {
      char *outmsg;

      switch (arguments->singlescan)
      {
        case 1:
          outmsg = "to run fast scanning";
          break;
        case 2:
          outmsg = "to run fast scanning with check";
          break;
        case 3:
          outmsg = "to run fast scanning with output";
          break;
        case 4:
          outmsg = "to run old scanning code";
          break;
        default:
          gt_error_set(err,"argument %u to option -singlescan not allowed",
                       arguments->singlescan);
          haserr = true;
      }
      if (!haserr)
      {
        timer = gt_timer_new_with_progress_description(outmsg);
        gt_timer_start(timer);
      }
    }
    if (!haserr)
    {
      unsigned int kmersize = 0;
      haserr = gt_encseq2spm_kmersize(arguments, &kmersize, err);
      if (!haserr)
      {
        if (arguments->singlescan == 4U)
        {
          gt_rungetencseqkmers(encseq,kmersize);
        } else
        {
          if (arguments->singlescan > 0)
          {
            gt_firstcode_runkmerscan(encseq,arguments->singlescan - 1,kmersize,
                arguments->minmatchlength);
          }
        }
      }
    }
    if (timer != NULL)
    {
      gt_timer_show_progress_final(timer, stdout);
      gt_timer_delete(timer);
    }
  }
  if (!haserr && arguments->singlescan == 0)
  {
    GtLogger *logger;
    const GtReadmode readmode = GT_READMODE_FORWARD;
    GtBUstate_spmsk **spmsk_states = NULL;
    unsigned int kmersize, threadcount;

#ifdef GT_THREADS_ENABLED
    const unsigned int threads = gt_jobs;
#else
    const unsigned int threads = 1U;
#endif

    if (arguments->countspms || arguments->outputspms)
    {
      spmsk_states = gt_malloc(sizeof (*spmsk_states) * threads);
      for (threadcount = 0; threadcount < threads; threadcount++)
      {
        spmsk_states[threadcount]
          = gt_spmsk_inl_new(encseq,
                             readmode,
                             (GtUword) arguments->minmatchlength,
                             arguments->countspms,
                             arguments->outputspms,
                             gt_str_get(arguments->encseqinput));
      }
    }
    logger = gt_logger_new(arguments->verbose,GT_LOGGER_DEFLT_PREFIX, stdout);
    haserr = gt_encseq2spm_kmersize(arguments, &kmersize, err);
    if (!haserr)
    {
      if (storefirstcodes_getencseqkmers_twobitencoding(encseq,
                                                      kmersize,
                                                      arguments->numofparts,
                                                      arguments->maximumspace,
                                                      arguments->minmatchlength,
                                     /* use false */  arguments->checksuftab,
                                     /* use false */  arguments->onlyaccum,
                                     /* use false */  arguments->
                                                            onlyallfirstcodes,
                                     /* use 5U */     arguments->
                                                            addbscache_depth,
                                     /* specify the extra space needed for
                                        the function processing the interval */
                                                      arguments->phase2extra,
                                     /* use true */   arguments->radixlarge ?
                                                        false : true,
                                     /* use 2 without threads and
                                        use 1 with threads */
                                                      arguments->radixparts,
                                                      spmsk_states != NULL
                                                        ? gt_spmsk_inl_process
                                                        : NULL,
                                                      gt_spmsk_inl_process_end,
                                                      spmsk_states,
                                                      logger,
                                                      err) != 0)
      {
        haserr = true;
      }
    }
    if (spmsk_states != NULL)
    {
      GtUword countmatches = 0;

      for (threadcount = 0; threadcount < threads; threadcount++)
      {
        countmatches += gt_spmsk_inl_delete(spmsk_states[threadcount]);
      }
      if (arguments->countspms)
      {
        printf("number of suffix-prefix matches="GT_WU"\n",countmatches);
      }
      gt_free(spmsk_states);
    }
    gt_logger_delete(logger);
  }
  gt_encseq_delete(encseq);
  gt_encseq_loader_delete(el);
  return haserr ? -1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r12
movq %rcx, %r15
testq %r8, %r8
je 0xa2b19
movq %r12, %rdi
callq 0xfcc32
testb %al, %al
jne 0xa2ebc
testq %r15, %r15
je 0xa2eb7
callq 0xef0cd
movq %rax, %r13
movq %rax, %rdi
callq 0xf22df
movq %r13, %rdi
callq 0xf238b
movq 0x30(%r15), %rdi
callq 0x11b0a1
movq %r13, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0xef129
movq %rax, %rbp
movb $0x1, %r14b
testq %rax, %rax
je 0xa2e92
cmpb $0x1, 0x1(%r15)
jne 0xa2b7d
leaq 0x2a7f22(%rip), %rsi    # 0x34aa90
movq %r12, %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0xa2e92
testq %rbp, %rbp
sete %bl
movq %rbp, 0x8(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0xf24ac
testl %eax, %eax
setne %bpl
orb %bl, %bpl
jne 0xa2c72
cmpl $0x0, 0x14(%r15)
je 0xa2c72
callq 0x119160
testb %al, %al
je 0xa2be7
movl 0x14(%r15), %edx
leal -0x1(%rdx), %eax
cmpl $0x4, %eax
jae 0xa2c26
movq %r13, %rbx
movl %eax, %eax
leaq 0x2a803e(%rip), %rcx    # 0x34ac0c
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x11c986
movq %rax, %r13
movq %rax, %rdi
callq 0x11c9e3
jmp 0xa2bed
movq %r13, %rbx
xorl %r13d, %r13d
leaq 0x1c(%rsp), %rsi
movl $0x0, (%rsi)
movq %r15, %rdi
movq %r12, %rdx
callq 0xa2ec1
movl %eax, %ebp
testb %al, %al
jne 0xa2c50
movl 0x14(%r15), %esi
testl %esi, %esi
je 0xa2c50
cmpl $0x4, %esi
jne 0xa2c3c
movl 0x1c(%rsp), %esi
movq 0x8(%rsp), %rdi
callq 0x1aaabb
jmp 0xa2c50
leaq 0x2a7ef9(%rip), %rsi    # 0x34ab26
movq %r12, %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0xa2e8d
decl %esi
movl 0x1c(%rsp), %edx
movl 0x8(%r15), %ecx
movq 0x8(%rsp), %rdi
callq 0x1aa926
testq %r13, %r13
je 0xa2c6f
movq 0x41627c(%rip), %rax    # 0x4b8ed8
movq (%rax), %rsi
movq %r13, %rdi
callq 0x11cf39
movq %r13, %rdi
callq 0x11d054
movq %rbx, %r13
movl %ebp, %r14d
testb %bpl, %bpl
jne 0xa2e8d
cmpl $0x0, 0x14(%r15)
movq 0x8(%rsp), %rbp
jne 0xa2e92
leaq 0x417183(%rip), %rax    # 0x4b9e18
movl (%rax), %r14d
cmpb $0x0, 0x7(%r15)
movq %r15, 0x20(%rsp)
movq %r13, 0x38(%rsp)
jne 0xa2cb4
cmpb $0x1, 0x3(%r15)
jne 0xa2d3e
leaq (,%r14,8), %rdi
leaq 0x2a79a4(%rip), %rsi    # 0x34a667
movl $0x198, %edx            # imm = 0x198
callq 0x104226
movq %rax, 0x10(%rsp)
testq %r14, %r14
je 0xa2d39
movq %r12, 0x28(%rsp)
xorl %ebx, %ebx
movq 0x20(%rsp), %r12
movl 0x8(%r12), %ebp
movzbl 0x7(%r12), %r13d
movq %r14, %r15
movzbl 0x3(%r12), %r14d
movq 0x30(%r12), %rdi
callq 0x11b0a1
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movq %rbp, %rdx
movl %r13d, %ecx
movl %r14d, %r8d
movq %r15, %r14
movq %rax, %r9
callq 0x1a7808
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
cmpq %rbx, %r15
jne 0xa2ce3
movq 0x38(%rsp), %r13
movq 0x28(%rsp), %r12
jmp 0xa2d4a
movq %r14, %r15
jmp 0xa2d4a
movq %r14, %r15
movq $0x0, 0x10(%rsp)
movq 0x20(%rsp), %rbx
movzbl 0x2(%rbx), %edi
movq 0x41617e(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x2a3b70(%rip), %rsi    # 0x3468d4
callq 0x103e40
movq %rax, %rbp
leaq 0x34(%rsp), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xa2ec1
movb $0x1, %r14b
testb %al, %al
jne 0xa2e21
movl 0x34(%rsp), %esi
movq 0x20(%rsp), %rax
movl 0x8(%rax), %r8d
movl 0xc(%rax), %edx
movq 0x20(%rax), %rcx
movzbl (%rax), %r9d
movzbl 0x4(%rax), %edi
movq %rdi, 0x28(%rsp)
movzbl 0x5(%rax), %edi
movq %rdi, 0x40(%rsp)
movl 0x18(%rax), %r11d
movq 0x28(%rax), %r14
xorl %r13d, %r13d
cmpb $0x0, 0x6(%rax)
sete %dil
movl 0x10(%rax), %eax
movq 0x10(%rsp), %rbx
movq %rbx, %r10
testq %rbx, %rbx
je 0xa2ddb
leaq 0x104b6f(%rip), %r10    # 0x1a794a
subq $0x8, %rsp
leaq 0x104f91(%rip), %rbx    # 0x1a7d77
movb %dil, %r13b
movq 0x10(%rsp), %rdi
pushq %r12
pushq %rbp
pushq 0x28(%rsp)
pushq %rbx
pushq %r10
pushq %rax
pushq %r13
pushq %r14
pushq %r11
pushq 0x90(%rsp)
pushq 0x80(%rsp)
callq 0x1aaae5
addq $0x60, %rsp
testl %eax, %eax
setne %r14b
movq 0x38(%rsp), %r13
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa2e85
testq %r15, %r15
je 0xa2e50
xorl %ebx, %ebx
xorl %r12d, %r12d
movq (%rdi,%rbx,8), %rdi
callq 0x1a788e
addq %rax, %r12
movq 0x10(%rsp), %rdi
incq %rbx
cmpq %rbx, %r15
jne 0xa2e35
jmp 0xa2e53
xorl %r12d, %r12d
movq 0x20(%rsp), %rax
cmpb $0x1, 0x7(%rax)
jne 0xa2e74
leaq 0x2a7cef(%rip), %rdi    # 0x34ab54
movq %r12, %rsi
xorl %eax, %eax
callq 0x17070
movq 0x10(%rsp), %rdi
leaq 0x2a77ec(%rip), %rsi    # 0x34a667
movl $0x1d2, %edx            # imm = 0x1D2
callq 0x1045eb
movq %rbp, %rdi
callq 0x1040e0
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
callq 0xea375
movq %r13, %rdi
callq 0xefbe3
movzbl %r14b, %eax
negl %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x19e64
callq 0x19e2b