// File: /workspace/github_c_makefile_star2_O2/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 0x1a067e
movq %rax, %rbx
testq %r15, %r15
je 0x2c5649
movq %r15, %rdi
callq 0x89eb7
testb %al, %al
jne 0x2c5895
movq 0x88(%rsp), %rbp
incq %rbp
movq 0x18(%rsp), %rax
movq %rbx, 0x30(%rsp)
subq %rbx, %rax
movq %rax, 0x38(%rsp)
pushq $0x1
popq %rbx
movzbl 0x98(%rsp), %eax
movl %eax, 0x24(%rsp)
cmpl $0x1f5, %ebx            # imm = 0x1F5
je 0x2c572b
andq $0x0, (%rsp)
movl %ebx, %edi
movq %r14, %rsi
movq %r12, %rdx
movq 0x40(%rsp), %rcx
movq 0x90(%rsp), %r8
movq %rbp, %r9
callq 0x2c4da5
movq %rax, %r13
movq %rax, %rdi
callq 0x2c5531
testq %r14, %r14
je 0x2c56cf
testq %r12, %r12
jne 0x2c582f
movq %rax, %rdi
movq 0x28(%rsp), %rsi
movl 0x24(%rsp), %edx
callq 0x1af274
jmp 0x2c56ec
testq %r12, %r12
je 0x2c585d
movq %rax, %rdi
movq 0x28(%rsp), %rsi
movl 0x80(%rsp), %edx
callq 0x1b25ee
movq %rax, %r15
cmpl $0x1, %ebx
jne 0x2c5702
addq 0x18(%rsp), %r15
cmpq 0x10(%rsp), %r15
ja 0x2c571c
jmp 0x2c574a
movq %r13, %rdi
callq 0x2c5574
movq 0x38(%rsp), %rcx
addq %r15, %rcx
addq %rax, %rcx
cmpq 0x10(%rsp), %rcx
jbe 0x2c575a
movq %r13, %rdi
callq 0x2c53b1
incl %ebx
jmp 0x2c5675
leaq 0x93955(%rip), %rsi     # 0x359087
movq 0xa0(%rsp), %rdi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
jmp 0x2c5754
movq %r13, %rdi
callq 0x2c53b1
pushq $0x1
popq %rbx
jmp 0x2c581e
movq %r15, %xmm1
movq 0x22179(%rip), %xmm4    # 0x2e78e0
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movapd 0x2217d(%rip), %xmm5    # 0x2e78f0
subpd %xmm5, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x22175(%rip), %xmm6    # 0x2e7900
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 0x9381b(%rip), %rdi     # 0x359028
movl %ebx, %esi
movb $0x5, %al
callq 0x92a82
movq %r13, %rdi
callq 0x2c53b1
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x172732(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7d3(%rip), %rsi     # 0x2e5013
leaq 0x937c9(%rip), %rdx     # 0x359010
leaq 0xbf6c4(%rip), %rcx     # 0x384f12
leaq 0xbf44f(%rip), %r8      # 0x384ca4
movl $0x1b3, %r9d            # imm = 0x1B3
jmp 0x2c5889
movq 0x172704(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f7a5(%rip), %rsi     # 0x2e5013
leaq 0x937a7(%rip), %rdx     # 0x35901c
leaq 0xbf696(%rip), %rcx     # 0x384f12
leaq 0xbf421(%rip), %r8      # 0x384ca4
movl $0x1b9, %r9d            # imm = 0x1B9
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x1726cc(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1f76d(%rip), %rsi     # 0x2e5013
leaq 0x1f912(%rip), %rdx     # 0x2e51bf
leaq 0xbf65e(%rip), %rcx     # 0x384f12
leaq 0xbf3e9(%rip), %r8      # 0x384ca4
movl $0x1a2, %r9d            # imm = 0x1A2
jmp 0x2c5889
nop