// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/sfx-linlcp.c
// Function: gt_plain_lcp13_kasai
unsigned int *gt_plain_lcp13_kasai(GtUword *maxlcp,
                                   const GtUchar *sequence,
                                   bool withspecial,
                                   GtUword partwidth,
                                   GtUword totallength,
                                   const unsigned int *suftab)
{
  unsigned int *lcptab, *inversesuftab, idx;
  GtUword pos, lcpvalue = 0;

  inversesuftab = gt_malloc(sizeof (*inversesuftab) * (totallength+1));
  gt_assert(totallength <= (GtUword) UINT_MAX);
  for (idx = 0; idx <= (unsigned int) totallength; idx++)
  {
    inversesuftab[suftab[idx]] = idx;
  }
  lcptab = gt_malloc(sizeof (*lcptab) * (totallength+1));
  lcptab[0] = 0;
  *maxlcp = 0;
  for (pos = 0; pos <= totallength; pos++)
  {
    GtUword fillpos = (GtUword) inversesuftab[pos];
    if (fillpos > 0 && fillpos < partwidth)
    {
      GtUword previousstart = (GtUword) suftab[fillpos-1],
              lastoffset = totallength - GT_MAX(pos,previousstart);

      while (lcpvalue < lastoffset)
      {
        GtUchar cc1, cc2;

        cc1 = sequence[pos+lcpvalue];
        cc2 = sequence[previousstart+lcpvalue];
        if (cc1 == cc2 && (!withspecial || GT_ISNOTSPECIAL(cc1)))
        {
          lcpvalue++;
        } else
        {
          break;
        }
      }
      gt_assert(lcpvalue <= (GtUword) UINT_MAX);
      lcptab[fillpos] = (unsigned int) lcpvalue;
      if (*maxlcp < lcpvalue)
      {
        *maxlcp = lcpvalue;
      }
    }
    if (lcpvalue > 0)
    {
      lcpvalue--;
    }
  }
  gt_free(inversesuftab);
  return lcptab;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0x4(,%r8,4), %r12
leaq 0x1caa58(%rip), %rsi    # 0x3b7c11
movq %r12, %rdi
movl $0x54, %edx
callq 0x104226
movq %rax, %r13
movq %r14, %rax
shrq $0x20, %rax
jne 0x1ed315
leal 0x1(%r14), %eax
cmpl $0x1, %eax
movl %r14d, %eax
adcl $0x1, %eax
xorl %ecx, %ecx
movl (%rbx,%rcx,4), %edx
movl %ecx, (%r13,%rdx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1ed1e5
leaq 0x1caa15(%rip), %rsi    # 0x3b7c11
movq %r12, %rdi
movl $0x5a, %edx
callq 0x104226
movq %rax, 0x10(%rsp)
movl $0x0, (%rax)
movq 0x8(%rsp), %rax
movq $0x0, (%rax)
movq $0x0, 0x20(%rsp)
movq 0x18(%rsp), %rax
xorl %edx, %edx
xorl %edi, %edi
movl (%r13,%rdx,4), %esi
testq %rsi, %rsi
sete %r8b
cmpq %r15, %rsi
setae %r9b
orb %r8b, %r9b
jne 0x1ed2c5
movq %r15, %rcx
movl -0x4(%rbx,%rsi,4), %r9d
cmpq %r9, %rdx
movq %r9, %r8
cmovaq %rdx, %r8
movq %r14, %r10
subq %r8, %r10
addq 0x18(%rsp), %r9
cmpq %r10, %rdi
movq %r10, %r8
cmovaq %rdi, %r8
cmpq %r10, %rdi
jae 0x1ed29a
movb (%rax,%rdi), %r15b
cmpb $-0x2, %r15b
setae %r12b
leaq 0x1(%rdi), %r11
cmpb (%r9,%rdi), %r15b
jne 0x1ed294
movq %r11, %rdi
andb %bpl, %r12b
je 0x1ed271
decq %r11
movq %r11, %r8
movq %r8, %rdi
shrq $0x20, %rdi
jne 0x1ed310
movq 0x10(%rsp), %rdi
movl %r8d, (%rdi,%rsi,4)
cmpq %r8, 0x20(%rsp)
movq %rcx, %r15
jae 0x1ed2c8
movq 0x8(%rsp), %rcx
movq %r8, (%rcx)
movq %r8, 0x20(%rsp)
jmp 0x1ed2c8
movq %rdi, %r8
subq $0x1, %r8
movl $0x0, %edi
cmovaeq %r8, %rdi
leaq 0x1(%rdx), %rsi
incq %rax
cmpq %r14, %rdx
movq %rsi, %rdx
jne 0x1ed232
leaq 0x1ca922(%rip), %rsi    # 0x3b7c11
movq %r13, %rdi
movl $0x7f, %edx
callq 0x1045eb
movq 0x10(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x78c7f
callq 0x78c48