// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/sfx-lwcheck.c
// Function: gt_suftab_lightweightcheck
void gt_suftab_lightweightcheck(LW_accesschar accesschar,
                                LW_charcount charcount,
                                const void *encseq,
                                GtReadmode readmode,
                                GtUword totallength,
                                unsigned int numofchars,
                                const void *suftab,
                                size_t unitsize,
                                GtLogger *logger)
{
  GtUword idx, countbitsset = 0, previouspos = 0,
                firstspecial = totallength, rangestart = 0;
  unsigned int charidx, rangeidx = 0, numofranges;
  GtBitsequence *startposoccurs;
  GtUchar previouscc = 0;
  GtRangewithchar *rangestore;
  const bool skcheck = true;

#ifdef _WIN32
  gt_assert(unitsize == (size_t) 4);
#else
  gt_assert(unitsize == (size_t) 4 || unitsize == (size_t) 8);
#endif
  GT_INITBITTAB(startposoccurs, totallength+1);
  rangestore = gt_malloc(sizeof(*rangestore) * numofchars);
  for (idx = 0; idx < totallength; idx++)
  {
    GtUword position = GEN_ESASUFFIXPTRGET(suftab, idx);
    GtUchar cc;

    if (GT_ISIBITSET(startposoccurs, position))
    {
      fprintf(stderr, "ERROR: suffix with startpos "GT_WU" already occurs\n",
              GEN_ESASUFFIXPTRGET(suftab, idx));
      exit(GT_EXIT_PROGRAMMING_ERROR);
    }
    GT_SETIBIT(startposoccurs, position);
    countbitsset++;
    cc = accesschar(encseq,position,readmode);
    if (idx > 0)
    {
      if (GT_ISSPECIAL(cc))
      {
        if (firstspecial == totallength)
        {
          firstspecial = idx;
          gt_assert(rangeidx < numofchars);
          rangestore[rangeidx].start = rangestart;
          rangestore[rangeidx].end = idx-1;
          rangestore[rangeidx++].firstchar = previouscc;
        }
        if (GT_ISSPECIAL(previouscc))
        {
          if (previouspos > position)
          {
            fprintf(stderr, "incorrect order: " GT_WU " = " GT_WU "=SPECIAL > "
                    "SPECIAL="GT_WU"  = "GT_WU"\n",
                    idx-1, position, previouspos, idx);
            exit(GT_EXIT_PROGRAMMING_ERROR);
          }
        }
      } else
      {
        if (GT_ISSPECIAL(previouscc))
        {
          fprintf(stderr, "incorrect order: "GT_WU"="GT_WU"=SPECIAL > "
                  "%u="GT_WU"="GT_WU"\n", idx-1, position, (unsigned int) cc,
                  previouspos, idx);
          exit(GT_EXIT_PROGRAMMING_ERROR);
        } else
        {
          if (previouscc > cc)
          {
            fprintf(stderr, "incorrect order: "GT_WU" = "GT_WU"=%u > "
                    "%u="GT_WU"="GT_WU"\n", idx-1, position, (unsigned int)
                    previouscc, (unsigned int) cc, previouspos, idx);
            exit(GT_EXIT_PROGRAMMING_ERROR);
          } else
          {
            if (previouscc < cc)
            {
              gt_assert(rangeidx < numofchars);
              rangestore[rangeidx].start = rangestart;
              rangestore[rangeidx].end = idx-1;
              rangestore[rangeidx++].firstchar = previouscc;
              rangestart = idx;
            }
          }
        }
      }
    } else
    {
      if (GT_ISSPECIAL(cc))
      {
        firstspecial = 0;
      }
    }
    previouscc = cc;
    previouspos = position;
  }
  if (countbitsset != totallength)
  {
    fprintf(stderr, "ERROR: only "GT_WU" of "GT_WU" suffixes occur\n",
            countbitsset, totallength);
    exit(GT_EXIT_PROGRAMMING_ERROR);
  }
  gt_free(startposoccurs);
  if (firstspecial == totallength)
  {
    gt_assert(firstspecial > 0 && rangeidx < numofchars);
    rangestore[rangeidx].start = rangestart;
    rangestore[rangeidx].end = firstspecial-1;
    rangestore[rangeidx++].firstchar = previouscc;
  }
  numofranges = rangeidx;
  for (charidx = 0, rangeidx = 0; charidx < numofchars; charidx++)
  {
    GtUword count;
    GtUchar thisidx = GT_ISDIRCOMPLEMENT(readmode)
                        ? (GtUchar) GT_COMPLEMENTBASE(charidx)
                        : (GtUchar) charidx;

    count = charcount(encseq,thisidx);
    if (count != 0)
    {
      gt_assert(rangeidx < numofranges &&
                rangestore[rangeidx].firstchar == (GtUchar) charidx);
      gt_assert(rangestore[rangeidx].end - rangestore[rangeidx].start + 1
                == count);
      rangeidx++;
    }
  }
  gt_logger_log(logger, "suftab-check, first phase done");
  if (skcheck)
  {
    gt_suftab_sk_suffixorder(totallength,
                             numofchars,
                             suftab,
                             unitsize,
                             rangestore,
                             numofranges);
    gt_logger_log(logger, "suftab-check, second phase (sk-method) done");
  } else
  {
    gt_suftab_bk_suffixorder(accesschar,
                             encseq,
                             readmode,
                             totallength,
                             numofchars,
                             suftab,
                             unitsize,
                             rangestore,
                             numofranges);
    gt_logger_log(logger, "suftab-check, second phase (bk-method) done");
  }
  gt_free(rangestore);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, 0xc(%rsp)
movq %r8, %r15
movl %ecx, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdi, 0x68(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xb8(%rsp), %r13
movq 0xb0(%rsp), %r12
cmpq $0x4, %r13
je 0x1ede1e
cmpq $0x8, %r13
jne 0x1ee340
leaq 0x1(%r15), %rax
movq %r15, %rcx
shrq $0x6, %rcx
cmpq $0x40, %rax
leaq 0x8(,%rcx,8), %rax
movl $0x8, %ebx
cmovaeq %rax, %rbx
leaq 0x1ca0f4(%rip), %r14    # 0x3b7f39
xorl %edi, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0xcc, %ecx
callq 0x104461
movq %rax, 0x28(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x173a0
movl 0xc(%rsp), %eax
movq %rax, 0x60(%rsp)
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %rdi
movq %r14, %rsi
movl $0xcd, %edx
callq 0x104226
movq %rax, 0x10(%rsp)
testq %r15, %r15
je 0x1edff9
xorl %ebx, %ebx
xorl %ebp, %ebp
movq %r15, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq 0x28(%rsp), %rdi
movq %rbp, 0x38(%rsp)
cmpq $0x4, %r13
jne 0x1edecc
movl (%r12,%rbx,4), %ebp
jmp 0x1eded0
movq (%r12,%rbx,8), %rbp
movq %rbp, %rax
shrq $0x6, %rax
movq (%rdi,%rax,8), %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
movl %ebp, %ecx
shrq %cl, %rsi
testq %rdx, %rsi
jne 0x1ee280
orq %rdx, %rsi
movq %rsi, (%rdi,%rax,8)
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
movl 0x40(%rsp), %edx
callq *0x68(%rsp)
movl %eax, %r9d
testq %rbx, %rbx
je 0x1edf7a
cmpb $-0x2, %r9b
movq 0x28(%rsp), %rdi
jb 0x1edf98
cmpq %r15, 0x18(%rsp)
jne 0x1edf5f
movl 0x8(%rsp), %esi
cmpl 0xc(%rsp), %esi
jae 0x1ee327
movl %esi, %eax
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rcx, (%rdx,%rax,8)
leaq -0x1(%rbx), %rcx
movq %rcx, 0x8(%rdx,%rax,8)
incl %esi
movl %esi, 0x8(%rsp)
movb %r14b, 0x10(%rdx,%rax,8)
movq %rbx, 0x18(%rsp)
cmpb $-0x2, %r14b
setb %al
movq 0x38(%rsp), %r8
cmpq %rbp, %r8
setbe %cl
orb %al, %cl
jne 0x1edfe8
jmp 0x1ee2c9
cmpb $-0x2, %r9b
movq 0x18(%rsp), %rax
movl $0x0, %ecx
cmovaeq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rdi
jmp 0x1edfe8
cmpb $-0x2, %r14b
jae 0x1ee29a
cmpb %r9b, %r14b
ja 0x1ee2ed
jae 0x1edfe8
movl 0x8(%rsp), %esi
cmpl 0xc(%rsp), %esi
jae 0x1ee322
movl %esi, %eax
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rcx, (%rdx,%rax,8)
leaq -0x1(%rbx), %rcx
movq %rcx, 0x8(%rdx,%rax,8)
incl %esi
movl %esi, 0x8(%rsp)
movb %r14b, 0x10(%rdx,%rax,8)
movq %rbx, 0x20(%rsp)
incq %rbx
movl %r9d, %r14d
cmpq %rbx, %r15
jne 0x1edebb
jmp 0x1ee01b
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x8(%rsp)
xorl %r9d, %r9d
movq 0x28(%rsp), %rdi
movq %r9, %rbx
leaq 0x1c9f14(%rip), %rsi    # 0x3b7f39
movl $0x11f, %edx            # imm = 0x11F
callq 0x1045eb
cmpq %r15, 0x18(%rsp)
jne 0x1ee076
testq %r15, %r15
movl 0x8(%rsp), %esi
je 0x1ee345
cmpl 0xc(%rsp), %esi
jae 0x1ee345
movl %esi, %eax
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rcx, (%rdx,%rax,8)
leaq -0x1(%r15), %rcx
movq %rcx, 0x8(%rdx,%rax,8)
incl %esi
movl %esi, 0x8(%rsp)
movb %bl, 0x10(%rdx,%rax,8)
jmp 0x1ee07d
cmpl $0x0, 0xc(%rsp)
je 0x1ee0ec
andl $-0x2, 0x40(%rsp)
xorl %ebx, %ebx
movl $0x3, %ebp
xorl %r14d, %r14d
cmpl $0x2, 0x40(%rsp)
movl %ebx, %eax
cmovel %ebp, %eax
movzbl %al, %esi
movq 0x30(%rsp), %rdi
callq *0x70(%rsp)
testq %rax, %rax
je 0x1ee0e2
cmpl 0x8(%rsp), %r14d
movq 0x10(%rsp), %rdx
jae 0x1ee27b
movl %r14d, %ecx
leaq (%rcx,%rcx,2), %rcx
cmpb 0x10(%rdx,%rcx,8), %bl
jne 0x1ee27b
leaq (%rdx,%rcx,8), %rcx
movq 0x8(%rcx), %rdx
subq (%rcx), %rdx
incq %rdx
cmpq %rax, %rdx
jne 0x1ee295
incl %r14d
incl %ebx
decl %ebp
cmpl %ebx, 0xc(%rsp)
jne 0x1ee08c
leaq 0x1c9fad(%rip), %rsi    # 0x3b80a0
movq 0x58(%rsp), %rdi
xorl %eax, %eax
callq 0x103fe1
movl 0x8(%rsp), %eax
testl %eax, %eax
je 0x1ee1d0
movl %eax, %eax
xorl %esi, %esi
xorl %edi, %edi
movq 0x10(%rsp), %rbp
leaq (%rsi,%rsi,2), %rcx
movq (%rbp,%rcx,8), %r8
movq 0x8(%rbp,%rcx,8), %r9
cmpq %r9, %r8
ja 0x1ee1a1
xorl %ecx, %ecx
cmpq $0x4, %r13
jne 0x1ee137
movl (%r12,%r8,4), %edx
jmp 0x1ee13b
movq (%r12,%r8,8), %rdx
incq %rdx
cmpq %r15, %rdx
ja 0x1ee199
cmpq %r15, %rcx
ja 0x1ee256
leaq (%r12,%rcx,4), %r11
leaq (%r12,%rcx,8), %rbx
xorl %r10d, %r10d
cmpq $0x4, %r13
jne 0x1ee163
movl (%r11,%r10,4), %r14d
jmp 0x1ee167
movq (%rbx,%r10,8), %r14
cmpq %rdx, %r14
je 0x1ee180
leaq (%rcx,%r10), %r14
incq %r14
incq %r10
cmpq %r15, %r14
jbe 0x1ee157
jmp 0x1ee256
leaq (%rcx,%r10), %r11
incq %r11
je 0x1ee256
addq %r10, %rdi
incq %rdi
addq %r10, %rcx
incq %rcx
incq %r8
cmpq %r9, %r8
jbe 0x1ee12b
incq %rsi
cmpq %rax, %rsi
jne 0x1ee116
movq %rdi, %xmm1
punpckldq 0x159726(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x15972e(%rip), %xmm1   # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
jmp 0x1ee1d9
xorpd %xmm0, %xmm0
movq 0x10(%rsp), %rbp
movq %r15, %xmm2
punpckldq 0x1596fa(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x159702(%rip), %xmm2   # 0x3478f0
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x60(%rsp), %xmm1
movapd %xmm0, 0x40(%rsp)
movsd %xmm1, 0x30(%rsp)
callq 0x105c1c
testl %eax, %eax
jg 0x1ee32c
leaq 0x1c9e97(%rip), %rsi    # 0x3b80bf
movq 0x58(%rsp), %rdi
xorl %eax, %eax
callq 0x103fe1
leaq 0x1c9cfe(%rip), %rsi    # 0x3b7f39
movq %rbp, %rdi
movl $0x150, %edx            # imm = 0x150
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1045eb
movq 0x2cad23(%rip), %rax    # 0x4b8f80
movq (%rax), %rdi
leaq 0x1c9e84(%rip), %rsi    # 0x3b80eb
movq %r15, %r8
xorl %eax, %eax
callq 0x17ab0
movl $0x2, %edi
callq 0x17940
callq 0x790e8
xorl %edi, %edi
cmpq $0x4, %r13
sete %dil
movq %r12, %rsi
movq %rbx, %rdx
callq 0x7900d
callq 0x79121
movzbl %r9b, %r8d
movq 0x2cacdb(%rip), %rax    # 0x4b8f80
movq (%rax), %rdi
leaq -0x1(%rbx), %rdx
subq $0x8, %rsp
leaq 0x1c9cd3(%rip), %rsi    # 0x3b7f8a
movq %rbp, %rcx
movq 0x40(%rsp), %r9
xorl %eax, %eax
pushq %rbx
callq 0x17ab0
jmp 0x1ee319
movq 0x2cacb0(%rip), %rax    # 0x4b8f80
movq (%rax), %rdi
leaq -0x1(%rbx), %rdx
leaq 0x1c9c73(%rip), %rsi    # 0x3b7f51
movq %rbp, %rcx
movq %rbx, %r9
xorl %eax, %eax
callq 0x17ab0
jmp 0x1ee271
movzbl %r9b, %r9d
movzbl %r14b, %r8d
movq 0x2cac84(%rip), %rax    # 0x4b8f80
movq (%rax), %rdi
leaq -0x1(%rbx), %rdx
leaq 0x1c9caf(%rip), %rsi    # 0x3b7fb9
movq %rbp, %rcx
xorl %eax, %eax
pushq %rbx
pushq 0x40(%rsp)
callq 0x17ab0
addq $0x10, %rsp
jmp 0x1ee271
callq 0x7903d
callq 0x79076
movaps 0x40(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movl 0xc(%rsp), %edi
callq 0x7915a
callq 0x79196
callq 0x790af
nop