// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/compressed_bitsequence.c
// Function: gt_compressed_bitsequence_select_1_word
static inline unsigned int
gt_compressed_bitsequence_select_1_word(uint64_t word, unsigned int i)
{
#ifdef __SSE4_2__
  uint64_t s = word, b;
  unsigned int byte_nr;
  s = s - ((s >> 1) & (uint64_t) 0x5555555555555555ULL);
  s = (s & (uint64_t) 0x3333333333333333ULL) +
      ((s >> 2) & (uint64_t) 0x3333333333333333ULL);
  s = (s + (s >> 4)) & (uint64_t) 0x0F0F0F0F0F0F0F0FULL;
  /* s *= (uint64_t) 0x0101010101010101ULL; [>this will add the running sums to
                                            the most significant byte<] */
  /* analog to multiplication which would use << */
  s = s         + (s >> 8)  + (s >> 16) + (s >> 24) +
      (s >> 32) + (s >> 40) + (s >> 48) + (s >> 52);
  /* now s contains 8 bytes s[0],...,s[7], s[i] contains the cumulative sum
     of (i+1)*8 least significant bits of s */
  b = (s + gt_compressed_bitsequence_ps_overflow[i]) &
      (uint64_t) 0x8080808080808080ULL;
  /* ps_overflow contains a bit mask mask consisting of 8 bytes
     mask[7],...,mask[0] and each set to 128-i
     => a byte b[i] in b is >= 128 if cum sum >= i */
  b >>= 7;

  /* __builtin_clzll returns the number of leading zeros, if b!=0 */
  byte_nr = __builtin_clzll(b) >> 3;   /* byte nr in [0..7] */
  /* subtract the cumulative sum of bits of all bytes before byte_nr */
  s >>= 8; /* remove total sum */
  i -= (s >> ((7 - byte_nr) << 3)) & 0xFFULL;
  return (byte_nr << 3) + (unsigned int)
    gt_byte_select[((i-1) << 8) +
                   ((word >> ((7 - byte_nr) << 3)) & 0xFFULL)];
#else
  unsigned int bytecount,
               idx,
               ranksum = 0,
               shift = (unsigned int) ((CHAR_BIT - 1) * sizeof (word));
  for (idx = 0; idx < (unsigned int) sizeof (word); ++idx, shift -= 8) {
    bytecount =
      (unsigned int) gt_byte_popcount[(word >> shift) & 0xFFULL];
    if (ranksum + bytecount >= i) {
      i -= ranksum;
      return (unsigned int) (idx * CHAR_BIT +
             gt_byte_select[((i - 1) << 8) + ((word >> shift) & 0xFFULL)]);
    }
    else
      ranksum += bytecount;
  }
  /* 64 if bit is not present */
  return (unsigned int) (CHAR_BIT * sizeof (word));
#endif
}

// Assembly:
movq %rdi, -0x10(%rsp)
movl %esi, -0x14(%rsp)
movl $0x0, -0x20(%rsp)
movl $0x38, -0x24(%rsp)
movl $0x0, -0x1c(%rsp)
cmpl $0x8, -0x1c(%rsp)
jae 0x13bdd7
movq -0x10(%rsp), %rax
movl -0x24(%rsp), %ecx
shrq %cl, %rax
movq %rax, %rcx
andq $0xff, %rcx
leaq 0x474517(%rip), %rax    # 0x5b0260
movzbl (%rax,%rcx), %eax
movl %eax, -0x18(%rsp)
movl -0x20(%rsp), %eax
addl -0x18(%rsp), %eax
cmpl -0x14(%rsp), %eax
jb 0x13bdae
movl -0x20(%rsp), %ecx
movl -0x14(%rsp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rsp)
movl -0x1c(%rsp), %eax
shll $0x3, %eax
movl -0x14(%rsp), %ecx
subl $0x1, %ecx
shll $0x8, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq -0x10(%rsp), %rsi
movl -0x24(%rsp), %ecx
shrq %cl, %rsi
movq %rsi, %rcx
andq $0xff, %rcx
addq %rcx, %rdx
leaq 0x4745be(%rip), %rcx    # 0x5b0360
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x4(%rsp)
jmp 0x13bddf
movl -0x18(%rsp), %eax
addl -0x20(%rsp), %eax
movl %eax, -0x20(%rsp)
jmp 0x13bdbc
movl -0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rsp)
movl -0x24(%rsp), %eax
subl $0x8, %eax
movl %eax, -0x24(%rsp)
jmp 0x13bd21
movl $0x40, -0x4(%rsp)
movl -0x4(%rsp), %eax
retq
nopw %cs:(%rax,%rax)