// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/tools/gt_packedindex_chk_search.c
// Function: gt_packedindex_chk_search
extern int
gt_packedindex_chk_search(int argc, const char *argv[], GtError *err)
{
  struct chkSearchOptions params;
  Suffixarray suffixarray;
  Enumpatterniterator *epi = NULL;
  bool saIsLoaded = false;
  BWTSeq *bwtSeq = NULL;
  GtStr *inputProject = NULL;
  int parsedArgs;
  bool had_err = false;
  BWTSeqExactMatchesIterator EMIter;
  bool EMIterInitialized = false;
  GtLogger *logger = NULL;
  inputProject = gt_str_new();

  do {
    gt_error_check(err);
    {
      bool exitNow = false;
      switch (parseChkBWTOptions(&parsedArgs, argc, argv, &params,
                                 inputProject, err))
      {
      case GT_OPTION_PARSER_OK:
        break;
      case GT_OPTION_PARSER_ERROR:
        had_err = true;
        exitNow = true;
        break;
      case GT_OPTION_PARSER_REQUESTS_EXIT:
        exitNow = true;
        break;
      }
      if (exitNow)
        break;
    }
    gt_str_set(inputProject, argv[parsedArgs]);

    logger = gt_logger_new(params.verboseOutput,
                           GT_LOGGER_DEFLT_PREFIX, stdout);

    bwtSeq = gt_availBWTSeq(&params.idx.final, logger, err);
    if ((had_err = bwtSeq == NULL))
      break;

    {
      enum verifyBWTSeqErrCode retval =
        gt_BWTSeqVerifyIntegrity(bwtSeq, gt_str_get(inputProject), params.flags,
                              params.progressInterval, stderr, logger, err);
      if ((had_err = (retval != VERIFY_BWTSEQ_NO_ERROR)))
      {
        fprintf(stderr, "index integrity check failed: %s\n",
                gt_error_get(err));
        gt_error_set(err, "aborted because of index integrity check fail");
        break;
      }
    }
    if (BWTSeqHasLocateInformation(bwtSeq))
    {
      if ((had_err = !gt_initEmptyEMIterator(&EMIter, bwtSeq)))
      {
        gt_error_set(err, "Cannot create matches iterator for sequence index.");
        break;
      }
      EMIterInitialized = true;
    }
    {
      GtUword totalLen, dbstart;
      GtUword trial, patternLen;

      if ((had_err =
           gt_mapsuffixarray(&suffixarray, SARR_SUFTAB | SARR_ESQTAB,
                             gt_str_get(inputProject), NULL, err) != 0))
      {
        gt_error_set(err, "Can't load suffix array project with"
                  " demand for encoded sequence and suffix table files\n");
        break;
      }
      totalLen = gt_encseq_total_length(suffixarray.encseq);
      saIsLoaded = true;
      if ((had_err = (params.minPatLen >= 0L && params.maxPatLen >= 0L
                      && params.minPatLen > params.maxPatLen)))
      {
        gt_error_set(err, "Invalid pattern lengths selected: min="GT_WD", "
                     "max="GT_WD";"
                     " min <= max is required.", params.minPatLen,
                     params.maxPatLen);
        break;
      }
      if (params.minPatLen < 0 || params.maxPatLen < 0)
      {
        unsigned int numofchars
          = gt_alphabet_num_of_chars(
                               gt_encseq_alphabet(suffixarray.encseq));
        if (params.minPatLen < 0)
          params.minPatLen
            = gt_recommendedprefixlength(numofchars,
                                         totalLen,
                                         GT_RECOMMENDED_MULTIPLIER_DEFAULT,
                                         true);
        if (params.maxPatLen < 0)
          params.maxPatLen =
            GT_MAX(params.minPatLen,
                125 * gt_recommendedprefixlength(numofchars,totalLen,
                                         GT_RECOMMENDED_MULTIPLIER_DEFAULT,
                                         true)/100);
        else
          params.maxPatLen = GT_MAX(params.maxPatLen, params.minPatLen);
      }
      fprintf(stderr, "Using patterns of lengths "GT_WU" to "GT_WU"\n",
              params.minPatLen, params.maxPatLen);
      if ((had_err = totalLen + 1 != BWTSeqLength(bwtSeq)))
      {
        gt_error_set(err, "base suffix array and index have diferrent lengths!"
                          ""GT_WU" vs. "GT_WU"",  totalLen + 1,
                  BWTSeqLength(bwtSeq));
        break;
      }
      if ((had_err =
           (epi = gt_newenumpatterniterator(params.minPatLen, params.maxPatLen,
                                         suffixarray.encseq,
                                         err)) == NULL))
      {
        fputs("Creation of pattern iterator failed!\n", stderr);
        break;
      }
      for (trial = 0; !had_err && trial < params.numOfSamples; ++trial)
      {
        const GtUchar *pptr = gt_nextEnumpatterniterator(&patternLen, epi);
        GtMMsearchiterator *mmsi =
          gt_mmsearchiterator_new_complete_plain(suffixarray.encseq,
                                            suffixarray.suftab,
                                            0,  /* leftbound */
                                            totalLen, /* rightbound */
                                            0, /* offset */
                                            suffixarray.readmode,
                                            pptr,
                                            patternLen);
        if (BWTSeqHasLocateInformation(bwtSeq))
        {
          if ((had_err = !gt_reinitEMIterator(&EMIter, bwtSeq, pptr, patternLen,
                                           false)))
          {
            fputs("Internal error: failed to reinitialize pattern match"
                  " iterator", stderr);
            abort();
          }
          gt_assert(gt_EMINumMatchesTotal(&EMIter) ==
                    gt_BWTSeqMatchCount(bwtSeq, pptr, patternLen,
                                        false));
          gt_assert(gt_EMINumMatchesTotal(&EMIter)
                      == gt_mmsearchiterator_count(mmsi));
          while (gt_mmsearchiterator_next(&dbstart,mmsi))
          {
            GtUword matchPos = 0;
            bool match = EMIGetNextMatch(&EMIter, &matchPos, bwtSeq);
            if ((had_err = !match))
            {
              gt_error_set(err,
                           "matches of packedindex expired before mmsearch!");
              break;
            }
            if ((had_err = matchPos != dbstart))
            {
              gt_error_set(err, "packedindex match doesn't equal mmsearch "
                           "match result!\n"GT_WU" vs. "GT_WU"\n",
                           matchPos, dbstart);
            }
          }
          if (!had_err)
          {
            GtUword matchPos;
            bool trailingMatch = EMIGetNextMatch(&EMIter, &matchPos, bwtSeq);
            if ((had_err = trailingMatch))
            {
              gt_error_set(err, "matches of mmsearch expired before fmindex!");
              break;
            }
          }
        }
        else
        {
          GtUword numFMIMatches = gt_BWTSeqMatchCount(bwtSeq, pptr,
                                                         patternLen,
                                                         false),
            numMMSearchMatches = gt_mmsearchiterator_count(mmsi);
          if ((had_err = numFMIMatches != numMMSearchMatches))
          {
            gt_error_set(err, "Number of matches not equal for suffix array ("
                              ""GT_WU") and fmindex ("GT_WU").\n",
                      numFMIMatches, numMMSearchMatches);
          }
        }
        gt_mmsearchiterator_delete(mmsi);
        mmsi = NULL;
        if (params.progressInterval && !((trial + 1) % params.progressInterval))
          putc('.', stderr);
      }
      if (params.progressInterval)
        putc('\n', stderr);
      fprintf(stderr, "Finished "GT_WU" of "GT_WU" matchings successfully.\n",
              trial, params.numOfSamples);
    }
  } while (0);
  if (EMIterInitialized) gt_destructEMIterator(&EMIter);
  if (saIsLoaded) gt_freesuffixarray(&suffixarray);
  gt_freeEnumpatterniterator(epi);
  if (bwtSeq) gt_deleteBWTSeq(bwtSeq);
  if (logger) gt_logger_delete(logger);
  if (inputProject) gt_str_delete(inputProject);
  return had_err?-1:0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdx, %r12
movq %rsi, %r14
movl %edi, %ebp
callq 0x11ac6c
movq %rax, %rbx
testq %r12, %r12
je 0xb1ec5
movq %r12, %rdi
callq 0xfcc32
testb %al, %al
jne 0xb2536
leaq 0x1c(%rsp), %rdi
leaq 0x48(%rsp), %rcx
movl %ebp, %esi
movq %r14, %rdx
movq %rbx, %r8
movq %r12, %r9
jmp 0xb1eda
leaq 0x1c(%rsp), %rdi
leaq 0x48(%rsp), %rcx
movl %ebp, %esi
movq %r14, %rdx
movq %rbx, %r8
xorl %r9d, %r9d
callq 0xb254a
movb $0x1, %bpl
cmpl $0x1, %eax
je 0xb1ef6
cmpl $0x2, %eax
jne 0xb1efe
xorl %r14d, %r14d
xorl %ebp, %ebp
jmp 0xb1ffe
xorl %r14d, %r14d
jmp 0xb1ffe
movslq 0x1c(%rsp), %rax
movq (%r14,%rax,8), %rsi
movq %rbx, %rdi
callq 0x11ad62
leaq 0x48(%rsp), %r15
movzbl 0x5c(%r15), %edi
movq 0x406fb8(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x2949aa(%rip), %rsi    # 0x3468d4
callq 0x103e40
movq %rax, %r14
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x198d84
testq %rax, %rax
je 0xb1ffe
movq %rax, %r15
movq %rbx, %rdi
callq 0x11b0a1
movl 0xa0(%rsp), %edx
movq 0x98(%rsp), %rcx
movq 0x407016(%rip), %rsi    # 0x4b8f80
movq (%rsi), %r8
subq $0x8, %rsp
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %r9
pushq %r12
callq 0x19c3dd
addq $0x10, %rsp
testl %eax, %eax
jne 0xb20ed
movl 0x20(%r15), %r13d
testl %r13d, %r13d
je 0xb1faa
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
callq 0x19c27c
testb %al, %al
je 0xb200a
movq %rbx, %rdi
callq 0x11b0a1
leaq 0xf8(%rsp), %rdi
movl $0x3, %esi
movq %rax, %rdx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x1a2288
testl %eax, %eax
je 0xb2026
leaq 0x29f7cc(%rip), %rsi    # 0x3517a3
movq %r12, %rdi
xorl %eax, %eax
callq 0xfcb67
movb $0x1, %bpl
testl %r13d, %r13d
je 0xb1ff6
leaq 0xa8(%rsp), %rdi
callq 0x19c34e
xorl %r13d, %r13d
jmp 0xb20ab
xorl %edi, %edi
callq 0x1a0cd4
jmp 0xb20bb
leaq 0x29f75f(%rip), %rsi    # 0x351770
xorl %r13d, %r13d
movq %r12, %rdi
xorl %eax, %eax
callq 0xfcb67
movb $0x1, %bpl
jmp 0xb20ab
movl %eax, 0x18(%rsp)
movq 0xf8(%rsp), %rdi
callq 0xe7b9c
movq 0x80(%rsp), %rbp
movq 0x88(%rsp), %rcx
testq %rbp, %rbp
js 0xb2101
testq %rcx, %rcx
js 0xb2101
cmpq %rcx, %rbp
jbe 0xb2101
leaq 0x29f793(%rip), %rsi    # 0x3517fc
movq $0x0, (%rsp)
movq %r12, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xfcb67
movb $0x1, %bpl
testl %r13d, %r13d
je 0xb2093
leaq 0xa8(%rsp), %rdi
callq 0x19c34e
cmpl $0x0, 0x18(%rsp)
movq (%rsp), %r13
jne 0xb20ab
leaq 0xf8(%rsp), %rdi
callq 0x1a1540
movq %r13, %rdi
callq 0x1a0cd4
movq %r15, %rdi
callq 0x19bd88
testq %r14, %r14
je 0xb20c8
movq %r14, %rdi
callq 0x1040e0
testq %rbx, %rbx
je 0xb20d5
movq %rbx, %rdi
callq 0x11bdbf
movzbl %bpl, %eax
negl %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x1ceed
leaq 0x29f646(%rip), %rsi    # 0x351742
jmp 0xb2011
movq %rax, 0x10(%rsp)
movq %rbp, %rax
orq %rcx, %rax
jns 0xb21ed
movl %r13d, 0xc(%rsp)
movq 0xf8(%rsp), %rdi
callq 0xebcd9
movq %rax, %rdi
callq 0xd11be
movl %eax, %r13d
movq 0x80(%rsp), %rbp
testq %rbp, %rbp
jns 0xb2160
movsd 0x29f594(%rip), %xmm0   # 0x3516d8
movl %r13d, %edi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x1e2c5c
movl %eax, %ebp
movq %rbp, 0x80(%rsp)
movq 0x88(%rsp), %rcx
testq %rcx, %rcx
jns 0xb21a7
movsd 0x29f563(%rip), %xmm0   # 0x3516d8
movl %r13d, %edi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x1e2c5c
imull $0x7d, %eax, %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
shrq $0x25, %rax
cmpq %rax, %rbp
jbe 0xb21b0
movq 0x80(%rsp), %rbp
movq %rbp, %rcx
jmp 0xb21e0
cmpq %rbp, %rcx
cmovbeq %rbp, %rcx
jmp 0xb21e0
movsd 0x29f520(%rip), %xmm0   # 0x3516d8
movl %r13d, %edi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x1e2c5c
imull $0x7d, %eax, %eax
imulq $0x51eb851f, %rax, %rcx # imm = 0x51EB851F
shrq $0x25, %rcx
movq 0x80(%rsp), %rbp
movq %rcx, 0x88(%rsp)
movl 0xc(%rsp), %r13d
movq 0x406d8c(%rip), %rax    # 0x4b8f80
movq (%rax), %rdi
leaq 0x29f64a(%rip), %rsi    # 0x351848
movq %rbp, %rdx
xorl %eax, %eax
callq 0x17ab0
movq 0x10(%rsp), %rdx
incq %rdx
movq (%r15), %rax
movq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0xb2233
leaq 0x29f64b(%rip), %rsi    # 0x35186e
movq $0x0, (%rsp)
movq %r12, %rdi
jmp 0xb2077
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0xf8(%rsp), %rdx
movq %r12, %rcx
callq 0x1a09fc
movq %rax, (%rsp)
testq %rax, %rax
jne 0xb2271
callq 0x1cfa1
movb $0x1, %bpl
movq $0x0, (%rsp)
jmp 0xb2081
movl %r13d, 0xc(%rsp)
cmpq $0x0, 0x90(%rsp)
jne 0xb228b
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0xb24ea
xorl %r13d, %r13d
movq %r15, 0x20(%rsp)
movq (%rsp), %rsi
movq %r13, 0x38(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x1a0b0e
movq %rax, %rbp
movq 0xf8(%rsp), %rdi
movq 0x150(%rsp), %rsi
movl 0x140(%rsp), %r9d
xorl %edx, %edx
movq 0x10(%rsp), %rcx
xorl %r8d, %r8d
pushq 0x30(%rsp)
pushq %rax
callq 0x1a3e08
addq $0x10, %rsp
cmpl $0x0, 0x20(%r15)
movq 0x30(%rsp), %rcx
movq %rax, 0x28(%rsp)
je 0xb23fd
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %r13
movq %rbp, %rdx
xorl %r8d, %r8d
callq 0x19c32e
testb %al, %al
je 0xb253b
movq %r15, %rbp
leaq 0xa8(%rsp), %rdi
callq 0x19c3a8
movq %rax, %r15
movq 0x30(%rsp), %rdx
movq %rbp, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x19bffa
cmpq %rax, %r15
jne 0xb2540
leaq 0xa8(%rsp), %rdi
callq 0x19c3a8
movq %rax, %r13
movq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x1a3ec7
cmpq %rax, %r13
jne 0xb2545
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x1a3ee5
testb %al, %al
je 0xb23e3
movq 0xb8(%rsp), %rsi
cmpq 0xb0(%rsp), %rsi
jae 0xb243b
movq 0x20(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x19ae8c
incq 0xb8(%rsp)
movq %rax, %r15
movq 0x40(%rsp), %r13
cmpq %r13, %rax
je 0xb23c8
movq %r12, %rdi
leaq 0x29f61f(%rip), %rsi    # 0x3519da
movq %r15, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0xfcb67
leaq 0x40(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1a3ee5
testb %al, %al
jne 0xb2374
movb $0x1, %bpl
cmpq %r13, %r15
jne 0xb244f
movq 0xb8(%rsp), %rsi
cmpq 0xb0(%rsp), %rsi
jb 0xb24b4
xorl %ebp, %ebp
jmp 0xb244f
movq %rax, %r13
movq %rbp, %rsi
xorl %ebp, %ebp
movq %r15, %rdi
movq %rcx, %rdx
xorl %ecx, %ecx
callq 0x19bffa
movq %rax, %r15
movq %r13, %rdi
callq 0x1a3ec7
cmpq %rax, %r15
je 0xb244f
movq %r12, %rdi
leaq 0x29f61e(%rip), %rsi    # 0x351a4a
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xfcb67
jmp 0xb244c
movq %r12, %rdi
leaq 0x29f565(%rip), %rsi    # 0x3519aa
xorl %eax, %eax
callq 0xfcb67
movb $0x1, %bpl
movq 0x28(%rsp), %rdi
callq 0x1a3f54
movq 0x98(%rsp), %rcx
movq 0x38(%rsp), %r13
incq %r13
testq %rcx, %rcx
je 0xb248f
movq %r13, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0xb248f
movq 0x406afe(%rip), %rax    # 0x4b8f80
movq (%rax), %rsi
movl $0x2e, %edi
callq 0x17f80
testb %bpl, %bpl
movq (%rsp), %rsi
jne 0xb24ad
cmpq 0x90(%rsp), %r13
movq 0x20(%rsp), %r15
jb 0xb2297
jmp 0xb24ea
movq 0x20(%rsp), %r15
jmp 0xb24ea
movq 0x20(%rsp), %r15
movq %r15, %rdi
leaq 0xc0(%rsp), %rdx
callq 0x19ae8c
incq 0xb8(%rsp)
leaq 0x29f546(%rip), %rsi    # 0x351a1e
movq %r12, %rdi
xorl %eax, %eax
callq 0xfcb67
movb $0x1, %bpl
movq 0x38(%rsp), %r13
cmpq $0x0, 0x98(%rsp)
je 0xb2509
movq 0x406a84(%rip), %rax    # 0x4b8f80
movq (%rax), %rsi
movl $0xa, %edi
callq 0x17f80
movq 0x406a70(%rip), %rax    # 0x4b8f80
movq (%rax), %rdi
movq 0x90(%rsp), %rcx
leaq 0x29f56f(%rip), %rsi    # 0x351a91
movq %r13, %rdx
xorl %eax, %eax
callq 0x17ab0
movl 0xc(%rsp), %r13d
jmp 0xb2081
callq 0x1ceb6
callq 0x1cf13
callq 0x1cf2f
callq 0x1cf68