// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/core/encseq.c
// Function: fillViadirectaccess
static int fillViadirectaccess(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);
  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;
  }

  encseq->plainseq = gt_malloc(sizeof (*encseq->plainseq) *
                               encseq->totallength);
  encseq->hasplainseqptr = false;
  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++;
        }
      }
      encseq->plainseq[currentposition] = cc;
      if (cc == (GtUchar) GT_SEPARATOR)
        ssptaboutinfo_processseppos(ssptaboutinfo, currentposition);
      ssptaboutinfo_processanyposition(ssptaboutinfo, currentposition);
    }
    else {
      if (retval < 0) {
        gt_free(encseq->plainseq);
        encseq->plainseq = NULL;
        return -1;
      }
      gt_assert(retval == 0);
      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);
      }
      break;
    }
    if (encseq->has_exceptiontable && currentposition == nextcheckpos) {
      exceptiontable->endidxinpage[pagenumber] = fillexceptionrangeidx;
      pagenumber++;
      nextcheckpos += 1UL + exceptiontable->maxrangevalue;
    }
  }
  if (encseq->has_exceptiontable) {
    while (pagenumber < exceptiontable->numofpages) {
      exceptiontable->endidxinpage[pagenumber] = fillexceptionrangeidx;
      pagenumber++;
    }
  }
  ssptaboutinfo_finalize(ssptaboutinfo);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %r12
