// File: /workspace/github_c_makefile_star2_O2/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 0xa85b4
movq %r8, %rbx
cmpq 0x50(%rsp), %r8
setae %al
testb %r9b, %al
jne 0xa85b4
movq %rsi, %r14
cmpq %rbx, 0x38(%rsi)
je 0xa85b4
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 0xa3924
movq %r14, %rdi
callq 0xa3eb4
testb %al, %al
je 0xa84b6
xorl %edi, %edi
movq %r12, %rsi
callq 0xa808b
movq %rax, %r12
testb %bpl, %bpl
je 0xa84d9
cmpl $0x1, %r13d
je 0xa84e6
movq 0x50(%rsp), %rbp
cmpq %rbp, %r12
cmovaeq %rbp, %r12
jmp 0xa8508
testb %bpl, %bpl
jne 0xa8606
cmpl $0x1, %r13d
je 0xa84e1
cmpb $0x1, 0x3a8(%r14)
jne 0xa85c5
movq 0x38(%r14), %r12
jmp 0xa8508
cmpl $0x1, %r13d
je 0xa8501
jmp 0xa8508
xorl %r12d, %r12d
jmp 0xa8501
movq 0x38(%r14), %rax
movq 0x50(%rsp), %rbp
cmpq %rbp, %rax
jbe 0xa8501
notq %rbp
addq %rbp, %rax
cmpq %rax, %r12
cmovbeq %rax, %r12
notq %rbx
addq 0x38(%r14), %rbx
xorl %ebp, %ebp
cmpl $0x1, %r13d
je 0xa851a
cmpq %r12, %rbx
jne 0xa8523
jmp 0xa85b4
cmpq %r12, %rbx
jb 0xa85b4
xorl %edx, %edx
cmpl $0x1, %r13d
setne %dl
movq %rsp, %rdi
movq %r14, %rsi
movq %rbx, %rcx
movq %r12, %r8
callq 0xa8312
movq 0x8(%r15), %rax
cmpq %rax, 0x10(%r15)
jae 0xa854c
movq (%r15), %rax
jmp 0xa8573
leaq 0x20(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%r15), %rdi
leaq 0x100(,%rax,8), %rsi
leaq 0x43634(%rip), %rdx     # 0xebb9a
movl $0x18b0, %ecx           # imm = 0x18B0
callq 0xcfc2
movq %rax, (%r15)
testq %rax, %rax
je 0xa85ce
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 0xa85b2
pushq $0x20
popq %rcx
cmpl $0x1, %r13d
jne 0xa85a7
pushq $-0x20
popq %rcx
cmpq $0x1f, %rbx
jbe 0xa85b2
addq %rcx, %rbx
addl $0x20, %ebp
jmp 0xa850a
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 0xa8508
movq 0x859e3(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x21a87(%rip), %rsi     # 0xca066
leaq 0x44661(%rip), %rdx     # 0xecc47
leaq 0x4463b(%rip), %rcx     # 0xecc28
leaq 0x435a6(%rip), %r8      # 0xebb9a
movl $0x18b0, %r9d           # imm = 0x18B0
xorl %eax, %eax
callq 0xb8c0
callq 0xb300
movq 0x859ab(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x21a4f(%rip), %rsi     # 0xca066
leaq 0x445fd(%rip), %rdx     # 0xecc1b
leaq 0x44603(%rip), %rcx     # 0xecc28
leaq 0x4356e(%rip), %r8      # 0xebb9a
movl $0x188d, %r9d           # imm = 0x188D
jmp 0xa85fa