// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::collectAllMEMs(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, interval_t, interval_t, std::vector<match_t, std::allocator<match_t>>&, int, int) const
void sparseSA::collectAllMEMs(const string &P, int prefix, const interval_t mli,
        interval_t xmi, vector<match_t> &matches, int min_len, int maxLeft) const {
  // All of the suffixes in xmi's interval are right maximal.
  long xmiEnd = xmi.end;
  for(long i = xmi.start; i <= xmiEnd; i++) find_LmaximalStrict(P, prefix, SA[i], xmi.depth, matches, min_len, maxLeft);

  if(mli.start == xmi.start && mli.end == xmi.end){ return;}
  while(xmi.depth >= mli.depth) {
    // Attempt to "unmatch" xmi using LCP information.
    if(xmi.end+1 < N/K) xmi.depth = max(LCP[xmi.start], LCP[xmi.end+1]);
    else xmi.depth = LCP[xmi.start];

    // If unmatched XMI is > matched depth from mli, then examine rmems.
    if(xmi.depth >= mli.depth) {
      // Scan RMEMs to the left, check their left maximality..
      while(LCP[xmi.start] >= xmi.depth) {
	xmi.start--;
	find_LmaximalStrict(P, prefix, SA[xmi.start], xmi.depth, matches, min_len, maxLeft);
      }
      // Find RMEMs to the right, check their left maximality.
      while(xmi.end+1 < N/K && LCP[xmi.end+1] >= xmi.depth) {
	xmi.end++;
	find_LmaximalStrict(P, prefix, SA[xmi.end], xmi.depth, matches, min_len, maxLeft);
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x38(%rsp)
movq %r8, %r14
movq %rcx, 0x10(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, %r13
movl 0x88(%rsp), %ebp
movq (%r8), %r15
movq 0x8(%r8), %rax
movq %rax, 0x8(%rsp)
cmpq %rax, %r15
movl %edx, 0x4(%rsp)
jg 0x13175
movslq %edx, %rbx
movl %ebx, %eax
movq %rax, 0x28(%rsp)
leaq -0x1(%rbx), %rax
movq %rax, 0x30(%rsp)
negq %rbx
testl %ebp, %ebp
jle 0x13160
movl 0x10(%r14), %ecx
movq 0x50(%r13), %rdi
movq 0x70(%r13), %rax
movl (%rax,%r15,4), %esi
movl 0x4(%rsp), %eax
cmpl %eax, %esi
movl %eax, %edx
cmovbl %esi, %edx
subl %edx, %eax
addl %ecx, %edx
movq 0x40(%rsp), %r8
movq (%r8), %r9
addq 0x30(%rsp), %r9
leaq (%rdi,%rsi), %r10
decq %r10
movl %ebp, %r11d
xorl %r8d, %r8d
leaq (%rsi,%r8), %rdi
cmpq %r8, %rbx
je 0x1313b
testq %rdi, %rdi
je 0x1313b
movb (%r9,%r8), %r12b
cmpb (%r10,%r8), %r12b
jne 0x13127
decq %r8
decl %r11d
movl 0x88(%rsp), %ebp
jne 0x130fe
jmp 0x13160
movq 0x28(%rsp), %rax
addl %r8d, %eax
subl %r8d, %ecx
movl %ecx, %edx
movl 0x88(%rsp), %ebp
cmpl 0x80(%rsp), %edx
jl 0x13160
movq %rdi, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movl %edx, 0x24(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x16a7a
leaq 0x1(%r15), %rax
cmpq 0x8(%rsp), %r15
movq %rax, %r15
jne 0x130bd
movq (%r14), %r15
movq 0x10(%rsp), %rax
cmpq %r15, (%rax)
jne 0x13192
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0x8(%r14), %rax
je 0x133e1
movl 0x10(%r14), %eax
movq 0x10(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jl 0x133e1
leaq 0xa0(%r13), %rax
movq %rax, 0x8(%rsp)
movl 0x4(%rsp), %eax
movslq %eax, %r15
movl %eax, %eax
movq %rax, 0x28(%rsp)
leaq -0x1(%r15), %rax
movq %rax, 0x30(%rsp)
negq %r15
movq (%r14), %rsi
movq 0x8(%r14), %rbp
incq %rbp
movq 0x38(%r13), %rax
cqto
idivq 0xe8(%r13)
movq %rax, %r12
movq 0x8(%rsp), %rdi
callq 0x15a0e
movl %eax, %ebx
cmpq %r12, %rbp
jge 0x1320d
movq 0x8(%r14), %rsi
incq %rsi
movq 0x8(%rsp), %rdi
callq 0x15a0e
cmpl %eax, %ebx
cmovgl %ebx, %eax
movl %eax, %ebx
movl %ebx, 0x10(%r14)
movq 0x10(%rsp), %rax
cmpl 0x10(%rax), %ebx
movl 0x88(%rsp), %r12d
jl 0x133d3
movq (%r14), %rsi
movq 0x8(%rsp), %rdi
callq 0x15a0e
movl 0x10(%r14), %ebx
cmpl %ebx, %eax
jl 0x132e1
movq (%r14), %rax
leaq -0x1(%rax), %rsi
movq %rsi, (%r14)
testl %r12d, %r12d
jle 0x1322a
movq 0x50(%r13), %rdi
movq 0x70(%r13), %rcx
movl -0x4(%rcx,%rax,4), %edx
movl 0x4(%rsp), %eax
cmpl %eax, %edx
movl %eax, %ecx
cmovbl %edx, %ecx
subl %ecx, %eax
addl %ebx, %ecx
movq 0x40(%rsp), %r8
movq (%r8), %r9
addq 0x30(%rsp), %r9
leaq (%rdi,%rdx), %r10
decq %r10
movl %r12d, %r11d
xorl %r8d, %r8d
leaq (%rdx,%r8), %rdi
cmpq %r8, %r15
je 0x132b3
testq %rdi, %rdi
je 0x132b3
movb (%r9,%r8), %bpl
cmpb (%r10,%r8), %bpl
jne 0x132a6
decq %r8
decl %r11d
jne 0x13284
jmp 0x1322a
movq 0x28(%rsp), %rax
addl %r8d, %eax
subl %r8d, %ebx
movl %ebx, %ecx
cmpl 0x80(%rsp), %ecx
jl 0x1322a
movq %rdi, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movl %ecx, 0x24(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x16a7a
jmp 0x13227
movq 0x8(%r14), %rsi
incq %rsi
movq 0x38(%r13), %rax
cqto
idivq 0xe8(%r13)
cmpq %rax, %rsi
jge 0x133d3
movq 0x8(%rsp), %rdi
callq 0x15a0e
movl 0x10(%r14), %ebx
cmpl %ebx, %eax
jl 0x133d3
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rsi
movq %rsi, 0x8(%r14)
testl %r12d, %r12d
jle 0x133b6
movq 0x50(%r13), %rdi
movq 0x70(%r13), %rcx
movl 0x4(%rcx,%rax,4), %edx
movl 0x4(%rsp), %eax
cmpl %eax, %edx
movl %eax, %ecx
cmovbl %edx, %ecx
subl %ecx, %eax
addl %ebx, %ecx
movq 0x40(%rsp), %r8
movq (%r8), %r9
addq 0x30(%rsp), %r9
leaq (%rdi,%rdx), %r10
decq %r10
movl %r12d, %r11d
xorl %r8d, %r8d
leaq (%rdx,%r8), %rdi
cmpq %r8, %r15
je 0x1338d
testq %rdi, %rdi
je 0x1338d
movb (%r9,%r8), %bpl
cmpb (%r10,%r8), %bpl
jne 0x13380
decq %r8
decl %r11d
jne 0x1335e
jmp 0x133b6
movq 0x28(%rsp), %rax
addl %r8d, %eax
subl %r8d, %ebx
movl %ebx, %ecx
cmpl 0x80(%rsp), %ecx
jl 0x133b6
movq %rdi, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movl %ecx, 0x24(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x16a7a
movq 0x8(%r14), %rsi
incq %rsi
movq 0x38(%r13), %rax
cqto
idivq 0xe8(%r13)
cmpq %rax, %rsi
jl 0x132fe
movl 0x10(%r14), %ebx
movq 0x10(%rsp), %rax
cmpl 0x10(%rax), %ebx
jge 0x131ca
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq