// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/sfx-linlcp.c
// Function: gt_ENCSEQ_lcp9_manzini
GtCompactUlongStore *gt_ENCSEQ_lcp9_manzini(GtCompactUlongStore *spacefortab,
                                            const GtEncseq *encseq,
                                            GtReadmode readmode,
                                            GtUword partwidth,
                                            GtUword totallength,
                                            const ESASuffixptr *suftab)
{
  GtUword pos, previousstart, nextfillpos = 0, fillpos, lcpvalue = 0,
                previouscc1pos, previouscc2pos;
  GtCompactUlongStore *lcptab, *ranknext, *rightposinverse;
  GtUchar cc1, cc2;
  GtEncseqReader *esr1, *esr2;

  if (spacefortab == NULL)
  {
    unsigned int bitsperentry = gt_determinebitspervalue(totallength);
    rightposinverse = ranknext
                    = gt_compact_ulong_store_new(totallength+1, bitsperentry);
    gt_compact_ulong_store_update(ranknext, totallength, totallength);
    gt_ENCSEQ_set_relevant_from_inversetab(rightposinverse, encseq, readmode,
                                           suftab, partwidth);
  } else
  {
    rightposinverse = ranknext = spacefortab;
  }
  gt_ENCSEQ_inversesuffixarray2specialranknext(rightposinverse, ranknext,
                                               encseq,
                                               readmode,
                                               partwidth,
                                               totallength);
  fillpos = gt_ENCSEQ_sa2ranknext(ranknext, encseq, readmode, partwidth,
                                  totallength, suftab);
  lcptab = ranknext;
  /* now ranknext and lcptab point to the same memory area. After reading
     ranknext at position fillpos, the same cell is used for storing
     the determined lcp-value */
  /* exploit the fact, that pos + lcpvalue is monotone */
  esr1 = gt_encseq_create_reader_with_readmode(encseq, readmode,0);
  cc1 = gt_encseq_reader_next_encoded_char(esr1);
  previouscc1pos = 0;
  esr2 = gt_encseq_create_reader_with_readmode(encseq, readmode, 0);
  previouscc2pos = totallength;
  cc2 = 0;
  for (pos = 0; pos < totallength; pos++)
  {
    if (pos < totallength - 1)
    {
      nextfillpos = gt_compact_ulong_store_get(ranknext, fillpos);
    }
    if (fillpos > 0 && fillpos - 1 < partwidth)
    {
      previousstart = ESASUFFIXPTRGET(suftab, fillpos-1);
      while (pos+lcpvalue < totallength &&
             previousstart+lcpvalue < totallength)
      {
        gt_assert(pos + lcpvalue >= previouscc1pos);
        while (previouscc1pos < pos + lcpvalue)
        {
          previouscc1pos++;
          cc1 = gt_encseq_reader_next_encoded_char(esr1);
        }
        if (GT_ISSPECIAL(cc1))
        {
          break;
        }
        if (previousstart+lcpvalue < previouscc2pos ||
            previousstart+lcpvalue > previouscc2pos+1)
        {
          previouscc2pos = previousstart+lcpvalue;
          gt_encseq_reader_reinit_with_readmode(esr2, encseq, readmode,
                                                previouscc2pos);
          cc2 = gt_encseq_reader_next_encoded_char(esr2);
        } else
        {
          if (previousstart+lcpvalue == previouscc2pos+1)
          {
            previouscc2pos++;
            cc2 = gt_encseq_reader_next_encoded_char(esr2);
          } else
          {
            gt_assert(previousstart+lcpvalue == previouscc2pos);
          }
        }
        if (cc1 != cc2)
        {
          break;
        }
        lcpvalue++;
      }
      gt_compact_ulong_store_update(lcptab, fillpos, lcpvalue);
      if (lcpvalue > 0)
      {
        lcpvalue--;
      }
    }
    fillpos = nextfillpos;
  }
  gt_encseq_reader_delete(esr1);
  gt_encseq_reader_delete(esr2);
  return lcptab;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movl %edx, 0x94(%rsp)
movq %rcx, 0x88(%rsp)
movq %r8, 0x80(%rsp)
movq %r9, 0x78(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x50(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0x2c85f2
movq 0x80(%rsp), %rdi
callq 0xec660
movl %eax, 0xc(%rsp)
movq 0x80(%rsp), %rdi
addq $0x1, %rdi
movl 0xc(%rsp), %esi
callq 0xa1e30
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x80(%rsp), %rdx
callq 0xa21f0
movq 0x28(%rsp), %rdi
movq 0x98(%rsp), %rsi
movl 0x94(%rsp), %edx
movq 0x78(%rsp), %rcx
movq 0x88(%rsp), %r8
callq 0x2c89b0
jmp 0x2c8604
movq 0xa0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x98(%rsp), %rdx
movl 0x94(%rsp), %ecx
movq 0x88(%rsp), %r8
movq 0x80(%rsp), %r9
callq 0x2c8a70
movq 0x30(%rsp), %rdi
movq 0x98(%rsp), %rsi
movl 0x94(%rsp), %edx
movq 0x88(%rsp), %rcx
movq 0x80(%rsp), %r8
movq 0x78(%rsp), %r9
callq 0x2c8da0
movq %rax, 0x58(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x98(%rsp), %rdi
movl 0x94(%rsp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xac380
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
callq 0xaae30
movb %al, 0x27(%rsp)
movq $0x0, 0x48(%rsp)
movq 0x98(%rsp), %rdi
movl 0x94(%rsp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xac380
movq %rax, 0x10(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x40(%rsp)
movb $0x0, 0x26(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x80(%rsp), %rax
jae 0x2c8980
movq 0x70(%rsp), %rax
movq 0x80(%rsp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x2c8718
movq 0x30(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0xa20c0
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x58(%rsp)
jbe 0x2c8963
movq 0x58(%rsp), %rax
subq $0x1, %rax
cmpq 0x88(%rsp), %rax
jae 0x2c8963
movq 0x78(%rsp), %rax
movq 0x58(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rcx
addq 0x50(%rsp), %rcx
xorl %eax, %eax
cmpq 0x80(%rsp), %rcx
movb %al, 0xb(%rsp)
jae 0x2c8785
movq 0x68(%rsp), %rax
addq 0x50(%rsp), %rax
cmpq 0x80(%rsp), %rax
setb %al
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
testb $0x1, %al
jne 0x2c8792
jmp 0x2c8937
jmp 0x2c8794
movq 0x70(%rsp), %rax
addq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rax
jae 0x2c87dd
movq 0x3737f4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x24d85d(%rip), %rsi    # 0x516013
leaq 0x2c244c(%rip), %rdx    # 0x58ac09
leaq 0x2c2466(%rip), %rcx    # 0x58ac2a
leaq 0x2c23b7(%rip), %r8     # 0x58ab82
movl $0x1f5, %r9d            # imm = 0x1F5
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2c87df
jmp 0x2c87e1
movq 0x48(%rsp), %rax
movq 0x70(%rsp), %rcx
addq 0x50(%rsp), %rcx
cmpq %rcx, %rax
jae 0x2c8813
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
movq 0x18(%rsp), %rdi
callq 0xaae30
movb %al, 0x27(%rsp)
jmp 0x2c87e1
movzbl 0x27(%rsp), %eax
cmpl $0xfe, %eax
jl 0x2c8824
jmp 0x2c8937
movq 0x68(%rsp), %rax
addq 0x50(%rsp), %rax
cmpq 0x40(%rsp), %rax
jb 0x2c884d
movq 0x68(%rsp), %rax
addq 0x50(%rsp), %rax
movq 0x40(%rsp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x2c888d
movq 0x68(%rsp), %rax
addq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rdi
movq 0x98(%rsp), %rsi
movl 0x94(%rsp), %edx
movq 0x40(%rsp), %rcx
callq 0xabdb0
movq 0x10(%rsp), %rdi
callq 0xaae30
movb %al, 0x26(%rsp)
jmp 0x2c8914
movq 0x68(%rsp), %rax
addq 0x50(%rsp), %rax
movq 0x40(%rsp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jne 0x2c88c3
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rdi
callq 0xaae30
movb %al, 0x26(%rsp)
jmp 0x2c8912
jmp 0x2c88c5
movq 0x68(%rsp), %rax
addq 0x50(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x2c890e
movq 0x3736c3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x24d72c(%rip), %rsi    # 0x516013
leaq 0x2c2353(%rip), %rdx    # 0x58ac41
leaq 0x2c2335(%rip), %rcx    # 0x58ac2a
leaq 0x2c2286(%rip), %r8     # 0x58ab82
movl $0x20e, %r9d            # imm = 0x20E
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2c8910
jmp 0x2c8912
jmp 0x2c8914
movzbl 0x27(%rsp), %eax
movzbl 0x26(%rsp), %ecx
cmpl %ecx, %eax
je 0x2c8924
jmp 0x2c8937
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x2c8752
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0xa21f0
cmpq $0x0, 0x50(%rsp)
jbe 0x2c8961
movq 0x50(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x2c8963
movq 0x60(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x2c86db
movq 0x18(%rsp), %rdi
callq 0xac3f0
movq 0x10(%rsp), %rdi
callq 0xac3f0
movq 0x38(%rsp), %rax
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)