// File: /workspace/github_c_makefile_star2_O1/felipelouza[P]egap/tools/lib/lcp_array.c
// Function: lcp_array_check
int lcp_array_check(unsigned char *T, int_t *SA, int_t *LCP, uint_t n, int cs, unsigned char separator){
  
  uint_t i,j,k;
  uint_t h;
  uint64_t sum=0;
  int_t maximum=0;

  for(i=1;i<n;i++) {
    
    j=SA[i-1]; k=SA[i];
    for(h=0;j+h<n && k+h<n;h++) if(chr(j+h)!=chr(k+h) || (chr(j+h)==separator && chr(k+h)==separator)) break;
    
    if(LCP[i]!=h) {
      fprintf(stdout,"isNotLCP! Incorrect LCP value: LCP[%" PRIdN "]=%" PRIdN "!=%" PRIdN "\t(%" PRIdN ")\n", i, LCP[i],h, SA[i]);
      return 0;
    }
    sum+=LCP[i];
    maximum=max(maximum, LCP[i]);
  }
  printf("LCP[%d]=%" PRIdN "\n",0,LCP[0]);
  printf("LCP_mean = %.2lf\n", (double)sum/(double)n);
  printf("LCP_max = %" PRIdN "\n", maximum);
  
return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %rbp
cmpq $0x2, %rcx
jb 0x5d7f
movzbl %r9b, %r11d
movl $0x1, %eax
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %rdx, 0x8(%rsp)
movq %rsi, (%rsp)
movq -0x8(%rsi,%rax,8), %rcx
movq (%rsi,%rax,8), %r9
movq %rbp, %r12
subq %rcx, %r12
jbe 0x5d1d
movq %rbx, 0x10(%rsp)
leaq (%rdi,%rcx,8), %r13
addq %rdi, %rcx
leaq (%rdi,%r9,8), %rsi
leaq (%rdi,%r9), %rbx
xorl %r10d, %r10d
leaq (%r9,%r10), %r14
cmpq %rbp, %r14
jae 0x5d16
cmpl $0x8, %r8d
jne 0x5cbd
movq (%r13,%r10,8), %r14
jmp 0x5cc2
movzbl (%rcx,%r10), %r14d
movq %rbp, %rdx
cmpl $0x8, %r8d
jne 0x5cd1
movq (%rsi,%r10,8), %rbp
jmp 0x5cd6
movzbl (%rbx,%r10), %ebp
cmpq %rbp, %r14
jne 0x5d22
cmpl $0x8, %r8d
movq %rdx, %rbp
jne 0x5ceb
movq (%r13,%r10,8), %r14
jmp 0x5cf0
movzbl (%rcx,%r10), %r14d
cmpq %r11, %r14
jne 0x5d0b
cmpl $0x8, %r8d
jne 0x5d01
movq (%rsi,%r10,8), %r14
jmp 0x5d06
movzbl (%rbx,%r10), %r14d
cmpq %r11, %r14
je 0x5d16
incq %r10
cmpq %r10, %r12
jne 0x5ca7
movq %r12, %r10
movq 0x10(%rsp), %rbx
jmp 0x5d2a
xorl %r10d, %r10d
jmp 0x5d33
movq 0x10(%rsp), %rbx
movq %rdx, %rbp
movq 0x8(%rsp), %rdx
movq (%rsp), %rsi
movq (%rdx,%rax,8), %rcx
cmpq %r10, %rcx
jne 0x5def
addq %rcx, %r15
cmpq %rcx, %rbx
cmovleq %rcx, %rbx
incq %rax
cmpq %rbp, %rax
jne 0x5c7b
movq %r15, %xmm0
punpckldq 0x52ad(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x52b5(%rip), %xmm0     # 0xb020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
jmp 0x5d8b
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
xorl %ebx, %ebx
movq (%rdx), %rdx
leaq 0x5cbc(%rip), %rdi      # 0xba51
xorl %esi, %esi
xorl %eax, %eax
callq 0x20f0
movq %rbp, %xmm0
punpckldq 0x5265(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x526d(%rip), %xmm0     # 0xb020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd 0x10(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0x5c8e(%rip), %rdi      # 0xba5e
movb $0x1, %al
callq 0x20f0
leaq 0x5c92(%rip), %rdi      # 0xba70
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
movl $0x1, %ebx
jmp 0x5e0f
movq 0x91d2(%rip), %rdx      # 0xefc8
movq (%rdx), %rdi
leaq 0x5c19(%rip), %rsi      # 0xba19
xorl %ebx, %ebx
movq %rax, %rdx
movq %r10, %r8
xorl %eax, %eax
callq 0x2190
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq