// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/core/bitpackstringop32.c
// Function: gt_bsStoreUniformUInt32Array
void
gt_bsStoreUniformUInt32Array(BitString str, BitOffset offset,
                                 unsigned numBits, size_t numValues,
                                 const uint32_t val[])
{
  /* idea: read as much as possible from val in each iteration,
   * accumulate if bitsInAccum < bitElemBits */
  size_t j = 0;
  BitOffset totalBitsLeft = numValues * numBits;
  unsigned bitTop = offset%bitElemBits,
    bitsLeft; /*< how many bits in currentVal == val[j] are left */
  BitElem *p = str + offset/bitElemBits;
  unsigned bitsInAccum;
  GtUword accum, valMask = ~(GtUword)0, currentVal;
  if (numBits < (sizeof (val[0])*CHAR_BIT))
    valMask = ~(valMask << numBits);
  gt_assert(str && val);
  gt_assert(numBits <= sizeof (val[0])*CHAR_BIT);
  /* user requested zero values, ugly but must be handled, since legal */
  if (!totalBitsLeft)
  {
    return;
  }
  accum = val[0] & valMask;
  totalBitsLeft -= bitsInAccum = numBits;
  if (totalBitsLeft)
  {
    currentVal = val[++j] & valMask;
    totalBitsLeft -= bitsLeft = numBits;
  }
  else
  {
    currentVal = 0;
    bitsLeft = 0;
  }
  /* set bits of first element if not aligned */
  if (bitTop)
  {
    BitElem mask = ~(~(GtUword)0 << (bitElemBits - bitTop));
    while ((totalBitsLeft || bitsLeft) && bitsInAccum < bitElemBits - bitTop)
    {
      unsigned bits2Read, bitsFree = sizeof (accum)*CHAR_BIT - bitsInAccum;

      if ((bits2Read = GT_MIN(bitsFree, bitsLeft)) < sizeof (accum)*CHAR_BIT)
      {
        accum = accum << bits2Read
          | ((currentVal) >> (bitsLeft - bits2Read));
      }
      else
        accum = currentVal;

      /* all of val[j] consumed? */
      bitsInAccum += bits2Read;
      if (!(bitsLeft -= bits2Read) && totalBitsLeft)
        currentVal = val[++j] & valMask, totalBitsLeft -= bitsLeft = numBits;
    }
    /* at this point accum holds as many bits as we could get
     * to fill the first BitElem in str, but did we get enough? */
    if (bitsInAccum < bitElemBits - bitTop)
    {
      /* no there's not enough */
      unsigned backShift = bitElemBits - bitsInAccum - bitTop;
      mask &= ~(GtUword)0 << backShift;
      *p = (*p & ~mask) | ((accum << backShift) & mask);
      /* TODO: try wether  r = a ^ ((a ^ b) & mask) is faster, see below */
      return; /* if we couldn't gather more bits, there's none left */
    }
    else
    {
      /* yep, just or with accumVals */
      *p = (*p & ~mask) | (accum >> (bitsInAccum - bitElemBits + bitTop));
      ++p;
      bitsInAccum -= bitElemBits - bitTop;
    }
  }

  while (totalBitsLeft || (bitsInAccum + bitsLeft) > bitElemBits)
  {
    while ((totalBitsLeft || bitsLeft)
          && ((bitsInAccum < bitElemBits)
              || (bitsLeft < sizeof (accum)*CHAR_BIT - bitsInAccum)))
    {
      unsigned bits2Read, bitsFree = sizeof (accum)*CHAR_BIT - bitsInAccum;
      if ((bits2Read = GT_MIN(bitsFree, bitsLeft)) < sizeof (accum)*CHAR_BIT)
      {
        GtUword mask = ~((~(GtUword)0) << bits2Read);
        accum = accum << bits2Read
          | ((currentVal >> (bitsLeft - bits2Read)) & mask);
      }
      else
        accum = currentVal;
      bitsInAccum += bits2Read;
      /* all of currentVal == val[j] consumed? */
      if (bits2Read == bitsLeft && totalBitsLeft)
        currentVal = val[++j] & valMask, totalBitsLeft -= bitsLeft = numBits;
      else
        bitsLeft -= bits2Read;
    }
    /* now we have enough bits in accum */
    while (bitsInAccum >= bitElemBits)
    {
      *p++ = accum >> (bitsInAccum - bitElemBits);
      bitsInAccum -= bitElemBits;
    }
  }
  /* write the rest bits left in accum and currentVal */
  accum = (accum << bitsLeft)
    | (currentVal & (valMask >> (numBits - bitsLeft)));
  bitsInAccum += bitsLeft;
  while (bitsInAccum >= bitElemBits)
  {
    *p++ = accum >> (bitsInAccum - bitElemBits);
    bitsInAccum -= bitElemBits;
  }
  if (bitsInAccum)
  {
    GtUword mask =
      ~(GtUword)0 << (bitElemBits - bitsInAccum);
    *p = (*p & ~mask) | ((accum << (bitElemBits - bitsInAccum))& mask);
  }
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movl %edx, 0x94(%rsp)
movq %rcx, 0x88(%rsp)
movq %r8, 0x80(%rsp)
movq $0x0, 0x78(%rsp)
movq 0x88(%rsp), %rax
movl 0x94(%rsp), %ecx
imulq %rcx, %rax
movq %rax, 0x70(%rsp)
movq 0x98(%rsp), %rax
andq $0x7, %rax
movl %eax, 0x6c(%rsp)
movq 0xa0(%rsp), %rax
movq 0x98(%rsp), %rcx
shrq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x60(%rsp)
movq $-0x1, 0x48(%rsp)
movl 0x94(%rsp), %eax
cmpq $0x20, %rax
jae 0x157e69
movq 0x48(%rsp), %rax
movl 0x94(%rsp), %ecx
shlq %cl, %rax
xorq $-0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x157e6b
cmpq $0x0, 0xa0(%rsp)
je 0x157e81
cmpq $0x0, 0x80(%rsp)
jne 0x157eb9
movq 0x5c150(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x61d4(%rip), %rsi      # 0x15e066
leaq 0x3704e(%rip), %rdx     # 0x18eee7
leaq 0x370cc(%rip), %rcx     # 0x18ef6c
leaq 0x36fc0(%rip), %r8      # 0x18ee67
movl $0x184, %r9d            # imm = 0x184
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x157ebb
jmp 0x157ebd
movl 0x94(%rsp), %eax
cmpq $0x20, %rax
jbe 0x157f02
movq 0x5c107(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x618b(%rip), %rsi      # 0x15e066
leaq 0x3702b(%rip), %rdx     # 0x18ef0d
leaq 0x37083(%rip), %rcx     # 0x18ef6c
leaq 0x36f77(%rip), %r8      # 0x18ee67
movl $0x185, %r9d            # imm = 0x185
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x157f04
cmpq $0x0, 0x70(%rsp)
jne 0x157f11
jmp 0x158464
movq 0x80(%rsp), %rax
movl (%rax), %eax
andq 0x48(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl %eax, %eax
movl %eax, %ecx
movq 0x70(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x70(%rsp)
je 0x157f8e
movq 0x80(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x78(%rsp)
movl 0x4(%rax,%rcx,4), %eax
andq 0x48(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x68(%rsp)
movl %eax, %eax
movl %eax, %ecx
movq 0x70(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x70(%rsp)
jmp 0x157f9f
movq $0x0, 0x40(%rsp)
movl $0x0, 0x68(%rsp)
cmpl $0x0, 0x6c(%rsp)
je 0x1581bb
movl $0x8, %eax
subl 0x6c(%rsp), %eax
movl %eax, %eax
movl %eax, %ecx
movq $-0x1, %rax
shlq %cl, %rax
xorq $-0x1, %rax
movb %al, 0x3f(%rsp)
cmpq $0x0, 0x70(%rsp)
jne 0x157fde
xorl %eax, %eax
cmpl $0x0, 0x68(%rsp)
movb %al, 0x17(%rsp)
je 0x157ff4
movl 0x5c(%rsp), %eax
movl $0x8, %ecx
subl 0x6c(%rsp), %ecx
cmpl %ecx, %eax
setb %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x158001
jmp 0x1580e3
movl 0x5c(%rsp), %eax
movl %eax, %ecx
movl $0x40, %eax
subq %rcx, %rax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x68(%rsp), %eax
jae 0x158027
movl 0x34(%rsp), %eax
movl %eax, 0x10(%rsp)
jmp 0x15802f
movl 0x68(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x38(%rsp)
movl %eax, %eax
cmpq $0x40, %rax
jae 0x15806a
movq 0x50(%rsp), %rax
movl 0x38(%rsp), %ecx
shlq %cl, %rax
movq 0x40(%rsp), %rdx
movl 0x68(%rsp), %ecx
subl 0x38(%rsp), %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x50(%rsp)
jmp 0x158074
movq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0x38(%rsp), %eax
addl 0x5c(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl 0x38(%rsp), %ecx
movl 0x68(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x68(%rsp)
cmpl $0x0, %eax
jne 0x1580de
cmpq $0x0, 0x70(%rsp)
je 0x1580de
movq 0x80(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x78(%rsp)
movl 0x4(%rax,%rcx,4), %eax
andq 0x48(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x68(%rsp)
movl %eax, %eax
movl %eax, %ecx
movq 0x70(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x70(%rsp)
jmp 0x157fc9
movl 0x5c(%rsp), %eax
movl $0x8, %ecx
subl 0x6c(%rsp), %ecx
cmpl %ecx, %eax
jae 0x158160
movl $0x8, %eax
subl 0x5c(%rsp), %eax
subl 0x6c(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x30(%rsp), %eax
movl %eax, %ecx
movq $-0x1, %rax
shlq %cl, %rax
movq %rax, %rcx
movzbl 0x3f(%rsp), %eax
andq %rcx, %rax
movb %al, 0x3f(%rsp)
movq 0x60(%rsp), %rax
movzbl (%rax), %eax
movzbl 0x3f(%rsp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
cltq
movq 0x50(%rsp), %rdx
movl 0x30(%rsp), %ecx
shlq %cl, %rdx
movq %rdx, %rcx
movzbl 0x3f(%rsp), %edx
andq %rdx, %rcx
orq %rcx, %rax
movb %al, %cl
movq 0x60(%rsp), %rax
movb %cl, (%rax)
jmp 0x158464
movq 0x60(%rsp), %rax
movzbl (%rax), %eax
movzbl 0x3f(%rsp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
cltq
movq 0x50(%rsp), %rdx
movl 0x5c(%rsp), %ecx
subl $0x8, %ecx
addl 0x6c(%rsp), %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
orq %rcx, %rax
movb %al, %cl
movq 0x60(%rsp), %rax
movb %cl, (%rax)
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
movl $0x8, %ecx
subl 0x6c(%rsp), %ecx
movl 0x5c(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x5c(%rsp)
jmp 0x1581bb
jmp 0x1581bd
movb $0x1, %al
cmpq $0x0, 0x70(%rsp)
movb %al, 0xf(%rsp)
jne 0x1581dd
movl 0x5c(%rsp), %eax
addl 0x68(%rsp), %eax
cmpl $0x8, %eax
seta %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x1581ea
jmp 0x158387
jmp 0x1581ec
cmpq $0x0, 0x70(%rsp)
jne 0x158201
xorl %eax, %eax
cmpl $0x0, 0x68(%rsp)
movb %al, 0xe(%rsp)
je 0x158232
movb $0x1, %al
cmpl $0x8, 0x5c(%rsp)
movb %al, 0xd(%rsp)
jb 0x15822a
movl 0x68(%rsp), %eax
movl 0x5c(%rsp), %ecx
movl %ecx, %edx
movl $0x40, %ecx
subq %rdx, %rcx
cmpq %rcx, %rax
setb %al
movb %al, 0xd(%rsp)
movb 0xd(%rsp), %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0x15823f
jmp 0x158346
movl 0x5c(%rsp), %eax
movl %eax, %ecx
movl $0x40, %eax
subq %rcx, %rax
movl %eax, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x68(%rsp), %eax
jae 0x158265
movl 0x28(%rsp), %eax
movl %eax, 0x8(%rsp)
jmp 0x15826d
movl 0x68(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl %eax, %eax
cmpq $0x40, %rax
jae 0x1582c6
movl 0x2c(%rsp), %eax
movl %eax, %ecx
movq $-0x1, %rax
shlq %cl, %rax
xorq $-0x1, %rax
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rax
movl 0x2c(%rsp), %ecx
shlq %cl, %rax
movq 0x40(%rsp), %rdx
movl 0x68(%rsp), %ecx
subl 0x2c(%rsp), %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq 0x20(%rsp), %rcx
orq %rcx, %rax
movq %rax, 0x50(%rsp)
jmp 0x1582d0
movq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0x2c(%rsp), %eax
addl 0x5c(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x68(%rsp), %eax
jne 0x158333
cmpq $0x0, 0x70(%rsp)
je 0x158333
movq 0x80(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x78(%rsp)
movl 0x4(%rax,%rcx,4), %eax
andq 0x48(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x68(%rsp)
movl %eax, %eax
movl %eax, %ecx
movq 0x70(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x70(%rsp)
jmp 0x158341
movl 0x2c(%rsp), %ecx
movl 0x68(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x68(%rsp)
jmp 0x1581ec
jmp 0x158348
cmpl $0x8, 0x5c(%rsp)
jb 0x158382
movq 0x50(%rsp), %rax
movl 0x5c(%rsp), %ecx
subl $0x8, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movb %al, %cl
movq 0x60(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x60(%rsp)
movb %cl, (%rax)
movl 0x5c(%rsp), %eax
subl $0x8, %eax
movl %eax, 0x5c(%rsp)
jmp 0x158348
jmp 0x1581bd
movq 0x50(%rsp), %rax
movl 0x68(%rsp), %ecx
shlq %cl, %rax
movq 0x40(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x48(%rsp), %rdx
movl 0x94(%rsp), %ecx
subl 0x68(%rsp), %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq (%rsp), %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x50(%rsp)
movl 0x68(%rsp), %eax
addl 0x5c(%rsp), %eax
movl %eax, 0x5c(%rsp)
cmpl $0x8, 0x5c(%rsp)
jb 0x158406
movq 0x50(%rsp), %rax
movl 0x5c(%rsp), %ecx
subl $0x8, %ecx
movl %ecx, %ecx
shrq %cl, %rax
movb %al, %cl
movq 0x60(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x60(%rsp)
movb %cl, (%rax)
movl 0x5c(%rsp), %eax
subl $0x8, %eax
movl %eax, 0x5c(%rsp)
jmp 0x1583cc
cmpl $0x0, 0x5c(%rsp)
je 0x158464
movl $0x8, %eax
subl 0x5c(%rsp), %eax
movl %eax, %eax
movl %eax, %ecx
movq $-0x1, %rax
shlq %cl, %rax
movq %rax, 0x18(%rsp)
movq 0x60(%rsp), %rax
movzbl (%rax), %eax
movq 0x18(%rsp), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq 0x50(%rsp), %rdx
movl $0x8, %ecx
subl 0x5c(%rsp), %ecx
movl %ecx, %ecx
shlq %cl, %rdx
movq %rdx, %rcx
andq 0x18(%rsp), %rcx
orq %rcx, %rax
movb %al, %cl
movq 0x60(%rsp), %rax
movb %cl, (%rax)
addq $0xa8, %rsp
retq
nopl (%rax)