// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/randomcodes-tab.c
// Function: gt_randomcodes_partialsums
GtUword gt_randomcodes_partialsums(GtFirstcodesspacelog *fcsl,
                                        GtRandomcodestab *rct,
                                        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 = 1UL << rct->modvaluebits;
#endif
#ifdef SKDEBUG
  GtDiscDistri *countdistri = gt_disc_distri_new();
#endif

  gt_assert(rct->differentcodes < UINT32_MAX);
  gt_log_log("hashmap_addcount="GT_WU" (%.2f%%)",rct->hashmap_addcount,
                  100.0 * (double) rct->hashmap_addcount/
                                   rct->differentcodes);
  gt_log_log("hashmap_incrementcount="GT_WU" (%.2f%%)",
                  rct->hashmap_incrementcount,
                  100.0 * (double) rct->hashmap_incrementcount/
                                   rct->all_incrementcount);
  gt_log_log("hashmap_getcount="GT_WU" (%.2f%%)",
                  rct->hashmap_getcount,
                  100.0 * (double) rct->hashmap_getcount/
                                   rct->all_incrementcount);

#if defined (_LP64) || defined (_WIN64)
  if (btp <= rct->modvaluebits)
  {
    rct->bitchangepoints.allocatedGtUword = 0;
    rct->bitchangepoints.spaceGtUword = NULL;
  } else
  {
    rct->bitchangepoints.allocatedGtUword = 1UL << (btp - rct->modvaluebits);
    gt_log_log("lastpartsum="GT_WU", bitchangepoints.allocated="GT_WU"",
              expectedlastpartsum,rct->bitchangepoints.allocatedGtUword);
    rct->bitchangepoints.spaceGtUword
      = gt_malloc(sizeof (*rct->bitchangepoints.spaceGtUword)
                  * rct->bitchangepoints.allocatedGtUword);
  }
  rct->bitchangepoints.nextfreeGtUword = 0;
#endif
  currentcount = gt_randomcodes_countocc_get(rct,0);
  partsum = (GtUword) currentcount;
  maxbucketsize = (GtUword) currentcount;
#ifdef SKDEBUG
  gt_disc_distri_add(countdistri,(GtUword) currentcount);
#endif
  rct->sampleshift = 9U;
  while (true)
  {
    rct->sampledistance = 1UL << rct->sampleshift;
    if (rct->sampledistance < rct->differentcodes)
    {
      break;
    }
    rct->sampleshift--;
  }
  bitmask = rct->sampledistance - 1;
  rct->numofsamples = 1UL + 1UL + rct->differentcodes/rct->sampledistance;
  rct->leftborder_samples = gt_malloc(sizeof (*rct->leftborder_samples) *
                                      rct->numofsamples);
  GT_FCI_ADDWORKSPACE(fcsl,"leftborder_samples",
                      sizeof (*rct->leftborder_samples) * rct->numofsamples);
  GT_RANDOMCODES_ADD_SAMPLE(partsum);
  leftborderbuffer_all = gt_leftborderbuffer_new("leftborder",fcsl);
  GT_RCT_PARTIALSUM_LEFTBORDER_SET(leftborderbuffer_all,partsum);
  for (idx = 1UL; idx < rct->differentcodes; idx++)
  {
    currentcount = gt_randomcodes_countocc_get(rct,idx);
#if defined (_LP64) || defined (_WIN64)
    gt_assert(currentcount <= rct->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 (rct->bitchangepoints.allocatedGtUword > 0 && partsum >= exceedvalue)
    {
      gt_assert(idx > 0 && rct->bitchangepoints.nextfreeGtUword <
                           rct->bitchangepoints.allocatedGtUword);
      gt_assert(rct->bitchangepoints.spaceGtUword != NULL);
      rct->bitchangepoints.spaceGtUword
        [rct->bitchangepoints.nextfreeGtUword++] = idx-1;
      exceedvalue = ((GtUword) (exceedvalue >> rct->modvaluebits) + 1)
                      << rct->modvaluebits;
    }
#endif
    if ((idx & bitmask) == 0)
    {
      GT_RANDOMCODES_ADD_SAMPLE(partsum);
    }
    GT_RCT_PARTIALSUM_LEFTBORDER_SET(leftborderbuffer_all,partsum);
  }
  GT_RCT_PARTIALSUM_LEFTBORDER_SET(leftborderbuffer_all,partsum);
  rct->outfilenameleftborder
      = gt_leftborderbuffer_delete(leftborderbuffer_all,fcsl,
                                   gt_randomcodes_leftborder_entries(rct));
  if (partsum > rct->leftborder_samples[samplecount-1])
  {
    GT_RANDOMCODES_ADD_SAMPLE(partsum);
  } else
  {
    gt_assert(partsum == rct->leftborder_samples[samplecount-1]);
  }
  gt_assert(expectedlastpartsum == partsum);
  rct->numofsamples = samplecount-1;
#ifdef SKDEBUG
  gt_randomcodes_evaluate_countdistri(countdistri);
  gt_disc_distri_delete(countdistri);
#endif
  gt_assert (rct->countocc_small != NULL);
  gt_free(rct->countocc_small);
  GT_FCI_SUBTRACTWORKSPACE(fcsl,"countocc_small");
  rct->countocc_small = NULL;
  if (rct->hashmap_addcount > 0 && gt_ma_bookkeeping_enabled())
  {
    spacewithhashmap = gt_ma_get_space_current() + gt_fa_get_space_current();
  }
  gt_hashtable_delete(rct->countocc_exceptions);
  if (rct->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/rct->hashmap_addcount);
  }
  rct->countocc_exceptions = NULL;
  return maxbucketsize;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq %rdx, %rdi
callq 0x9580f
movb 0x7c(%rbx), %cl
pushq $0x1
popq %r12
movq %r12, %rdx
shlq %cl, %rdx
movq %rdx, 0x18(%rsp)
movl %eax, %ebp
movq (%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jae 0x2c608d
movq 0x18(%rbx), %rsi
movq %rsi, %xmm1
punpckldq 0x21db7(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x21dbf(%rip), %xmm1    # 0x2e78f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x23c9b(%rip), %xmm0    # 0x2e97e0
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xbf551(%rip), %rdi     # 0x3850a6
movb $0x1, %al
callq 0x92a82
movq 0x20(%rbx), %rsi
movq %rsi, %xmm1
movq 0x21d73(%rip), %xmm2    # 0x2e78e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x21d77(%rip), %xmm3    # 0x2e78f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x23c4f(%rip), %xmm0    # 0x2e97e0
movq 0x30(%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 0xbf50f(%rip), %rdi     # 0x3850c4
movb $0x1, %al
callq 0x92a82
movq 0x28(%rbx), %rsi
movq %rsi, %xmm1
movq 0x21d13(%rip), %xmm2    # 0x2e78e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x21d17(%rip), %xmm3    # 0x2e78f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x23bef(%rip), %xmm0    # 0x2e97e0
movq 0x30(%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 0xbf4d3(%rip), %rdi     # 0x3850e8
movb $0x1, %al
callq 0x92a82
subl 0x7c(%rbx), %ebp
jbe 0x2c5c5f
pushq $0x1
popq %rdx
movl %ebp, %ecx
shlq %cl, %rdx
movq %rdx, 0x88(%rbx)
leaq 0xbd042(%rip), %rdi     # 0x382c79
movq %r14, %rsi
xorl %eax, %eax
callq 0x92a82
movq 0x88(%rbx), %rdi
shlq $0x3, %rdi
leaq 0xbf37b(%rip), %rsi     # 0x384fce
movl $0x108, %edx            # imm = 0x108
callq 0x93160
jmp 0x2c5c69
andq $0x0, 0x88(%rbx)
xorl %eax, %eax
movq %r14, 0x30(%rsp)
movq %rax, 0x80(%rbx)
andq $0x0, 0x90(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2c61de
movl %eax, %ebp
movq (%rbx), %rax
pushq $0xa
popq %rcx
decl %ecx
movq %r12, %r14
shlq %cl, %r14
cmpq %rax, %r14
jae 0x2c5c8f
movq %r12, 0x10(%rsp)
movl %ecx, 0x38(%rbx)
shrq %cl, %rax
movq %r14, 0x10(%rbx)
leaq 0x2(%rax), %rcx
movq %rcx, 0x8(%rbx)
leaq 0x10(,%rax,8), %rdi
leaq 0xbf30c(%rip), %r12     # 0x384fce
movq %r12, %rsi
movl $0x11f, %edx            # imm = 0x11F
callq 0x93160
movq %rax, 0x58(%rbx)
movq 0x8(%rbx), %rax
shlq $0x3, %rax
movq %rax, (%rsp)
leaq 0xbcfc2(%rip), %r8      # 0x382ca8
pushq $0x1
popq %rcx
movq %r15, %rdi
movl $0x121, %esi            # imm = 0x121
movq %r12, %rdx
movl %ecx, %r9d
callq 0x2b613a
cmpq $0x0, 0x8(%rbx)
je 0x2c60bb
movl %ebp, %r12d
movq 0x58(%rbx), %rax
movq %r12, (%rax)
leaq 0x495ba(%rip), %rdi     # 0x30f2d2
movq %r15, 0x28(%rsp)
movq %r15, %rsi
callq 0x2dfb60
movq %rax, %r13
movq 0x8(%rax), %rdx
cmpq 0x10(%rax), %rdx
jne 0x2c5d3e
movq %r13, %rdi
callq 0x2dfc11
movq 0x8(%r13), %rdx
decq %r14
movl 0x78(%rbx), %esi
andl %ebp, %esi
movq (%r13), %rax
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%r13)
movl %esi, (%rax,%rdx,4)
xorl %r15d, %r15d
movq %r12, 0x20(%rsp)
leaq 0x1(%r15), %rbp
movq (%rbx), %rdx
cmpq %rdx, %rbp
jae 0x2c5e4a
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2c61de
movl 0x78(%rbx), %edx
cmpl %edx, %eax
ja 0x2c5fc8
movl %eax, %eax
movq 0x20(%rsp), %rcx
cmpq %rax, %rcx
cmovbeq %rax, %rcx
movq %rcx, 0x20(%rsp)
addq %rax, %r12
movq 0x88(%rbx), %rcx
testq %rcx, %rcx
je 0x2c5df1
cmpq 0x18(%rsp), %r12
jb 0x2c5df1
movq 0x90(%rbx), %rax
cmpq %rcx, %rax
jae 0x2c5ff9
movq 0x80(%rbx), %rcx
testq %rcx, %rcx
je 0x2c6027
leaq 0x1(%rax), %rsi
movq %rsi, 0x90(%rbx)
movq %r15, (%rcx,%rax,8)
movb 0x7c(%rbx), %cl
movq 0x18(%rsp), %rax
shrq %cl, %rax
incq %rax
shlq %cl, %rax
movq %rax, 0x18(%rsp)
testq %r14, %rbp
jne 0x2c5e15
movq 0x10(%rsp), %rcx
cmpq 0x8(%rbx), %rcx
jae 0x2c6055
movq 0x58(%rbx), %rax
movq %r12, (%rax,%rcx,8)
incq %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%r13), %rsi
cmpq 0x10(%r13), %rsi
jne 0x2c5e2e
movq %r13, %rdi
callq 0x2dfc11
movl 0x78(%rbx), %edx
movq 0x8(%r13), %rsi
movl %r12d, %edi
andl %edx, %edi
movq (%r13), %rax
leaq 0x1(%rsi), %rcx
movq %rcx, 0x8(%r13)
movl %edi, (%rax,%rsi,4)
movq %rbp, %r15
jmp 0x2c5d5d
cmpq 0x10(%r13), %rcx
jne 0x2c5e63
movq %r13, %rdi
callq 0x2dfc11
movq (%r13), %rax
movq 0x8(%r13), %rcx
movq (%rbx), %rdx
movl 0x78(%rbx), %esi
andl %r12d, %esi
leaq 0x1(%rcx), %rdi
movq %rdi, 0x8(%r13)
movl %esi, (%rax,%rcx,4)
incq %rdx
movq %r13, %rdi
movq 0x28(%rsp), %rsi
callq 0x2dfc37
movq %rax, 0x60(%rbx)
movq 0x58(%rbx), %rax
movq 0x10(%rsp), %rcx
cmpq -0x8(%rax,%rcx,8), %r12
jbe 0x2c5eab
cmpq 0x8(%rbx), %rcx
jae 0x2c614b
movq %r12, (%rax,%rcx,8)
incq %rcx
jmp 0x2c5eb1
jne 0x2c617c
cmpq 0x30(%rsp), %r12
jne 0x2c60e9
decq %rcx
movq %rcx, 0x8(%rbx)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
movq 0x20(%rsp), %r12
je 0x2c611a
leaq 0xbf0f2(%rip), %r13     # 0x384fce
movq %r13, %rsi
movl $0x157, %edx            # imm = 0x157
callq 0x936f9
andq $0x0, (%rsp)
leaq 0xbceb9(%rip), %r8      # 0x382dae
xorl %r15d, %r15d
pushq $0x1
popq %r9
movq 0x28(%rsp), %rdi
movl $0x158, %esi            # imm = 0x158
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x2b613a
andq $0x0, 0x48(%rbx)
cmpq %r15, 0x18(%rbx)
je 0x2c5f3c
callq 0x93b7c
testb %al, %al
je 0x2c5f39
callq 0x93934
movq %rax, %r14
callq 0x8bf8b
movq %rax, %r15
addq %r14, %r15
jmp 0x2c5f3c
xorl %r15d, %r15d
movq 0x50(%rbx), %rdi
callq 0x9082d
cmpq $0x0, 0x18(%rbx)
je 0x2c5fb1
callq 0x93b7c
testb %al, %al
je 0x2c5fb1
callq 0x93934
movq %rax, %r14
callq 0x8bf8b
addq %r14, %rax
subq %rax, %r15
jbe 0x2c61ad
movq %r15, %xmm1
punpckldq 0x21965(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2196d(%rip), %xmm1    # 0x2e78f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x21969(%rip), %xmm0    # 0x2e7900
movq %r15, %rax
xorl %edx, %edx
divq 0x18(%rbx)
leaq 0xbce3d(%rip), %rdi     # 0x382de4
movq %rax, %rsi
movb $0x1, %al
callq 0x92a82
andq $0x0, 0x50(%rbx)
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x171f99(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f03a(%rip), %rsi     # 0x2e5013
leaq 0xbf146(%rip), %rdx     # 0x385126
leaq 0xbf0a4(%rip), %rcx     # 0x38508b
leaq 0xbefe0(%rip), %r8      # 0x384fce
movl $0x129, %r9d            # imm = 0x129
jmp 0x2c6081
movq 0x171f68(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f009(%rip), %rsi     # 0x2e5013
leaq 0xbf137(%rip), %rdx     # 0x385148
leaq 0xbf073(%rip), %rcx     # 0x38508b
leaq 0xbefaf(%rip), %r8      # 0x384fce
movl $0x137, %r9d            # imm = 0x137
jmp 0x2c6081
movq 0x171f3a(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1efdb(%rip), %rsi     # 0x2e5013
leaq 0xbf161(%rip), %rdx     # 0x3851a0
leaq 0xbf045(%rip), %rcx     # 0x38508b
leaq 0xbef81(%rip), %r8      # 0x384fce
movl $0x138, %r9d            # imm = 0x138
jmp 0x2c6081
movq 0x171f0c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1efad(%rip), %rsi     # 0x2e5013
leaq 0xbf099(%rip), %rdx     # 0x385106
leaq 0xbf017(%rip), %rcx     # 0x38508b
leaq 0xbef53(%rip), %r8      # 0x384fce
movl $0x141, %r9d            # imm = 0x141
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x171ed4(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1ef75(%rip), %rsi     # 0x2e5013
leaq 0xbefc5(%rip), %rdx     # 0x38506a
leaq 0xbefdf(%rip), %rcx     # 0x38508b
leaq 0xbef1b(%rip), %r8      # 0x384fce
movl $0xef, %r9d
jmp 0x2c6081
movq 0x171ea6(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1ef47(%rip), %rsi     # 0x2e5013
leaq 0xbf033(%rip), %rdx     # 0x385106
leaq 0xbefb1(%rip), %rcx     # 0x38508b
leaq 0xbeeed(%rip), %r8      # 0x384fce
movl $0x122, %r9d            # imm = 0x122
jmp 0x2c6081
movq 0x171e78(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1ef19(%rip), %rsi     # 0x2e5013
leaq 0xbcc8e(%rip), %rdx     # 0x382d8f
leaq 0xbef83(%rip), %rcx     # 0x38508b
leaq 0xbeebf(%rip), %r8      # 0x384fce
movl $0x150, %r9d            # imm = 0x150
jmp 0x2c6081
movq 0x171e47(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1eee8(%rip), %rsi     # 0x2e5013
leaq 0xbf0ca(%rip), %rdx     # 0x3851fc
leaq 0xbef52(%rip), %rcx     # 0x38508b
leaq 0xbee8e(%rip), %r8      # 0x384fce
movl $0x156, %r9d            # imm = 0x156
jmp 0x2c6081
movq 0x171e16(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1eeb7(%rip), %rsi     # 0x2e5013
leaq 0xbefa3(%rip), %rdx     # 0x385106
leaq 0xbef21(%rip), %rcx     # 0x38508b
leaq 0xbee5d(%rip), %r8      # 0x384fce
movl $0x14b, %r9d            # imm = 0x14B
jmp 0x2c6081
movq 0x171de5(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1ee86(%rip), %rsi     # 0x2e5013
leaq 0xbf036(%rip), %rdx     # 0x3851ca
leaq 0xbeef0(%rip), %rcx     # 0x38508b
leaq 0xbee2c(%rip), %r8      # 0x384fce
movl $0x14e, %r9d            # imm = 0x14E
jmp 0x2c6081
movq 0x171db4(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1ee55(%rip), %rsi     # 0x2e5013
leaq 0xbcbf8(%rip), %rdx     # 0x382dbd
leaq 0xbeebf(%rip), %rcx     # 0x38508b
leaq 0xbedfb(%rip), %r8      # 0x384fce
movl $0x164, %r9d            # imm = 0x164
jmp 0x2c6081