// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/encseq.c
// Function: fillViabytecompress
static int fillViabytecompress(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;
  unsigned int numofchars;
  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;
  }
  numofchars = gt_alphabet_num_of_chars(encseq->alpha);
  encseq->bitpackarray
    = bitpackarray_new(gt_alphabet_bits_per_symbol(encseq->alpha),
                       (BitOffset) encseq->totallength, true);
  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)) {
        if (cc == (GtUchar) GT_SEPARATOR) {
          ssptaboutinfo_processseppos(ssptaboutinfo, currentposition);
          cc = (GtUchar) (numofchars+1);
        }
        else {
          cc = (GtUchar) numofchars;
        }
      }
      else {
        gt_assert(cc < (GtUchar) numofchars);
      }
      gt_assert(currentposition < encseq->totallength);
      ssptaboutinfo_processanyposition(ssptaboutinfo, currentposition);
      bitpackarray_store_uint32(encseq->bitpackarray,
                                (BitOffset) currentposition,
                                (uint32_t) cc);
    }
    else {
      if (retval < 0) {
        bitpackarray_delete(encseq->bitpackarray);
        encseq->bitpackarray = NULL;
        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);
      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 $0x48, %rsp
movq %r8, %rbp
movq %rcx, 0x40(%rsp)
movq %rdx, %r14
movq %rsi, 0x38(%rsp)
movq %rdi, %rbx
testq %r8, %r8
je 0xd07d3
movq %rbp, %rdi
callq 0x34fea
testb %al, %al
jne 0xd0c63
movq $-0x1, %r13
cmpb $0x1, 0x2f0(%rbx)
jne 0xd0871
movq 0x320(%rbx), %rdi
shlq $0x2, %rdi
leaq 0x32121(%rip), %r12     # 0x10291a
movq %r12, %rsi
movl $0x92b, %edx            # imm = 0x92B
callq 0x35862
movq %rax, 0x2f8(%rbx)
movq 0x320(%rbx), %rdi
shlq $0x2, %rdi
movq %r12, %rsi
movl $0x92e, %edx            # imm = 0x92E
callq 0x35862
movq %rax, 0x300(%rbx)
movq 0x318(%rbx), %rdi
shlq $0x3, %rdi
movq %r12, %rsi
movl $0x931, %edx            # imm = 0x931
callq 0x35862
movq %rax, 0x308(%rbx)
movq 0x320(%rbx), %rdi
shlq $0x3, %rdi
movq %r12, %rsi
movl $0x934, %edx            # imm = 0x934
callq 0x35862
movq %rax, 0x310(%rbx)
movq 0x328(%rbx), %r13
movq 0x220(%rbx), %rdi
callq 0xba7a2
movq %rax, 0x28(%rsp)
movq 0x220(%rbx), %rdi
callq 0xba7e4
movl %eax, 0x18(%rsp)
movq 0x30(%rbx), %r15
leaq 0x353db(%rip), %rsi     # 0x105c78
movl $0x18, %edi
movl $0x48, %edx
callq 0x35862
testq %rax, %rax
je 0xd0911
movq %rax, %r12
movl 0x18(%rsp), %eax
imulq %r15, %rax
movq %rax, %rdi
shrq $0x3, %rdi
andl $0x7, %eax
cmpq $0x1, %rax
sbbq $-0x1, %rdi
leaq 0x353a3(%rip), %rdx     # 0x105c78
movl $0x1, %esi
movl $0x4c, %ecx
callq 0x359a6
movq %rax, (%r12)
testq %rax, %rax
je 0xd08fd
movl 0x18(%rsp), %eax
movl %eax, 0x10(%r12)
movq %r15, 0x8(%r12)
jmp 0xd0914
leaq 0x35374(%rip), %rsi     # 0x105c78
movq %r12, %rdi
movl $0x4d, %edx
callq 0x35c27
xorl %r12d, %r12d
movq %r12, 0x2a0(%rbx)
leaq 0x6(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rbp, %r8
callq 0x7f610
cmpl $0x1, %eax
jne 0xd0b7f
movq %rbp, 0x18(%rsp)
movq 0x28(%rsp), %rax
incl %eax
movl %eax, 0x34(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
xorl %r15d, %r15d
movq $0x0, 0x10(%rsp)
movb 0x6(%rsp), %al
cmpb $-0x1, %al
setne %cl
andb 0x2f0(%rbx), %cl
cmpb $0x1, %cl
jne 0xd0a8b
movzbl %al, %edx
movsbq 0x7(%rsp), %rcx
movq 0x348(%rbx), %rsi
cmpb (%rsi,%rdx), %cl
jne 0xd09b5
testq %rbp, %rbp
je 0xd09ae
decl %ebp
movq 0x300(%rbx), %rcx
movq 0x8(%rsp), %rdx
movl %ebp, -0x4(%rcx,%rdx,4)
xorl %ebp, %ebp
jmp 0xd0a8b
movq 0x328(%rbx), %rax
testq %rbp, %rbp
je 0xd09f4
cmpq %rax, %rbp
jne 0xd09ea
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
je 0xd0c5e
movq 0x300(%rbx), %rax
movl %ebp, -0x4(%rax,%rdx,4)
movq $0x0, 0x20(%rsp)
jmp 0xd0a29
incq %rbp
movq %rbp, 0x20(%rsp)
jmp 0xd0a29
andl %r12d, %eax
movq 0x2f8(%rbx), %rdx
movq 0x8(%rsp), %rsi
movl %eax, (%rdx,%rsi,4)
movq 0x310(%rbx), %rax
movq 0x10(%rsp), %rdx
movq %rdx, (%rax,%rsi,8)
leaq 0x1(%rsi), %rax
movl $0x1, %edx
movq %rdx, 0x20(%rsp)
movq %rax, 0x8(%rsp)
movq 0x330(%rbx), %rax
testq %rax, %rax
je 0xd0c54
movq 0x10(%rsp), %rdx
cmpq %rdx, 0x8(%rax)
jbe 0xd0c54
movl 0x10(%rax), %edx
cmpq $0x21, %rdx
jae 0xd0c54
movq %r14, %rbp
movq 0x358(%rbx), %rsi
movzbl (%rsi,%rcx), %ecx
movq (%rax), %rdi
movq %rdx, %rsi
movq 0x10(%rsp), %r14
imulq %r14, %rsi
callq 0xde284
incq %r14
movq %r14, 0x10(%rsp)
movb 0x6(%rsp), %al
movq %rbp, %r14
movq 0x20(%rsp), %rbp
cmpb $-0x2, %al
jb 0xd0a9e
cmpb $-0x1, %al
je 0xd0aa9
movq 0x28(%rsp), %rax
movb %al, 0x6(%rsp)
jmp 0xd0abc
cmpb 0x28(%rsp), %al
jb 0xd0abc
jmp 0xd0c59
movq %r14, %rdi
movq %r12, %rsi
callq 0xc4427
movl 0x34(%rsp), %eax
movb %al, 0x6(%rsp)
cmpq 0x30(%rbx), %r12
jae 0xd0c4f
testq %r14, %r14
je 0xd0ae5
cmpq %r12, 0x10(%r14)
jne 0xd0ae5
movq %r14, %rdi
callq 0xcf47b
movq 0x18(%r14), %rax
addq %rax, 0x10(%r14)
movb 0x6(%rsp), %al
movq 0x2a0(%rbx), %rsi
testq %rsi, %rsi
je 0xd0c4a
cmpq %r12, 0x8(%rsi)
jbe 0xd0c4a
movl 0x10(%rsi), %edx
cmpq $0x21, %rdx
jae 0xd0c4a
movzbl %al, %ecx
movq (%rsi), %rdi
movq %rdx, %rsi
imulq %r12, %rsi
callq 0xde284
cmpb $0x1, 0x2f0(%rbx)
jne 0xd0b4e
cmpq %r13, %r12
jne 0xd0b4e
movq 0x308(%rbx), %rax
movq 0x8(%rsp), %rcx
movq %rcx, (%rax,%r15,8)
incq %r15
incq %r12
movq 0x328(%rbx), %r13
addq %r12, %r13
jmp 0xd0b51
incq %r12
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
leaq 0x6(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq 0x18(%rsp), %r8
callq 0x7f610
cmpl $0x1, %eax
je 0xd096a
movq 0x8(%rsp), %rsi
jmp 0xd0b86
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %esi, %esi
testl %eax, %eax
js 0xd0bf8
movb 0x2f0(%rbx), %cl
testq %rbp, %rbp
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xd0bc0
testq %rsi, %rsi
je 0xd0c68
cmpq 0x320(%rbx), %rsi
ja 0xd0c68
decl %ebp
movq 0x300(%rbx), %rdx
movl %ebp, -0x4(%rdx,%rsi,4)
testl %eax, %eax
jne 0xd0c6d
testb %cl, %cl
je 0xd0bec
cmpq 0x318(%rbx), %r15
jae 0xd0bec
movq 0x308(%rbx), %rax
movq %rsi, (%rax,%r15,8)
incq %r15
cmpq 0x318(%rbx), %r15
jb 0xd0bdc
movq %r14, %rdi
callq 0xc4493
xorl %eax, %eax
jmp 0xd0c3b
movq 0x2a0(%rbx), %r14
testq %r14, %r14
je 0xd0c2b
movq (%r14), %rdi
leaq 0x3506a(%rip), %r15     # 0x105c78
movq %r15, %rsi
movl $0x5d, %edx
callq 0x35c27
movq %r14, %rdi
movq %r15, %rsi
movl $0x5e, %edx
callq 0x35c27
movq $0x0, 0x2a0(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2ef5e
callq 0x2eeb3
callq 0x2ee43
callq 0x2ee7a
callq 0x2ee0a
callq 0x2edd1
callq 0x2ef25
callq 0x2eeec