// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/encseq.c
// Function: gt_encseq_extract2bitenc
static GtUword gt_encseq_extract2bitenc(
                                            GtEndofTwobitencoding *ptbe,
                                            const GtEncseq *encseq,
                                            bool fwd,
                                            GtUword currentpos,
                                            GtUword twobitencodingstoppos)
{
  bool mirrored = false;
  GtUword pos;

  gt_assert(currentpos < encseq->logicaltotallength);
  if (encseq->hasmirror && currentpos >= encseq->totallength) {
    if (currentpos == encseq->totallength) {
      /* handle special case where we start on the virtual separator */
      pos = currentpos + (fwd ? GT_UNITSIN2BITENC : -GT_UNITSIN2BITENC);
      ptbe->tbe = 0;
      ptbe->unitsnotspecial = 0;
      return pos;
    }
    mirrored = true;
    /* invert coordinates */
    fwd = !fwd;
    currentpos = GT_REVERSEPOS(encseq->totallength,
                               currentpos - encseq->totallength - 1);
    twobitencodingstoppos = GT_REVERSEPOS(encseq->totallength,
                                          twobitencodingstoppos -
                                            encseq->totallength - 2);
  }

  /* run extraction */
  pos = (fwd ?
            fwdextract2bitenc :
            revextract2bitenc)(ptbe, encseq, currentpos, twobitencodingstoppos);

  if (mirrored) {
    /* reverse */
    ptbe->tbe = gt_intbits_reverse_unitwise(ptbe->tbe);
    /* complement */
    if (ptbe->unitsnotspecial > 0)
      ptbe->tbe ^= ~0;
    /* handle the fact that the position returned by (fwd|rev)extract2bitenc()
       cannot be negative */
    if (pos == 0 && currentpos < (GtUword) GT_UNITSIN2BITENC) {
      pos = GT_REVERSEPOS(encseq->logicaltotallength, currentpos)
              + GT_UNITSIN2BITENC;
    } else {
      pos = GT_REVERSEPOS(encseq->logicaltotallength, pos);
    }
  }

  return pos;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpq %rcx, 0x38(%rsi)
jbe 0xc5035
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x1, 0x3a8(%rsi)
jne 0xc4f25
movq 0x30(%rbx), %rax
movq %rax, %rsi
subq %rcx, %rsi
jbe 0xc4f4d
leaq 0xa89b(%rip), %rax      # 0xcf7c7
leaq 0xa9e5(%rip), %r9       # 0xcf918
testb %dl, %dl
cmovneq %rax, %r9
movq %r14, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
popq %rbx
popq %r14
popq %r15
jmpq *%r9
jne 0xc4f70
movzbl %dl, %eax
shll $0x6, %eax
addq %rax, %rcx
addq $-0x20, %rcx
movq $0x0, (%r14)
movl $0x0, 0x8(%r14)
jmp 0xc502c
leaq (%rsi,%rax), %r15
decq %r15
incq %r15
movq %rax, %rcx
subq %r8, %rcx
addq %rax, %rcx
incq %rcx
leaq 0xa98b(%rip), %rax      # 0xcf918
leaq 0xa833(%rip), %r8       # 0xcf7c7
testb %dl, %dl
cmovneq %rax, %r8
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq *%r8
movq (%r14), %rcx
bswapq %rcx
movq %rcx, %rdx
shrq $0x4, %rdx
movabsq $0xf0f0f0f0f0f0f0f, %rsi # imm = 0xF0F0F0F0F0F0F0F
andq %rdx, %rsi
shlq $0x4, %rcx
movabsq $-0xf0f0f0f0f0f0f10, %rdx # imm = 0xF0F0F0F0F0F0F0F0
andq %rcx, %rdx
orq %rsi, %rdx
movabsq $-0xccccccccccccccd, %rcx # imm = 0xF333333333333333
andq %rdx, %rcx
shrq $0x2, %rdx
movabsq $0x3333333333333333, %rsi # imm = 0x3333333333333333
andq %rdx, %rsi
leaq (%rsi,%rcx,4), %rcx
movq %rcx, (%r14)
cmpl $0x0, 0x8(%r14)
je 0xc5006
notq %rcx
movq %rcx, (%r14)
testq %rax, %rax
setne %dl
cmpq $0x20, %r15
setae %sil
movq 0x38(%rbx), %rcx
orb %dl, %sil
jne 0xc5026
subq %r15, %rcx
addq $0x1f, %rcx
jmp 0xc502c
notq %rax
addq %rax, %rcx
movq %rcx, %rax
popq %rbx
popq %r14
popq %r15
retq
callq 0x2bcaf