// File: /workspace/github_c_makefile_star2_O3/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 $0x198, %rsp            # imm = 0x198
movl %r9d, -0x7c(%rbp)
movq %r8, %r12
movq %rcx, %r14
movq %rdx, -0x48(%rbp)
movq %rsi, %rdx
movq %rdi, %rbx
movq 0x18(%rbp), %r15
movq 0x10(%rbp), %rcx
movq 0x10(%rdi), %r13
leaq -0x1c0(%rbp), %rdi
movl $0x8, %esi
movq %r15, %r8
callq 0x1a1676
testl %eax, %eax
je 0x19d188
leaq 0x20648b(%rip), %rsi    # 0x3a35ff
movq %r15, %rdi
xorl %eax, %eax
callq 0xfcb67
movl $0x3, %eax
jmp 0x19d75e
movq %r13, -0x40(%rbp)
movq %r14, -0xc0(%rbp)
movq %r12, -0x90(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x38(%rax)
movq %rax, -0x30(%rbp)
movq 0x8(%rbx), %r14
movq %r14, -0x60(%rbp)
movq %r14, %rdi
callq 0x19e077
movq %rsp, -0x88(%rbp)
movl 0x4(%r14), %ecx
movl %ecx, -0x74(%rbp)
movzwl %ax, %ecx
leal 0xf(,%rcx,8), %eax
andl $-0x10, %eax
movq %rsp, %r13
subq %rax, %r13
movq %r13, %rsp
movq %rsp, %r12
movq -0x48(%rbp), %r15
movl %ecx, %r14d
shll $0x4, %r14d
subq %r14, %r12
movq %r12, %rsp
movq %rsp, %rax
subq %r14, %rax
movq %rax, -0xa8(%rbp)
movq %rax, %rsp
movq %rcx, -0x68(%rbp)
leal (,%rcx,8), %edx
movq $0x0, -0xb0(%rbp)
movq %r13, %rdi
xorl %esi, %esi
callq 0x173a0
movq %r12, -0xa0(%rbp)
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x173a0
movq %r15, %r12
testq %r15, %r15
movq -0x60(%rbp), %r15
je 0x19d2c3
movq %r12, %rdx
movq -0x40(%rbp), %rcx
cmpq %r12, %rcx
jbe 0x19d634
movq %rdx, %rsi
xorl %r14d, %r14d
movq -0x70(%rbp), %rdi
xorl %edx, %edx
callq 0x17cf0
cmpl $0x1, (%r15)
jne 0x19d823
movq 0x8(%r15), %rax
movl 0x4(%r15), %ecx
decl %ecx
cmpw $0xff, (%rax,%rcx,2)
je 0x19d28f
cmpb $-0x1, 0x18(%r15,%r14)
je 0x19d2b7
movq 0x8(%rbx), %rax
cmpl $0x1, (%rax)
jne 0x19d823
movzbl 0x18(%rax,%r14), %esi
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rdx
movq -0x30(%rbp), %rcx
callq *0x8(%rax)
movq %rax, (%r13,%r14,8)
incq %r14
cmpq $0x100, %r14            # imm = 0x100
jne 0x19d26b
testq %rbx, %rbx
setne %al
cmpq $0x0, -0x30(%rbp)
setne %cl
andb %al, %cl
movb %cl, -0x31(%rbp)
movl $0x0, -0x4c(%rbp)
movq $0x0, -0x98(%rbp)
movq %r12, %r14
movq -0x70(%rbp), %rdi
callq 0x171f0
cmpl $-0x1, %eax
je 0x19d657
movq -0x60(%rbp), %rcx
cmpl $0x1, (%rcx)
jne 0x19d823
cmpb $0x0, -0x31(%rbp)
je 0x19d828
movzbl %al, %eax
movzbl 0x18(%rcx,%rax), %r12d
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %rdx
callq *0x30(%rax)
movzbl %al, %r15d
movq -0x68(%rbp), %rcx
cmpl %ecx, %r15d
jae 0x19d76d
cmpl %ecx, %r12d
jae 0x19d68a
cmpb %r12b, %al
jne 0x19d76d
movq %r14, -0x48(%rbp)
movq (%r13,%r12,8), %r14
incq %r14
movq %r14, (%r13,%r12,8)
testb $0x1, -0x7c(%rbp)
jne 0x19d39c
movq 0x8(%rbx), %rdi
callq 0x19e077
cmpw %r12w, %ax
jbe 0x19d82d
movq -0x48(%rbp), %rax
leaq 0x1(%rax), %rdx
movq (%rbx), %rax
movq %rbx, %rdi
movl %r12d, %esi
movq -0x30(%rbp), %rcx
callq *0x8(%rax)
cmpq %rax, %r14
je 0x19d3e8
jmp 0x19d7bd
movq -0x48(%rbp), %rax
leaq 0x1(%rax), %r12
xorl %r15d, %r15d
movq (%r13,%r15,8), %r14
movq 0x8(%rbx), %rdi
callq 0x19e077
movzbl %r15b, %ecx
cmpw %cx, %ax
jbe 0x19d81e
movq (%rbx), %rax
movzbl %r15b, %esi
movq %rbx, %rdi
movq %r12, %rdx
movq -0x30(%rbp), %rcx
callq *0x8(%rax)
cmpq %rax, %r14
jne 0x19d5b6
incq %r15
cmpq %r15, -0x68(%rbp)
jne 0x19d3a7
xorl %r12d, %r12d
movb $0x1, %r15b
movq -0x48(%rbp), %r14
callq 0x11fe0c
testb $0x7f, %al
je 0x19d403
incq %r14
jmp 0x19d57a
movl %r15d, -0x78(%rbp)
callq 0x11fe0c
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edx, %edx
divl -0x74(%rbp)
movq -0x60(%rbp), %rax
cmpl %edx, 0x4(%rax)
jbe 0x19d832
movl %edx, %r15d
testl %edx, %edx
movl %r12d, -0x40(%rbp)
je 0x19d444
movq -0x60(%rbp), %rdx
movq 0x8(%rdx), %rcx
movl %r15d, %eax
movzbl -0x2(%rcx,%rax,2), %ecx
movq %rcx, -0x58(%rbp)
jmp 0x19d452
xorl %eax, %eax
movq $0x0, -0x58(%rbp)
movq -0x60(%rbp), %rdx
movq 0x10(%rdx), %rcx
movzwl (%rcx,%rax,2), %r12d
leaq 0x1(%r14), %rdx
movl -0x4c(%rbp), %eax
imulq -0x68(%rbp), %rax
movq -0xa0(%rbp), %rcx
leaq (%rcx,%rax,8), %r14
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
movq %rdx, -0xb8(%rbp)
movq %r14, %rcx
movq -0x30(%rbp), %r8
callq *0x18(%rax)
testq %r12, %r12
movq -0xa8(%rbp), %r9
je 0x19d4c2
movq -0x58(%rbp), %rax
leaq (,%rax,8), %rdx
addq %r13, %rdx
xorl %eax, %eax
movq (%r14,%rax,8), %rcx
movq (%rdx,%rax,8), %r8
cmpq %r8, %rcx
jne 0x19d6c7
incq %rax
cmpq %rax, %r12
jne 0x19d4a9
cmpb $0x0, -0x78(%rbp)
movq -0x48(%rbp), %r14
je 0x19d73b
movq -0xb0(%rbp), %rsi
cmpl %esi, %r15d
jne 0x19d55b
movq (%rbx), %rax
movq %rbx, %rdi
movq -0x98(%rbp), %rdx
movq -0xb8(%rbp), %rcx
movq %r9, %r8
movq -0x30(%rbp), %r9
callq *0x20(%rax)
movq -0xa8(%rbp), %r9
testq %r12, %r12
je 0x19d55b
movl -0x4c(%rbp), %eax
xorl $0x1, %eax
imulq -0x68(%rbp), %rax
movq -0xa0(%rbp), %rcx
leaq (%rcx,%rax,8), %rdx
leaq (%r9,%r12,8), %rsi
movq -0x58(%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 0x19d6e5
movq (%r9,%rax,8), %rcx
movq (%rdx,%rax,8), %r8
cmpq %r8, %rcx
jne 0x19d6e5
incq %rax
cmpq %rax, %r12
jne 0x19d531
xorl $0x1, -0x4c(%rbp)
xorl %r12d, %r12d
movq -0xb8(%rbp), %r14
movq %r14, -0x98(%rbp)
movl %r15d, %eax
movq %rax, -0xb0(%rbp)
movq -0xc0(%rbp), %rcx
testq %rcx, %rcx
je 0x19d5a4
movq %r14, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x19d5a4
movl $0x2e, %edi
movq -0x90(%rbp), %rsi
callq 0x17f80
movl %r12d, -0x40(%rbp)
testl %r12d, %r12d
je 0x19d2eb
jmp 0x19d73b
movq 0x31b9c3(%rip), %rcx    # 0x4b8f80
movq (%rcx), %rdi
leaq 0x206164(%rip), %rsi    # 0x3a372b
movq -0x48(%rbp), %r12
movq %r12, %rdx
movq %rax, %rcx
movq %r14, %r8
movl %r15d, %r9d
xorl %eax, %eax
callq 0x17ab0
movq 0x18(%rbp), %rdi
leaq 0x206199(%rip), %rsi    # 0x3a3782
xorl %eax, %eax
callq 0xfcb67
movq (%rbx), %rax
movq 0x60(%rax), %rax
testq %rax, %rax
je 0x19d623
movq 0x31b97d(%rip), %rcx    # 0x4b8f80
movq (%rcx), %rdx
movq %rbx, %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rcx
callq *%rax
xorl %r15d, %r15d
movq %r12, %r14
movl $0x4, %r12d
jmp 0x19d3f2
movq %r12, %r14
movl $0x4, %r12d
xorl %r15d, %r15d
jmp 0x19d3f2
leaq 0x205fff(%rip), %rsi    # 0x3a363a
movq 0x10(%rbp), %rdi
xorl %eax, %eax
callq 0x103fe1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq -0x88(%rbp), %rsp
jmp 0x19d75e
cmpq $0x0, -0xc0(%rbp)
je 0x19d672
movl $0xa, %edi
movq -0x90(%rbp), %rsi
callq 0x17f80
movq -0x70(%rbp), %rdi
callq 0x17f00
movl $0x0, -0x40(%rbp)
testl %eax, %eax
je 0x19d73b
movq 0x31b8ef(%rip), %r15    # 0x4b8f80
movq (%r15), %rdi
leaq 0x206044(%rip), %rsi    # 0x3a36df
movq %r14, %rdx
xorl %eax, %eax
callq 0x17ab0
leaq 0x20605a(%rip), %rsi    # 0x3a3706
movq 0x18(%rbp), %rdi
xorl %eax, %eax
callq 0xfcb67
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x2, -0x40(%rbp)
jmp 0x19d727
movq -0x58(%rbp), %r9
addl %eax, %r9d
movq 0x31b8ab(%rip), %r15    # 0x4b8f80
movq (%r15), %rdi
leaq 0x20604c(%rip), %rsi    # 0x3a372b
movq -0x48(%rbp), %r14
jmp 0x19d6fd
movq -0x58(%rbp), %r9
addl %eax, %r9d
movq 0x31b88d(%rip), %r15    # 0x4b8f80
movq (%r15), %rdi
leaq 0x20602e(%rip), %rsi    # 0x3a372b
movq %r14, %rdx
xorl %eax, %eax
callq 0x17ab0
leaq 0x206074(%rip), %rsi    # 0x3a3782
movq 0x18(%rbp), %rdi
xorl %eax, %eax
callq 0xfcb67
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x4, -0x40(%rbp)
testq %rax, %rax
je 0x19d73b
movq (%r15), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %rcx
callq *%rax
movq -0x88(%rbp), %rsp
movq (%rbx), %rax
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq *0x40(%rax)
leaq -0x1c0(%rbp), %rdi
callq 0x1a1540
movl -0x40(%rbp), %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x31b80c(%rip), %r13    # 0x4b8f80
movq (%r13), %rdi
leaq 0x205efa(%rip), %rsi    # 0x3a3679
movq %r14, %rdx
movl %r12d, %ecx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x17ab0
leaq 0x205f2d(%rip), %rsi    # 0x3a36c3
movq 0x18(%rbp), %rdi
xorl %eax, %eax
callq 0xfcb67
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x1, -0x40(%rbp)
testq %rax, %rax
je 0x19d73b
movq (%r13), %rdx
jmp 0x19d72f
movq 0x31b7bc(%rip), %r13    # 0x4b8f80
movq (%r13), %rdi
leaq 0x205f5c(%rip), %rsi    # 0x3a372b
movq -0x48(%rbp), %r12
movq %r12, %rdx
movq %rax, %rcx
movq %r14, %r8
movl %r15d, %r9d
xorl %eax, %eax
callq 0x17ab0
leaq 0x205f95(%rip), %rsi    # 0x3a3782
movq 0x18(%rbp), %rdi
xorl %eax, %eax
callq 0xfcb67
movq (%rbx), %rax
movq 0x60(%rax), %rax
movl $0x4, -0x40(%rbp)
testq %rax, %rax
je 0x19d73b
movq (%r13), %rdx
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x19d735
callq 0x601b6
callq 0x173b0
callq 0x6017f
callq 0x601ed
callq 0x60224