// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movb %dl, %al
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
andb $0x1, %al
movb %al, 0x2f(%rsp)
movq %rcx, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movb $0x0, 0x17(%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq 0x38(%rcx), %rax
jb 0x11d8ad
movq 0x9675c(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x407e0(%rip), %rsi     # 0x15e066
leaq 0x6bea2(%rip), %rdx     # 0x18972f
leaq 0x6bec3(%rip), %rcx     # 0x189757
leaq 0x67dc3(%rip), %r8      # 0x18565e
movl $0x1825, %r9d           # imm = 0x1825
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x11d8af
movq 0x30(%rsp), %rax
testb $0x1, 0x3a8(%rax)
je 0x11d991
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jb 0x11d991
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jne 0x11d932
movq 0x20(%rsp), %rax
movb 0x2f(%rsp), %sil
movl $0xffffffe0, %ecx       # imm = 0xFFFFFFE0
movl $0x20, %edx
testb $0x1, %sil
cmovnel %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rax
movq $0x0, (%rax)
movq 0x38(%rsp), %rax
movl $0x0, 0x8(%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x11da4e
movb $0x1, 0x17(%rsp)
movb 0x2f(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x2f(%rsp)
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rax
subq $0x1, %rax
movq 0x20(%rsp), %rcx
movq 0x30(%rsp), %rdx
subq 0x30(%rdx), %rcx
subq $0x1, %rcx
subq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rax
subq $0x1, %rax
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rdx
subq 0x30(%rdx), %rcx
subq $0x2, %rcx
subq %rcx, %rax
movq %rax, 0x18(%rsp)
movb 0x2f(%rsp), %dl
leaq 0x14d74(%rip), %rax     # 0x132710
leaq 0x14bcd(%rip), %rcx     # 0x132570
testb $0x1, %dl
cmovneq %rcx, %rax
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq *%rax
movq %rax, 0x8(%rsp)
testb $0x1, 0x17(%rsp)
je 0x11da44
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x1328d0
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movq 0x38(%rsp), %rax
cmpl $0x0, 0x8(%rax)
jbe 0x11d9fe
movq 0x38(%rsp), %rax
movq (%rax), %rcx
xorq $-0x1, %rcx
movq %rcx, (%rax)
cmpq $0x0, 0x8(%rsp)
jne 0x11da2b
cmpq $0x20, 0x20(%rsp)
jae 0x11da2b
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
subq $0x1, %rax
subq 0x20(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x8(%rsp)
jmp 0x11da42
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
subq $0x1, %rax
subq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x11da44
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopl (%rax,%rax)