// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %r9, 0x20(%rsp)
movq %r8, 0x28(%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x1a13fe
callq 0x89eb7
testb %al, %al
jne 0x1a167a
movq 0x78(%rsp), %rax
incq %rax
movq %rax, 0x30(%rsp)
pushq $0x1
popq %rbx
movzbl 0x88(%rsp), %eax
movl %eax, 0x1c(%rsp)
cmpl $0x1f5, %ebx            # imm = 0x1F5
je 0x1a14e3
subq $0x8, %rsp
movl %ebx, %edi
movq %r15, %rsi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
movq %r14, %r8
movq 0x30(%rsp), %r9
pushq $0x0
pushq 0x40(%rsp)
pushq 0x98(%rsp)
callq 0x1a0aa6
addq $0x20, %rsp
testq %rax, %rax
je 0x1a15e6
movq %rax, %r12
movq 0x28(%rax), %rdi
testq %r15, %r15
je 0x1a1480
testq %r14, %r14
jne 0x1a1614
movq 0x20(%rsp), %rsi
movl 0x1c(%rsp), %edx
callq 0x1af274
jmp 0x1a1497
testq %r14, %r14
je 0x1a1642
movq 0x20(%rsp), %rsi
movl 0x70(%rsp), %edx
callq 0x1b25ee
movq %rax, %r13
cmpl $0x1, %ebx
jne 0x1a14b0
addq 0x10(%rsp), %r13
cmpq 0x8(%rsp), %r13
ja 0x1a14d4
jmp 0x1a15ca
movq 0x20(%r12), %rbp
movq 0x28(%rsp), %rdi
callq 0x1a067e
movq 0x10(%rsp), %rcx
addq %r13, %rcx
addq %rbp, %rcx
subq %rax, %rcx
cmpq 0x8(%rsp), %rcx
jbe 0x1a1505
movq %r12, %rdi
callq 0x1a11bd
incl %ebx
jmp 0x1a141a
leaq 0x1b7b9d(%rip), %rsi    # 0x359087
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
jmp 0x1a15d4
movq %r13, %xmm1
movq 0x1463ce(%rip), %xmm4   # 0x2e78e0
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movapd 0x1463d2(%rip), %xmm5   # 0x2e78f0
subpd %xmm5, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x1463ca(%rip), %xmm6   # 0x2e7900
mulsd %xmm6, %xmm0
movq %rbp, %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 0x10(%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 %rax, %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 0x8(%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 0x1b7a71(%rip), %rdi    # 0x359028
movl %ebx, %esi
movb $0x5, %al
callq 0x92a82
movq %r12, %rdi
callq 0x1a11bd
jmp 0x1a15d5
movq %r12, %rdi
callq 0x1a11bd
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x29697b(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x143a1c(%rip), %rsi    # 0x2e5013
leaq 0x1b94af(%rip), %rdx    # 0x35aaad
leaq 0x1b79ef(%rip), %rcx    # 0x358ff4
leaq 0x1b7664(%rip), %r8     # 0x358c70
movl $0x1dd, %r9d            # imm = 0x1DD
jmp 0x1a166e
movq 0x29694d(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1439ee(%rip), %rsi    # 0x2e5013
leaq 0x1b79e4(%rip), %rdx    # 0x359010
leaq 0x1b79c1(%rip), %rcx    # 0x358ff4
leaq 0x1b7636(%rip), %r8     # 0x358c70
movl $0x1e1, %r9d            # imm = 0x1E1
jmp 0x1a166e
movq 0x29691f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1439c0(%rip), %rsi    # 0x2e5013
leaq 0x1b79c2(%rip), %rdx    # 0x35901c
leaq 0x1b7993(%rip), %rcx    # 0x358ff4
leaq 0x1b7608(%rip), %r8     # 0x358c70
movl $0x1e7, %r9d            # imm = 0x1E7
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x2968e7(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x143988(%rip), %rsi    # 0x2e5013
leaq 0x143b2d(%rip), %rdx    # 0x2e51bf
leaq 0x1b795b(%rip), %rcx    # 0x358ff4
leaq 0x1b75d0(%rip), %r8     # 0x358c70
movl $0x1cf, %r9d            # imm = 0x1CF
jmp 0x1a166e