// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x88, %rsp
movb %dl, %al
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
andb $0x1, %al
movb %al, 0x77(%rsp)
movq %rcx, 0x68(%rsp)
movq %r8, 0x60(%rsp)
movq %r9, 0x58(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x60(%rsp), %rdi
addq $0x1, %rdi
shlq $0x2, %rdi
leaq 0x2c2cea(%rip), %rsi    # 0x58ab82
movl $0x54, %edx
callq 0xe80f0
movq %rax, 0x48(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, 0x60(%rsp)
jbe 0x2c7eeb
movq 0x3740e6(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x24e14f(%rip), %rsi    # 0x516013
leaq 0x2c2cce(%rip), %rdx    # 0x58ab99
leaq 0x2c2ce9(%rip), %rcx    # 0x58abbb
leaq 0x2c2ca9(%rip), %r8     # 0x58ab82
movl $0x55, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2c7eed
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
movq 0x60(%rsp), %rcx
cmpl %ecx, %eax
ja 0x2c7f27
movl 0x44(%rsp), %edx
movq 0x48(%rsp), %rax
movq 0x58(%rsp), %rcx
movl 0x44(%rsp), %esi
movl (%rcx,%rsi,4), %ecx
movl %edx, (%rax,%rcx,4)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x2c7ef5
movq 0x60(%rsp), %rdi
addq $0x1, %rdi
shlq $0x2, %rdi
leaq 0x2c2c47(%rip), %rsi    # 0x58ab82
movl $0x5a, %edx
callq 0xe80f0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movl $0x0, (%rax)
movq 0x80(%rsp), %rax
movq $0x0, (%rax)
movq $0x0, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpq 0x60(%rsp), %rax
ja 0x2c8114
movq 0x48(%rsp), %rax
movq 0x38(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jbe 0x2c80e9
movq 0x28(%rsp), %rax
cmpq 0x68(%rsp), %rax
jae 0x2c80e9
movq 0x58(%rsp), %rax
movq 0x28(%rsp), %rcx
subq $0x1, %rcx
movl (%rax,%rcx,4), %eax
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rax
cmpq 0x20(%rsp), %rax
jbe 0x2c7fe2
movq 0x38(%rsp), %rax
movq %rax, (%rsp)
jmp 0x2c7feb
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
movq 0x8(%rsp), %rax
movq (%rsp), %rcx
subq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
cmpq 0x18(%rsp), %rax
jae 0x2c8069
movq 0x78(%rsp), %rax
movq 0x38(%rsp), %rcx
addq 0x30(%rsp), %rcx
movb (%rax,%rcx), %al
movb %al, 0x17(%rsp)
movq 0x78(%rsp), %rax
movq 0x20(%rsp), %rcx
addq 0x30(%rsp), %rcx
movb (%rax,%rcx), %al
movb %al, 0x16(%rsp)
movzbl 0x17(%rsp), %eax
movzbl 0x16(%rsp), %ecx
cmpl %ecx, %eax
jne 0x2c8065
testb $0x1, 0x77(%rsp)
je 0x2c8055
movzbl 0x17(%rsp), %eax
cmpl $0xfe, %eax
jge 0x2c8065
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x2c8067
jmp 0x2c8069
jmp 0x2c7ffc
jmp 0x2c806b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, 0x30(%rsp)
jbe 0x2c80af
movq 0x373f22(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x24df8b(%rip), %rsi    # 0x516013
leaq 0x2c2b41(%rip), %rdx    # 0x58abd0
leaq 0x2c2b25(%rip), %rcx    # 0x58abbb
leaq 0x2c2ae5(%rip), %r8     # 0x58ab82
movl $0x73, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2c80b1
movq 0x30(%rsp), %rax
movl %eax, %edx
movq 0x50(%rsp), %rax
movq 0x28(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x80(%rsp), %rax
movq (%rax), %rax
cmpq 0x30(%rsp), %rax
jae 0x2c80e7
movq 0x30(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
jmp 0x2c80e9
cmpq $0x0, 0x30(%rsp)
jbe 0x2c80ff
movq 0x30(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x2c8101
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0x2c7f6d
movq 0x48(%rsp), %rdi
leaq 0x2c2a62(%rip), %rsi    # 0x58ab82
movl $0x7f, %edx
callq 0xe88c0
movq 0x50(%rsp), %rax
addq $0x88, %rsp
retq
nopw (%rax,%rax)