// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/randomcodes-sfx-partssuf.c
// Function: gt_suftabparts_rc_fit_memlimit
int gt_suftabparts_rc_fit_memlimit(size_t estimatedspace,
                                GtUword maximumspace,
                                const GtBcktab *bcktab,
                                const GtRandomcodestab *fct,
                                const GtSfxmappedrangelist *sfxmrlist,
                                GtUword totallength,
                                unsigned int bitsforseqnumrelpos,
                                GtUword specialcharacters,
                                GtUword numofsuffixestosort,
                                bool suftabuint,
                                GtError *err)
{
  unsigned int parts;
  GtSuftabparts_rc *suftabparts_rc;
  GtUword size_mapped = gt_Sfxmappedrangelist_size_entire(sfxmrlist);

  gt_error_check(err);
  for (parts = 1U; parts <= 500U; parts++)
  {
    size_t suftabsize;
    GtUword numofentries;

    suftabparts_rc = gt_suftabparts_rc_new(parts,
                                     bcktab,
                                     fct,
                                     sfxmrlist,
                                     numofsuffixestosort,
                                     specialcharacters + 1,
                                     NULL);
    gt_assert(suftabparts_rc != NULL);
    numofentries = gt_suftabparts_rc_largest_width(suftabparts_rc);
    if (bcktab != NULL)
    {
      gt_assert(fct == NULL);
      suftabsize = gt_suffixsortspace_requiredspace(numofentries,
                                                    totallength,
                                                    suftabuint);
    } else
    {
      gt_assert(fct != NULL);
      suftabsize = gt_spmsuftab_requiredspace(numofentries,
                                              totallength,
                                              bitsforseqnumrelpos);
    }
    if (parts == 1U)
    {
      if ((GtUword) (suftabsize + estimatedspace) <= maximumspace)
      {
        gt_suftabparts_rc_delete(suftabparts_rc);
        return (int) parts;
      }
    } else
    {
      GtUword largest
        = gt_suftabparts_rc_largestsizemappedpartwise(suftabparts_rc);
      if ((GtUword) (suftabsize + largest + estimatedspace - size_mapped)
                           <= maximumspace)
      {
        gt_log_log("return parts = %u as suftabsize=%.2f +"
                   "largest=%.2f + estimated=%.2f - size_mapped=%2.f <= %.2f",
                    parts,
                    GT_MEGABYTES(suftabsize),
                    GT_MEGABYTES(largest),
                    GT_MEGABYTES(estimatedspace),
                    GT_MEGABYTES(size_mapped),
                    GT_MEGABYTES(maximumspace));
        gt_suftabparts_rc_delete(suftabparts_rc);
        return (int) parts;
      }
    }
    gt_suftabparts_rc_delete(suftabparts_rc);
  }
  gt_error_set(err,"cannot compute enhanced suffix array in at most " GT_WU
               " bytes", maximumspace);
  return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x28(%rsp)
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
movq 0xa0(%rsp), %r15
movq %r8, 0x40(%rsp)
movq %r8, %rdi
callq 0x1ef570
movq %rax, %rbx
testq %r15, %r15
je 0x323fb1
movq %r15, %rdi
callq 0xfcc32
testb %al, %al
jne 0x3241a9
movq 0x88(%rsp), %rbp
incq %rbp
movq 0x18(%rsp), %rax
movq %rbx, 0x30(%rsp)
subq %rbx, %rax
movq %rax, 0x38(%rsp)
movl $0x1, %ebx
movzbl 0x98(%rsp), %eax
movl %eax, 0x24(%rsp)
movq $0x0, (%rsp)
movl %ebx, %edi
movq %r14, %rsi
movq %r12, %rdx
movq 0x40(%rsp), %rcx
movq 0x90(%rsp), %r8
movq %rbp, %r9
callq 0x323978
movq %rax, %r13
movq %rax, %rdi
callq 0x323f32
testq %r14, %r14
je 0x324030
testq %r12, %r12
jne 0x32419f
movq %rax, %rdi
movq 0x28(%rsp), %rsi
movl 0x24(%rsp), %edx
callq 0x1fc564
jmp 0x32404d
testq %r12, %r12
je 0x3241a4
movq %rax, %rdi
movq 0x28(%rsp), %rsi
movl 0x80(%rsp), %edx
callq 0x1febb2
movq %rax, %r15
cmpl $0x1, %ebx
jne 0x324063
addq 0x18(%rsp), %r15
cmpq 0x10(%rsp), %r15
ja 0x32407d
jmp 0x3240b8
movq %r13, %rdi
callq 0x323f42
movq 0x38(%rsp), %rcx
addq %r15, %rcx
addq %rax, %rcx
cmpq 0x10(%rsp), %rcx
jbe 0x3240ca
movq %r13, %rdi
callq 0x323e6e
incl %ebx
cmpl $0x1f5, %ebx            # imm = 0x1F5
jne 0x323fdf
leaq 0x94b8d(%rip), %rsi     # 0x3b8c27
movq 0xa0(%rsp), %rdi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x32418e
movq %r13, %rdi
callq 0x323e6e
movl $0x1, %ebx
jmp 0x32418e
movq %r15, %xmm1
movq 0x23809(%rip), %xmm4    # 0x3478e0
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movapd 0x2380d(%rip), %xmm5    # 0x3478f0
subpd %xmm5, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x23805(%rip), %xmm6    # 0x347900
mulsd %xmm6, %xmm0
movq %rax, %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm5, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
mulsd %xmm6, %xmm1
movq 0x18(%rsp), %xmm3
punpckldq %xmm4, %xmm3    # xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1]
subpd %xmm5, %xmm3
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
addsd %xmm3, %xmm2
mulsd %xmm6, %xmm2
movq 0x30(%rsp), %xmm7
punpckldq %xmm4, %xmm7    # xmm7 = xmm7[0],xmm4[0],xmm7[1],xmm4[1]
subpd %xmm5, %xmm7
movapd %xmm7, %xmm3
unpckhpd %xmm7, %xmm3            # xmm3 = xmm3[1],xmm7[1]
addsd %xmm7, %xmm3
mulsd %xmm6, %xmm3
movq 0x10(%rsp), %xmm7
punpckldq %xmm4, %xmm7    # xmm7 = xmm7[0],xmm4[0],xmm7[1],xmm4[1]
subpd %xmm5, %xmm7
movapd %xmm7, %xmm4
unpckhpd %xmm7, %xmm4            # xmm4 = xmm4[1],xmm7[1]
addsd %xmm7, %xmm4
mulsd %xmm6, %xmm4
leaq 0x94a4b(%rip), %rdi     # 0x3b8bc8
movl %ebx, %esi
movb $0x5, %al
callq 0x103d72
movq %r13, %rdi
callq 0x323e6e
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x94bfe
callq 0x94c37
callq 0x94bc5
nop