// File: /workspace/github_c_makefile_star2_O2/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 0x245e7
movq %r12, %rdi
callq 0x89eb7
testb %al, %al
jne 0x2497b
testq %r15, %r15
je 0x2494d
callq 0x791cd
movq %rax, %r13
movq %rax, %rdi
callq 0x7cece
movq %r13, %rdi
callq 0x7d046
movq 0x30(%r15), %rdi
callq 0xad1fa
movq %r13, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x7921d
movq %rax, %rbp
movb $0x1, %bl
testq %rax, %rax
je 0x24929
cmpb $0x1, 0x1(%r15)
jne 0x2464a
leaq 0x2c6455(%rip), %rsi    # 0x2eaa90
movq %r12, %rdi
xorl %eax, %eax
callq 0x89dbb
jmp 0x24929
testq %rbp, %rbp
sete %r14b
movq %rbp, 0x8(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x7d4ca
testl %eax, %eax
setne %bpl
orb %r14b, %bpl
jne 0x2473d
cmpl $0x0, 0x14(%r15)
je 0x2473d
callq 0xaaf34
testb %al, %al
je 0x246b5
movl 0x14(%r15), %edx
leal -0x1(%rdx), %eax
cmpl $0x4, %eax
jae 0x246f1
movq %r13, %rbx
movl %eax, %eax
leaq 0x2c6570(%rip), %rcx    # 0x2eac0c
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0xaf4a5
movq %rax, %r13
movq %rax, %rdi
callq 0xaf4d6
jmp 0x246bb
movq %r13, %rbx
xorl %r13d, %r13d
leaq 0x1c(%rsp), %rsi
andl $0x0, (%rsi)
movq %r15, %rdi
movq %r12, %rdx
callq 0x249b3
movl %eax, %ebp
testb %al, %al
jne 0x2471b
movl 0x14(%r15), %esi
testl %esi, %esi
je 0x2471b
cmpl $0x4, %esi
jne 0x24707
movl 0x1c(%rsp), %esi
movq 0x8(%rsp), %rdi
callq 0x157839
jmp 0x2471b
leaq 0x2c642e(%rip), %rsi    # 0x2eab26
movq %r12, %rdi
xorl %eax, %eax
callq 0x89dbb
jmp 0x24924
decl %esi
movl 0x1c(%rsp), %edx
movl 0x8(%r15), %ecx
movq 0x8(%rsp), %rdi
callq 0x1576ad
testq %r13, %r13
je 0x2473a
movq 0x413789(%rip), %rax    # 0x437eb0
movq (%rax), %rsi
movq %r13, %rdi
callq 0xafb49
movq %r13, %rdi
callq 0xafc5b
movq %rbx, %r13
movl %ebp, %ebx
testb %bpl, %bpl
jne 0x24924
cmpl $0x0, 0x14(%r15)
movq 0x8(%rsp), %rbp
jne 0x24929
leaq 0x414669(%rip), %rax    # 0x438dc8
movl (%rax), %eax
movq %rax, 0x20(%rsp)
cmpb $0x0, 0x7(%r15)
movq %r13, 0x30(%rsp)
jne 0x24779
cmpb $0x1, 0x3(%r15)
jne 0x247e9
movq 0x20(%rsp), %rax
leaq (,%rax,8), %rdi
leaq 0x2c5eda(%rip), %rsi    # 0x2ea667
movl $0x198, %edx            # imm = 0x198
callq 0x93160
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
cmpq %r13, 0x20(%rsp)
je 0x247e2
movl 0x8(%r15), %ebp
movzbl 0x7(%r15), %ebx
movzbl 0x3(%r15), %r14d
movq 0x30(%r15), %rdi
callq 0xad1fa
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movq %rbp, %rdx
movl %ebx, %ecx
movl %r14d, %r8d
movq %rax, %r9
callq 0x153f21
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0x2479f
movq 0x30(%rsp), %r13
jmp 0x247f2
movq $0x0, 0x10(%rsp)
movzbl 0x2(%r15), %edi
movq 0x4136b2(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x2c20cc(%rip), %rsi    # 0x2e68d4
callq 0x92b50
movq %rax, %rbp
leaq 0x2c(%rsp), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x249b3
movb $0x1, %bl
testb %al, %al
jne 0x248c3
movl 0x2c(%rsp), %esi
movl 0x8(%r15), %r8d
movl 0xc(%r15), %edx
movq 0x20(%r15), %rcx
movzbl (%r15), %r9d
movzbl 0x4(%r15), %eax
movq %rax, 0x40(%rsp)
movzbl 0x5(%r15), %eax
movq %rax, 0x38(%rsp)
movl 0x18(%r15), %r11d
movq 0x28(%r15), %rbx
xorl %r14d, %r14d
cmpb $0x0, 0x6(%r15)
sete %dil
movl 0x10(%r15), %r13d
movq 0x10(%rsp), %rax
movq %rax, %r10
testq %rax, %rax
je 0x2487e
leaq 0x12f7b5(%rip), %r10    # 0x154033
subq $0x8, %rsp
leaq 0x12fd58(%rip), %rax    # 0x1545e1
movb %dil, %r14b
movq 0x10(%rsp), %rdi
pushq %r12
pushq %rbp
pushq 0x28(%rsp)
pushq %rax
pushq %r10
pushq %r13
pushq %r14
pushq %rbx
pushq %r11
pushq 0x88(%rsp)
pushq 0x98(%rsp)
callq 0x157860
addq $0x60, %rsp
testl %eax, %eax
setne %bl
movq 0x30(%rsp), %r13
cmpq $0x0, 0x10(%rsp)
je 0x2491c
xorl %r14d, %r14d
xorl %r12d, %r12d
cmpq %r14, 0x20(%rsp)
je 0x248ee
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x153fa2
addq %rax, %r12
incq %r14
jmp 0x248d1
cmpb $0x1, 0x7(%r15)
jne 0x24906
leaq 0x2c6258(%rip), %rdi    # 0x2eab54
movq %r12, %rsi
xorl %eax, %eax
callq 0x17070
leaq 0x2c5d5a(%rip), %rsi    # 0x2ea667
movq 0x10(%rsp), %rdi
movl $0x1d2, %edx            # imm = 0x1D2
callq 0x936f9
movq %rbp, %rdi
callq 0x92fd0
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
callq 0x735fd
movq %r13, %rdi
callq 0x79f01
movzbl %bl, %eax
negl %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x413614(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2c06b5(%rip), %rsi    # 0x2e5013
leaq 0x323cee(%rip), %rdx    # 0x348653
leaq 0x2c610f(%rip), %rcx    # 0x2eaa7b
leaq 0x2c5cf4(%rip), %r8     # 0x2ea667
movl $0x136, %r9d            # imm = 0x136
jmp 0x249a7
movq 0x4135e6(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2c0687(%rip), %rsi    # 0x2e5013
leaq 0x2c082c(%rip), %rdx    # 0x2e51bf
leaq 0x2c60e1(%rip), %rcx    # 0x2eaa7b
leaq 0x2c5cc6(%rip), %r8     # 0x2ea667
movl $0x135, %r9d            # imm = 0x135
xorl %eax, %eax
callq 0x17a50
callq 0x17390