// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpq %rcx, 0x38(%rsi)
jbe 0xc3ffc
movq %rcx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpb $0x1, 0x3a8(%rsi)
jne 0xc3f00
movq 0x30(%r15), %rax
movq %rax, %rcx
subq %rbx, %rcx
jbe 0xc3fa9
xorl %ebp, %ebp
leaq 0xaa25(%rip), %rax      # 0xce92e
leaq 0xab75(%rip), %r9       # 0xcea85
testb %dl, %dl
cmovneq %rax, %r9
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r8, %rcx
callq *%r9
testb %bpl, %bpl
je 0xc3fcf
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 0xc3f8e
notq %rcx
movq %rcx, (%r14)
movq 0x38(%r15), %rcx
cmpq $0x1f, %rbx
ja 0xc3fc9
testq %rax, %rax
jne 0xc3fc9
subq %rbx, %rcx
addq $0x1f, %rcx
movq %rcx, %rax
jmp 0xc3fcf
jne 0xc3fda
movzbl %dl, %eax
shll $0x6, %eax
addq %rbx, %rax
addq $-0x20, %rax
movq $0x0, (%r14)
movl $0x0, 0x8(%r14)
jmp 0xc3fcf
notq %rax
addq %rcx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorb $0x1, %dl
leaq (%rcx,%rax), %rbx
decq %rbx
incq %rbx
movq %rax, %rcx
subq %r8, %rcx
leaq (%rcx,%rax), %r8
incq %r8
movb $0x1, %bpl
jmp 0xc3f02
callq 0x2bf55