// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/sfx-linlcp.c
// Function: gt_plain_lcp_phialgorithm
unsigned int *gt_plain_lcp_phialgorithm(bool onlyplcp,
                                        GtUword *maxlcp,
                                        const GtUchar *sequence,
                                        bool withspecial,
                                        GtUword partwidth,
                                        GtUword totallength,
                                        const unsigned int *suftab)
{
  unsigned int *plcptab, *phitab, pos, suftab0, previousvalue;
  GtUword idx, lcpvalue = 0;

  phitab = gt_malloc(sizeof (*phitab) * (totallength+1));
  previousvalue = suftab[0];
  for (idx = 1UL; idx <= totallength; idx++)
  {
    unsigned int currentvalue = suftab[idx];
    phitab[currentvalue] = previousvalue;
    previousvalue = currentvalue;
  }
  plcptab = phitab; /* overlay both arrays */
  suftab0 = suftab[0];
  gt_assert(totallength <= (GtUword) UINT_MAX);
  *maxlcp = 0;
  for (pos = 0; pos < (unsigned int) totallength; pos++)
  {
    if (pos != suftab0)
    {
      const unsigned int currentphitab = phitab[pos];
      const GtUword lastoffset = totallength - GT_MAX(pos,currentphitab);
      const GtUchar *ptr1 = sequence + pos,
                    *ptr2 = sequence + currentphitab;

      while (lcpvalue < lastoffset)
      {
        GtUchar cc1 = ptr1[lcpvalue];
        GtUchar cc2 = ptr2[lcpvalue];
        if (cc1 == cc2 && (!withspecial || GT_ISNOTSPECIAL(cc1)))
        {
          lcpvalue++;
        } else
        {
          break;
        }
      }
      gt_assert(lcpvalue <= (GtUword) UINT_MAX);
      plcptab[pos] = (unsigned int) lcpvalue;
      if (lcpvalue > 0)
      {
        if (*maxlcp < lcpvalue)
        {
          *maxlcp = lcpvalue;
        }
        lcpvalue--;
      }
    } else
    {
      plcptab[pos] = 0;
    }
  }
  if (onlyplcp)
  {
    return plcptab;
  } else
  {
    unsigned int *lcptab = gt_malloc(sizeof (*lcptab) * (totallength+1));

    for (idx = 0; idx < partwidth; idx++)
    {
      lcptab[idx] = plcptab[suftab[idx]];
    }
    gt_free(plcptab);
    for (idx = partwidth; idx <= totallength; idx++)
    {
      lcptab[idx] = 0;
    }
    return lcptab;
  }
}

// Assembly:
subq $0xa8, %rsp
movb %cl, %al
movb %dil, %cl
movq 0xb0(%rsp), %rdi
andb $0x1, %cl
movb %cl, 0x9f(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
andb $0x1, %al
movb %al, 0x87(%rsp)
movq %r8, 0x78(%rsp)
movq %r9, 0x70(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x70(%rsp), %rdi
addq $0x1, %rdi
shlq $0x2, %rdi
leaq 0x2c29e4(%rip), %rsi    # 0x58ab82
movl $0x8e, %edx
callq 0xe80f0
movq %rax, 0x60(%rsp)
movq 0xb0(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x54(%rsp)
movq $0x1, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x70(%rsp), %rax
ja 0x2c820c
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x3c(%rsp)
movl 0x54(%rsp), %edx
movq 0x60(%rsp), %rax
movl 0x3c(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movl 0x3c(%rsp), %eax
movl %eax, 0x54(%rsp)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2c81c4
movq 0x60(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xb0(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x58(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, 0x70(%rsp)
jbe 0x2c8268
movq 0x373d69(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x24ddd2(%rip), %rsi    # 0x516013
leaq 0x2c2951(%rip), %rdx    # 0x58ab99
leaq 0x2c29a0(%rip), %rcx    # 0x58abef
leaq 0x2c292c(%rip), %r8     # 0x58ab82
movl $0x98, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2c826a
movq 0x90(%rsp), %rax
movq $0x0, (%rax)
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movq 0x70(%rsp), %rcx
cmpl %ecx, %eax
jae 0x2c842e
movl 0x5c(%rsp), %eax
cmpl 0x58(%rsp), %eax
je 0x2c840c
movq 0x60(%rsp), %rax
movl 0x5c(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x38(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x5c(%rsp), %eax
cmpl 0x38(%rsp), %eax
jbe 0x2c82ce
movl 0x5c(%rsp), %eax
movl %eax, 0x4(%rsp)
jmp 0x2c82d6
movl 0x38(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, %ecx
subq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x88(%rsp), %rax
movl 0x5c(%rsp), %ecx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x88(%rsp), %rax
movl 0x38(%rsp), %ecx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x30(%rsp), %rax
jae 0x2c8377
movq 0x28(%rsp), %rax
movq 0x40(%rsp), %rcx
movb (%rax,%rcx), %al
movb %al, 0x1f(%rsp)
movq 0x20(%rsp), %rax
movq 0x40(%rsp), %rcx
movb (%rax,%rcx), %al
movb %al, 0x1e(%rsp)
movzbl 0x1f(%rsp), %eax
movzbl 0x1e(%rsp), %ecx
cmpl %ecx, %eax
jne 0x2c8373
testb $0x1, 0x87(%rsp)
je 0x2c8363
movzbl 0x1f(%rsp), %eax
cmpl $0xfe, %eax
jge 0x2c8373
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x2c8375
jmp 0x2c8377
jmp 0x2c8311
jmp 0x2c8379
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, 0x40(%rsp)
jbe 0x2c83bd
movq 0x373c14(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x24dc7d(%rip), %rsi    # 0x516013
leaq 0x2c2833(%rip), %rdx    # 0x58abd0
leaq 0x2c284b(%rip), %rcx    # 0x58abef
leaq 0x2c27d7(%rip), %r8     # 0x58ab82
movl $0xaf, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2c83bf
movq 0x40(%rsp), %rax
movl %eax, %edx
movq 0x68(%rsp), %rax
movl 0x5c(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
cmpq $0x0, 0x40(%rsp)
jbe 0x2c840a
movq 0x90(%rsp), %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
jae 0x2c83fc
movq 0x40(%rsp), %rcx
movq 0x90(%rsp), %rax
movq %rcx, (%rax)
movq 0x40(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x2c841c
movq 0x68(%rsp), %rax
movl 0x5c(%rsp), %ecx
movl $0x0, (%rax,%rcx,4)
jmp 0x2c841e
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x2c8281
testb $0x1, 0x9f(%rsp)
je 0x2c844a
movq 0x68(%rsp), %rax
movq %rax, 0xa0(%rsp)
jmp 0x2c8511
movq 0x70(%rsp), %rdi
addq $0x1, %rdi
shlq $0x2, %rdi
leaq 0x2c2724(%rip), %rsi    # 0x58ab82
movl $0xc3, %edx
callq 0xe80f0
movq %rax, 0x10(%rsp)
movq $0x0, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x78(%rsp), %rax
jae 0x2c84b7
movq 0x68(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq 0x48(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
movq 0x48(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2c8476
movq 0x68(%rsp), %rdi
leaq 0x2c26bf(%rip), %rsi    # 0x58ab82
movl $0xc9, %edx
callq 0xe88c0
movq 0x78(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x70(%rsp), %rax
ja 0x2c8504
movq 0x10(%rsp), %rax
movq 0x48(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2c84d7
movq 0x10(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)