// File: /workspace/github_c_makefile_star2_O1/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, 0x4(%rsp)
movq %r8, %r15
movl %ecx, 0x40(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdi, 0x70(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xb8(%rsp), %r14
movq 0xb0(%rsp), %r12
cmpq $0x4, %r14
je 0x1f75d2
cmpq $0x8, %r14
jne 0x1f7b04
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 0x1c9f99(%rip), %r13    # 0x3c1592
xorl %edi, %edi
movq %rbx, %rsi
movq %r13, %rdx
movl $0xcc, %ecx
callq 0x1094e6
movq %rax, 0x30(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x173a0
movl 0x4(%rsp), %eax
movq %rax, 0x60(%rsp)
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %rdi
movq %r13, %rsi
movl $0xcd, %edx
callq 0x1092b2
movq %rax, 0x10(%rsp)
testq %r15, %r15
je 0x1f77bc
xorl %ebx, %ebx
xorl %r11d, %r11d
movq %r15, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
xorl %edi, %edi
movl %edi, %ebp
cmpq $0x4, %r14
jne 0x1f7679
movl (%r12,%rbx,4), %ecx
jmp 0x1f767d
movq (%r12,%rbx,8), %rcx
movq 0x30(%rsp), %rdi
movq %rcx, %rax
shrq $0x6, %rax
movq (%rdi,%rax,8), %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
shrq %cl, %rsi
testq %rdx, %rsi
jne 0x1f7a3d
movq %r11, %r13
orq %rdx, %rsi
movq %rsi, (%rdi,%rax,8)
movq 0x28(%rsp), %rdi
movq %rcx, 0x38(%rsp)
movq %rcx, %rsi
movl 0x40(%rsp), %edx
callq *0x70(%rsp)
movl %eax, %edi
testq %rbx, %rbx
je 0x1f772e
cmpb $-0x2, %dil
jb 0x1f774c
cmpq %r15, 0x20(%rsp)
movq 0x38(%rsp), %r11
jne 0x1f7718
movq 0x8(%rsp), %rsi
cmpl 0x4(%rsp), %esi
jae 0x1f7ae3
movl %esi, %eax
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %rcx, (%rdx,%rax,8)
leaq -0x1(%rbx), %rcx
movq %rcx, 0x8(%rdx,%rax,8)
incl %esi
movq %rsi, 0x8(%rsp)
movb %bpl, 0x10(%rdx,%rax,8)
movq %rbx, 0x20(%rsp)
cmpb $-0x2, %bpl
setb %al
cmpq %r11, %r13
setbe %cl
orb %al, %cl
jne 0x1f77a3
jmp 0x1f7a84
cmpb $-0x2, %dil
movq 0x20(%rsp), %rax
movl $0x0, %ecx
cmovaeq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %r11
jmp 0x1f77a3
cmpb $-0x2, %bpl
movq 0x38(%rsp), %r11
jae 0x1f7a57
cmpb %dil, %bpl
ja 0x1f7aab
jae 0x1f77a3
movq 0x8(%rsp), %rsi
cmpl 0x4(%rsp), %esi
jae 0x1f7ade
movl %esi, %eax
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %rcx, (%rdx,%rax,8)
leaq -0x1(%rbx), %rcx
movq %rcx, 0x8(%rdx,%rax,8)
incl %esi
movq %rsi, 0x8(%rsp)
movb %bpl, 0x10(%rdx,%rax,8)
movq %rbx, 0x18(%rsp)
incq %rbx
cmpq %rbx, %r15
jne 0x1f766b
movq %rdi, %r13
movq %r15, %rdi
movq 0x20(%rsp), %rbx
jmp 0x1f77d6
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x18(%rsp)
movq %r15, %rbx
xorl %edi, %edi
cmpq %r15, %rdi
jne 0x1f7ae8
leaq 0x1c9dac(%rip), %rsi    # 0x3c1592
movq 0x30(%rsp), %rdi
movl $0x11f, %edx            # imm = 0x11F
callq 0x109670
cmpq %r15, %rbx
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
jne 0x1f783a
testq %rbx, %rbx
je 0x1f7b09
cmpl 0x4(%rsp), %edx
jae 0x1f7b09
movl %edx, %eax
leaq (%rax,%rax,2), %rax
movq 0x18(%rsp), %rsi
movq %rsi, (%rcx,%rax,8)
decq %rbx
movq %rbx, 0x8(%rcx,%rax,8)
incl %edx
movq %rdx, 0x8(%rsp)
movb %r13b, 0x10(%rcx,%rax,8)
cmpl $0x0, 0x4(%rsp)
je 0x1f78b0
andl $-0x2, 0x40(%rsp)
xorl %ebx, %ebx
movl $0x3, %ebp
xorl %r13d, %r13d
cmpl $0x2, 0x40(%rsp)
movl %ebx, %eax
cmovel %ebp, %eax
movzbl %al, %esi
movq 0x28(%rsp), %rdi
callq *0x68(%rsp)
testq %rax, %rax
je 0x1f78a6
cmpl 0x8(%rsp), %r13d
movq 0x10(%rsp), %rdx
jae 0x1f7a38
movl %r13d, %ecx
leaq (%rcx,%rcx,2), %rcx
cmpb 0x10(%rdx,%rcx,8), %bl
jne 0x1f7a38
leaq (%rdx,%rcx,8), %rcx
movq 0x8(%rcx), %rdx
subq (%rcx), %rdx
incq %rdx
cmpq %rax, %rdx
jne 0x1f7a52
incl %r13d
incl %ebx
decl %ebp
cmpl %ebx, 0x4(%rsp)
jne 0x1f7850
leaq 0x1c9e69(%rip), %rsi    # 0x3c1720
movq 0x58(%rsp), %rdi
xorl %eax, %eax
callq 0x10906e
movq 0x8(%rsp), %rax
testl %eax, %eax
je 0x1f798d
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 0x1f795e
xorl %ecx, %ecx
cmpq $0x4, %r14
jne 0x1f78fc
movl (%r12,%r8,4), %edx
jmp 0x1f7900
movq (%r12,%r8,8), %rdx
incq %rdx
cmpq %r15, %rdx
ja 0x1f7956
movq $-0x1, %r10
cmpq %r15, %rcx
ja 0x1f793d
movq %rcx, %rbx
cmpq $0x4, %r14
jne 0x1f7923
movl (%r12,%rbx,4), %r13d
jmp 0x1f7927
movq (%r12,%rbx,8), %r13
cmpq %rdx, %r13
cmoveq %rbx, %r11
je 0x1f793a
incq %rbx
cmpq %r15, %rbx
jbe 0x1f7917
jmp 0x1f793d
movq %r11, %r10
cmpq $-0x1, %r10
je 0x1f7a13
subq %rcx, %rdi
addq %r10, %rdi
incq %rdi
incq %r10
movq %r10, %rcx
incq %r8
cmpq %r9, %r8
jbe 0x1f78f0
incq %rsi
cmpq %rax, %rsi
jne 0x1f78db
movq %rdi, %xmm1
punpckldq 0x158f69(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x158f71(%rip), %xmm1   # 0x3508f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
jmp 0x1f7996
xorpd %xmm0, %xmm0
movq 0x10(%rsp), %rbp
movq %r15, %xmm2
punpckldq 0x158f3d(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x158f45(%rip), %xmm2   # 0x3508f0
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, 0x28(%rsp)
callq 0x10acd4
testl %eax, %eax
jg 0x1f7af0
leaq 0x1c9d5a(%rip), %rsi    # 0x3c173f
movq 0x58(%rsp), %rdi
xorl %eax, %eax
callq 0x10906e
leaq 0x1c9b9a(%rip), %rsi    # 0x3c1592
movq %rbp, %rdi
movl $0x150, %edx            # imm = 0x150
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x109670
movq 0x2cc566(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
leaq 0x1c9d47(%rip), %rsi    # 0x3c176b
movq %r15, %r8
xorl %eax, %eax
callq 0x17ab0
movl $0x2, %edi
callq 0x17940
callq 0x7ae0e
xorl %edi, %edi
cmpq $0x4, %r14
sete %dil
movq %r12, %rsi
movq %rbx, %rdx
callq 0x7ad0c
callq 0x7ae47
movzbl %dil, %r8d
movq 0x2cc51e(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
leaq -0x1(%rbx), %rdx
subq $0x8, %rsp
leaq 0x1c9b6f(%rip), %rsi    # 0x3c15e3
movq %r11, %rcx
movq %r13, %r9
xorl %eax, %eax
pushq %rbx
callq 0x17ab0
jmp 0x1f7ad5
movq 0x2cc4f5(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
leaq -0x1(%rbx), %rdx
leaq 0x1c9b11(%rip), %rsi    # 0x3c15aa
movq %r11, %rcx
movq %r13, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x17ab0
jmp 0x1f7a2e
movzbl %dil, %r9d
movzbl %bpl, %r8d
movq 0x2cc4c6(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
leaq -0x1(%rbx), %rdx
leaq 0x1c9b4a(%rip), %rsi    # 0x3c1612
movq %r11, %rcx
xorl %eax, %eax
pushq %rbx
pushq %r13
callq 0x17ab0
addq $0x10, %rsp
jmp 0x1f7a2e
callq 0x7ad3c
callq 0x7ad75
movq %r15, %rsi
callq 0x7adae
movaps 0x40(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movl 0x4(%rsp), %edi
callq 0x7ae80
callq 0x7aebc
callq 0x7add5
nop