// File: /workspace/github_c_makefile_star2_O2/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, 0x40(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, %r14
movq 0x30(%rdi), %rax
leaq -0x1(%rax), %rcx
shrq $0x5, %rcx
addq $0x2, %rcx
cmpq $0x20, %rax
pushq $0x2
popq %rdi
cmovaeq %rcx, %rdi
movq %rdi, 0x288(%r14)
shlq $0x3, %rdi
leaq 0x351e5(%rip), %rsi     # 0xebb9a
movl $0xac7, %edx            # imm = 0xAC7
callq 0xccb0
movq %rax, %r15
movq %rax, 0x280(%r14)
movq 0x288(%r14), %rax
andq $0x0, -0x8(%r15,%rax,8)
testq %r13, %r13
je 0xb69eb
movq %r13, %rdi
callq 0xc103
testb %al, %al
jne 0xb6dae
cmpb $0x1, 0x2f0(%r14)
jne 0xb6a85
movq 0x320(%r14), %rdi
shlq $0x2, %rdi
leaq 0x3518f(%rip), %rbx     # 0xebb9a
movq %rbx, %rsi
movl $0xacc, %edx            # imm = 0xACC
callq 0xccb0
movq %rax, 0x2f8(%r14)
movq 0x320(%r14), %rdi
shlq $0x2, %rdi
movq %rbx, %rsi
movl $0xacf, %edx            # imm = 0xACF
callq 0xccb0
movq %rax, 0x300(%r14)
movq 0x318(%r14), %rdi
shlq $0x3, %rdi
movq %rbx, %rsi
movl $0xad2, %edx            # imm = 0xAD2
callq 0xccb0
movq %rax, 0x308(%r14)
movq 0x320(%r14), %rdi
shlq $0x3, %rdi
movq %rbx, %rsi
movl $0xad5, %edx            # imm = 0xAD5
callq 0xccb0
movq %rax, 0x310(%r14)
movq 0x328(%r14), %r12
jmp 0xb6a89
pushq $-0x1
popq %r12
movabsq $-0x8000000000000000, %rbp # imm = 0x8000000000000000
movq 0x30(%r14), %rax
leaq 0x3f(%rax), %rcx
shrq $0x6, %rcx
cmpq $-0x40, %rax
leaq 0x8(,%rcx,8), %rax
pushq $0x8
popq %rbx
cmovbq %rax, %rbx
leaq 0x350e1(%rip), %rdx     # 0xebb9a
xorl %edi, %edi
movq %rbx, %rsi
movl $0xada, %ecx            # imm = 0xADA
callq 0xcfc2
movq %rax, 0x2b0(%r14)
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0xb2f0
movq 0x30(%r14), %rax
movq %rax, %rcx
addq $0x40, %rax
cmpq %rax, %rcx
jae 0xb6b0d
movq %rbp, %rax
shrq %cl, %rax
movq 0x2b0(%r14), %rdx
movq %rcx, %rsi
shrq $0x6, %rsi
orq %rax, (%rdx,%rsi,8)
incq %rcx
movq 0x30(%r14), %rax
jmp 0xb6ae3
movq %r12, 0x28(%rsp)
movq %r13, 0x30(%rsp)
movq %r15, 0x18(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movq $0x0, 0x10(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
leaq 0xe(%rsp), %rdx
leaq 0xf(%rsp), %rcx
movq 0x30(%rsp), %r8
callq 0x5ecab
cmpl $0x1, %eax
jne 0xb6cb0
movb 0xe(%rsp), %al
cmpb $-0x1, %al
setne %cl
andb 0x2f0(%r14), %cl
cmpb $0x1, %cl
jne 0xb6c1e
movzbl %al, %edx
movsbq 0xf(%rsp), %rcx
movq 0x348(%r14), %rsi
cmpb (%rsi,%rdx), %cl
jne 0xb6ba2
testq %rbp, %rbp
je 0xb6b9e
decl %ebp
movq 0x300(%r14), %rcx
movq 0x10(%rsp), %rdx
movl %ebp, -0x4(%rcx,%rdx,4)
xorl %ebp, %ebp
jmp 0xb6c1e
movq 0x328(%r14), %rax
testq %rbp, %rbp
je 0xb6bd5
cmpq %rax, %rbp
jne 0xb6bd0
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
je 0xb6d76
movq 0x300(%r14), %rax
movl %ebp, -0x4(%rax,%rdx,4)
xorl %ebp, %ebp
jmp 0xb6bfd
incq %rbp
jmp 0xb6bfd
andl %ebx, %eax
movq 0x2f8(%r14), %rdx
movq 0x10(%rsp), %rsi
movl %eax, (%rdx,%rsi,4)
movq 0x310(%r14), %rax
movq %r13, (%rax,%rsi,8)
leaq 0x1(%rsi), %rax
pushq $0x1
popq %rbp
movq %rax, 0x10(%rsp)
movq 0x330(%r14), %rdi
movq 0x358(%r14), %rax
movzbl (%rax,%rcx), %edx
movq %r13, %rsi
callq 0xb8e42
incq %r13
movb 0xe(%rsp), %al
cmpb $-0x2, %al
jb 0xb6c54
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movl %ebx, %ecx
shrq %cl, %rdx
movq 0x2b0(%r14), %rcx
movq %rbx, %rsi
shrq $0x6, %rsi
orq %rdx, (%rcx,%rsi,8)
cmpb $-0x1, %al
jne 0xb6c54
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0xa734f
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0xa73d4
shlq $0x2, %r12
movzbl 0xe(%rsp), %ecx
xorl %eax, %eax
cmpq $0xff, %rcx
sete %al
cmpq $0xfe, %rcx
cmovbq %rcx, %rax
orq %r12, %rax
cmpq $0x1e, %r15
ja 0xb6c8f
incq %r15
jmp 0xb6ca5
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x18(%rsp)
xorl %eax, %eax
xorl %r15d, %r15d
incq %rbx
movq %rax, %r12
jmp 0xb6b32
testl %eax, %eax
js 0xb6d64
movb 0x2f0(%r14), %cl
testq %rbp, %rbp
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
movq 0x10(%rsp), %rdx
jne 0xb6cfe
testq %rdx, %rdx
je 0xb6ddc
cmpq 0x320(%r14), %rdx
ja 0xb6ddc
decl %ebp
movq 0x300(%r14), %rdx
movq 0x10(%rsp), %rsi
movl %ebp, -0x4(%rdx,%rsi,4)
movq 0x10(%rsp), %rdx
testl %eax, %eax
jne 0xb6e0a
xorl %eax, %eax
testb %cl, %cl
je 0xb6d20
cmpq %rbx, 0x28(%rsp)
jne 0xb6d20
movq 0x308(%r14), %rax
movq %rdx, (%rax)
pushq $0x1
popq %rax
testb %cl, %cl
je 0xb6d3d
cmpq 0x318(%r14), %rax
jae 0xb6d3d
movq 0x308(%r14), %rcx
movq %rdx, (%rcx,%rax,8)
incq %rax
jmp 0xb6d24
testq %r15, %r15
je 0xb6d56
addl %r15d, %r15d
negb %r15b
movl %r15d, %ecx
shlq %cl, %r12
movq 0x18(%rsp), %rax
movq %r12, (%rax)
movq 0x20(%rsp), %rdi
callq 0xa73f5
xorl %eax, %eax
jmp 0xb6d67
pushq $-0x1
popq %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7723b(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x132df(%rip), %rsi     # 0xca066
leaq 0x39cc5(%rip), %rdx     # 0xf0a53
leaq 0x39a94(%rip), %rcx     # 0xf0829
leaq 0x34dfe(%rip), %r8      # 0xebb9a
movl $0xaf9, %r9d            # imm = 0xAF9
xorl %eax, %eax
callq 0xb8c0
callq 0xb300
movq 0x77203(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x132a7(%rip), %rsi     # 0xca066
leaq 0x13893(%rip), %rdx     # 0xca659
leaq 0x39a5c(%rip), %rcx     # 0xf0829
leaq 0x34dc6(%rip), %r8      # 0xebb9a
movl $0xac8, %r9d            # imm = 0xAC8
jmp 0xb6da2
movq 0x771d5(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x13279(%rip), %rsi     # 0xca066
leaq 0x39c85(%rip), %rdx     # 0xf0a79
leaq 0x39a2e(%rip), %rcx     # 0xf0829
leaq 0x34d98(%rip), %r8      # 0xebb9a
movl $0xb24, %r9d            # imm = 0xB24
jmp 0xb6da2
movq 0x771a7(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x1324b(%rip), %rsi     # 0xca066
leaq 0x39c4b(%rip), %rdx     # 0xf0a6d
leaq 0x39a00(%rip), %rcx     # 0xf0829
leaq 0x34d6a(%rip), %r8      # 0xebb9a
movl $0xb28, %r9d            # imm = 0xB28
jmp 0xb6da2