// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/encseq.c
// Function: gt_encseq_extract2bitencvector
unsigned int gt_encseq_extract2bitencvector(
                                       GtArrayGtTwobitencoding *tbereservoir,
                                       const GtEncseq *encseq,
                                       GtEncseqReader *esr,
                                       GtReadmode readmode,
                                       GtUword pos,
                                       bool withstoppos,
                                       GtUword stoppos)
{
  GtEndofTwobitencoding etbecurrent;
  GtUword twobitencodingstoppos;
  unsigned int offset;
  bool fwd;

  if (pos == encseq->totallength || pos == encseq->logicaltotallength ||
      (withstoppos && pos >= stoppos)) {
    return 0;
  }
  fwd = GT_ISDIRREVERSE(readmode) ? false : true;
  gt_encseq_reader_reinit_with_readmode(esr, encseq, readmode, pos);
  if (gt_encseq_has_twobitencoding_stoppos_support(encseq)) {
    twobitencodingstoppos = gt_getnexttwobitencodingstoppos(fwd, esr);
  }
  else {
    gt_assert(!withstoppos);
    twobitencodingstoppos = fwd ? GT_TWOBITENCODINGSTOPPOSUNDEF(encseq) : 0;
  }
  if (withstoppos) {
    if (fwd) {
      if (twobitencodingstoppos > stoppos) {
        twobitencodingstoppos = stoppos;
      }
    }
    else {
      if (stoppos < encseq->logicaltotallength) {
        stoppos = GT_REVERSEPOS(encseq->logicaltotallength, stoppos);
        if (twobitencodingstoppos < stoppos) {
          twobitencodingstoppos = stoppos;
        }
      }
    }
  }
  if (GT_ISDIRREVERSE(readmode)) {
    pos = GT_REVERSEPOS(encseq->logicaltotallength, pos);
  }
  for (offset = 0; /* Nothing */;
       offset += (unsigned int) GT_UNITSIN2BITENC) {
    if (fwd) {
      if (pos == twobitencodingstoppos) {
        return offset;
      }
    }
    else {
      if (pos < twobitencodingstoppos) {
        return offset;
      }
    }
    (void) gt_encseq_extract2bitenc(&etbecurrent, encseq, fwd, pos,
                                    twobitencodingstoppos);
    GT_STOREINARRAY(tbereservoir, GtTwobitencoding, 32UL, etbecurrent.tbe);
    if (etbecurrent.unitsnotspecial < (unsigned int) GT_UNITSIN2BITENC) {
      return offset + etbecurrent.unitsnotspecial;
    }
    if (fwd) {
      pos += GT_UNITSIN2BITENC;
    }
    else {
      if (pos >= (GtUword) GT_UNITSIN2BITENC) {
        pos -= (GtUword) GT_UNITSIN2BITENC;
      }
      else {
        return offset + etbecurrent.unitsnotspecial;
      }
    }
  }
  /*@ignore@*/
  return 0;
  /*@end@*/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %ebp, %ebp
cmpq %r8, 0x30(%rsi)
je 0xc51cb
movq %r8, %rbx
cmpq 0x50(%rsp), %r8
setae %al
testb %r9b, %al
jne 0xc51cb
movq %rsi, %r14
cmpq %rbx, 0x38(%rsi)
je 0xc51cb
movq %rdx, %r12
movq %rdi, %r15
movl %r9d, %ebp
movl %ecx, %r13d
andl $-0x3, %r13d
movq %rdx, %rdi
movq %r14, %rsi
movl %ecx, %edx
movq %rbx, %rcx
callq 0xc12b5
movq %r14, %rdi
callq 0xc1740
testb %al, %al
je 0xc50c7
xorl %edi, %edi
movq %r12, %rsi
callq 0xc4ca3
movq %rax, %r12
testb %bpl, %bpl
je 0xc50ea
cmpl $0x1, %r13d
je 0xc50f7
movq 0x50(%rsp), %rbp
cmpq %rbp, %r12
cmovaeq %rbp, %r12
jmp 0xc5119
testb %bpl, %bpl
jne 0xc51ea
cmpl $0x1, %r13d
je 0xc50f2
cmpb $0x1, 0x3a8(%r14)
jne 0xc51dc
movq 0x38(%r14), %r12
jmp 0xc5119
cmpl $0x1, %r13d
je 0xc5112
jmp 0xc5119
xorl %r12d, %r12d
jmp 0xc5112
movq 0x38(%r14), %rax
movq 0x50(%rsp), %rbp
cmpq %rbp, %rax
jbe 0xc5112
notq %rbp
addq %rbp, %rax
cmpq %rax, %r12
cmovbeq %rax, %r12
notq %rbx
addq 0x38(%r14), %rbx
xorl %ebp, %ebp
cmpl $0x1, %r13d
je 0xc512b
cmpq %r12, %rbx
jne 0xc5134
jmp 0xc51cb
cmpq %r12, %rbx
jb 0xc51cb
xorl %edx, %edx
cmpl $0x1, %r13d
setne %dl
movq %rsp, %rdi
movq %r14, %rsi
movq %rbx, %rcx
movq %r12, %r8
callq 0xc4efb
movq 0x8(%r15), %rax
cmpq %rax, 0x10(%r15)
jae 0xc515d
movq (%r15), %rax
jmp 0xc5184
leaq 0x20(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%r15), %rdi
leaq 0x100(,%rax,8), %rsi
leaq 0x3d7a3(%rip), %rdx     # 0x10291a
movl $0x18b0, %ecx           # imm = 0x18B0
callq 0x35a9d
movq %rax, (%r15)
testq %rax, %rax
je 0xc51e5
movq (%rsp), %rcx
movq 0x10(%r15), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x10(%r15)
movq %rcx, (%rax,%rdx,8)
movl 0x8(%rsp), %eax
cmpl $0x1f, %eax
jbe 0xc51c9
movl $0x20, %ecx
cmpl $0x1, %r13d
jne 0xc51be
movq $-0x20, %rcx
cmpq $0x1f, %rbx
jbe 0xc51c9
addq %rcx, %rbx
addl $0x20, %ebp
jmp 0xc511b
addl %eax, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%r14), %r12
jmp 0xc5119
callq 0x2bd21
callq 0x2bce8