// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/eis-encidxseq.c
// Function: gt_EISVerifyIntegrity
enum EISIntegrityCheckResults
gt_EISVerifyIntegrity(EISeq *seqIdx, const char *projectName,
                      GtUword skip,
                      GtUword tickPrint, FILE *fp, int chkFlags,
                      GtLogger *verbosity, GtError *err)
{
  FILE *bwtFP;
  GtUword pos = 0,
                length = EISLength(seqIdx);
  Suffixarray suffixArray;
  Symbol symOrig;
  unsigned symEnc;
  EISHint hint;
  GtUword rankQueryResult, rankExpect;
  const MRAEnc *alphabet;
  AlphabetRangeSize alphabetSize;
  AlphabetRangeID numRanges;
  enum EISIntegrityCheckResults retval = EIS_INTEGRITY_CHECK_NO_ERROR;
  /* two part process: enumerate all positions of original sequence
   * and verify that the query functions return correct values */
  if (streamsuffixarray(&suffixArray, SARR_BWTTAB, projectName, verbosity, err))
  {
    gt_error_set(err, "Cannot load suffix array project with"
                  " demand for BWT file\n");
    return EIS_INTEGRITY_CHECK_SA_LOAD_ERROR;
  }
  bwtFP = suffixArray.bwttabstream.fp;
  hint = newEISHint(seqIdx);
  alphabet = EISGetAlphabet(seqIdx);
  alphabetSize = gt_MRAEncGetSize(alphabet);
  numRanges = MRAEncGetNumRanges(alphabet);
  do
  {
    GtUword rankTable[alphabetSize], rangeRanks[2][alphabetSize],
      pairRangeRanks[2* alphabetSize], lastRangeRankPos = 0;
    int symRead, rt = 0;
    AlphabetRangeID lastRangeID = 0;
    unsigned rankCmpSym;
    memset(rankTable, 0, sizeof (rankTable));
    memset(rangeRanks, 0, sizeof (rangeRanks));
    if (skip > 0)
    {
      unsigned sym;
      if (skip >= length)
      {
        gt_logger_log(verbosity, "Invalid skip request: "GT_LLD","
                    " too large for sequence length: "GT_WU"",
                    (GtInt64)skip, length);
        return -1;
      }
      fseeko(bwtFP, skip, SEEK_SET);
      for (sym = 0; sym <= (unsigned) GT_MAXALPHABETCHARACTER; ++sym)
        if (MRAEncSymbolHasValidMapping(alphabet, sym))
          rankTable[sym] = EISRank(seqIdx, sym, skip, hint);
      pos = skip;
    }
    while (retval == EIS_INTEGRITY_CHECK_NO_ERROR
           && (symRead = getc(bwtFP)) != EOF)
    {
      symOrig = MRAEncMapSymbol(alphabet, symRead);
      symEnc = EISGetTransformedSym(seqIdx, pos, hint);
      if (symEnc >= alphabetSize)
        verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_INVALID_SYMBOL);
      if (symOrig >= alphabetSize)
        verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_BWT_READ_ERROR);
      if (symEnc != symOrig)
        verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_INVALID_SYMBOL);
      ++rankTable[symOrig];
      if (chkFlags & EIS_VERIFY_EXT_RANK)
      {
        for (rankCmpSym = 0; rankCmpSym < alphabetSize; ++rankCmpSym)
          if ((rankExpect = rankTable[rankCmpSym])
              != (rankQueryResult
                  = EISSymTransformedRank(seqIdx, rankCmpSym, pos + 1, hint)))
            verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_RANK_FAILED);
      }
      else
      {
        rankCmpSym = symEnc;
        if ((rankExpect = rankTable[symEnc])
            != (rankQueryResult = EISSymTransformedRank(seqIdx, symEnc,
                                                        pos + 1, hint)))
          verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_RANK_FAILED);
      }
      /* do rank for full range on some occasions */
      if (!(random() % AVG_RANGE_RANK_INTERVAL))
      {
        unsigned i;
        AlphabetRangeSize rangeSize;
        AlphabetRangeID range = random() % numRanges;
        Symbol rangeBase = MRAEncGetRangeBase(alphabet, range);
        rangeSize = MRAEncGetRangeSize(alphabet, range);
        EISRangeRank(seqIdx, range, pos + 1, rangeRanks[rt], hint);
        for (i = 0; i < rangeSize; ++i)
        {
          rankCmpSym = rangeBase + i;
          if ((rankQueryResult = rangeRanks[rt][i])
              != (rankExpect = rankTable[rankCmpSym]))
            verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_RANK_FAILED);
        }
        if (retval)
          break;
        if (range == lastRangeID)
        {
          EISPosPairRangeRank(seqIdx, range, lastRangeRankPos, pos + 1,
                              pairRangeRanks, hint);
          for (i = 0; i < rangeSize; ++i)
          {
            rankCmpSym = rangeBase + i;
            if ((rankQueryResult = pairRangeRanks[rangeSize + i])
                != (rankExpect = rankTable[rankCmpSym]))
              verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_RANK_FAILED);
            if ((rankQueryResult = pairRangeRanks[i])
                != (rankExpect = rangeRanks[rt ^ 1][i]))
              verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_RANK_FAILED);
          }
          if (retval)
            break;
        }
        lastRangeID = range;
        lastRangeRankPos = pos + 1;
        rt ^= 1;
      }
      ++pos;
      if (tickPrint && !(pos % tickPrint))
        putc('.', fp);
    }
    if (retval)
      break;
    if (tickPrint)
      putc('\n', fp);
    if (ferror(bwtFP))
      verifyIntegrityErrRet(EIS_INTEGRITY_CHECK_BWT_READ_ERROR);
  } while (0);
  deleteEISHint(seqIdx, hint);
  gt_freesuffixarray(&suffixArray);
  return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movl %r9d, -0x80(%rbp)
