// File: /workspace/github_cpp_makefile_star2_O2/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 $0x18, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, 0x8(%rsp)
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r13
movq (%r8), %r15
movq 0x8(%r8), %rax
movq %rax, (%rsp)
cmpq (%rsp), %r15
jg 0xf489
movq 0x70(%r13), %rax
movl (%rax,%r15,4), %ecx
movl 0x10(%r14), %r8d
movq %r13, %rdi
movq %r12, %rsi
movl %ebp, %edx
movq %rbx, %r9
movl 0x58(%rsp), %eax
pushq %rax
movl 0x58(%rsp), %eax
pushq %rax
callq 0x1123a
popq %rax
popq %rcx
incq %r15
jmp 0xf456
movq 0x8(%rsp), %rax
movq (%rax), %rax
cmpq (%r14), %rax
jne 0xf4b4
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0x8(%r14), %rax
jne 0xf4b4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa0(%r13), %r15
movl 0x10(%r14), %eax
movq 0x8(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jl 0xf4a5
movq (%r14), %rsi
movq 0x8(%r14), %rax
incq %rax
movq %rax, (%rsp)
movq 0x38(%r13), %rax
cqto
idivq 0xe8(%r13)
movq %rax, 0x10(%rsp)
movq %r15, %rdi
callq 0x10ed8
movl %eax, %ecx
movq 0x10(%rsp), %rax
cmpq %rax, (%rsp)
jge 0xf518
movq 0x8(%r14), %rsi
incq %rsi
movq %r15, %rdi
movl %ecx, (%rsp)
callq 0x10ed8
movl (%rsp), %ecx
cmpl %eax, %ecx
cmovlel %eax, %ecx
movl %ecx, 0x10(%r14)
movq 0x8(%rsp), %rax
cmpl 0x10(%rax), %ecx
jl 0xf4bb
movq (%r14), %rsi
movq %r15, %rdi
callq 0x10ed8
movl 0x10(%r14), %r8d
cmpl %r8d, %eax
jl 0xf59a
movq (%r14), %rax
leaq -0x1(%rax), %rcx
movq %rcx, (%r14)
movq 0x70(%r13), %rcx
movl -0x4(%rcx,%rax,4), %ecx
movq %r13, %rdi
movq %r12, %rsi
movl %ebp, %edx
movq %rbx, %r9
movl 0x58(%rsp), %eax
pushq %rax
movl 0x58(%rsp), %eax
pushq %rax
callq 0x1123a
popq %rax
popq %rcx
jmp 0xf526
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movq 0x70(%r13), %rcx
movl 0x4(%rcx,%rax,4), %ecx
movq %r13, %rdi
movq %r12, %rsi
movl %ebp, %edx
movq %rbx, %r9
movl 0x58(%rsp), %eax
pushq %rax
movl 0x58(%rsp), %eax
pushq %rax
callq 0x1123a
popq %rax
popq %rcx
movq 0x8(%r14), %rsi
incq %rsi
movq 0x38(%r13), %rax
cqto
idivq 0xe8(%r13)
cmpq %rax, %rsi
jge 0xf4bb
movq %r15, %rdi
callq 0x10ed8
movl 0x10(%r14), %r8d
cmpl %r8d, %eax
jge 0xf56a
jmp 0xf4bb
nop