// File: /workspace/github_c_makefile_star2_O1/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 $0x88, %rsp
movq %r9, %r13
movq %r8, %rbp
movq %rcx, %r12
movq %rdx, 0x48(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, 0x30(%rsp)
movq 0xe0(%rsp), %rbx
movq %r8, %rdi
callq 0x1f8d23
movq %rax, %r14
testq %rbx, %rbx
je 0x32e30c
movq %rbx, %rdi
callq 0x101a9a
testb %al, %al
jne 0x32e588
movq 0xc8(%rsp), %rax
incq %rax
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rax
movq %rax, %rcx
subq %r14, %rcx
movq %rcx, 0x38(%rsp)
movq %rax, %xmm0
movq 0x225a7(%rip), %xmm1    # 0x3508e0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x225ab(%rip), %xmm2    # 0x3508f0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movsd 0x225a3(%rip), %xmm4    # 0x350900
mulsd %xmm4, %xmm3
movapd %xmm3, 0x70(%rsp)
movq %r14, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
mulsd %xmm4, %xmm3
movapd %xmm3, 0x60(%rsp)
movq 0x18(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd %xmm4, %xmm1
movapd %xmm1, 0x50(%rsp)
movzbl 0xd8(%rsp), %eax
movl %eax, 0x24(%rsp)
movl $0x1, %r14d
movq %r12, 0x28(%rsp)
movq $0x0, (%rsp)
movl %r14d, %edi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq 0xd0(%rsp), %r8
movq 0x40(%rsp), %r9
callq 0x32dd44
movq %rax, %r15
movq %rax, %rdi
callq 0x32e28c
testq %rbx, %rbx
je 0x32e41a
testq %r12, %r12
jne 0x32e57e
movq %rax, %rdi
movq %r13, %rsi
movl 0x24(%rsp), %edx
callq 0x205c70
jmp 0x32e435
testq %r12, %r12
je 0x32e583
movq %rax, %rdi
movq %r13, %rsi
movl 0xc0(%rsp), %edx
callq 0x20834e
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0x32e460
addq 0x30(%rsp), %rbx
cmpq 0x18(%rsp), %rbx
seta %bl
movl $0x1, %eax
movl 0x14(%rsp), %ecx
cmovbel %eax, %ecx
movl %ecx, 0x14(%rsp)
jmp 0x32e51b
movq %rbp, %r12
movq %r13, %rbp
movq %r15, %rdi
callq 0x32e29c
movq 0x38(%rsp), %rcx
leaq (%rcx,%rbx), %r13
addq %rax, %r13
cmpq 0x18(%rsp), %r13
ja 0x32e507
movq %rbx, %xmm1
movq 0x2244e(%rip), %xmm3    # 0x3508e0
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x22452(%rip), %xmm4    # 0x3508f0
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x2244a(%rip), %xmm5    # 0x350900
mulsd %xmm5, %xmm0
movq %rax, %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm4, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
mulsd %xmm5, %xmm1
leaq 0x93d5c(%rip), %rdi     # 0x3c223a
movl %r14d, %esi
movapd 0x70(%rsp), %xmm2
movapd 0x60(%rsp), %xmm3
movapd 0x50(%rsp), %xmm4
movb $0x5, %al
callq 0x108e02
movq %r15, %rdi
callq 0x32e1c8
movl %r14d, 0x14(%rsp)
movb $0x1, %bl
cmpq 0x18(%rsp), %r13
jbe 0x32e525
movq %rbp, %r13
movq %r12, %rbp
movq 0x28(%rsp), %r12
movq %r15, %rdi
callq 0x32e1c8
jmp 0x32e532
xorl %ebx, %ebx
movq %rbp, %r13
movq %r12, %rbp
movq 0x28(%rsp), %r12
testb %bl, %bl
je 0x32e568
incl %r14d
cmpl $0x1f5, %r14d           # imm = 0x1F5
jne 0x32e3c5
leaq 0x93d4c(%rip), %rsi     # 0x3c2299
movq 0xe0(%rsp), %rdi
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x32e56c
movl 0x14(%rsp), %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x96bf5
callq 0x96c2e
callq 0x96bbc
nopl (%rax)