// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r13
movq %rdx, %rdi
callq 0x10af48
movb 0x7c(%rbx), %cl
movl $0x1, %r15d
shlq %cl, %r15
movl %eax, %ebp
movq (%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jae 0x32eca9
movq 0x18(%rbx), %rsi
movq %rsi, %xmm1
punpckldq 0x2210c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x22114(%rip), %xmm1    # 0x3508f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x24000(%rip), %xmm0    # 0x3527f0
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xbfc87(%rip), %rdi     # 0x3ee48a
movb $0x1, %al
callq 0x108e02
movq 0x20(%rbx), %rsi
movq %rsi, %xmm1
movq 0x220c5(%rip), %xmm2    # 0x3508e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x220c9(%rip), %xmm3    # 0x3508f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x23fb1(%rip), %xmm0    # 0x3527f0
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 0xbfc45(%rip), %rdi     # 0x3ee4a8
movb $0x1, %al
callq 0x108e02
movq 0x28(%rbx), %rsi
movq %rsi, %xmm1
movq 0x22065(%rip), %xmm2    # 0x3508e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x22069(%rip), %xmm3    # 0x3508f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x23f51(%rip), %xmm0    # 0x3527f0
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 0xbfc09(%rip), %rdi     # 0x3ee4cc
movb $0x1, %al
callq 0x108e02
subl 0x7c(%rbx), %ebp
jbe 0x32e916
movl $0x1, %edx
movl %ebp, %ecx
shlq %cl, %rdx
movq %rdx, 0x88(%rbx)
leaq 0xbd6d6(%rip), %rdi     # 0x3ebfbd
movq %r14, %rsi
xorl %eax, %eax
callq 0x108e02
movq 0x88(%rbx), %rdi
shlq $0x3, %rdi
leaq 0xbfaaf(%rip), %rsi     # 0x3ee3b2
movl $0x108, %edx            # imm = 0x108
callq 0x1092b2
movq %rax, 0x80(%rbx)
jmp 0x32e922
xorpd %xmm0, %xmm0
movupd %xmm0, 0x80(%rbx)
movq %r14, 0x20(%rsp)
movq $0x0, 0x90(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x32eccc
movl %eax, %ebp
movq (%rbx), %rax
movl $0xa, %ecx
decl %ecx
movl $0x1, %r14d
shlq %cl, %r14
cmpq %rax, %r14
jae 0x32e946
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 0xbfa3b(%rip), %r12     # 0x3ee3b2
movq %r12, %rsi
movl $0x11f, %edx            # imm = 0x11F
callq 0x1092b2
movq %rax, 0x58(%rbx)
movq 0x8(%rbx), %rax
shlq $0x3, %rax
movq %rax, (%rsp)
leaq 0xbd651(%rip), %r8      # 0x3ebfec
movq %r13, %rdi
movl $0x121, %esi            # imm = 0x121
movq %r12, %rdx
movl $0x1, %ecx
movl $0x1, %r9d
callq 0x320ca8
cmpq $0x0, 0x8(%rbx)
je 0x32ecae
movl %ebp, %r12d
movq 0x58(%rbx), %rax
movq %r12, (%rax)
leaq 0x49858(%rip), %rdi     # 0x37822a
movq %r13, 0x18(%rsp)
movq %r13, %rsi
callq 0x349b34
movq %rax, %r13
movq 0x8(%rax), %rax
cmpq 0x10(%r13), %rax
jne 0x32e9f4
movq %r13, %rdi
callq 0x349bfc
movl 0x78(%rbx), %eax
andl %ebp, %eax
movq (%r13), %rcx
movq 0x8(%r13), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%r13)
movl %eax, (%rcx,%rdx,4)
cmpq $0x2, (%rbx)
jb 0x32eb04
decq %r14
movl $0x1, %ebp
movl $0x1, %eax
movq %rax, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x32eccc
cmpl 0x78(%rbx), %eax
ja 0x32ec95
movl %eax, %eax
movq 0x10(%rsp), %rdi
cmpq %rax, %rdi
cmovbeq %rax, %rdi
addq %rax, %r12
movq 0x88(%rbx), %rcx
testq %rcx, %rcx
je 0x32eaa2
cmpq %r15, %r12
jb 0x32eaa2
movq 0x90(%rbx), %rax
cmpq %rcx, %rax
jae 0x32ec9a
movq 0x80(%rbx), %rcx
testq %rcx, %rcx
je 0x32ec9f
leaq -0x1(%rbp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x90(%rbx)
movq %rdx, (%rcx,%rax,8)
movb 0x7c(%rbx), %cl
shrq %cl, %r15
incq %r15
shlq %cl, %r15
testq %r14, %rbp
jne 0x32eac6
movq 0x8(%rsp), %rcx
cmpq 0x8(%rbx), %rcx
jae 0x32eca4
movq 0x58(%rbx), %rax
movq %r12, (%rax,%rcx,8)
incq %rcx
movq %rcx, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x8(%r13), %rax
cmpq 0x10(%r13), %rax
jne 0x32eadd
movq %r13, %rdi
callq 0x349bfc
movl 0x78(%rbx), %eax
andl %r12d, %eax
movq (%r13), %rcx
movq 0x8(%r13), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%r13)
movl %eax, (%rcx,%rdx,4)
incq %rbp
cmpq (%rbx), %rbp
jb 0x32ea2d
jmp 0x32eb13
movl $0x1, %eax
movq %rax, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq 0x8(%r13), %rax
cmpq 0x10(%r13), %rax
jne 0x32eb25
movq %r13, %rdi
callq 0x349bfc
movl 0x78(%rbx), %eax
andl %r12d, %eax
movq (%r13), %rcx
movq 0x8(%r13), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%r13)
movl %eax, (%rcx,%rdx,4)
movq (%rbx), %rdx
incq %rdx
movq %r13, %rdi
movq 0x18(%rsp), %rsi
callq 0x349c27
movq %rax, 0x60(%rbx)
movq 0x58(%rbx), %rax
movq 0x8(%rsp), %rcx
cmpq -0x8(%rax,%rcx,8), %r12
jbe 0x32eb78
cmpq 0x8(%rbx), %rcx
jae 0x32ecbd
movq %r12, (%rax,%rcx,8)
incq %rcx
jmp 0x32eb7e
jne 0x32ecc2
cmpq 0x20(%rsp), %r12
jne 0x32ecb3
decq %rcx
movq %rcx, 0x8(%rbx)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x32ecb8
leaq 0xbf80e(%rip), %r13     # 0x3ee3b2
movq %r13, %rsi
movl $0x157, %edx            # imm = 0x157
callq 0x109670
xorl %r15d, %r15d
movq %r15, (%rsp)
leaq 0xbd533(%rip), %r8      # 0x3ec0f2
movq 0x18(%rsp), %rdi
movl $0x158, %esi            # imm = 0x158
movq %r13, %rdx
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x320ca8
movq %r15, 0x48(%rbx)
cmpq %r15, 0x18(%rbx)
je 0x32ec04
callq 0x10989a
testb %al, %al
je 0x32ec01
callq 0x10978b
movq %rax, %r12
callq 0x102df2
movq %rax, %r15
addq %r12, %r15
jmp 0x32ec04
xorl %r15d, %r15d
movq 0x50(%rbx), %rdi
callq 0x106d10
cmpq $0x0, 0x18(%rbx)
je 0x32ec79
callq 0x10989a
testb %al, %al
je 0x32ec79
callq 0x10978b
movq %rax, %r12
callq 0x102df2
addq %r12, %rax
subq %rax, %r15
jbe 0x32ecc7
movq %r15, %xmm1
punpckldq 0x21c9d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x21ca5(%rip), %xmm1    # 0x3508f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x21ca1(%rip), %xmm0    # 0x350900
movq %r15, %rax
xorl %edx, %edx
divq 0x18(%rbx)
leaq 0xbd4b9(%rip), %rdi     # 0x3ec128
movq %rax, %rsi
movb $0x1, %al
callq 0x108e02
movq $0x0, 0x50(%rbx)
movq 0x10(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x96e9f
callq 0x96cd7
callq 0x96d10
callq 0x96d49
callq 0x96c9e
callq 0x96ed8
callq 0x96df4
callq 0x96e66
callq 0x96dbb
callq 0x96d82
callq 0x96e2d