// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, 0x10(%rsp)
leaq 0x4(,%r8,4), %rdi
leaq 0x1ca8b7(%rip), %rsi    # 0x3c126a
movq %rdi, 0x8(%rsp)
movl $0x54, %edx
callq 0x1092b2
movq %rax, %r13
movq %r14, %rax
shrq $0x20, %rax
jne 0x1f6ae7
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 0x1f69e1
leaq 0x1ca872(%rip), %rsi    # 0x3c126a
movq 0x8(%rsp), %rdi
movl $0x5a, %edx
callq 0x1092b2
movq %rax, 0x8(%rsp)
movl $0x0, (%rax)
movq 0x10(%rsp), %r11
movq $0x0, (%r11)
xorl %eax, %eax
xorb $0x1, %bpl
xorl %ecx, %ecx
movl (%r13,%rax,4), %edx
testq %rdx, %rdx
sete %sil
cmpq %r15, %rdx
setae %dil
orb %sil, %dil
jne 0x1f6a9d
movl -0x4(%rbx,%rdx,4), %esi
cmpq %rsi, %rax
movq %rsi, %r8
cmovaq %rax, %r8
movq %r14, %rdi
subq %r8, %rdi
addq %r12, %rsi
leaq (%r12,%rax), %r8
cmpq %rdi, %rcx
jae 0x1f6a84
movb (%r8,%rcx), %r9b
cmpb (%rsi,%rcx), %r9b
sete %r10b
cmpb $-0x2, %r9b
setb %r9b
orb %bpl, %r9b
andb %r10b, %r9b
movzbl %r9b, %r9d
addq %r9, %rcx
testb %r9b, %r9b
jne 0x1f6a59
movq %rcx, %rsi
shrq $0x20, %rsi
jne 0x1f6ae2
movq 0x8(%rsp), %rsi
movl %ecx, (%rsi,%rdx,4)
cmpq %rcx, (%r11)
jae 0x1f6a9d
movq %rcx, (%r11)
subq $0x1, %rcx
movl $0x0, %edx
cmovbq %rdx, %rcx
leaq 0x1(%rax), %rdx
cmpq %r14, %rax
movq %rdx, %rax
jne 0x1f6a26
leaq 0x1ca7a9(%rip), %rsi    # 0x3c126a
movq %r13, %rdi
movl $0x7f, %edx
callq 0x109670
movq 0x8(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7a97e
callq 0x7a947