// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/firstcodes-tab.c
// Function: gt_firstcodes_partialsums
GtUword gt_firstcodes_partialsums(GtFirstcodesspacelog *fcsl,
                                        GtFirstcodestab *fct,
                                        const GtUword *differences,
                                        GT_UNUSED GtUword
                                                            expectedlastpartsum)
{
  GtUword idx, partsum, maxbucketsize, bitmask, samplecount = 0,
                spacewithhashmap = 0, spacewithouthashmap = 0;
  uint32_t currentcount;
  GtLeftborderOutbuffer *leftborderbuffer_all = NULL;
#if defined (_LP64) || defined (_WIN64)
  const unsigned int btp = gt_determinebitspervalue(expectedlastpartsum);
  GtUword exceedvalue = (GtUword) 1 << (GtUword) GT_MODVALUEBITS;
#endif
#ifdef SKDEBUG
  GtDiscDistri *countdistri = gt_disc_distri_new();
#endif

  gt_assert(fct->differentcodes < UINT32_MAX);
  gt_log_log("hashmap_addcount="GT_WU" (%.5f%%)",fct->hashmap_addcount,
                  100.0 * (double) fct->hashmap_addcount/
                                   fct->differentcodes);
  gt_log_log("hashmap_getcount="GT_WU" (%.5f%%)",
                  fct->hashmap_getcount,
                  100.0 * (double) fct->hashmap_getcount/
                                   fct->differentcodes);

#if defined (_LP64) || defined (_WIN64)
  if (btp <= GT_MODVALUEBITS)
  {
    fct->bitchangepoints.allocatedGtUword = 0;
    fct->bitchangepoints.spaceGtUword = NULL;
  } else
  {
    fct->bitchangepoints.allocatedGtUword = 1UL << (btp - GT_MODVALUEBITS);
    gt_log_log("lastpartsum="GT_WU", bitchangepoints.allocated="GT_WU"",
              expectedlastpartsum,fct->bitchangepoints.allocatedGtUword);
    fct->bitchangepoints.spaceGtUword
      = gt_malloc(sizeof (*fct->bitchangepoints.spaceGtUword)
                  * fct->bitchangepoints.allocatedGtUword);
  }
  fct->bitchangepoints.nextfreeGtUword = 0;
#endif
  currentcount = gt_firstcodes_countocc_get(fct,differences,0);
  partsum = (GtUword) currentcount;
  maxbucketsize = (GtUword) currentcount;
#ifdef SKDEBUG
  gt_disc_distri_add(countdistri,(GtUword) currentcount);
#endif
  fct->sampleshift = 9U;
  while (true)
  {
    fct->sampledistance = 1UL << fct->sampleshift;
    if (fct->sampledistance < fct->differentcodes)
    {
      break;
    }
    fct->sampleshift--;
  }
  bitmask = fct->sampledistance - 1;
  fct->numofsamples = 1UL + 1UL + fct->differentcodes/fct->sampledistance;
  fct->leftborder_samples = gt_malloc(sizeof (*fct->leftborder_samples) *
                                      fct->numofsamples);
  GT_FCI_ADDWORKSPACE(fcsl,"leftborder_samples",
                      sizeof (*fct->leftborder_samples) * fct->numofsamples);
  GT_FIRSTCODES_ADD_SAMPLE(partsum);
  leftborderbuffer_all = gt_leftborderbuffer_new("leftborder",fcsl);
  GT_PARTIALSUM_LEFTBORDER_SET(leftborderbuffer_all,partsum);
  for (idx = 1UL; idx < fct->differentcodes; idx++)
  {
    currentcount = gt_firstcodes_countocc_get(fct,differences,idx);
#if defined (_LP64) || defined (_WIN64)
    gt_assert(currentcount <= GT_MODVALUEMASK);
#endif
#ifdef SKDEBUG
    gt_disc_distri_add(countdistri,(GtUword) currentcount);
#endif
    if (maxbucketsize < (GtUword) currentcount)
    {
      maxbucketsize = (GtUword) currentcount;
    }
    partsum += currentcount;
#if defined (_LP64) || defined (_WIN64)
    if (fct->bitchangepoints.allocatedGtUword > 0 && partsum >= exceedvalue)
    {
      gt_assert(idx > 0 && fct->bitchangepoints.nextfreeGtUword <
                           fct->bitchangepoints.allocatedGtUword);
      gt_assert(fct->bitchangepoints.spaceGtUword != NULL);
      fct->bitchangepoints.spaceGtUword
        [fct->bitchangepoints.nextfreeGtUword++] = idx-1;
      exceedvalue = (GtUword) ((exceedvalue >> GT_MODVALUEBITS) + 1)
                      << (GtUword) GT_MODVALUEBITS;
    }
#endif
    if ((idx & bitmask) == 0)
    {
      GT_FIRSTCODES_ADD_SAMPLE(partsum);
    }
    GT_PARTIALSUM_LEFTBORDER_SET(leftborderbuffer_all,partsum);
  }
  GT_PARTIALSUM_LEFTBORDER_SET(leftborderbuffer_all,partsum);
  fct->outfilenameleftborder
      = gt_leftborderbuffer_delete(leftborderbuffer_all,fcsl,
                                   gt_firstcodes_leftborder_entries(fct));
  if (partsum > fct->leftborder_samples[samplecount-1])
  {
    GT_FIRSTCODES_ADD_SAMPLE(partsum);
  } else
  {
    gt_assert(partsum == fct->leftborder_samples[samplecount-1]);
  }
  gt_assert(expectedlastpartsum == partsum);
  fct->numofsamples = samplecount-1;
#ifdef SKDEBUG
  gt_firstcodes_evaluate_countdistri(countdistri);
  gt_disc_distri_delete(countdistri);
#endif
  if (fct->countocc_small != NULL)
  {
    gt_free(fct->countocc_small);
    GT_FCI_SUBTRACTWORKSPACE(fcsl,"countocc_small");
    fct->countocc_small = NULL;
  }
  if (fct->hashmap_addcount > 0 && gt_ma_bookkeeping_enabled())
  {
    spacewithhashmap = gt_ma_get_space_current() + gt_fa_get_space_current();
  }
  gt_hashtable_delete(fct->countocc_exceptions);
  if (fct->hashmap_addcount > 0 && gt_ma_bookkeeping_enabled())
  {
    GtUword hashmapspace;

    spacewithouthashmap = gt_ma_get_space_current() + gt_fa_get_space_current();
    gt_assert(spacewithouthashmap < spacewithhashmap);
    hashmapspace = spacewithhashmap - spacewithouthashmap;
    gt_log_log("space for hashmap=%.2f ("GT_WU" bytes per entry)",
               GT_MEGABYTES(hashmapspace),hashmapspace/fct->hashmap_addcount);
  }
  fct->countocc_exceptions = NULL;
  return maxbucketsize;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq %rdx, 0x20(%rsp)
movq %rsi, %rbx
movq %rdi, %r12
movq %rcx, %rdi
callq 0x9580f
movl %eax, %ebp
movq (%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jae 0x2b72bd
movq 0x18(%rbx), %rsi
movq %rsi, %xmm1
punpckldq 0x30b30(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x30b38(%rip), %xmm1    # 0x2e78f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x32a14(%rip), %xmm0    # 0x2e97e0
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xcbe61(%rip), %rdi     # 0x382c3d
movb $0x1, %al
callq 0x92a82
movq 0x20(%rbx), %rsi
movq %rsi, %xmm1
movq 0x30aec(%rip), %xmm2    # 0x2e78e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x30af0(%rip), %xmm3    # 0x2e78f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x329c8(%rip), %xmm0    # 0x2e97e0
movq (%rbx), %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0xcbe20(%rip), %rdi     # 0x382c5b
movb $0x1, %al
callq 0x92a82
pushq $0x1
popq %rdx
cmpl $0x20, %ebp
movq %rdx, 0x10(%rsp)
ja 0x2b6e58
andq $0x0, 0x78(%rbx)
xorl %eax, %eax
jmp 0x2b6e8f
addb $-0x20, %bpl
movl %ebp, %ecx
shlq %cl, %rdx
movq %rdx, 0x78(%rbx)
leaq 0xcbe0d(%rip), %rdi     # 0x382c79
movq %r14, %rsi
xorl %eax, %eax
callq 0x92a82
movq 0x78(%rbx), %rdi
shlq $0x3, %rdi
leaq 0xcbc45(%rip), %rsi     # 0x382aca
movl $0x1ea, %edx            # imm = 0x1EA
callq 0x93160
movq %r14, 0x28(%rsp)
movq %rbx, 0x8(%rsp)
movq %rax, 0x70(%rbx)
andq $0x0, 0x80(%rbx)
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x2b73dd
movq 0x8(%rsp), %rdx
movl %eax, %r15d
movq (%rdx), %rax
pushq $0xa
popq %rcx
pushq $0x1
popq %rsi
decl %ecx
movq %rsi, %r14
shlq %cl, %r14
cmpq %rax, %r14
jae 0x2b6ec5
movl %ecx, 0x28(%rdx)
shrq %cl, %rax
movq %r14, 0x10(%rdx)
leaq 0x2(%rax), %rcx
movq %rcx, 0x8(%rdx)
leaq 0x10(,%rax,8), %rdi
leaq 0xcbbd7(%rip), %r13     # 0x382aca
movq %r13, %rsi
movl $0x201, %edx            # imm = 0x201
callq 0x93160
movq 0x8(%rsp), %rcx
movq %rax, 0x48(%rcx)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
shlq $0x3, %rax
movq %rax, (%rsp)
leaq 0xcbd87(%rip), %r8      # 0x382ca8
pushq $0x1
popq %rcx
movq %r12, %rdi
movl $0x203, %esi            # imm = 0x203
movq %r13, %rdx
movl %ecx, %r9d
callq 0x2b613a
movq 0x8(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2b72eb
movl %r15d, %r13d
movq 0x48(%rax), %rax
movq %r13, (%rax)
leaq 0x5837a(%rip), %rdi     # 0x30f2d2
movq %r12, 0x30(%rsp)
movq %r12, %rsi
callq 0x2dfb60
movq %rax, %rbp
movq 0x8(%rax), %rdx
cmpq 0x10(%rax), %rdx
jne 0x2b6f7e
movq %rbp, %rdi
callq 0x2dfc11
movq 0x8(%rbp), %rdx
decq %r14
movabsq $0x100000000, %r12      # imm = 0x100000000
movq (%rbp), %rax
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%rbp)
movl %r15d, (%rax,%rdx,4)
xorl %ebx, %ebx
movq %r13, 0x18(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x1(%rbx), %r15
movq (%rdi), %rdx
cmpq %rdx, %r15
jae 0x2b708a
movq 0x20(%rsp), %rsi
movq %r15, %rdx
callq 0x2b73dd
movq 0x8(%rsp), %rdi
movl %eax, %eax
movq 0x18(%rsp), %rcx
cmpq %rax, %rcx
cmovbeq %rax, %rcx
movq %rcx, 0x18(%rsp)
addq %rax, %r13
movq 0x78(%rdi), %rcx
testq %rcx, %rcx
je 0x2b7033
cmpq %r12, %r13
jb 0x2b7033
movq 0x80(%rdi), %rax
cmpq %rcx, %rax
jae 0x2b7229
movq 0x70(%rdi), %rcx
testq %rcx, %rcx
je 0x2b7257
leaq 0x1(%rax), %rdx
movq %rdx, 0x80(%rdi)
movq %rbx, (%rcx,%rax,8)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rax, %r12
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r12
testq %r14, %r15
jne 0x2b7057
movq 0x10(%rsp), %rcx
cmpq 0x8(%rdi), %rcx
jae 0x2b7285
movq 0x48(%rdi), %rax
movq %r13, (%rax,%rcx,8)
incq %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rbp), %rdx
cmpq 0x10(%rbp), %rdx
jne 0x2b7072
movq %rbp, %rdi
callq 0x2dfc11
movq 0x8(%rsp), %rdi
movq 0x8(%rbp), %rdx
movq (%rbp), %rax
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%rbp)
movl %r13d, (%rax,%rdx,4)
movq %r15, %rbx
jmp 0x2b6fa7
cmpq 0x10(%rbp), %rcx
jne 0x2b70a8
movq %rbp, %rdi
callq 0x2dfc11
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x8(%rbp)
movl %r13d, (%rax,%rcx,4)
incq %rdx
movq %rbp, %rdi
movq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0x2dfc37
movq 0x8(%rsp), %rcx
movq %rax, 0x50(%rcx)
movq 0x48(%rcx), %rax
movq 0x10(%rsp), %rdx
cmpq -0x8(%rax,%rdx,8), %r13
jbe 0x2b70f3
cmpq 0x8(%rcx), %rdx
jae 0x2b734a
movq %r13, (%rax,%rdx,8)
incq %rdx
jmp 0x2b70f9
jne 0x2b737b
cmpq 0x28(%rsp), %r13
jne 0x2b7319
decq %rdx
movq %rdx, 0x8(%rcx)
movq 0x38(%rcx), %rdi
testq %rdi, %rdi
movq 0x18(%rsp), %r12
je 0x2b7159
leaq 0xcb9aa(%rip), %r15     # 0x382aca
movq %r15, %rsi
movl $0x23a, %edx            # imm = 0x23A
callq 0x936f9
andq $0x0, (%rsp)
leaq 0xcbc75(%rip), %r8      # 0x382dae
pushq $0x1
popq %r9
movq %rbx, %rdi
movl $0x23b, %esi            # imm = 0x23B
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x2b613a
movq 0x8(%rsp), %rcx
andq $0x0, 0x38(%rcx)
cmpq $0x0, 0x18(%rcx)
je 0x2b717e
callq 0x93b7c
testb %al, %al
je 0x2b7183
callq 0x93934
movq %rax, %r15
callq 0x8bf8b
movq %rax, %r14
addq %r15, %r14
jmp 0x2b7186
xorl %r14d, %r14d
jmp 0x2b718b
xorl %r14d, %r14d
movq 0x8(%rsp), %rcx
movq 0x40(%rcx), %rdi
callq 0x9082d
movq 0x8(%rsp), %rcx
cmpq $0x0, 0x18(%rcx)
je 0x2b7212
callq 0x93b7c
movq 0x8(%rsp), %rcx
testb %al, %al
je 0x2b7212
callq 0x93934
movq %rax, %r15
callq 0x8bf8b
addq %r15, %rax
subq %rax, %r14
jbe 0x2b73ac
movq %r14, %xmm1
punpckldq 0x3070c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x30714(%rip), %xmm1    # 0x2e78f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x30710(%rip), %xmm0    # 0x2e7900
movq %r14, %rax
xorl %edx, %edx
movq 0x8(%rsp), %rbx
divq 0x18(%rbx)
leaq 0xcbbdf(%rip), %rdi     # 0x382de4
movq %rax, %rsi
movb $0x1, %al
callq 0x92a82
movq %rbx, %rcx
andq $0x0, 0x40(%rcx)
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x180d38(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2ddd9(%rip), %rsi     # 0x2e5013
leaq 0xcba9a(%rip), %rdx     # 0x382cdb
leaq 0xcb9db(%rip), %rcx     # 0x382c23
leaq 0xcb87b(%rip), %r8      # 0x382aca
movl $0x219, %r9d            # imm = 0x219
jmp 0x2b72b1
movq 0x180d0a(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2ddab(%rip), %rsi     # 0x2e5013
leaq 0xcbac4(%rip), %rdx     # 0x382d33
leaq 0xcb9ad(%rip), %rcx     # 0x382c23
leaq 0xcb84d(%rip), %r8      # 0x382aca
movl $0x21a, %r9d            # imm = 0x21A
jmp 0x2b72b1
movq 0x180cdc(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2dd7d(%rip), %rsi     # 0x2e5013
leaq 0xcba1e(%rip), %rdx     # 0x382cbb
leaq 0xcb97f(%rip), %rcx     # 0x382c23
leaq 0xcb81f(%rip), %r8      # 0x382aca
movl $0x223, %r9d            # imm = 0x223
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x180ca4(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2dd45(%rip), %rsi     # 0x2e5013
leaq 0xcb92d(%rip), %rdx     # 0x382c02
leaq 0xcb947(%rip), %rcx     # 0x382c23
leaq 0xcb7e7(%rip), %r8      # 0x382aca
movl $0x1d5, %r9d            # imm = 0x1D5
jmp 0x2b72b1
movq 0x180c76(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2dd17(%rip), %rsi     # 0x2e5013
leaq 0xcb9b8(%rip), %rdx     # 0x382cbb
leaq 0xcb919(%rip), %rcx     # 0x382c23
leaq 0xcb7b9(%rip), %r8      # 0x382aca
movl $0x204, %r9d            # imm = 0x204
jmp 0x2b72b1
movq 0x180c48(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2dce9(%rip), %rsi     # 0x2e5013
leaq 0xcba5e(%rip), %rdx     # 0x382d8f
leaq 0xcb8eb(%rip), %rcx     # 0x382c23
leaq 0xcb78b(%rip), %r8      # 0x382aca
movl $0x232, %r9d            # imm = 0x232
jmp 0x2b72b1
movq 0x180c17(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2dcb8(%rip), %rsi     # 0x2e5013
leaq 0xcb959(%rip), %rdx     # 0x382cbb
leaq 0xcb8ba(%rip), %rcx     # 0x382c23
leaq 0xcb75a(%rip), %r8      # 0x382aca
movl $0x22d, %r9d            # imm = 0x22D
jmp 0x2b72b1
movq 0x180be6(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2dc87(%rip), %rsi     # 0x2e5013
leaq 0xcb9ca(%rip), %rdx     # 0x382d5d
leaq 0xcb889(%rip), %rcx     # 0x382c23
leaq 0xcb729(%rip), %r8      # 0x382aca
movl $0x230, %r9d            # imm = 0x230
jmp 0x2b72b1
movq 0x180bb5(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2dc56(%rip), %rsi     # 0x2e5013
leaq 0xcb9f9(%rip), %rdx     # 0x382dbd
leaq 0xcb858(%rip), %rcx     # 0x382c23
leaq 0xcb6f8(%rip), %r8      # 0x382aca
movl $0x248, %r9d            # imm = 0x248
jmp 0x2b72b1