// File: /workspace/github_cpp_makefile_star2_O1/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, 0x30(%rsp)
movq %r8, %r14
movq %rcx, 0x8(%rsp)
movl %edx, %ebp
movq %rsi, 0x38(%rsp)
movq %rdi, %r13
movq (%r8), %r12
movq 0x8(%r8), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r12
jg 0x13308
movslq %ebp, %r15
movl %r15d, %eax
movq %rax, 0x40(%rsp)
leaq -0x1(%r15), %rax
movq %rax, 0x20(%rsp)
negq %r15
cmpl $0x0, 0x88(%rsp)
jle 0x132f5
movl 0x10(%r14), %ecx
movq 0x50(%r13), %rdi
movq 0x70(%r13), %rax
movl (%rax,%r12,4), %esi
cmpl %ebp, %esi
movl %ebp, %edx
cmovbl %esi, %edx
movl %ebp, %eax
subl %edx, %eax
addl %ecx, %edx
movq 0x38(%rsp), %r8
movq (%r8), %r9
addq 0x20(%rsp), %r9
leaq (%rdi,%rsi), %r10
decq %r10
movl 0x88(%rsp), %r11d
xorl %r8d, %r8d
leaq (%rsi,%r8), %rdi
cmpq %r8, %r15
je 0x132d0
testq %rdi, %rdi
je 0x132d0
movb (%r9,%r8), %bl
cmpb (%r10,%r8), %bl
jne 0x132c3
decq %r8
decl %r11d
jne 0x132a1
jmp 0x132f5
movq 0x40(%rsp), %rax
addl %r8d, %eax
subl %r8d, %ecx
movl %ecx, %edx
cmpl 0x80(%rsp), %edx
jl 0x132f5
movq %rdi, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movl %edx, 0x1c(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x16cc0
leaq 0x1(%r12), %rax
cmpq 0x28(%rsp), %r12
movq %rax, %r12
jne 0x13257
movq 0x8(%rsp), %rax
movq (%rax), %rax
cmpq (%r14), %rax
jne 0x13328
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0x8(%r14), %rax
je 0x13553
movl 0x10(%r14), %eax
movq 0x8(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jl 0x13553
leaq 0xa0(%r13), %r15
movslq %ebp, %r12
movl %ebp, %eax
movq %rax, 0x20(%rsp)
leaq -0x1(%r12), %rax
movq %rax, 0x28(%rsp)
negq %r12
movq (%r14), %rsi
movq 0x8(%r14), %rcx
incq %rcx
movq 0x38(%r13), %rax
cqto
idivq 0xe8(%r13)
movq %r15, %rdi
cmpq %rax, %rcx
jge 0x13394
callq 0x15b7a
movl %eax, %ebx
movq 0x8(%r14), %rsi
incq %rsi
movq %r15, %rdi
callq 0x15b7a
cmpl %eax, %ebx
cmovgl %ebx, %eax
jmp 0x13399
callq 0x15b7a
movl %eax, 0x10(%r14)
movq 0x8(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jl 0x13541
movq (%r14), %rsi
movq %r15, %rdi
callq 0x15b7a
movl 0x10(%r14), %ecx
cmpl %ecx, %eax
jl 0x13514
movq (%r14), %rax
leaq -0x1(%rax), %rdx
movq %rdx, (%r14)
cmpl $0x0, 0x88(%rsp)
jle 0x133ab
movq 0x50(%r13), %rdi
movq 0x70(%r13), %rdx
movl -0x4(%rdx,%rax,4), %esi
cmpl %ebp, %esi
movl %ebp, %edx
cmovbl %esi, %edx
movl %ebp, %eax
subl %edx, %eax
addl %ecx, %edx
movq 0x38(%rsp), %r8
movq (%r8), %r9
addq 0x28(%rsp), %r9
leaq (%rdi,%rsi), %r10
decq %r10
movl 0x88(%rsp), %r11d
xorl %r8d, %r8d
leaq (%rsi,%r8), %rdi
cmpq %r8, %r12
je 0x13440
testq %rdi, %rdi
je 0x13440
movb (%r9,%r8), %bl
cmpb (%r10,%r8), %bl
jne 0x13433
decq %r8
decl %r11d
jne 0x1340e
jmp 0x133ab
movq 0x20(%rsp), %rax
addl %r8d, %eax
subl %r8d, %ecx
movl %ecx, %edx
cmpl 0x80(%rsp), %edx
jl 0x133ab
movq %rdi, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movl %edx, 0x1c(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x16cc0
jmp 0x133ab
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%r14)
cmpl $0x0, 0x88(%rsp)
jle 0x13514
movq 0x50(%r13), %rdi
movq 0x70(%r13), %rdx
movl 0x4(%rdx,%rax,4), %esi
cmpl %ebp, %esi
movl %ebp, %edx
cmovbl %esi, %edx
movl %ebp, %eax
subl %edx, %eax
addl %ecx, %edx
movq 0x38(%rsp), %r8
movq (%r8), %r9
addq 0x28(%rsp), %r9
leaq (%rdi,%rsi), %r10
decq %r10
movl 0x88(%rsp), %r11d
xorl %r8d, %r8d
leaq (%rsi,%r8), %rdi
cmpq %r8, %r12
je 0x134ef
testq %rdi, %rdi
je 0x134ef
movb (%r9,%r8), %bl
cmpb (%r10,%r8), %bl
jne 0x134e2
decq %r8
decl %r11d
jne 0x134c0
jmp 0x13514
movq 0x20(%rsp), %rax
addl %r8d, %eax
subl %r8d, %ecx
movl %ecx, %edx
cmpl 0x80(%rsp), %edx
jl 0x13514
movq %rdi, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movl %edx, 0x1c(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x16cc0
movq 0x8(%r14), %rsi
incq %rsi
movq 0x38(%r13), %rax
cqto
idivq 0xe8(%r13)
cmpq %rax, %rsi
jge 0x13541
movq %r15, %rdi
callq 0x15b7a
movl 0x10(%r14), %ecx
cmpl %ecx, %eax
jge 0x1346e
movl 0x10(%r14), %eax
movq 0x8(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x13358
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq