// File: /workspace/github_c_makefile_star2_O1/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 $0x208, %rsp            # imm = 0x208
movq %rdx, %r14
movq %rsi, (%rsp)
movl %edi, %ebp
callq 0x1208f8
movq %rax, %rbx
testq %r14, %r14
je 0xb41c8
movq %r14, %rdi
callq 0x101a9a
testb %al, %al
jne 0xb49cb
testq %r14, %r14
je 0xb41c8
movq %r14, %rdi
callq 0x101a9a
testb %al, %al
jne 0xb49d0
leaq 0x2bab43(%rip), %rdi    # 0x36ed12
leaq 0x2a6933(%rip), %rsi    # 0x35ab09
callq 0x10cc4e
movq %rax, %r12
leaq 0x58(%rsp), %rsi
movq %rax, %rdi
movl $0x2, %edx
movq %rbx, 0x40(%rsp)
movq %rbx, %rcx
callq 0x1a3b34
leaq 0x90(%rsp), %rdx
leaq 0x2a696d(%rip), %rdi    # 0x35ab74
leaq 0x2a6970(%rip), %rsi    # 0x35ab7e
movq $-0x1, %rcx
callq 0x10f7c9
movq %r12, %rdi
movq %rax, %rsi
callq 0x10cd10
leaq 0x98(%rsp), %rdx
leaq 0x2a69a9(%rip), %rdi    # 0x35abdd
leaq 0x2a69ac(%rip), %rsi    # 0x35abe7
movq $-0x1, %rcx
callq 0x10f7c9
movq %r12, %rdi
movq %rax, %rsi
callq 0x10cd10
leaq 0xa0(%rsp), %rdx
leaq 0x2a69e5(%rip), %rdi    # 0x35ac46
leaq 0x2a69e7(%rip), %rsi    # 0x35ac4f
movl $0x3e8, %ecx            # imm = 0x3E8
callq 0x10f4c7
movq %r12, %rdi
movq %rax, %rsi
callq 0x10cd10
leaq 0x2a69ed(%rip), %rdi    # 0x35ac71
leaq 0x2a69f2(%rip), %rsi    # 0x35ac7d
leaq 0x108(%rsp), %rdx
xorl %ebx, %ebx
xorl %ecx, %ecx
callq 0x10f451
movq %r12, %rdi
movq %rax, %rsi
callq 0x10cd10
leaq 0x2a6a01(%rip), %rdi    # 0x35acaf
leaq 0x2a6a05(%rip), %rsi    # 0x35acba
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x10f451
movq %r12, %rdi
movq %rax, %rsi
callq 0x10cd10
leaq 0x2a6a23(%rip), %rdi    # 0x35acf6
leaq 0x2a6a27(%rip), %rsi    # 0x35ad01
leaq 0xb8(%rsp), %r13
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x10f451
movq %r12, %rdi
movq %rax, %rsi
callq 0x10cd10
leaq 0xa8(%rsp), %rdx
leaq 0x2a639a(%rip), %rdi    # 0x35a6a0
leaq 0x2a6399(%rip), %rsi    # 0x35a6a6
movl $0x186a0, %ecx          # imm = 0x186A0
callq 0x10f4c7
movq %r12, %rdi
movq %rax, %rsi
callq 0x10cd10
leaq 0xb4(%rsp), %r15
leaq 0x2e4929(%rip), %rdi    # 0x398c5a
leaq 0x2a632b(%rip), %rsi    # 0x35a663
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x10f451
movq %r12, %rdi
movq %rax, %rsi
callq 0x10cd10
movq %r12, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x10d784
leaq 0x71062(%rip), %r8      # 0x1253c8
leaq 0x34(%rsp), %rsi
movq %r12, %rdi
movl %ebp, %edx
movq (%rsp), %rcx
movq %r14, 0x8(%rsp)
movq %r14, %r9
callq 0x10d796
movl %eax, %ebp
leaq 0x108(%rsp), %rax
movzbl (%rax), %eax
leaq 0x18(%rsp), %rcx
movzbl (%rcx), %ecx
leal (%rax,%rcx,2), %eax
movzbl (%r13), %ecx
leal (%rax,%rcx,4), %eax
movl %eax, -0x4(%r15)
leaq 0x58(%rsp), %rdi
xorl %esi, %esi
callq 0x1a3c1f
movq %r12, %rdi
callq 0x10f2d0
cmpl $0x2, %ebp
je 0xb43d0
movl $0x0, %r14d
cmpl $0x1, %ebp
jne 0xb43d5
movb $0x1, %bl
movb $0x1, %r14b
jmp 0xb43d5
movb $0x1, %bl
xorl %r14d, %r14d
testb %bl, %bl
je 0xb43e1
xorl %r15d, %r15d
jmp 0xb44e9
movslq 0x34(%rsp), %rax
movq (%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x40(%rsp), %r13
movq %r13, %rdi
callq 0x1209e4
leaq 0x58(%rsp), %rbx
movzbl 0x5c(%rbx), %edi
movq 0x40fadd(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x29b4bf(%rip), %rsi    # 0x34f8d4
callq 0x108ed0
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x1a12b0
testq %rax, %rax
sete %r14b
je 0xb44e9
movq %rax, %r12
movq %r13, %rdi
callq 0x120d23
movl 0xb0(%rsp), %edx
movq 0xa8(%rsp), %rcx
movq 0x40fb22(%rip), %rbp    # 0x4c3f80
movq (%rbp), %r8
subq $0x8, %rsp
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %r9
pushq %rbx
callq 0x1a495f
addq $0x10, %rsp
testl %eax, %eax
jne 0xb45d8
cmpl $0x0, 0x20(%r12)
setne %bpl
je 0xb44a1
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
callq 0x1a4800
testb %al, %al
je 0xb44f5
movq %r13, %rdi
callq 0x120d23
leaq 0x108(%rsp), %rdi
movl $0x3, %esi
movq %rax, %rdx
xorl %ecx, %ecx
movq 0x8(%rsp), %rbx
movq %rbx, %r8
callq 0x1aab20
testl %eax, %eax
sete %al
movq %rax, (%rsp)
je 0xb4513
leaq 0x2a6301(%rip), %rsi    # 0x35a7db
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0xb4562
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %r13d, %r13d
jmp 0xb4569
movl %eax, %r14d
xorb $0x1, %r14b
leaq 0x2a62a5(%rip), %rsi    # 0x35a7a8
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0xb44ee
movq 0x108(%rsp), %rdi
callq 0xec1d8
movq %rax, %r14
movq 0x90(%rsp), %rdx
movq 0x98(%rsp), %rcx
testq %rdx, %rdx
js 0xb4612
testq %rcx, %rcx
js 0xb4612
cmpq %rcx, %rdx
jle 0xb4612
leaq 0x2a62df(%rip), %rsi    # 0x35a834
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1019cf
movb $0x1, %r14b
movq (%rsp), %rbx
testb %bpl, %bpl
je 0xb457b
leaq 0xb8(%rsp), %rdi
callq 0x1a48d2
testb %bl, %bl
je 0xb458c
leaq 0x108(%rsp), %rdi
callq 0x1a9e1c
movq %r13, %rdi
callq 0x1a94bc
testq %r12, %r12
je 0xb45a1
movq %r12, %rdi
callq 0x1a430c
testq %r15, %r15
movq 0x40(%rsp), %rbx
je 0xb45b3
movq %r15, %rdi
callq 0x10916a
testq %rbx, %rbx
je 0xb45c0
movq %rbx, %rdi
callq 0x121b03
movzbl %r14b, %eax
negl %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
setne %r14b
movq (%rbp), %rbx
movq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x101ac2
leaq 0x2a6164(%rip), %rsi    # 0x35a758
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x17ab0
leaq 0x2a6170(%rip), %rsi    # 0x35a77a
movq %r13, %rdi
jmp 0xb450a
orq %rcx, %rdx
jns 0xb4637
leaq 0x108(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x98(%rsp), %rdx
movq %r14, %rcx
callq 0x1d094
movq 0x40f942(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
movq 0x90(%rsp), %rdx
movq 0x98(%rsp), %rcx
leaq 0x2a6228(%rip), %rsi    # 0x35a880
xorl %eax, %eax
callq 0x17ab0
movq %r14, %rdx
incq %rdx
movq (%r12), %rax
movq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0xb467e
leaq 0x2a622d(%rip), %rsi    # 0x35a8a6
jmp 0xb4555
movq %r14, 0x48(%rsp)
movq 0x90(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq %rbx, %rcx
callq 0x1a91f0
testq %rax, %rax
sete %r14b
jne 0xb46b9
callq 0x1d1d9
xorl %r13d, %r13d
jmp 0xb4565
movq %rax, %r13
cmpq $0x0, 0xa0(%rsp)
movq (%rsp), %rbx
jne 0xb46d9
movq $0x0, 0x10(%rsp)
jmp 0xb4982
movq $0x0, 0x10(%rsp)
movq %rbp, 0x38(%rsp)
leaq 0x28(%rsp), %rdi
movq %r13, %rsi
callq 0x1a9308
movq %rax, %rbx
movq 0x108(%rsp), %rdi
movq 0x160(%rsp), %rsi
movl 0x150(%rsp), %r9d
xorl %edx, %edx
movq 0x48(%rsp), %rcx
xorl %r8d, %r8d
pushq 0x28(%rsp)
pushq %rax
callq 0x1ac81c
addq $0x10, %rsp
cmpl $0x0, 0x20(%r12)
movq 0x28(%rsp), %rcx
movq %rax, 0x20(%rsp)
je 0xb4854
leaq 0xb8(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x1a48b2
testb %al, %al
je 0xb49d5
movl %eax, %r14d
movq %rbp, %rdi
callq 0x1a492a
movq %rax, 0x50(%rsp)
movq 0x28(%rsp), %rdx
movq %r12, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x1a457e
cmpq %rax, 0x50(%rsp)
jne 0xb49da
movq %rbp, %rdi
callq 0x1a492a
movq %rax, %rbx
movq 0x20(%rsp), %rbp
movq %rbp, %rdi
callq 0x1ac8db
cmpq %rax, %rbx
jne 0xb49df
leaq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x1ac8f9
testb %al, %al
je 0xb489a
movq 0xc0(%rsp), %rbp
movq 0xc8(%rsp), %rbx
cmpq %rbp, %rbx
jae 0xb47f3
movq %r12, %rdi
movq %rbx, %rsi
leaq 0xd0(%rsp), %rdx
callq 0x1a3411
incq 0xc8(%rsp)
jmp 0xb47f5
xorl %eax, %eax
movq 0x8(%rsp), %rdi
cmpq %rbp, %rbx
jae 0xb4825
movq 0x18(%rsp), %rcx
cmpq %rcx, %rax
setne %r14b
je 0xb4836
movq 0x8(%rsp), %rdi
leaq 0x2a61f9(%rip), %rsi    # 0x35aa12
movq %rax, %rdx
xorl %eax, %eax
callq 0x1019cf
jmp 0xb4833
leaq 0x2a61b6(%rip), %rsi    # 0x35a9e2
xorl %eax, %eax
callq 0x1019cf
movb $0x1, %r14b
cmpq %rbp, %rbx
jae 0xb489e
leaq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x1ac8f9
testb %al, %al
jne 0xb47c1
jmp 0xb489e
movq %rax, %r14
movq %r12, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
xorl %ecx, %ecx
callq 0x1a457e
movq %rax, %rbx
movq %r14, %rdi
callq 0x1ac8db
cmpq %rax, %rbx
setne %r14b
je 0xb4894
movq 0x8(%rsp), %rdi
leaq 0x2a61fb(%rip), %rsi    # 0x35aa82
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1019cf
movq (%rsp), %rbx
jmp 0xb490f
xorb $0x1, %r14b
testb %r14b, %r14b
movq (%rsp), %rbx
jne 0xb490f
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rbx
cmpq %rax, %rbx
jae 0xb48dd
movq %r12, %rdi
movq %rbx, %rsi
leaq 0xd0(%rsp), %rdx
movq %rax, %r14
callq 0x1a3411
movq %r14, %rax
incq 0xc8(%rsp)
xorl %ebp, %ebp
cmpq %rax, %rbx
setb %r14b
jae 0xb4906
movq 0x8(%rsp), %rdi
leaq 0x2a6162(%rip), %rsi    # 0x35aa56
movq %rax, %rbp
xorl %eax, %eax
callq 0x1019cf
movq %rbp, %rax
movl $0x7, %ebp
cmpq %rax, %rbx
movq (%rsp), %rbx
jb 0xb4952
movq 0x20(%rsp), %rdi
callq 0x1ac968
movq 0xa8(%rsp), %rcx
testq %rcx, %rcx
je 0xb4950
movq 0x10(%rsp), %rax
incq %rax
xorl %ebp, %ebp
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0xb4952
movq 0x40f63f(%rip), %rax    # 0x4c3f80
movq (%rax), %rsi
movl $0x2e, %edi
callq 0x17f80
jmp 0xb4952
xorl %ebp, %ebp
testl %ebp, %ebp
jne 0xb497d
movq 0x10(%rsp), %rax
incq %rax
testb %r14b, %r14b
movq 0x38(%rsp), %rbp
movq %rax, 0x10(%rsp)
jne 0xb4982
cmpq 0xa0(%rsp), %rax
jb 0xb46e7
jmp 0xb4982
movq 0x38(%rsp), %rbp
cmpq $0x0, 0xa8(%rsp)
je 0xb49a1
movq 0x40f5ec(%rip), %rax    # 0x4c3f80
movq (%rax), %rsi
movl $0xa, %edi
callq 0x17f80
movq 0x40f5d8(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
movq 0xa0(%rsp), %rcx
leaq 0x2a610f(%rip), %rsi    # 0x35aac9
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x17ab0
jmp 0xb4569
callq 0x1d05d
callq 0x1d024
callq 0x1d14b
callq 0x1d167
callq 0x1d1a0