// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
cmpq %rcx, 0x38(%rsi)
jbe 0xa83f1
movq %rcx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpb $0x1, 0x3a8(%rsi)
jne 0xa8342
movq 0x30(%r15), %rax
movq %rax, %rcx
subq %rbx, %rcx
jbe 0xa83a2
xorl %ebp, %ebp
leaq 0xc77f(%rip), %rax      # 0xb4aca
leaq 0xc858(%rip), %r9       # 0xb4baa
testb %dl, %dl
cmovneq %rax, %r9
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r8, %rcx
callq *%r9
movq %rax, %r12
testb %bpl, %bpl
je 0xa83c3
movq (%r14), %rdi
callq 0xb4c96
movq %rax, (%r14)
cmpl $0x0, 0x8(%r14)
je 0xa8387
notq %rax
movq %rax, (%r14)
movq 0x38(%r15), %rax
cmpq $0x1f, %rbx
ja 0xa83bd
testq %r12, %r12
jne 0xa83bd
subq %rbx, %rax
addq $0x1f, %rax
movq %rax, %r12
jmp 0xa83c3
jne 0xa83cf
movzbl %dl, %eax
shll $0x6, %eax
andq $0x0, (%r14)
leaq (%rax,%rbx), %r12
addq $-0x20, %r12
andl $0x0, 0x8(%r14)
jmp 0xa83c3
notq %r12
addq %rax, %r12
movq %r12, %rax
popq %rbx
popq %r12
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 0xa8344
movq 0x85bc0(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x21c64(%rip), %rsi     # 0xca066
leaq 0x4771e(%rip), %rdx     # 0xefb27
leaq 0x4773f(%rip), %rcx     # 0xefb4f
leaq 0x43783(%rip), %r8      # 0xebb9a
movl $0x1825, %r9d           # imm = 0x1825
xorl %eax, %eax
callq 0xb8c0
callq 0xb300