// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/reads2twobit.c
// Function: gt_reads2twobit_decode_range
void gt_reads2twobit_decode_range(const GtReads2Twobit *r2t,
    GtFile *outfp, GtUword seqnum_from, GtUword nofseqs,
    const GtBitsequence *skip)
{
  GtTwobitencoding code;
  unsigned short charsincode;
  const char code2char[] = "acgt";
  GtUword seqnum, pos, nextsep, nextdecoded, seqnum_to;
  const GtTwobitencoding *nextencoded;
  char *decoded;

  gt_assert(r2t->seqlen_max > 0);
  if (nofseqs == 0)
    return;
  seqnum_to = seqnum_from + nofseqs - 1UL;
  decoded = gt_malloc(sizeof (*decoded) * (r2t->seqlen_max + 3UL));
  decoded[0] = '>';
  decoded[1] = '\n';
  nextdecoded = 2UL;

  seqnum = seqnum_from;
  if (skip != NULL)
    while (GT_ISIBITSET(skip, seqnum))
      seqnum++;

  if (r2t->seqlen_eqlen > 0)
  {
    nextsep = r2t->seqlen_eqlen * (seqnum + 1UL) - 1UL;
    pos = seqnum * r2t->seqlen_eqlen;
  }
  else
  {
    nextsep = r2t->seppos[seqnum];
    pos = (seqnum == 0) ? 0 : r2t->seppos[seqnum - 1UL] + 1UL;
  }

  nextencoded = r2t->twobitencoding + GT_DIVBYUNITSIN2BITENC(pos);
  code = *(nextencoded++);
  charsincode = (unsigned short)GT_UNITSIN2BITENC -
    (unsigned short)GT_MODBYUNITSIN2BITENC(pos);

  while (true)
  {
    if (charsincode == 0)
    {
      code = *(nextencoded++);
      charsincode = (unsigned short)GT_UNITSIN2BITENC;
    }
    if (pos++ < nextsep)
    {
      gt_assert(nextsep - pos <= r2t->seqlen_max);
      decoded[nextdecoded++] = code2char[code >> ((--charsincode) << 1) & 3];
    }
    else
    {
      /* output sequence */
      charsincode--;
      decoded[nextdecoded++] = '\n';
      decoded[nextdecoded] = '\0';
      gt_file_xfputs(decoded, outfp);
      nextdecoded = 2UL;

      seqnum++;
      if (seqnum > seqnum_to)
        break;
      if (skip != NULL && GT_ISIBITSET(skip, seqnum))
      {
        /* jump to next non-contained sequence */
        while (seqnum <= seqnum_to && GT_ISIBITSET(skip, seqnum))
          seqnum++;
        if (seqnum > seqnum_to)
          break;
        pos = r2t->seqlen_eqlen > 0 ? seqnum * r2t->seqlen_eqlen :
          r2t->seppos[seqnum - 1UL] + 1UL;
        nextencoded = r2t->twobitencoding + GT_DIVBYUNITSIN2BITENC(pos);
        code = *(nextencoded++);
        charsincode = (unsigned short)GT_UNITSIN2BITENC -
          (unsigned short)GT_MODBYUNITSIN2BITENC(pos);
      }
      nextsep = (r2t->seqlen_eqlen > 0)
        ? r2t->seqlen_eqlen * (seqnum + 1UL) - 1UL
        : r2t->seppos[seqnum];
    }
  }
  gt_free(decoded);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, 0x20(%rsp)
movq %rdi, %r15
movq 0x50(%rdi), %rdi
testq %rdi, %rdi
je 0x18a9ea
movq %rcx, %r12
testq %rcx, %rcx
je 0x18a7e3
movq %rdx, %r14
movabsq $-0x8000000000000000, %rbx # imm = 0x8000000000000000
addq $0x3, %rdi
leaq 0x1c7ed4(%rip), %rsi    # 0x352656
movl $0x665, %edx            # imm = 0x665
movq %r8, 0x8(%rsp)
callq 0x93160
movq 0x8(%rsp), %rsi
movq %rax, (%rsp)
movw $0xa3e, (%rax)          # imm = 0xA3E
movq %r14, %r13
testq %rsi, %rsi
je 0x18a7c9
movq %rbx, %rdi
movq %r14, %r13
movq %r13, %rax
movq %rdi, %rdx
movl %r13d, %ecx
shrq %cl, %rdx
shrq $0x6, %rax
incq %r13
testq %rdx, (%rsi,%rax,8)
jne 0x18a7ad
decq %r13
movq 0x48(%r15), %rbp
testq %rbp, %rbp
je 0x18a7f2
leaq 0x1(%r13), %rax
imulq %rbp, %rax
decq %rax
imulq %r13, %rbp
jmp 0x18a80b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%r15), %rcx
movq (%rcx,%r13,8), %rax
testq %r13, %r13
je 0x18a809
movq -0x8(%rcx,%r13,8), %rbp
incq %rbp
jmp 0x18a80b
xorl %ebp, %ebp
leaq (%r14,%r12), %r9
decq %r9
movq 0x10(%r15), %rcx
movq %rbp, %rdx
shrq $0x5, %rdx
leaq (%rcx,%rdx,8), %r14
addq $0x8, %r14
movq -0x8(%r14), %rbx
movl %ebp, %ecx
andl $0x1f, %ecx
pushq $0x20
popq %rdx
movl %edx, %r12d
subl %ecx, %r12d
movq (%rsp), %rcx
addq $0x2, %rcx
movq %rcx, 0x18(%rsp)
leaq 0x1739e9(%rip), %r10    # 0x2fe234
movq %r9, 0x10(%rsp)
movq %rbp, %rdx
notq %rdx
addq %rax, %rdx
movq 0x18(%rsp), %rsi
testw %r12w, %r12w
jne 0x18a870
movq (%r14), %rbx
addq $0x8, %r14
movw $0x20, %r12w
cmpq %rax, %rbp
jae 0x18a8aa
cmpq 0x50(%r15), %rdx
ja 0x18a9b2
leal -0x2(,%r12,2), %ecx
movl %r12d, %edi
movq %rbx, %r8
shrq %cl, %r8
decl %edi
andl $0x3, %r8d
movb (%r8,%r10), %cl
movb %cl, (%rsi)
decq %rdx
incq %rsi
incq %rbp
movl %edi, %r12d
jmp 0x18a85e
movw $0xa, (%rsi)
movq (%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x8d7e9
leaq 0x173970(%rip), %r10    # 0x2fe234
movq 0x10(%rsp), %r9
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
movq 0x8(%rsp), %rdx
incq %r13
cmpq %r9, %r13
ja 0x18a98f
decl %r12d
incq %rbp
testq %rdx, %rdx
je 0x18a969
movq %rsi, %rax
movl %r13d, %ecx
shrq %cl, %rax
movq %r13, %rcx
shrq $0x6, %rcx
testq %rax, (%rdx,%rcx,8)
je 0x18a969
cmpq %r9, %r13
ja 0x18a98f
movq %rsi, %rax
movl %r13d, %ecx
shrq %cl, %rax
movq %r13, %rcx
shrq $0x6, %rcx
testq %rax, (%rdx,%rcx,8)
je 0x18a929
incq %r13
jmp 0x18a905
movq 0x48(%r15), %rbp
testq %rbp, %rbp
je 0x18a938
imulq %r13, %rbp
jmp 0x18a944
movq 0x38(%r15), %rax
movq -0x8(%rax,%r13,8), %rbp
incq %rbp
movq 0x10(%r15), %rax
movq %rbp, %rcx
shrq $0x5, %rcx
leaq (%rax,%rcx,8), %r14
addq $0x8, %r14
movq -0x8(%r14), %rbx
movl %ebp, %eax
andl $0x1f, %eax
pushq $0x20
popq %rcx
movl %ecx, %r12d
subl %eax, %r12d
movq 0x48(%r15), %rax
testq %rax, %rax
je 0x18a982
leaq 0x1(%r13), %rcx
imulq %rcx, %rax
decq %rax
jmp 0x18a850
movq 0x38(%r15), %rax
movq (%rax,%r13,8), %rax
jmp 0x18a850
leaq 0x1c7cc0(%rip), %rsi    # 0x352656
movq (%rsp), %rdi
movl $0x6aa, %edx            # imm = 0x6AA
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x936f9
movq 0x2ad5af(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x15a650(%rip), %rsi    # 0x2e5013
leaq 0x1c7ec3(%rip), %rdx    # 0x35288d
leaq 0x1c7e9f(%rip), %rcx    # 0x352870
leaq 0x1c7c7e(%rip), %r8     # 0x352656
movl $0x688, %r9d            # imm = 0x688
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x2ad577(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x15a618(%rip), %rsi    # 0x2e5013
leaq 0x1c7e5a(%rip), %rdx    # 0x35285c
leaq 0x1c7e67(%rip), %rcx    # 0x352870
leaq 0x1c7c46(%rip), %r8     # 0x352656
movl $0x661, %r9d            # imm = 0x661
jmp 0x18a9de