// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/core/encseq.c
// Function: fillViabitaccess
static int fillViabitaccess(GtEncseq *encseq,
                            GtDustMasker *dust_masker, /* NULL if not used */
                            Gtssptaboutinfo *ssptaboutinfo,
                            GtSequenceBuffer *fb, GtError *err)
{
   GtUword currentposition,
                fillexceptionrangeidx = 0,
                mapposition = 0,
                nextcheckpos = GT_UNDEF_UWORD,
                pagenumber = 0,
                lastexceptionrangelength = 0;
  int retval;
  GtUchar cc;
  char orig;
  GtSWtable_uint32 *exceptiontable = &(encseq->exceptiontable.st_uint32);
  DECLARESEQBUFFER(encseq->twobitencoding); /* in fillViabitaccess */
  gt_error_check(err);

  if (encseq->has_exceptiontable) {
    exceptiontable->positions = gt_malloc(sizeof (*exceptiontable->positions) *
                                         exceptiontable->numofpositionstostore);
    exceptiontable->rangelengths =
                               gt_malloc(sizeof(*exceptiontable->rangelengths) *
                                         exceptiontable->numofpositionstostore);
    exceptiontable->endidxinpage =
                               gt_malloc(sizeof(*exceptiontable->endidxinpage) *
                                         exceptiontable->numofpages);
    exceptiontable->mappositions =
                              gt_malloc(sizeof (*exceptiontable->mappositions) *
                                        exceptiontable->numofpositionstostore);

    nextcheckpos = exceptiontable->maxrangevalue;
  }

  GT_INITBITTAB(encseq->specialbits, encseq->totallength + GT_INTWORDSIZE);
  for (currentposition = encseq->totallength;
       currentposition < encseq->totallength + GT_INTWORDSIZE;
       currentposition++) {
    GT_SETIBIT(encseq->specialbits, currentposition);
  }
  for (currentposition=0; /* Nothing */; currentposition++) {
    retval = gt_sequence_buffer_next_with_original(fb, dust_masker, &cc, &orig,
                                                   err);
    if (retval == 1) {
      if (encseq->has_exceptiontable && cc != (GtUchar) GT_SEPARATOR) {
        if (orig == encseq->maxchars[cc]) {
          if (lastexceptionrangelength > 0) {
            exceptiontable->rangelengths[fillexceptionrangeidx-1]
              = (uint32_t) (lastexceptionrangelength-1);
            lastexceptionrangelength = 0;
          }
        }
        else {
          /* at beginning of exception range */
          if (lastexceptionrangelength == 0) {
            /* store remainder of currentposition: this value is not larger
               than maxrangevalue and this can be stored in a page */
            exceptiontable->positions[fillexceptionrangeidx++]
              = (uint32_t) (currentposition & exceptiontable->maxrangevalue);
            exceptiontable->mappositions[fillexceptionrangeidx-1]
              = mapposition;
            lastexceptionrangelength = 1UL;
          }
          else /* extend exception range */ {
            if (lastexceptionrangelength == exceptiontable->maxrangevalue) {
              gt_assert(fillexceptionrangeidx > 0);
              exceptiontable->rangelengths[fillexceptionrangeidx-1]
                = (uint32_t) exceptiontable->maxrangevalue;
              lastexceptionrangelength = 0;
            }
            else {
              lastexceptionrangelength++;
            }
          }
          bitpackarray_store_uint32(encseq->exceptions,
                                   (BitOffset) mapposition,
                                   (uint32_t) encseq->subsymbolmap[(int) orig]);
          mapposition++;
        }
      }
      if (GT_ISSPECIAL(cc)) {
        GT_SETIBIT(encseq->specialbits, currentposition);
        if (cc == (GtUchar) GT_SEPARATOR)
          ssptaboutinfo_processseppos(ssptaboutinfo, currentposition);
      }
      ssptaboutinfo_processanyposition(ssptaboutinfo, currentposition);
      bitwise <<= 2;
      if (GT_ISNOTSPECIAL(cc))
        bitwise |= (GtTwobitencoding) cc;
      else {
        if (cc == (GtUchar) GT_SEPARATOR)
          bitwise |= (GtTwobitencoding) GT_TWOBITS_FOR_SEPARATOR;
      }
      if (widthbuffer < (GtUword) (GT_UNITSIN2BITENC - 1))
        widthbuffer++;
      else {
        *twobitencodingptr++ = bitwise;
        widthbuffer = 0;
        bitwise = 0;
      }
    }
    else {
      if (retval < 0)
        return -1;
      if (encseq->has_exceptiontable && lastexceptionrangelength > 0) {
        /* note that we store one less than the length to prevent overflows */
        gt_assert(fillexceptionrangeidx > 0 &&
                  fillexceptionrangeidx <=
                  exceptiontable->numofpositionstostore);
        exceptiontable->rangelengths[fillexceptionrangeidx-1]
          = (uint32_t) (lastexceptionrangelength-1);
      }
      gt_assert(retval == 0);
      if (encseq->has_exceptiontable && currentposition == nextcheckpos) {
        exceptiontable->endidxinpage[pagenumber] = fillexceptionrangeidx;
        pagenumber++;
      }
      break;
    }
  }
  if (encseq->has_exceptiontable) {
    while (pagenumber < exceptiontable->numofpages) {
      exceptiontable->endidxinpage[pagenumber] = fillexceptionrangeidx;
      pagenumber++;
    }
  }
  UPDATESEQBUFFERFINAL(bitwise, twobitencodingptr); /* in fillViabitaccess */
  ssptaboutinfo_finalize(ssptaboutinfo);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r13
movq %rcx, 0x30(%rsp)
movq %rdx, %rbx
movq %rsi, 0x28(%rsp)
movq %rdi, %r14
movq 0x30(%rdi), %rax
leaq -0x1(%rax), %rcx
shrq $0x5, %rcx
addq $0x2, %rcx
cmpq $0x20, %rax
movl $0x2, %edi
cmovaeq %rcx, %rdi
movq %rdi, 0x288(%r14)
shlq $0x3, %rdi
leaq 0x3254d(%rip), %rsi     # 0x102a2a
movl $0xac7, %edx            # imm = 0xAC7
callq 0x35ee2
movq %rax, %r12
movq %rax, 0x280(%r14)
movq 0x288(%r14), %rax
movq $0x0, -0x8(%r12,%rax,8)
testq %r13, %r13
je 0xd0516
movq %r13, %rdi
callq 0x3566a
testb %al, %al
jne 0xd0965
movq $-0x1, %rax
cmpb $0x1, 0x2f0(%r14)
jne 0xd05b5
movq 0x320(%r14), %rdi
shlq $0x2, %rdi
leaq 0x324ed(%rip), %r15     # 0x102a2a
movq %r15, %rsi
movl $0xacc, %edx            # imm = 0xACC
callq 0x35ee2
movq %rax, 0x2f8(%r14)
movq 0x320(%r14), %rdi
shlq $0x2, %rdi
movq %r15, %rsi
movl $0xacf, %edx            # imm = 0xACF
callq 0x35ee2
movq %rax, 0x300(%r14)
movq 0x318(%r14), %rdi
shlq $0x3, %rdi
movq %r15, %rsi
movl $0xad2, %edx            # imm = 0xAD2
callq 0x35ee2
movq %rax, 0x308(%r14)
movq 0x320(%r14), %rdi
shlq $0x3, %rdi
movq %r15, %rsi
movl $0xad5, %edx            # imm = 0xAD5
callq 0x35ee2
movq %rax, 0x310(%r14)
movq 0x328(%r14), %rax
movq %rax, 0x38(%rsp)
movabsq $-0x8000000000000000, %rbp # imm = 0x8000000000000000
movq 0x30(%r14), %rax
leaq 0x3f(%rax), %rcx
shrq $0x6, %rcx
cmpq $-0x40, %rax
leaq 0x8(,%rcx,8), %rax
movl $0x8, %r15d
cmovbq %rax, %r15
leaq 0x3243d(%rip), %rdx     # 0x102a2a
xorl %edi, %edi
movq %r15, %rsi
movl $0xada, %ecx            # imm = 0xADA
callq 0x36116
movq %rax, 0x2b0(%r14)
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0xb2f0
movq 0x30(%r14), %rcx
cmpq $-0x41, %rcx
ja 0xd0642
movq 0x2b0(%r14), %rax
movq %rbp, %rdx
shrq %cl, %rdx
movq %rcx, %rsi
shrq $0x6, %rsi
orq %rdx, (%rax,%rsi,8)
incq %rcx
movq 0x30(%r14), %rdx
addq $0x40, %rdx
cmpq %rdx, %rcx
jb 0xd0621
movq %r12, 0x20(%rsp)
leaq 0x6(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %r13, %r8
callq 0x7f59b
cmpl $0x1, %eax
jne 0xd087e
movq %r13, 0x40(%rsp)
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r13d, %r13d
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x10(%rsp)
movb 0x6(%rsp), %al
cmpb $-0x1, %al
setne %cl
andb 0x2f0(%r14), %cl
cmpb $0x1, %cl
jne 0xd07b6
movzbl %al, %ecx
movsbq 0x7(%rsp), %rax
movq 0x348(%r14), %rdx
cmpb (%rdx,%rcx), %al
jne 0xd06dd
testq %r12, %r12
je 0xd06d5
decl %r12d
movq 0x300(%r14), %rax
movq 0x8(%rsp), %rcx
movl %r12d, -0x4(%rax,%rcx,4)
xorl %r12d, %r12d
jmp 0xd07b6
testq %r12, %r12
je 0xd071c
movq 0x328(%r14), %rcx
cmpq %rcx, %r12
jne 0xd0712
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0xd0960
movq 0x300(%r14), %rdx
movl %ecx, -0x4(%rdx,%rsi,4)
movq $0x0, 0x18(%rsp)
jmp 0xd0758
incq %r12
movq %r12, 0x18(%rsp)
jmp 0xd0758
movl 0x328(%r14), %ecx
andl %r13d, %ecx
movq 0x2f8(%r14), %rdx
movq 0x8(%rsp), %rsi
movl %ecx, (%rdx,%rsi,4)
movq 0x310(%r14), %rcx
movq 0x10(%rsp), %rdx
movq %rdx, (%rcx,%rsi,8)
leaq 0x1(%rsi), %rcx
movl $0x1, %edx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x8(%rsp)
movq 0x330(%r14), %rsi
testq %rsi, %rsi
je 0xd095b
movq 0x10(%rsp), %rcx
cmpq %rcx, 0x8(%rsi)
jbe 0xd095b
movl 0x10(%rsi), %edx
cmpq $0x21, %rdx
jae 0xd095b
movq %rbx, %r12
movq 0x358(%r14), %rcx
movzbl (%rcx,%rax), %ecx
movq (%rsi), %rdi
movq %rdx, %rsi
movq 0x10(%rsp), %rbx
imulq %rbx, %rsi
callq 0xddb77
incq %rbx
movq %rbx, 0x10(%rsp)
movq %r12, %rbx
movq 0x18(%rsp), %r12
movb 0x6(%rsp), %al
cmpb $-0x2, %al
jb 0xd07ef
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movl %r13d, %ecx
shrq %cl, %rdx
movq 0x2b0(%r14), %rcx
movq %r13, %rsi
shrq $0x6, %rsi
orq %rdx, (%rcx,%rsi,8)
cmpb $-0x1, %al
jne 0xd07ef
movq %rbx, %rdi
movq %r13, %rsi
callq 0xc33e4
testq %rbx, %rbx
je 0xd080a
cmpq 0x10(%rbx), %r13
jne 0xd080a
movq %rbx, %rdi
callq 0xce5a4
movq 0x18(%rbx), %rax
addq %rax, 0x10(%rbx)
movq %rbp, %rax
shlq $0x2, %rax
movzbl 0x6(%rsp), %ecx
xorl %ebp, %ebp
cmpq $0xff, %rcx
sete %bpl
cmpq $0xfe, %rcx
cmovbq %rcx, %rbp
orq %rax, %rbp
cmpq $0x1e, %r15
ja 0xd083c
incq %r15
jmp 0xd0852
movq 0x20(%rsp), %rax
movq %rbp, (%rax)
addq $0x8, %rax
movq %rax, 0x20(%rsp)
xorl %ebp, %ebp
xorl %r15d, %r15d
incq %r13
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
leaq 0x6(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq 0x40(%rsp), %r8
callq 0x7f59b
cmpl $0x1, %eax
je 0xd068e
jmp 0xd0892
xorl %r12d, %r12d
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r15d, %r15d
testl %eax, %eax
js 0xd0947
movb 0x2f0(%r14), %cl
cmpb $0x1, %cl
jne 0xd08d5
testq %r12, %r12
je 0xd08d5
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0xd096a
cmpq 0x320(%r14), %rsi
ja 0xd096a
decl %r12d
movq 0x300(%r14), %rdx
movl %r12d, -0x4(%rdx,%rsi,4)
testl %eax, %eax
jne 0xd096f
xorl %eax, %eax
testb %cl, %cl
movq 0x8(%rsp), %rdx
je 0xd08fe
cmpq 0x38(%rsp), %r13
jne 0xd08fe
movq 0x308(%r14), %rax
movq %rdx, (%rax)
movl $0x1, %eax
testb %cl, %cl
je 0xd0922
cmpq 0x318(%r14), %rax
jae 0xd0922
movq 0x308(%r14), %rcx
movq %rdx, (%rcx,%rax,8)
incq %rax
cmpq 0x318(%r14), %rax
jb 0xd0912
testq %r15, %r15
je 0xd093b
addl %r15d, %r15d
negb %r15b
movl %r15d, %ecx
shlq %cl, %rbp
movq 0x20(%rsp), %rax
movq %rbp, (%rax)
movq %rbx, %rdi
callq 0xc3450
xorl %eax, %eax
jmp 0xd094c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2f8e7
callq 0x2f8ae
callq 0x2f875
callq 0x2f957
callq 0x2f91e