// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/eis-bwtseq-extinfo.c
// Function: locBitsUpperBounds
static bool
locBitsUpperBounds(void *cbState, struct segmentDesc *desc,
                   size_t numSegmentDesc, struct varBitsEstimate *result)
{
  struct addLocateInfoState *state = cbState;
  gt_assert(cbState);
  if (state->featureToggles & (BWTLocateCount | BWTLocateBitmap))
  {
    unsigned maxBitsPerPos = bitsPerPosUpperBound(state);
    result->maxBitsPerPos = maxBitsPerPos;
    if (desc)
    {
      size_t i, maxSegLen = 0;
      BitOffset maxBitsTotal = 0;
      GT_UNUSED GtUword numSegmentsTotal = 0;
      unsigned bitsPerOrigRank = state->bitsPerOrigRank;
      for (i = 0; i < numSegmentDesc; ++i)
      {
        size_t len = desc[i].len;
        maxSegLen = GT_MAX(len, maxSegLen);
        if (state->featureToggles & BWTLocateCount)
          maxBitsTotal += requiredUlongBits(len) * desc[i].repeatCount;
        numSegmentsTotal += desc[i].repeatCount;
      }
      maxBitsTotal +=
        (state->seqLen / state->locateInterval + state->extraLocMarksUpperBound)
        * (((state->featureToggles & BWTLocateCount) ?
            requiredUlongBits(maxSegLen) : 0)
           + state->bitsPerOrigPos);
      if (bitsPerOrigRank)
      {
        GtUword maxRank = specialsRank(state->sprTable, state->seqLen);
        /* rank values stored */
        maxBitsTotal += maxRank * bitsPerOrigRank;
      }
      result->maxBitsPerBucket =
        /* locate marks and rank sorts */
        maxSegLen * bitsPerPosUpperBoundWithoutSegmentAggregates(state)
        /* count of locate marks */
        + ((state->featureToggles & BWTLocateCount) ?
           requiredUlongBits(maxSegLen) : 0);
      result->maxBitsTotal = maxBitsTotal;
      return true;
    }
    else
      return false;
  }
  else
  {
    result->maxBitsTotal = result->maxBitsPerBucket
      = result->maxBitsPerPos = 0;
    return false;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x1a3277
movq %rdi, %r14
movl 0x58(%rdi), %eax
testb $0x3, %al
je 0x1a31c7
movq %rdx, %r12
movq %rsi, %r13
xorl %edx, %edx
andl $0x2, %eax
je 0x1a3164
movl 0x48(%r14), %edx
movl 0x4c(%r14), %esi
shrl %eax
addl %edx, %eax
addl 0x44(%r14), %eax
addl %esi, %eax
movq %rax, (%rcx)
testq %r13, %r13
setne %al
je 0x1a3268
movq %rsi, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
xorl %ebp, %ebp
testq %r12, %r12
je 0x1a31dc
addq $0x8, %r13
xorl %r15d, %r15d
xorl %ebx, %ebx
movq (%r13), %rdi
cmpq %r15, %rdi
cmovaq %rdi, %r15
testb $0x2, 0x58(%r14)
je 0x1a31bc
callq 0x2f9d41
cltq
imulq -0x8(%r13), %rax
addq %rax, %rbx
addq $0x10, %r13
decq %r12
jne 0x1a319b
jmp 0x1a31e1
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
xorl %eax, %eax
jmp 0x1a3268
xorl %ebx, %ebx
xorl %r15d, %r15d
movq (%r14), %rax
movl 0x40(%r14), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, %r12
addq 0x8(%r14), %r12
testb $0x2, 0x58(%r14)
je 0x1a3205
movq %r15, %rdi
callq 0x2f9d41
movl %eax, %ebp
addl 0x44(%r14), %ebp
imulq %rbp, %r12
addq %rbx, %r12
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
je 0x1a322a
movq (%r14), %rsi
movq 0x50(%r14), %rdi
callq *(%rdi)
imulq %rbx, %rax
addq %rax, %r12
movl 0x58(%r14), %eax
xorl %ebx, %ebx
testb $0x2, %al
je 0x1a3238
movl 0x48(%r14), %ebx
addl 0x44(%r14), %ebx
addl 0x4c(%r14), %ebx
imulq %r15, %rbx
testb $0x2, %al
jne 0x1a324c
xorl %eax, %eax
jmp 0x1a3256
movq %r15, %rdi
callq 0x2f9d41
cltq
addq %rbx, %rax
movq 0x10(%rsp), %rcx
movq %rax, 0x8(%rcx)
movq %r12, 0x10(%rcx)
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x60403