// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/core/bitpackstringop.c
// Function: gt_bsPrint
int gt_bsPrint(FILE *fp, constBitString str, BitOffset offset,
               BitOffset numBits)
{
  uint32_t accum = 0;
  unsigned bitsLeft = numBits, bitTop = offset%bitElemBits, bitsInAccum = 0;
  size_t elemStart = offset/bitElemBits;
  const BitElem *p = str + elemStart;
  char buf[sizeof (accum) * CHAR_BIT];
  int ioGtError = 0;
  gt_assert(str);
  do {
    if (bitTop)
    {
      uint32_t mask;
      unsigned bits2Read = GT_MIN(bitElemBits - bitTop, bitsLeft);
      unsigned unreadRightBits = (bitElemBits - bitTop - bits2Read);
      mask = (~((~(uint32_t)0) << bits2Read)) << unreadRightBits;
      ACCUM2FP(((*p++) & mask) >> unreadRightBits, bits2Read);
      bitsLeft -= bits2Read;
    }
    /* get bits from intervening elems */
    while (bitsLeft >= bitElemBits && !ioGtError)
    {
      while (bitsLeft >= bitElemBits
             && sizeof (accum) * CHAR_BIT - bitElemBits >= bitsInAccum)
      {
        accum = accum << bitElemBits | (*p++);
        bitsLeft -= bitElemBits;
        bitsInAccum += bitElemBits;
      }
      ACCUM2FP(accum, bitsInAccum);
      accum = 0; bitsInAccum = 0;
    }
    if (ioGtError)
      break;
    /* get bits from last elem */
    if (bitsLeft)
    {
      accum = ((*p) & ((~(uint32_t)0)<<(bitElemBits - bitsLeft)))
        >> (bitElemBits - bitsLeft);
      ACCUM2FP(accum, bitsLeft);
    }
  } while (0);
  return ioGtError?-1:0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
testq %rsi, %rsi
je 0x2fa8b5
movq %rcx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl %edx, %ecx
andl $0x7, %ecx
shrq $0x3, %rdx
addq %rdx, %r15
testl %ecx, %ecx
je 0x2fa7eb
movl $0x8, %eax
subl %ecx, %eax
cmpl %r14d, %eax
movl %r14d, %r12d
cmovbl %eax, %r12d
subl %r12d, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %r12d, %ecx
shll %cl, %esi
movzbl (%r15), %edx
movl %eax, %ecx
shrl %cl, %edx
movb $0x0, (%rsp,%r12)
testl %r14d, %r14d
je 0x2fa7c3
notl %esi
andl %esi, %edx
movl $0x1, %eax
movq %r12, %rcx
testl %edx, %eax
sete %sil
xorb $0x31, %sil
addl %eax, %eax
movb %sil, -0x1(%rsp,%rcx)
decq %rcx
jne 0x2fa7ad
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x178c0
xorl %ecx, %ecx
xorl %ebp, %ebp
cmpl $-0x1, %eax
cmovnel %r12d, %ecx
sete %bpl
je 0x2fa8a4
incq %r15
subl %ecx, %r14d
jmp 0x2fa7ed
xorl %ebp, %ebp
movq %rsp, %r12
testl %ebp, %ebp
jne 0x2fa856
cmpl $0x8, %r14d
jb 0x2fa856
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %ecx
shll $0x8, %ecx
movzbl (%r15), %eax
incq %r15
orl %ecx, %eax
addl $-0x8, %r14d
leaq 0x8(%rdx), %rcx
cmpl $0x8, %r14d
jb 0x2fa822
cmpl $0x11, %edx
movq %rcx, %rdx
jb 0x2fa7fe
movb $0x0, (%rsp,%rcx)
movl $0x1, %edx
testl %eax, %edx
sete %sil
xorb $0x31, %sil
addl %edx, %edx
movb %sil, -0x1(%rsp,%rcx)
decq %rcx
jne 0x2fa82b
movq %r12, %rdi
movq %rbx, %rsi
callq 0x178c0
cmpl $-0x1, %eax
jne 0x2fa7f0
movl $0x1, %ebp
testl %ebp, %ebp
jne 0x2fa8a4
testl %r14d, %r14d
je 0x2fa8a4
movzbl (%r15), %eax
movb $0x8, %cl
subb %r14b, %cl
shrl %cl, %eax
shll %cl, %eax
shrl %cl, %eax
movl %r14d, %ecx
movb $0x0, (%rsp,%rcx)
movl $0x1, %edx
testl %eax, %edx
sete %sil
xorb $0x31, %sil
addl %edx, %edx
movb %sil, -0x1(%rsp,%rcx)
decq %rcx
jne 0x2fa87a
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x178c0
xorl %ebp, %ebp
cmpl $-0x1, %eax
sete %bpl
negl %ebp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x88ee8
nop