movq %rcx, 0x20(%rsp)
movq %rdx, %r14
movq %rsi, 0x18(%rsp)
movq %rdi, %rbx
testq %r8, %r8
je 0xcf4cb
movq %r12, %rdi
callq 0x3566a
testb %al, %al
jne 0xcf848
movq $-0x1, %r15
cmpb $0x1, 0x2f0(%rbx)
jne 0xcf569
movq 0x320(%rbx), %rdi
shlq $0x2, %rdi
leaq 0x33539(%rip), %rbp     # 0x102a2a
movq %rbp, %rsi
movl $0x886, %edx            # imm = 0x886
callq 0x35ee2
movq %rax, 0x2f8(%rbx)
movq 0x320(%rbx), %rdi
shlq $0x2, %rdi
movq %rbp, %rsi
movl $0x889, %edx            # imm = 0x889
callq 0x35ee2
movq %rax, 0x300(%rbx)
movq 0x318(%rbx), %rdi
shlq $0x3, %rdi
movq %rbp, %rsi
movl $0x88c, %edx            # imm = 0x88C
callq 0x35ee2
movq %rax, 0x308(%rbx)
movq 0x320(%rbx), %rdi
shlq $0x3, %rdi
movq %rbp, %rsi
movl $0x88f, %edx            # imm = 0x88F
callq 0x35ee2
movq %rax, 0x310(%rbx)
movq 0x328(%rbx), %r15
movq 0x30(%rbx), %rdi
leaq 0x334b6(%rip), %rsi     # 0x102a2a
movl $0x895, %edx            # imm = 0x895
callq 0x35ee2
movq %rax, 0x290(%rbx)
movb $0x0, 0x298(%rbx)
leaq 0x6(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r12, %r8
callq 0x7f59b
cmpl $0x1, %eax
jne 0xcf780
movq %r12, 0x30(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r12d, %r12d
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movb 0x6(%rsp), %al
cmpb $-0x1, %al
setne %cl
andb 0x2f0(%rbx), %cl
cmpb $0x1, %cl
jne 0xcf6eb
movzbl %al, %ecx
movsbq 0x7(%rsp), %rax
movq 0x348(%rbx), %rdx
cmpb (%rdx,%rcx), %al
jne 0xcf61e
testq %r13, %r13
je 0xcf616
decl %r13d
movq 0x300(%rbx), %rax
movq 0x8(%rsp), %rcx
movl %r13d, -0x4(%rax,%rcx,4)
xorl %r13d, %r13d
jmp 0xcf6eb
testq %r13, %r13
movq %r15, 0x28(%rsp)
je 0xcf657
movq 0x328(%rbx), %rcx
cmpq %rcx, %r13
jne 0xcf652
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0xcf843
movq 0x300(%rbx), %rdx
movl %ecx, -0x4(%rdx,%rsi,4)
xorl %r13d, %r13d
jmp 0xcf68d
incq %r13
jmp 0xcf68d
movl 0x328(%rbx), %ecx
andl %ebp, %ecx
movq 0x2f8(%rbx), %rdx
movq 0x8(%rsp), %rsi
movl %ecx, (%rdx,%rsi,4)
movq 0x310(%rbx), %rcx
movq 0x10(%rsp), %rdx
movq %rdx, (%rcx,%rsi,8)
leaq 0x1(%rsi), %rcx
movl $0x1, %r13d
movq %rcx, 0x8(%rsp)
movq 0x330(%rbx), %rsi
testq %rsi, %rsi
je 0xcf83e
movq 0x10(%rsp), %rcx
cmpq %rcx, 0x8(%rsi)
jbe 0xcf83e
movl 0x10(%rsi), %edx
cmpq $0x21, %rdx
jae 0xcf83e
movq %r13, %r15
movq 0x358(%rbx), %rcx
movzbl (%rcx,%rax), %ecx
movq (%rsi), %rdi
movq %rdx, %rsi
movq 0x10(%rsp), %r13
imulq %r13, %rsi
callq 0xddb77
incq %r13
movq %r13, 0x10(%rsp)
movq %r15, %r13
movq 0x28(%rsp), %r15
movb 0x6(%rsp), %al
movq 0x290(%rbx), %rcx
movb %al, (%rcx,%rbp)
cmpb $-0x1, 0x6(%rsp)
jne 0xcf70b
movq %r14, %rdi
movq %rbp, %rsi
callq 0xc33e4
testq %r14, %r14
je 0xcf726
cmpq 0x10(%r14), %rbp
jne 0xcf726
movq %r14, %rdi
callq 0xce5a4
movq 0x18(%r14), %rax
addq %rax, 0x10(%r14)
cmpb $0x1, 0x2f0(%rbx)
jne 0xcf754
cmpq %r15, %rbp
jne 0xcf754
movq 0x308(%rbx), %rax
movq 0x8(%rsp), %rcx
movq %rcx, (%rax,%r12,8)
incq %r12
movq 0x328(%rbx), %rax
addq %rax, %r15
incq %r15
incq %rbp
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x6(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq 0x30(%rsp), %r8
callq 0x7f59b
cmpl $0x1, %eax
je 0xcf5d0
jmp 0xcf78f
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
testl %eax, %eax
js 0xcf807
jne 0xcf84d
movb 0x2f0(%rbx), %al
cmpb $0x1, %al
jne 0xcf7d2
testq %r13, %r13
je 0xcf7d2
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
je 0xcf852
cmpq 0x320(%rbx), %rdx
ja 0xcf852
decl %r13d
movq 0x300(%rbx), %rcx
movl %r13d, -0x4(%rcx,%rdx,4)
testb %al, %al
movq 0x8(%rsp), %rcx
je 0xcf7fb
cmpq 0x318(%rbx), %r12
jae 0xcf7fb
movq 0x308(%rbx), %rax
movq %rcx, (%rax,%r12,8)
incq %r12
cmpq 0x318(%rbx), %r12
jb 0xcf7eb
movq %r14, %rdi
callq 0xc3450
xorl %eax, %eax
jmp 0xcf82f
movq 0x290(%rbx), %rdi
leaq 0x33215(%rip), %rsi     # 0x102a2a
movl $0x8c6, %edx            # imm = 0x8C6
callq 0x362a0
movq $0x0, 0x290(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2f27a
callq 0x2f241
callq 0x2f208
callq 0x2f2b1
callq 0x2f2ea