// File: /workspace/github_c_makefile_star2_O1/felipelouza[P]egap/tools/src/gsacak.c
// Function: compute_lcp_phi_sparse
void compute_lcp_phi_sparse(int_t *s, uint_t *SA1, 
  uint_t *RA, int_t *LCP, int_t *PLCP,
  uint_t n1, int cs, uint_t separator) {

  uint_t i;

  PLCP[SA1[0]]=0;//PLCP* (lms) is stored in PLCP array
  for(i=1; i<n1; i++)
    PLCP[SA1[i]] = LCP[i]; 

  LCP[SA1[0]]=0;//PHI is stored in LCP array
  for(i=1; i<n1; i++)
    LCP[SA1[i]] = SA1[i-1]; //RA[SA1[i-1]];

  int_t l=0; //q=0;
  for(i=0; i<n1-1;i++){
    if(chr(RA[i])==separator) continue;

    l = max(PLCP[i], l);//consider the LCP-value of the lms-substrings

    while(chr(RA[i]+l)==chr(RA[LCP[i]]+l) && !(chr(RA[i]+l) == separator && chr(RA[LCP[i]]+l)==separator) ) ++l;
    PLCP[i]=l;

    if(LCP[i]==n1-1) l -= RA[i+1]-RA[i];
    else l -= max(RA[i+1]-RA[i], RA[LCP[i]+1]-RA[LCP[i]]);//LCP[i] stores the distance of i-th suffix to its successor
  }

  LCP[0]=0;
  for(i=1; i<n1;i++) LCP[i]=PLCP[SA1[i]];

}

// Assembly:
movq (%rsi), %rax
movq $0x0, (%r8,%rax,8)
cmpq $0x2, %r9
jb 0x5ff1
movl $0x1, %eax
movq (%rcx,%rax,8), %r10
movq (%rsi,%rax,8), %r11
movq %r10, (%r8,%r11,8)
incq %rax
cmpq %rax, %r9
jne 0x5fdd
movq (%rsi), %rax
movq $0x0, (%rcx,%rax,8)
cmpq $0x2, %r9
jb 0x601c
movl $0x1, %eax
movq -0x8(%rsi,%rax,8), %r10
movq (%rsi,%rax,8), %r11
movq %r10, (%rcx,%r11,8)
incq %rax
cmpq %rax, %r9
jne 0x6007
movq %r9, %rax
decq %rax
je 0x6159
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x38(%rsp), %r10
movl 0x30(%rsp), %r11d
xorl %ebx, %ebx
xorl %r14d, %r14d
movq (%rdx,%r14,8), %r15
cmpl $0x8, %r11d
jne 0x6050
movq (%rdi,%r15,8), %r15
jmp 0x6055
movzbl (%rdi,%r15), %r15d
cmpq %r10, %r15
je 0x6144
movq (%r8,%r14,8), %r15
cmpq %rbx, %r15
cmovgq %r15, %rbx
cmpl $0x8, %r11d
jne 0x607d
movq (%rdx,%r14,8), %r15
leaq (%rdi,%r15,8), %r15
movq (%r15,%rbx,8), %r15
jmp 0x6089
movq (%rdx,%r14,8), %r15
addq %rdi, %r15
movzbl (%rbx,%r15), %r15d
cmpl $0x8, %r11d
jne 0x60a1
movq (%rcx,%r14,8), %r12
movq (%rdx,%r12,8), %r12
leaq (%rdi,%r12,8), %r12
movq (%r12,%rbx,8), %r12
jmp 0x60b1
movq (%rcx,%r14,8), %r12
movq (%rdx,%r12,8), %r12
addq %rdi, %r12
movzbl (%rbx,%r12), %r12d
cmpq %r12, %r15
jne 0x6110
cmpl $0x8, %r11d
jne 0x60ca
movq (%rdx,%r14,8), %r15
leaq (%rdi,%r15,8), %r15
movq (%r15,%rbx,8), %r15
jmp 0x60d6
movq (%rdx,%r14,8), %r15
addq %rdi, %r15
movzbl (%rbx,%r15), %r15d
cmpq %r10, %r15
jne 0x6108
cmpl $0x8, %r11d
jne 0x60f3
movq (%rcx,%r14,8), %r15
movq (%rdx,%r15,8), %r15
leaq (%rdi,%r15,8), %r15
movq (%r15,%rbx,8), %r15
jmp 0x6103
movq (%rcx,%r14,8), %r15
movq (%rdx,%r15,8), %r15
addq %rdi, %r15
movzbl (%rbx,%r15), %r15d
cmpq %r10, %r15
je 0x6110
incq %rbx
jmp 0x6069
movq %rbx, (%r8,%r14,8)
movq (%rcx,%r14,8), %r12
movq (%rdx,%r14,8), %r13
movq 0x8(%rdx,%r14,8), %r15
cmpq %rax, %r12
jne 0x612e
subq %r15, %r13
addq %r13, %rbx
jmp 0x6144
subq %r13, %r15
movq 0x8(%rdx,%r12,8), %r13
subq (%rdx,%r12,8), %r13
cmpq %r13, %r15
cmovaq %r15, %r13
subq %r13, %rbx
incq %r14
cmpq %rax, %r14
jne 0x6040
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
movq $0x0, (%rcx)
cmpq $0x2, %r9
jb 0x617f
movl $0x1, %eax
movq (%rsi,%rax,8), %rdx
movq (%r8,%rdx,8), %rdx
movq %rdx, (%rcx,%rax,8)
incq %rax
cmpq %rax, %r9
jne 0x616b
retq