// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %rdx, 0x20(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
movq %rcx, %rdi
callq 0x105e91
movl %eax, %ebp
movq (%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jae 0x3178b4
movq 0x18(%rbx), %rsi
movq %rsi, %xmm1
punpckldq 0x3049b(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x304a3(%rip), %xmm1    # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x3237f(%rip), %xmm0    # 0x3497e0
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xcb3e9(%rip), %rdi     # 0x3e285d
movb $0x1, %al
callq 0x103d72
movq 0x20(%rbx), %rsi
movq %rsi, %xmm1
movq 0x30454(%rip), %xmm2    # 0x3478e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x30458(%rip), %xmm3    # 0x3478f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x32330(%rip), %xmm0    # 0x3497e0
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 0xcb3a8(%rip), %rdi     # 0x3e287b
movb $0x1, %al
callq 0x103d72
cmpl $0x20, %ebp
ja 0x3174eb
movq $0x0, 0x78(%rbx)
xorl %eax, %eax
jmp 0x317527
addb $-0x20, %bpl
movl $0x1, %edx
movl %ebp, %ecx
shlq %cl, %rdx
movq %rdx, 0x78(%rbx)
leaq 0xcb395(%rip), %rdi     # 0x3e2899
movq %r15, %rsi
xorl %eax, %eax
callq 0x103d72
movq 0x78(%rbx), %rdi
shlq $0x3, %rdi
leaq 0xcb1cd(%rip), %rsi     # 0x3e26ea
movl $0x1ea, %edx            # imm = 0x1EA
callq 0x104226
movq %r15, 0x28(%rsp)
movq %rax, 0x70(%rbx)
movq $0x0, 0x80(%rbx)
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x3178d2
movl %eax, %r15d
movq (%rbx), %rax
movl $0xa, %ecx
decl %ecx
movl $0x1, %r12d
shlq %cl, %r12
cmpq %rax, %r12
jae 0x317555
movl %ecx, 0x28(%rbx)
shrq %cl, %rax
movq %r12, 0x10(%rbx)
leaq 0x2(%rax), %rcx
movq %rcx, 0x8(%rbx)
leaq 0x10(,%rax,8), %rdi
leaq 0xcb164(%rip), %r13     # 0x3e26ea
movq %r13, %rsi
movl $0x201, %edx            # imm = 0x201
callq 0x104226
movq %rax, 0x48(%rbx)
movq 0x8(%rbx), %rax
shlq $0x3, %rax
movq %rax, (%rsp)
leaq 0xcb31e(%rip), %r8      # 0x3e28c8
movq %r14, %rdi
movl $0x203, %esi            # imm = 0x203
movq %r13, %rdx
movl $0x1, %ecx
movl $0x1, %r9d
callq 0x316945
cmpq $0x0, 0x8(%rbx)
je 0x3178b9
movl %r15d, %r13d
movq 0x48(%rbx), %rax
movq %r13, (%rax)
leaq 0x579d9(%rip), %rdi     # 0x36efba
movq %r14, %rsi
callq 0x3407e4
movq %rax, %rbp
movq 0x8(%rax), %rdx
cmpq 0x10(%rax), %rdx
jne 0x317602
movq %rbp, %rdi
callq 0x3408ac
movq 0x8(%rbp), %rdx
movq %r14, 0x30(%rsp)
movq (%rbp), %rax
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%rbp)
movl %r15d, (%rax,%rdx,4)
movq (%rbx), %rdx
cmpq $0x2, %rdx
jb 0x31771f
decq %r12
movl $0x1, %r15d
movabsq $0x100000000, %r14      # imm = 0x100000000
movl $0x1, %eax
movq %rax, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
movq %r15, %rdx
callq 0x3178d2
movl %eax, %eax
movq 0x18(%rsp), %rdi
cmpq %rax, %rdi
cmovbeq %rax, %rdi
addq %rax, %r13
movq 0x78(%rbx), %rcx
testq %rcx, %rcx
je 0x3176bf
cmpq %r14, %r13
jb 0x3176bf
movq 0x80(%rbx), %rax
cmpq %rcx, %rax
jae 0x3178a5
movq 0x70(%rbx), %rcx
testq %rcx, %rcx
je 0x3178aa
leaq -0x1(%r15), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x80(%rbx)
movq %rdx, (%rcx,%rax,8)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rax, %r14
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r14
testq %r12, %r15
jne 0x3176e3
movq 0x10(%rsp), %rcx
cmpq 0x8(%rbx), %rcx
jae 0x3178af
movq 0x48(%rbx), %rax
movq %r13, (%rax,%rcx,8)
incq %rcx
movq %rcx, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
movq 0x8(%rbp), %rdx
cmpq 0x10(%rbp), %rdx
jne 0x3176fe
movq %rbp, %rdi
callq 0x3408ac
movq 0x8(%rbp), %rdx
movq (%rbp), %rax
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%rbp)
movl %r13d, (%rax,%rdx,4)
incq %r15
movq (%rbx), %rdx
cmpq %rdx, %r15
jb 0x317646
jmp 0x31772e
movl $0x1, %esi
movq %rsi, 0x10(%rsp)
movq %r13, 0x18(%rsp)
cmpq 0x10(%rbp), %rcx
jne 0x317747
movq %rbp, %rdi
callq 0x3408ac
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
movq (%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x8(%rbp)
movl %r13d, (%rax,%rcx,4)
incq %rdx
movq %rbp, %rdi
movq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0x3408d7
movq %rax, 0x50(%rbx)
movq 0x48(%rbx), %rax
movq 0x10(%rsp), %rcx
cmpq -0x8(%rax,%rcx,8), %r13
jbe 0x31778d
cmpq 0x8(%rbx), %rcx
jae 0x3178c3
movq %r13, (%rax,%rcx,8)
incq %rcx
jmp 0x317793
jne 0x3178c8
cmpq 0x28(%rsp), %r13
jne 0x3178be
decq %rcx
movq %rcx, 0x8(%rbx)
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x3177ec
leaq 0xcaf35(%rip), %r15     # 0x3e26ea
movq %r15, %rsi
movl $0x23a, %edx            # imm = 0x23A
callq 0x1045eb
movq %r14, %rdi
xorl %r14d, %r14d
movq %r14, (%rsp)
leaq 0xcb1fb(%rip), %r8      # 0x3e29ce
movl $0x23b, %esi            # imm = 0x23B
movq %r15, %rdx
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x316945
movq %r14, 0x38(%rbx)
cmpq $0x0, 0x18(%rbx)
je 0x317811
callq 0x104815
testb %al, %al
je 0x317811
callq 0x104706
movq %rax, %r15
callq 0xfdf34
movq %rax, %r12
addq %r15, %r12
jmp 0x317814
xorl %r12d, %r12d
movq 0x40(%rbx), %rdi
callq 0x101d90
cmpq $0x0, 0x18(%rbx)
je 0x317889
callq 0x104815
testb %al, %al
je 0x317889
callq 0x104706
movq %rax, %r15
callq 0xfdf34
addq %r15, %rax
subq %rax, %r12
jbe 0x3178cd
movq %r12, %xmm1
punpckldq 0x3008d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x30095(%rip), %xmm1    # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x30091(%rip), %xmm0    # 0x347900
movq %r12, %rax
xorl %edx, %edx
divq 0x18(%rbx)
leaq 0xcb185(%rip), %rdi     # 0x3e2a04
movq %rax, %rsi
movb $0x1, %al
callq 0x103d72
movq $0x0, 0x40(%rbx)
movq 0x18(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x917a7
callq 0x917e0
callq 0x91819
callq 0x9176e
callq 0x91936
callq 0x918c4
callq 0x9188b
callq 0x91852
callq 0x918fd