// File: /workspace/github_c_makefile_star2_O3/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 0x2f14d5
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 0x2f140f
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
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movb $0x0, (%rsp,%r12)
testl %r14d, %r14d
je 0x2f13f5
notl %esi
andl %esi, %edx
movl $0x1, %eax
movq %r12, %rcx
testl %eax, %edx
sete %sil
xorb $0x31, %sil
addl %eax, %eax
movb %sil, -0x1(%rsp,%rcx)
decq %rcx
jne 0x2f13df
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x178c0
cmpl $-0x1, %eax
je 0x2f14c6
incq %r15
subl %r12d, %r14d
movq %rsp, %r12
cmpl $0x8, %r14d
jb 0x2f1476
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 0x2f1440
cmpl $0x11, %edx
movq %rcx, %rdx
jb 0x2f141c
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 0x2f1449
movq %r12, %rdi
movq %rbx, %rsi
callq 0x178c0
cmpl $-0x1, %eax
jne 0x2f1412
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x2f14c6
testl %r14d, %r14d
je 0x2f14c4
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 0x2f1496
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x178c0
xorl %ebp, %ebp
cmpl $-0x1, %eax
sete %bpl
negl %ebp
jmp 0x2f14c6
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x871b9
nop