movq %r8, -0xa0(%rbp)
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %rdx
movq %rdi, %rbx
movq 0x18(%rbp), %r14
movq 0x10(%rbp), %rcx
movq 0x10(%rdi), %r15
leaq -0x1b0(%rbp), %rdi
movl $0x8, %esi
movq %r14, %r8
callq 0x1a9f52
testl %eax, %eax
je 0x1a57bc
leaq 0x2073c9(%rip), %rsi    # 0x3acb70
movq %r14, %rdi
xorl %eax, %eax
callq 0x1019cf
movl $0x3, %r12d
jmp 0x1a5df2
movq %r15, -0x38(%rbp)
movq %r12, -0x48(%rbp)
movq %r13, -0x50(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x38(%rax)
movq %rax, -0x40(%rbp)
testq %rbx, %rbx
je 0x1a5f63
movq 0x8(%rbx), %r15
movq %r15, %rdi
callq 0x1a67a7
movq %rsp, -0xb0(%rbp)
movl 0x4(%r15), %ecx
movl %ecx, -0x7c(%rbp)
movzwl %ax, %ecx
leal 0xf(,%rcx,8), %eax
andl $-0x10, %eax
movq %rsp, %r13
subq %rax, %r13
movq %r13, %rsp
movq %rsp, %r12
movl %ecx, %r14d
shll $0x4, %r14d
subq %r14, %r12
movq %r12, %rsp
movq %rsp, %rax
subq %r14, %rax
movq %rax, -0x88(%rbp)
movq %rax, %rsp
movq %rcx, -0x70(%rbp)
leal (,%rcx,8), %edx
movq %r13, %rdi
xorl %esi, %esi
callq 0x173a0
movq %r12, -0x90(%rbp)
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x173a0
movq -0x48(%rbp), %r12
testq %r12, %r12
je 0x1a58df
cmpq %r12, -0x38(%rbp)
jbe 0x1a58e4
xorl %r14d, %r14d
movq -0x78(%rbp), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x17cf0
cmpl $0x1, (%r15)
jne 0x1a5f4f
movq 0x8(%r15), %rax
movl 0x4(%r15), %ecx
decl %ecx
cmpw $0xff, (%rax,%rcx,2)
je 0x1a58a6
cmpb $-0x1, 0x18(%r15,%r14)
je 0x1a58ce
movq 0x8(%rbx), %rax
cmpl $0x1, (%rax)
jne 0x1a5f4f
movzbl 0x18(%rax,%r14), %esi
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rdx
movq -0x40(%rbp), %rcx
callq *0x8(%rax)
movq %rax, (%r13,%r14,8)
incq %r14
cmpq $0x100, %r14            # imm = 0x100
jne 0x1a5882
movq %r12, %r14
jmp 0x1a5900
xorl %r14d, %r14d
jmp 0x1a590d
leaq 0x2072c0(%rip), %rsi    # 0x3acbab
xorl %r14d, %r14d
movq 0x10(%rbp), %rdi
movq %r12, %rdx
movq -0x38(%rbp), %rcx
xorl %eax, %eax
callq 0x10906e
movq -0x38(%rbp), %rax
cmpq %r12, %rax
jbe 0x1a5d74
testq %rbx, %rbx
setne %al
cmpq $0x0, -0x40(%rbp)
setne %cl
andb %al, %cl
movb %cl, -0x29(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movq $0x0, -0x68(%rbp)
movq %r15, -0xa8(%rbp)
movq -0x78(%rbp), %rdi
callq 0x171f0
cmpl $-0x1, %eax
je 0x1a5d7f
cmpl $0x1, (%r15)
jne 0x1a5f4f
cmpb $0x0, -0x29(%rbp)
je 0x1a5f54
movzbl %al, %eax
movzbl 0x18(%r15,%rax), %r15d
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rdx
callq *0x30(%rax)
movzbl %al, %r12d
movq -0x70(%rbp), %rcx
cmpl %ecx, %r12d
jae 0x1a5e04
cmpl %ecx, %r15d
jae 0x1a5e4a
cmpb %r15b, %al
jne 0x1a5e04
movl %r15d, %eax
incq (%r13,%rax,8)
testb $0x1, -0x80(%rbp)
jne 0x1a59f0
movq %r14, %r15
movl %r12d, %eax
movq (%r13,%rax,8), %r14
movq 0x8(%rbx), %rdi
callq 0x1a67a7
cmpw %r12w, %ax
jbe 0x1a5f59
leaq 0x1(%r15), %rdx
movq (%rbx), %rax
movq %rbx, %rdi
movl %r12d, %esi
movq -0x40(%rbp), %rcx
callq *0x8(%rax)
cmpq %rax, %r14
jne 0x1a5ee5
xorl %r12d, %r12d
movq %r15, %r14
jmp 0x1a5a43
movq %r14, -0x38(%rbp)
leaq 0x1(%r14), %r15
xorl %r12d, %r12d
movq (%r13,%r12,8), %r14
movq 0x8(%rbx), %rdi
callq 0x1a67a7
movzbl %r12b, %ecx
cmpw %cx, %ax
jbe 0x1a5f4a
movq (%rbx), %rax
movzbl %r12b, %esi
movq %rbx, %rdi
movq %r15, %rdx
movq -0x40(%rbp), %rcx
callq *0x8(%rax)
cmpq %rax, %r14
jne 0x1a5c3c
incq %r12
cmpq %r12, -0x70(%rbp)
jne 0x1a59fb
xorl %r12d, %r12d
movq -0x38(%rbp), %r14
callq 0x125bcc
testb $0x7f, %al
movq -0xa8(%rbp), %r15
je 0x1a5a5c
movq -0x50(%rbp), %rcx
jmp 0x1a5c04
movl %r12d, -0x48(%rbp)
callq 0x125bcc
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edx, %edx
divl -0x7c(%rbp)
cmpl %edx, 0x4(%r15)
jbe 0x1a5f5e
movl %edx, %r12d
movl %edx, %eax
testl %edx, %edx
je 0x1a5a91
movq 0x8(%r15), %rcx
movzbl -0x2(%rcx,%rax,2), %ecx
movq %rcx, -0x60(%rbp)
jmp 0x1a5a99
movq $0x0, -0x60(%rbp)
movq 0x10(%r15), %rcx
movzwl (%rcx,%rax,2), %r15d
movq %r14, -0x38(%rbp)
leaq 0x1(%r14), %rdx
movl -0x58(%rbp), %eax
imulq -0x70(%rbp), %rax
movq -0x90(%rbp), %rcx
leaq (%rcx,%rax,8), %r14
movq (%rbx), %rax
movq %rbx, %rdi
movl %r12d, %esi
movq %rdx, -0x98(%rbp)
movq %r14, %rcx
movq -0x40(%rbp), %r8
callq *0x18(%rax)
testq %r15, %r15
je 0x1a5b07
movq -0x60(%rbp), %rax
leaq (,%rax,8), %rax
addq %r13, %rax
xorl %r9d, %r9d
movq (%r14,%r9,8), %rcx
movq (%rax,%r9,8), %r8
cmpq %r8, %rcx
jne 0x1a5ca7
incq %r9
cmpq %r9, %r15
jne 0x1a5aee
movq -0x38(%rbp), %r14
cmpl $0x0, -0x48(%rbp)
movq -0x50(%rbp), %rcx
movq -0x88(%rbp), %r8
je 0x1a5b2b
xorl %eax, %eax
movq -0x68(%rbp), %rdx
movl -0x54(%rbp), %r12d
jmp 0x1a5be9
cmpl -0x54(%rbp), %r12d
jne 0x1a5bd5
movq (%rbx), %rax
movq %rbx, %rdi
movl %r12d, %esi
movq -0x68(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0x40(%rbp), %r9
callq *0x20(%rax)
movl $0x0, -0x48(%rbp)
testq %r15, %r15
setne %r14b
je 0x1a5bc3
movl -0x58(%rbp), %eax
xorl $0x1, %eax
imulq -0x70(%rbp), %rax
movq -0x90(%rbp), %rcx
leaq (%rcx,%rax,8), %rdx
movq -0x88(%rbp), %r9
leaq (%r9,%r15,8), %rsi
movq -0x60(%rbp), %rax
leaq (,%rax,8), %rdi
addq %r13, %rdi
xorl %eax, %eax
movq (%rsi,%rax,8), %rcx
movq (%rdi,%rax,8), %r8
cmpq %r8, %rcx
jne 0x1a5d0e
movq (%r9,%rax,8), %rcx
movq (%rdx,%rax,8), %r8
cmpq %r8, %rcx
jne 0x1a5d0e
incq %rax
cmpq %r15, %rax
setb %r14b
cmpq %rax, %r15
jne 0x1a5b92
testb $0x1, %r14b
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %r14
jne 0x1a5b1c
xorl $0x1, -0x58(%rbp)
movl $0x0, -0x48(%rbp)
movb $0x1, %al
movq -0x98(%rbp), %rdx
movq %rdx, -0x68(%rbp)
movl %r12d, -0x54(%rbp)
testb %al, %al
movq -0xa8(%rbp), %r15
movl -0x48(%rbp), %r12d
je 0x1a5d86
incq %r14
testq %rcx, %rcx
je 0x1a5c2e
movq %r14, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x1a5c2e
movl $0x2e, %edi
movq -0xa0(%rbp), %rsi
callq 0x17f80
movq -0x50(%rbp), %rcx
testl %r12d, %r12d
je 0x1a593d
jmp 0x1a5d86
movq 0x31e33d(%rip), %rcx    # 0x4c3f80
movq (%rcx), %rdi
leaq 0x20704f(%rip), %rsi    # 0x3acc9c
movq -0x38(%rbp), %r15
movq %r15, %rdx
movq %rax, %rcx
movq %r14, %r8
movl %r12d, %r9d
xorl %eax, %eax
callq 0x17ab0
movq 0x18(%rbp), %rdi
leaq 0x207084(%rip), %rsi    # 0x3accf3
xorl %eax, %eax
callq 0x1019cf
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x4, %r12d
testq %rax, %rax
je 0x1a59eb
movq 0x31e2ed(%rip), %rcx    # 0x4c3f80
movq (%rcx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq -0x40(%rbp), %rcx
callq *%rax
jmp 0x1a59eb
addl -0x60(%rbp), %r9d
movq 0x31e2ce(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
leaq 0x206fe0(%rip), %rsi    # 0x3acc9c
movq -0x38(%rbp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x17ab0
movq 0x18(%rbp), %rdi
leaq 0x20701e(%rip), %rsi    # 0x3accf3
xorl %eax, %eax
callq 0x1019cf
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x4, -0x48(%rbp)
testq %rax, %rax
je 0x1a5b0b
movq 0x31e286(%rip), %rcx    # 0x4c3f80
movq (%rcx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rcx
callq *%rax
jmp 0x1a5b0b
movq -0x60(%rbp), %r9
addl %eax, %r9d
movq 0x31e264(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
leaq 0x206f76(%rip), %rsi    # 0x3acc9c
movq -0x38(%rbp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x17ab0
movq 0x18(%rbp), %rdi
leaq 0x206fb4(%rip), %rsi    # 0x3accf3
xorl %eax, %eax
callq 0x1019cf
movq (%rbx), %rax
movq 0x60(%rax), %rax
testq %rax, %rax
je 0x1a5d68
movq 0x31e227(%rip), %rcx    # 0x4c3f80
movq (%rcx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq -0x40(%rbp), %rcx
callq *%rax
movl $0x4, -0x48(%rbp)
jmp 0x1a5bc3
xorl %r12d, %r12d
movl $0x1, %r14d
jmp 0x1a5dc4
xorl %r12d, %r12d
movq -0x50(%rbp), %rcx
movq %r14, %r15
movl $0x2, %r14d
testl %r12d, %r12d
jne 0x1a5dc4
testq %rcx, %rcx
je 0x1a5daa
movl $0xa, %edi
movq -0xa0(%rbp), %rsi
callq 0x17f80
movq -0x78(%rbp), %rdi
callq 0x17f00
xorl %r14d, %r14d
movl $0x0, %r12d
testl %eax, %eax
jne 0x1a5e8a
movq -0xb0(%rbp), %rsp
testb $0x1, %r14b
jne 0x1a5dec
movq (%rbx), %rax
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq *0x40(%rax)
leaq -0x1b0(%rbp), %rdi
callq 0x1a9e1c
jmp 0x1a5df2
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x31e175(%rip), %r13    # 0x4c3f80
movq (%r13), %rdi
leaq 0x206dd4(%rip), %rsi    # 0x3acbea
movq %r14, %rdx
movl %r15d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x17ab0
leaq 0x206e07(%rip), %rsi    # 0x3acc34
movq 0x18(%rbp), %rdi
xorl %eax, %eax
callq 0x1019cf
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x1, %r12d
jmp 0x1a5f2c
movq 0x31e12f(%rip), %r13    # 0x4c3f80
movq (%r13), %rdi
leaq 0x206df4(%rip), %rsi    # 0x3acc50
movq %r14, %rdx
xorl %eax, %eax
callq 0x17ab0
leaq 0x206e0a(%rip), %rsi    # 0x3acc77
movq 0x18(%rbp), %rdi
xorl %eax, %eax
callq 0x1019cf
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x2, %r12d
jmp 0x1a5f2c
movq 0x31e0ef(%rip), %r12    # 0x4c3f80
movq (%r12), %rdi
leaq 0x206db4(%rip), %rsi    # 0x3acc50
movq %r15, %rdx
xorl %eax, %eax
callq 0x17ab0
leaq 0x206dca(%rip), %rsi    # 0x3acc77
movq 0x18(%rbp), %rdi
xorl %eax, %eax
callq 0x1019cf
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x2, %r14d
testq %rax, %rax
je 0x1a5eda
movq (%r12), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq -0x40(%rbp), %rcx
callq *%rax
movl $0x2, %r12d
jmp 0x1a5dc4
movq 0x31e094(%rip), %r13    # 0x4c3f80
movq (%r13), %rdi
leaq 0x206da5(%rip), %rsi    # 0x3acc9c
movq %r15, %rdx
movq %rax, %rcx
movq %r14, %r8
movq %r15, %r14
movl %r12d, %r9d
xorl %eax, %eax
callq 0x17ab0
leaq 0x206ddf(%rip), %rsi    # 0x3accf3
movq 0x18(%rbp), %rdi
xorl %eax, %eax
callq 0x1019cf
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x4, %r12d
testq %rax, %rax
je 0x1a5d82
movq (%r13), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rcx
callq *%rax
jmp 0x1a5d82
callq 0x61661
callq 0x173b0
callq 0x6162a
callq 0x61698
callq 0x616cf
callq 0x61706