// File: /workspace/github_c_makefile_star2_O1/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 0x10af48
movl %eax, %ebp
movq (%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jae 0x321c5a
movq 0x18(%rbx), %rsi
movq %rsi, %xmm1
punpckldq 0x2f0f2(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2f0fa(%rip), %xmm1    # 0x3508f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x30fe6(%rip), %xmm0    # 0x3527f0
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xca764(%rip), %rdi     # 0x3ebf81
movb $0x1, %al
callq 0x108e02
movq 0x20(%rbx), %rsi
movq %rsi, %xmm1
movq 0x2f0ab(%rip), %xmm2    # 0x3508e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x2f0af(%rip), %xmm3    # 0x3508f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x30f97(%rip), %xmm0    # 0x3527f0
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 0xca723(%rip), %rdi     # 0x3ebf9f
movb $0x1, %al
callq 0x108e02
cmpl $0x20, %ebp
ja 0x321893
xorpd %xmm0, %xmm0
movupd %xmm0, 0x70(%rbx)
jmp 0x3218d3
addb $-0x20, %bpl
movl $0x1, %edx
movl %ebp, %ecx
shlq %cl, %rdx
movq %rdx, 0x78(%rbx)
leaq 0xca711(%rip), %rdi     # 0x3ebfbd
movq %r15, %rsi
xorl %eax, %eax
callq 0x108e02
movq 0x78(%rbx), %rdi
shlq $0x3, %rdi
leaq 0xca549(%rip), %rsi     # 0x3ebe0e
movl $0x1ea, %edx            # imm = 0x1EA
callq 0x1092b2
movq %rax, 0x70(%rbx)
movq %r15, 0x28(%rsp)
movq $0x0, 0x80(%rbx)
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x321c78
movl %eax, %r15d
movq (%rbx), %rax
movl $0xa, %ecx
decl %ecx
movl $0x1, %r12d
shlq %cl, %r12
cmpq %rax, %r12
jae 0x3218fd
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 0xca4e0(%rip), %r13     # 0x3ebe0e
movq %r13, %rsi
movl $0x201, %edx            # imm = 0x201
callq 0x1092b2
movq %rax, 0x48(%rbx)
movq 0x8(%rbx), %rax
shlq $0x3, %rax
movq %rax, (%rsp)
leaq 0xca69a(%rip), %r8      # 0x3ebfec
movq %r14, %rdi
movl $0x203, %esi            # imm = 0x203
movq %r13, %rdx
movl $0x1, %ecx
movl $0x1, %r9d
callq 0x320ca8
cmpq $0x0, 0x8(%rbx)
je 0x321c5f
movl %r15d, %r13d
movq 0x48(%rbx), %rax
movq %r13, (%rax)
leaq 0x568a1(%rip), %rdi     # 0x37822a
movq %r14, %rsi
callq 0x349b34
movq %rax, %rbp
movq 0x8(%rax), %rax
cmpq 0x10(%rbp), %rax
jne 0x3219a6
movq %rbp, %rdi
callq 0x349bfc
movq %r14, 0x30(%rsp)
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbp)
movl %r15d, (%rax,%rcx,4)
cmpq $0x2, (%rbx)
jb 0x321ac1
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 0x321c78
movl %eax, %eax
movq 0x18(%rsp), %rdi
cmpq %rax, %rdi
cmovbeq %rax, %rdi
addq %rax, %r13
movq 0x78(%rbx), %rcx
testq %rcx, %rcx
je 0x321a64
cmpq %r14, %r13
jb 0x321a64
movq 0x80(%rbx), %rax
cmpq %rcx, %rax
jae 0x321c4b
movq 0x70(%rbx), %rcx
testq %rcx, %rcx
je 0x321c50
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 0x321a88
movq 0x10(%rsp), %rcx
cmpq 0x8(%rbx), %rcx
jae 0x321c55
movq 0x48(%rbx), %rax
movq %r13, (%rax,%rcx,8)
incq %rcx
movq %rcx, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
movq 0x8(%rbp), %rax
cmpq 0x10(%rbp), %rax
jne 0x321a9f
movq %rbp, %rdi
callq 0x349bfc
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbp)
movl %r13d, (%rax,%rcx,4)
incq %r15
cmpq (%rbx), %r15
jb 0x3219eb
jmp 0x321ad0
movl $0x1, %eax
movq %rax, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movq 0x8(%rbp), %rax
cmpq 0x10(%rbp), %rax
jne 0x321ae2
movq %rbp, %rdi
callq 0x349bfc
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbp)
movl %r13d, (%rax,%rcx,4)
movq (%rbx), %rdx
incq %rdx
movq %rbp, %rdi
movq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0x349c27
movq %rax, 0x50(%rbx)
movq 0x48(%rbx), %rax
movq 0x10(%rsp), %rcx
cmpq -0x8(%rax,%rcx,8), %r13
jbe 0x321b33
cmpq 0x8(%rbx), %rcx
jae 0x321c69
movq %r13, (%rax,%rcx,8)
incq %rcx
jmp 0x321b39
jne 0x321c6e
cmpq 0x28(%rsp), %r13
jne 0x321c64
decq %rcx
movq %rcx, 0x8(%rbx)
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x321b92
leaq 0xca2b3(%rip), %r15     # 0x3ebe0e
movq %r15, %rsi
movl $0x23a, %edx            # imm = 0x23A
callq 0x109670
movq %r14, %rdi
xorl %r14d, %r14d
movq %r14, (%rsp)
leaq 0xca579(%rip), %r8      # 0x3ec0f2
movl $0x23b, %esi            # imm = 0x23B
movq %r15, %rdx
xorl %ecx, %ecx
movl $0x1, %r9d
callq 0x320ca8
movq %r14, 0x38(%rbx)
cmpq $0x0, 0x18(%rbx)
je 0x321bb7
callq 0x10989a
testb %al, %al
je 0x321bb7
callq 0x10978b
movq %rax, %r15
callq 0x102df2
movq %rax, %r12
addq %r15, %r12
jmp 0x321bba
xorl %r12d, %r12d
movq 0x40(%rbx), %rdi
callq 0x106d10
cmpq $0x0, 0x18(%rbx)
je 0x321c2f
callq 0x10989a
testb %al, %al
je 0x321c2f
callq 0x10978b
movq %rax, %r15
callq 0x102df2
addq %r15, %rax
subq %rax, %r12
jbe 0x321c73
movq %r12, %xmm1
punpckldq 0x2ece7(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2ecef(%rip), %xmm1    # 0x3508f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2eceb(%rip), %xmm0    # 0x350900
movq %r12, %rax
xorl %edx, %edx
divq 0x18(%rbx)
leaq 0xca503(%rip), %rdi     # 0x3ec128
movq %rax, %rsi
movb $0x1, %al
callq 0x108e02
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 0x93648
callq 0x93681
callq 0x936ba
callq 0x9360f
callq 0x937d7
callq 0x93765
callq 0x9372c
callq 0x936f3
callq 0x9379e