// File: /workspace/github_c_makefile_star2_O2/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, 0x20(%rsp)
movl %edx, %ebp
movq %rsi, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0x4(,%r8,4), %r12
leaq 0x1ba6fe(%rip), %rsi    # 0x358071
pushq $0x54
popq %rdx
movq %r12, %rdi
callq 0x93160
movq %rax, %r13
movq %r14, %rax
shrq $0x20, %rax
jne 0x19dadf
leal 0x1(%r14), %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x19d9a6
movl (%rbx,%rcx,4), %edx
movl %ecx, (%r13,%rdx,4)
incq %rcx
jmp 0x19d994
leaq 0x1ba6c4(%rip), %rsi    # 0x358071
pushq $0x5a
popq %rdx
movq %r12, %rdi
callq 0x93160
movq %rax, 0x10(%rsp)
andl $0x0, (%rax)
movq 0x8(%rsp), %rax
andq $0x0, (%rax)
xorl %ecx, %ecx
movq 0x18(%rsp), %rax
xorl %esi, %esi
xorl %edx, %edx
cmpq %r14, %rdx
ja 0x19da83
movl (%r13,%rdx,4), %edi
testq %rdi, %rdi
sete %r8b
cmpq 0x20(%rsp), %rdi
setae %r9b
orb %r8b, %r9b
jne 0x19da68
movl -0x4(%rbx,%rdi,4), %r9d
cmpq %r9, %rdx
movq %r9, %r8
cmovaq %rdx, %r8
movq %r14, %r10
subq %r8, %r10
addq 0x18(%rsp), %r9
cmpq %r10, %rsi
movq %r10, %r8
cmovaq %rsi, %r8
cmpq %r10, %rsi
jae 0x19da44
movb (%rax,%rsi), %r15b
cmpb $-0x2, %r15b
setae %r12b
leaq 0x1(%rsi), %r11
cmpb (%r9,%rsi), %r15b
jne 0x19da3e
movq %r11, %rsi
andb %bpl, %r12b
je 0x19da1b
decq %r11
movq %r11, %r8
movq %r8, %rsi
shrq $0x20, %rsi
jne 0x19daa9
movq 0x10(%rsp), %rsi
movl %r8d, (%rsi,%rdi,4)
cmpq %r8, %rcx
jae 0x19da6b
movq 0x8(%rsp), %rcx
movq %r8, (%rcx)
movq %r8, %rcx
jmp 0x19da6b
movq %rsi, %r8
subq $0x1, %r8
movl $0x0, %esi
cmovaeq %r8, %rsi
incq %rdx
incq %rax
jmp 0x19d9d4
leaq 0x1ba5e7(%rip), %rsi    # 0x358071
pushq $0x7f
popq %rdx
movq %r13, %rdi
callq 0x936f9
movq 0x10(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x29a4b8(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x147559(%rip), %rsi    # 0x2e5013
leaq 0x1ba5fe(%rip), %rdx    # 0x3580bf
leaq 0x1ba5e2(%rip), %rcx    # 0x3580aa
leaq 0x1ba5a2(%rip), %r8     # 0x358071
pushq $0x73
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x29a482(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x147523(%rip), %rsi    # 0x2e5013
leaq 0x1ba591(%rip), %rdx    # 0x358088
leaq 0x1ba5ac(%rip), %rcx    # 0x3580aa
leaq 0x1ba56c(%rip), %r8     # 0x358071
pushq $0x55
jmp 0x19dad1