// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/sfx-partssuf.c
// Function: gt_suftabparts_fit_memlimit
int gt_suftabparts_fit_memlimit(size_t estimatedspace,
                                GtUword maximumspace,
                                const GtBcktab *bcktab,
                                const GtFirstcodestab *fct,
                                const GtSfxmappedrangelist *sfxmrlist,
                                GtUword totallength,
                                unsigned int bitsforseqnumrelpos,
                                GtUword specialcharacters,
                                GtUword numofsuffixestosort,
                                bool suftabuint,
                                GtError *err)
{
  unsigned int parts;

  gt_error_check(err);
  for (parts = 1U; parts <= 500U; parts++)
  {
    uint64_t suftabsize;
    GtUword numofentries;
    GtSuftabparts *suftabparts = gt_suftabparts_new(parts,
                                                    bcktab,
                                                    (GtCodetype) 1,
                                                    (GtCodetype) 0,
                                                    fct,
                                                    sfxmrlist,
                                                    numofsuffixestosort,
                                                    specialcharacters + 1,
                                                    NULL);
    gt_assert(suftabparts != NULL);
    numofentries = gt_suftabparts_largest_width(suftabparts);
    if (bcktab != NULL)
    {
      gt_assert(fct == NULL);
      suftabsize = gt_suffixsortspace_requiredspace(numofentries,
                                                    totallength,
                                                    suftabuint);
    } else
    {
      gt_assert(fct != NULL);
      suftabsize = (uint64_t) gt_spmsuftab_requiredspace(numofentries,
                                                         totallength,
                                                         bitsforseqnumrelpos);
    }
    if (parts == 1U)
    {
      if (suftabsize + (uint64_t) estimatedspace <= (uint64_t) maximumspace)
      {
        gt_suftabparts_delete(suftabparts);
        return (int) parts;
      }
    } else
    {
      GtUword largest
        = gt_suftabparts_largestsizemappedpartwise(suftabparts);
      GtUword size_mapped = gt_Sfxmappedrangelist_size_entire(sfxmrlist);

      if (suftabsize
          + (uint64_t) largest
          + (uint64_t) estimatedspace
          - (uint64_t) size_mapped <= (uint64_t) 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_delete(suftabparts);
        return (int) parts;
      }
    }
    gt_suftabparts_delete(suftabparts);
  }
  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 $0x78, %rsp
movq %r9, %r13
movq %r8, 0x38(%rsp)
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f96ec
callq 0x101a9a
testb %al, %al
jne 0x1f999f
movq 0xb8(%rsp), %rax
incq %rax
movq %rax, 0x48(%rsp)
movsd 0x18(%rsp), %xmm0
movsd 0x1571d6(%rip), %xmm1   # 0x3508e0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1571db(%rip), %xmm2   # 0x3508f0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movsd 0x1571d3(%rip), %xmm4   # 0x350900
mulsd %xmm4, %xmm3
movapd %xmm3, 0x60(%rsp)
movsd 0x10(%rsp), %xmm0
unpcklps %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 0xc8(%rsp), %eax
movl %eax, 0x24(%rsp)
movl $0x1, %r15d
movq %rbp, 0x30(%rsp)
movq %r12, 0x40(%rsp)
movq %r13, 0x28(%rsp)
subq $0x8, %rsp
movl $0x1, %edx
movl %r15d, %edi
movq %r12, %rsi
xorl %ecx, %ecx
movq %rbp, %r8
movq 0x40(%rsp), %r9
pushq $0x0
pushq 0x58(%rsp)
pushq 0xd8(%rsp)
callq 0x1f905f
addq $0x20, %rsp
testq %rax, %rax
je 0x1f9990
movq %rax, %r14
movq 0x28(%rax), %rdi
testq %r12, %r12
je 0x1f97d6
testq %rbp, %rbp
jne 0x1f9995
movq %r13, %rsi
movl 0x24(%rsp), %edx
callq 0x205c70
jmp 0x1f97ee
testq %rbp, %rbp
je 0x1f999a
movq %r13, %rsi
movl 0xb0(%rsp), %edx
callq 0x20834e
movq %rax, %rbx
cmpl $0x1, %r15d
jne 0x1f981c
movq %r13, %rbp
addq 0x18(%rsp), %rbx
cmpq 0x10(%rsp), %rbx
seta %bl
movl $0x1, %eax
movl 0xc(%rsp), %ecx
cmovbel %eax, %ecx
movl %ecx, 0xc(%rsp)
jmp 0x1f990f
movq 0x20(%r14), %rbp
movq 0x38(%rsp), %rdi
callq 0x1f8d23
movq 0x18(%rsp), %rcx
leaq (%rbx,%rcx), %r13
addq %rbp, %r13
subq %rax, %r13
cmpq 0x10(%rsp), %r13
ja 0x1f98fc
movq %rbx, %xmm1
movq 0x15708f(%rip), %xmm3   # 0x3508e0
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x157093(%rip), %xmm4   # 0x3508f0
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x15708b(%rip), %xmm5   # 0x350900
mulsd %xmm5, %xmm0
movq %rbp, %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
movq %rax, %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm4, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
mulsd %xmm5, %xmm3
leaq 0x1c8980(%rip), %rdi    # 0x3c223a
movl %r15d, %esi
movapd 0x60(%rsp), %xmm2
movapd 0x50(%rsp), %xmm4
movb $0x5, %al
callq 0x108e02
movq (%r14), %rdi
leaq 0x1c85a8(%rip), %rbx    # 0x3c1e82
movq %rbx, %rsi
movl $0x17b, %edx            # imm = 0x17B
callq 0x109670
movq %r14, %rdi
movq %rbx, %rsi
movl $0x17c, %edx            # imm = 0x17C
callq 0x109670
movl %r15d, 0xc(%rsp)
movb $0x1, %bl
cmpq 0x10(%rsp), %r13
movq 0x40(%rsp), %r12
jbe 0x1f993b
movq 0x28(%rsp), %rbp
movq (%r14), %rdi
leaq 0x1c8569(%rip), %r13    # 0x3c1e82
movq %r13, %rsi
movl $0x17b, %edx            # imm = 0x17B
callq 0x109670
movq %r14, %rdi
movq %r13, %rsi
movl $0x17c, %edx            # imm = 0x17C
callq 0x109670
movq %rbp, %r13
jmp 0x1f9942
xorl %ebx, %ebx
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %rbp
testb %bl, %bl
je 0x1f997d
incl %r15d
cmpl $0x1f5, %r15d           # imm = 0x1F5
jne 0x1f977b
leaq 0x1c8937(%rip), %rsi    # 0x3c2299
movq 0xd0(%rsp), %rdi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1f9981
movl 0xc(%rsp), %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7bc5b
callq 0x7bbe9
callq 0x7bc22
callq 0x7bbb0