// File: /workspace/github_c_makefile_star2_O3/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 0x105e91
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 0x3248d6
movq 0x18(%rbx), %rsi
movq %rsi, %xmm1
punpckldq 0x234e6(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x234ee(%rip), %xmm1    # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x253ca(%rip), %xmm0    # 0x3497e0
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xc089d(%rip), %rdi     # 0x3e4cc6
movb $0x1, %al
callq 0x103d72
movq 0x20(%rbx), %rsi
movq %rsi, %xmm1
movq 0x2349f(%rip), %xmm2    # 0x3478e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x234a3(%rip), %xmm3    # 0x3478f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2537b(%rip), %xmm0    # 0x3497e0
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 0xc085b(%rip), %rdi     # 0x3e4ce4
movb $0x1, %al
callq 0x103d72
movq 0x28(%rbx), %rsi
movq %rsi, %xmm1
movq 0x2343f(%rip), %xmm2    # 0x3478e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x23443(%rip), %xmm3    # 0x3478f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2531b(%rip), %xmm0    # 0x3497e0
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 0xc081f(%rip), %rdi     # 0x3e4d08
movb $0x1, %al
callq 0x103d72
subl 0x7c(%rbx), %ebp
jbe 0x324535
movl $0x1, %edx
movl %ebp, %ecx
shlq %cl, %rdx
movq %rdx, 0x88(%rbx)
leaq 0xbe38c(%rip), %rdi     # 0x3e2899
movq %r14, %rsi
xorl %eax, %eax
callq 0x103d72
movq 0x88(%rbx), %rdi
shlq $0x3, %rdi
leaq 0xc06c5(%rip), %rsi     # 0x3e4bee
movl $0x108, %edx            # imm = 0x108
callq 0x104226
jmp 0x324542
movq $0x0, 0x88(%rbx)
xorl %eax, %eax
movq %r14, 0x20(%rsp)
movq %rax, 0x80(%rbx)
movq $0x0, 0x90(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3248f9
movl %eax, %ebp
movq (%rbx), %rax
movl $0xa, %ecx
decl %ecx
movl $0x1, %r14d
shlq %cl, %r14
cmpq %rax, %r14
jae 0x32456d
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 0xc0650(%rip), %r12     # 0x3e4bee
movq %r12, %rsi
movl $0x11f, %edx            # imm = 0x11F
callq 0x104226
movq %rax, 0x58(%rbx)
movq 0x8(%rbx), %rax
shlq $0x3, %rax
movq %rax, (%rsp)
leaq 0xbe306(%rip), %r8      # 0x3e28c8
movq %r13, %rdi
movl $0x121, %esi            # imm = 0x121
movq %r12, %rdx
movl $0x1, %ecx
movl $0x1, %r9d
callq 0x316945
cmpq $0x0, 0x8(%rbx)
je 0x3248db
movl %ebp, %r12d
movq 0x58(%rbx), %rax
movq %r12, (%rax)
leaq 0x4a9c1(%rip), %rdi     # 0x36efba
movq %r13, 0x18(%rsp)
movq %r13, %rsi
callq 0x3407e4
movq %rax, %r13
movq 0x8(%rax), %rdx
cmpq 0x10(%rax), %rdx
jne 0x32461f
movq %r13, %rdi
callq 0x3408ac
movq 0x8(%r13), %rdx
movl 0x78(%rbx), %esi
andl %ebp, %esi
movq (%r13), %rax
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%r13)
movl %esi, (%rax,%rdx,4)
movq (%rbx), %rdx
cmpq $0x2, %rdx
jb 0x324735
decq %r14
movl $0x1, %ebp
movl $0x1, %eax
movq %rax, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3248f9
movl 0x78(%rbx), %edx
cmpl %edx, %eax
ja 0x3248c2
movl %eax, %eax
movq 0x10(%rsp), %r8
cmpq %rax, %r8
cmovbeq %rax, %r8
addq %rax, %r12
movq 0x88(%rbx), %rcx
testq %rcx, %rcx
je 0x3246ce
cmpq %r15, %r12
jb 0x3246ce
movq 0x90(%rbx), %rax
cmpq %rcx, %rax
jae 0x3248c7
movq 0x80(%rbx), %rcx
testq %rcx, %rcx
je 0x3248cc
leaq -0x1(%rbp), %rsi
leaq 0x1(%rax), %rdi
movq %rdi, 0x90(%rbx)
movq %rsi, (%rcx,%rax,8)
movb 0x7c(%rbx), %cl
shrq %cl, %r15
incq %r15
shlq %cl, %r15
testq %r14, %rbp
jne 0x3246f2
movq 0x8(%rsp), %rcx
cmpq 0x8(%rbx), %rcx
jae 0x3248d1
movq 0x58(%rbx), %rax
movq %r12, (%rax,%rcx,8)
incq %rcx
movq %rcx, 0x8(%rsp)
movq %r8, 0x10(%rsp)
movq 0x8(%r13), %rsi
cmpq 0x10(%r13), %rsi
jne 0x324710
movq %r13, %rdi
callq 0x3408ac
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)
incq %rbp
movq (%rbx), %rdx
cmpq %rdx, %rbp
jb 0x324657
jmp 0x324744
movl $0x1, %esi
movq %rsi, 0x8(%rsp)
movq %r12, 0x10(%rsp)
cmpq 0x10(%r13), %rcx
jne 0x32475d
movq %r13, %rdi
callq 0x3408ac
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 0x18(%rsp), %rsi
callq 0x3408d7
movq %rax, 0x60(%rbx)
movq 0x58(%rbx), %rax
movq 0x8(%rsp), %rcx
cmpq -0x8(%rax,%rcx,8), %r12
jbe 0x3247a5
cmpq 0x8(%rbx), %rcx
jae 0x3248ea
movq %r12, (%rax,%rcx,8)
incq %rcx
jmp 0x3247ab
jne 0x3248ef
cmpq 0x20(%rsp), %r12
jne 0x3248e0
decq %rcx
movq %rcx, 0x8(%rbx)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x3248e5
leaq 0xc041d(%rip), %r13     # 0x3e4bee
movq %r13, %rsi
movl $0x157, %edx            # imm = 0x157
callq 0x1045eb
xorl %r15d, %r15d
movq %r15, (%rsp)
leaq 0xbe1e2(%rip), %r8      # 0x3e29ce
movq 0x18(%rsp), %rdi
movl $0x158, %esi            # imm = 0x158
movq %r13, %rdx
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x316945
movq %r15, 0x48(%rbx)
cmpq %r15, 0x18(%rbx)
je 0x324831
callq 0x104815
testb %al, %al
je 0x32482e
callq 0x104706
movq %rax, %r12
callq 0xfdf34
movq %rax, %r15
addq %r12, %r15
jmp 0x324831
xorl %r15d, %r15d
movq 0x50(%rbx), %rdi
callq 0x101d90
cmpq $0x0, 0x18(%rbx)
je 0x3248a6
callq 0x104815
testb %al, %al
je 0x3248a6
callq 0x104706
movq %rax, %r12
callq 0xfdf34
addq %r12, %rax
subq %rax, %r15
jbe 0x3248f4
movq %r15, %xmm1
punpckldq 0x23070(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x23078(%rip), %xmm1    # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x23074(%rip), %xmm0    # 0x347900
movq %r15, %rax
xorl %edx, %edx
divq 0x18(%rbx)
leaq 0xbe168(%rip), %rdi     # 0x3e2a04
movq %rax, %rsi
movb $0x1, %al
callq 0x103d72
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 0x94ea8
callq 0x94ce0
callq 0x94d19
callq 0x94d52
callq 0x94ca7
callq 0x94ee1
callq 0x94dfd
callq 0x94e6f
callq 0x94dc4
callq 0x94d8b
callq 0x94e36