// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/sfx-bentsedg.c
// Function: bentsedgresources_new
static GtBentsedgresources *bentsedgresources_new(
                                   GtSuffixsortspace *suffixsortspace,
                                   const GtEncseq *encseq,
                                   GtReadmode readmode,
                                   unsigned int prefixlength,
                                   const GtBcktab *bcktab,
                                   unsigned int sortmaxdepth,
                                   const Sfxstrategy *sfxstrategy,
                                   bool withlcps)
{
  GtBentsedgresources *bsr = (GtBentsedgresources *) gt_malloc(sizeof *bsr);

  bsr->encseq = encseq;
  bsr->readmode = readmode;
  bsr->totallength = gt_encseq_total_length(encseq);
  bsr->sfxstrategy = sfxstrategy;
  bsr->sssp = suffixsortspace;
  bsr->rsi = NULL;
  bsr->fwd = GT_ISDIRREVERSE(bsr->readmode) ? false : true;
  bsr->complement = GT_ISDIRCOMPLEMENT(bsr->readmode) ? true : false;
  bsr->tableoflcpvalues = NULL;
  bsr->prefixlength = prefixlength;
  bsr->esr1 = gt_encseq_create_reader_with_readmode(encseq, readmode, 0);
  bsr->esr2 = gt_encseq_create_reader_with_readmode(encseq, readmode, 0);
  bsr->radixsortminwidth = gt_radixsort_str_minwidth();
  bsr->radixsortmaxwidth = 0;
  if (gt_encseq_accesstype_get(bsr->encseq) == GT_ACCESS_TYPE_EQUALLENGTH)
  {
    bsr->twobitencoding = gt_encseq_twobitencoding_export(bsr->encseq);
  } else
  {
    bsr->twobitencoding = NULL;
  }
  if (sortmaxdepth > 0)
  {
    if (sortmaxdepth > prefixlength)
    {
      bsr->srs_maxremain = sortmaxdepth - (GtUword) prefixlength;
    } else
    {
      bsr->srs_maxremain = 0;
    }
  } else
  {
    GtUword longestnsp = gt_encseq_lengthoflongestnonspecial(encseq);
    if (longestnsp > (GtUword) prefixlength)
    {
      bsr->srs_maxremain = longestnsp - prefixlength;
    } else
    {
      bsr->srs_maxremain = 0;
    }
  }
  bsr->shortreadsort_maxwidth
    = gt_shortreadsort_maxwidth(false,
                                bsr->srs_maxremain,
                                gt_size_of_sort_workspace (sfxstrategy));
  GT_INITARRAY(&bsr->mkvauxstack,GtMKVstack);
  bsr->countingsortinfo = NULL;
  bsr->medianinfospace = NULL;
  bsr->blindtrie = NULL;
  bsr->equalwithprevious = NULL;
  bsr->srsw = NULL;
  if (!sfxstrategy->cmpcharbychar)
  {
    int idx;
    const bool withmediumsizelcps = (sortmaxdepth > 0 && !withlcps)
                                    ? true : false;
    if (sortmaxdepth == 0 ||
        gt_encseq_has_twobitencoding_stoppos_support(encseq))
    {
      bsr->srsw = gt_shortreadsort_new(0,bsr->srs_maxremain,readmode,false,
                                       withmediumsizelcps);
    }
    for (idx = 0; idx < GT_UNITSIN2BITENC; idx++)
    {
      bsr->leftlcpdist[idx] = bsr->rightlcpdist[idx] = 0;
    }
    bsr->countingsortinfo = gt_malloc(sizeof (*bsr->countingsortinfo) *
                                      sfxstrategy->maxcountingsort);
    if (sfxstrategy->maxwidthrealmedian >= MINMEDIANOF9WIDTH)
    {
      bsr->medianinfospace = gt_malloc(sizeof (*bsr->medianinfospace) *
                                       sfxstrategy->maxwidthrealmedian);
    } else
    {
      bsr->medianinfospace = NULL;
    }
  }
  bsr->blindtrie = gt_blindtrie_new(bsr->sssp,
                                    sfxstrategy->maxbltriesort,
                                    0, /* the nodenumberincrement */
                                    encseq,
                                    sfxstrategy->cmpcharbychar,
                                    bsr->esr1,
                                    bsr->esr2,
                                    readmode);
  if (sortmaxdepth > 0 && bsr->sfxstrategy->maxinsertionsort >= 2UL)
  {
    GtUword idx;

    bsr->equalwithprevious = gt_malloc(sizeof (*bsr->equalwithprevious) *
                                       bsr->sfxstrategy->maxinsertionsort);
    for (idx=0; idx < bsr->sfxstrategy->maxinsertionsort; idx++)
    {
      bsr->equalwithprevious[idx] = false;
    }
  }
  bsr->sortmaxdepth = sortmaxdepth;
  bsr->processunsortedsuffixrange = NULL;
  bsr->processunsortedsuffixrangeinfo = NULL;
  bsr->countinsertionsort = 0;
  bsr->counttqsort = 0;
  bsr->countcountingsort = 0;
  bsr->countbltriesort = 0;
  bsr->countshortreadsort = 0;
  bsr->countradixsort = 0;
  if (bcktab != NULL &&
      sfxstrategy->withradixsort &&
      gt_encseq_accesstype_get(encseq) == GT_ACCESS_TYPE_EQUALLENGTH &&
      readmode == GT_READMODE_FORWARD)
  {
    bsr->rsi = gt_radixsort_str_new(bsr->twobitencoding,
                                    gt_encseq_is_mirrored(encseq)
                                      ? GT_DIV2(bsr->totallength - 1)
                                      : bsr->totallength,
                                    1 + gt_encseq_equallength(encseq),
                                    gt_bcktab_nonspecialsmaxsize(bcktab));
    bsr->radixsortmaxwidth = gt_radixsort_str_maxwidth(bsr->rsi);
  }
  return bsr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, 0x4(%rsp)
movq %r8, 0x10(%rsp)
movl %ecx, %r14d
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %r13
movq 0x50(%rsp), %rbp
leaq 0x1d23e2(%rip), %rsi    # 0x3bed40
movl $0x2f8, %edi            # imm = 0x2F8
movl $0x549, %edx            # imm = 0x549
callq 0x1092b2
movq %rax, %rbx
movq %r15, (%rax)
movl %r12d, 0x18(%rax)
movq %r15, %rdi
callq 0xec1d8
movq %rax, 0xb0(%rbx)
movq %rbp, 0x40(%rbx)
movq %r13, 0x48(%rbx)
xorl %r13d, %r13d
movq %r13, 0x2f0(%rbx)
movl 0x18(%rbx), %eax
movl %eax, %ecx
andl $-0x3, %ecx
cmpl $0x1, %ecx
setne 0x1c(%rbx)
andl $-0x2, %eax
cmpl $0x2, %eax
sete 0x1d(%rbx)
movq %r13, 0x38(%rbx)
movl %r14d, 0x64(%rbx)
movq %r15, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0xed76d
movq %rax, 0x8(%rbx)
movq %r15, %rdi
movq %r12, 0x8(%rsp)
movl %r12d, %esi
xorl %edx, %edx
callq 0xed76d
movq %rax, 0x10(%rbx)
callq 0x32ac3e
movq %rax, 0xa0(%rbx)
movq %r13, 0xa8(%rbx)
movq (%rbx), %rdi
callq 0xfac0f
cmpl $0x2, %eax
jne 0x1eca0b
movq (%rbx), %rdi
callq 0xf1c71
movq %rax, %r13
movq %r13, 0x2e8(%rbx)
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x1eca2a
cmpl %r14d, %eax
jbe 0x1eca41
movl %eax, %r13d
movl %r14d, %eax
subq %rax, %r13
jmp 0x1eca44
movq %r15, %rdi
callq 0xf0ccd
movl %r14d, %ecx
xorl %r13d, %r13d
subq %rcx, %rax
cmovaeq %rax, %r13
jmp 0x1eca44
xorl %r13d, %r13d
movq %r13, 0x98(%rbx)
movq 0x50(%rsp), %rbp
movq %rbp, %rdi
callq 0x1ec770
xorl %r14d, %r14d
xorl %edi, %edi
movq %r13, %rsi
movq %rax, %rdx
callq 0x1fe965
movq %rax, 0xb8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbx)
movq %r14, 0x30(%rbx)
movups %xmm0, 0x2c0(%rbx)
movups %xmm0, 0x2d0(%rbx)
movq %r14, 0x2e0(%rbx)
cmpb $0x0, 0x2c(%rbp)
movq 0x10(%rsp), %r13
movl 0x4(%rsp), %r12d
jne 0x1ecb5e
testl %r12d, %r12d
setne %r14b
je 0x1ecab8
movq %r15, %rdi
callq 0xed937
testb %al, %al
je 0x1ecae1
movb 0x58(%rsp), %al
xorb $0x1, %al
andb %al, %r14b
movq 0x98(%rbx), %rsi
movzbl %r14b, %r8d
xorl %edi, %edi
movq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x1fe9ca
movq %rax, 0x2e0(%rbx)
movq %rbx, %rdi
addq $0xc0, %rdi
xorl %r14d, %r14d
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x173a0
xorps %xmm0, %xmm0
movups %xmm0, 0x1c0(%rbx,%r14,8)
addq $0x2, %r14
cmpq $0x20, %r14
jne 0x1ecafd
movq 0x50(%rsp), %r14
movq 0x18(%r14), %rdi
shlq $0x4, %rdi
leaq 0x1d221c(%rip), %rsi    # 0x3bed40
movl $0x58e, %edx            # imm = 0x58E
callq 0x1092b2
movq %rax, 0x2d8(%rbx)
movq (%r14), %rdi
cmpq $0x1f, %rdi
jb 0x1ecb55
shlq $0x5, %rdi
leaq 0x1d21f7(%rip), %rsi    # 0x3bed40
movl $0x592, %edx            # imm = 0x592
callq 0x1092b2
jmp 0x1ecb57
xorl %eax, %eax
movq %rax, 0x2d0(%rbx)
movq 0x48(%rbx), %rdi
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rsi
movzbl 0x2c(%rax), %r8d
movq 0x8(%rbx), %r9
xorl %edx, %edx
movq %r15, %rcx
pushq 0x8(%rsp)
pushq 0x10(%rbx)
callq 0x1ef774
addq $0x10, %rsp
movq %rax, 0x2c8(%rbx)
testl %r12d, %r12d
je 0x1ecbd2
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rdi
cmpq $0x2, %rdi
jb 0x1ecbd2
leaq 0x1d2196(%rip), %rsi    # 0x3bed40
movl $0x5a5, %edx            # imm = 0x5A5
callq 0x1092b2
movq %rax, 0x2c0(%rbx)
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
je 0x1ecbd2
movq %rax, %rdi
xorl %esi, %esi
callq 0x173a0
movl %r12d, 0x60(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x68(%rbx)
movups %xmm0, 0x78(%rbx)
movups %xmm0, 0x88(%rbx)
testq %r13, %r13
je 0x1ecc6e
movq 0x50(%rsp), %rax
cmpb $0x1, 0x37(%rax)
jne 0x1ecc6e
movq %r15, %rdi
callq 0xfac0f
xorl $0x2, %eax
movq 0x8(%rsp), %rcx
orl %eax, %ecx
jne 0x1ecc6e
movq 0x2e8(%rbx), %r14
movq %r15, %rdi
callq 0xfac80
movq 0xb0(%rbx), %rcx
leaq -0x1(%rcx), %r12
shrq %r12
testb %al, %al
cmoveq %rcx, %r12
movq %r15, %rdi
callq 0xfac12
leaq 0x1(%rax), %r15
movq %r13, %rdi
callq 0x1946c7
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x32aa38
movq %rax, 0x2f0(%rbx)
movq %rax, %rdi
callq 0x32ac44
movq %rax, 0xa8(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq