// File: /workspace/github_c_makefile_star2_O1/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 0xc4190
movq %r8, %rbx
cmpq 0x50(%rsp), %r8
setae %al
testb %r9b, %al
jne 0xc4190
movq %rsi, %r14
cmpq %rbx, 0x38(%rsi)
je 0xc4190
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 0xc0212
movq %r14, %rdi
callq 0xc06bb
testb %al, %al
je 0xc4077
xorl %edi, %edi
movq %r12, %rsi
callq 0xc3c5e
movq %rax, %r12
jmp 0xc409f
testb %bpl, %bpl
jne 0xc41a6
cmpl $0x1, %r13d
je 0xc4096
cmpb $0x1, 0x3a8(%r14)
jne 0xc409b
movq 0x38(%r14), %r12
jmp 0xc409f
xorl %r12d, %r12d
jmp 0xc409f
movq 0x30(%r14), %r12
testb %bpl, %bpl
je 0xc40d3
cmpl $0x1, %r13d
je 0xc40b8
movq 0x50(%rsp), %rbp
cmpq %rbp, %r12
cmovaeq %rbp, %r12
jmp 0xc40d3
movq 0x38(%r14), %rax
movq 0x50(%rsp), %rbp
cmpq %rbp, %rax
jbe 0xc40d3
notq %rbp
addq %rbp, %rax
cmpq %rax, %r12
cmovbeq %rax, %r12
cmpl $0x1, %r13d
jne 0xc40e0
notq %rbx
addq 0x38(%r14), %rbx
xorl %ebp, %ebp
cmpl $0x1, %r13d
je 0xc40f2
cmpq %r12, %rbx
jne 0xc40fb
jmp 0xc4190
cmpq %r12, %rbx
jb 0xc4190
xorl %edx, %edx
cmpl $0x1, %r13d
setne %dl
movq %rsp, %rdi
movq %r14, %rsi
movq %rbx, %rcx
movq %r12, %r8
callq 0xc3ecd
movq 0x8(%r15), %rax
cmpq %rax, 0x10(%r15)
jb 0xc4146
leaq 0x20(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%r15), %rdi
leaq 0x100(,%rax,8), %rsi
leaq 0x3e8f1(%rip), %rdx     # 0x102a2a
movl $0x18b0, %ecx           # imm = 0x18B0
callq 0x36116
movq %rax, (%r15)
movq (%r15), %rax
testq %rax, %rax
je 0xc41a1
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 0xc418e
movl $0x20, %ecx
cmpl $0x1, %r13d
jne 0xc4183
movq $-0x20, %rcx
cmpq $0x1f, %rbx
jbe 0xc418e
addq %rcx, %rbx
addl $0x20, %ebp
jmp 0xc40e2
addl %eax, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2bfc7
callq 0x2bf8e