// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::collectXmiAndMli(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, intervTuple_t, std::vector<match_t, std::allocator<match_t>>&, bool, int, int, int, int, int) const
void sparseSA::collectXmiAndMli(const string &P, intervTuple_t interval, 
        vector<match_t> &matches, bool calcMli, int nextEndStop, 
        int nextEndStopPrefix, int min_len, int maxCount, int maxLeft) const {
    int prefix = interval.prefix;
    interval_t xmi = interval.xmi;
    interval_t mli = interval.mli;
    if(xmi.depth + prefix < min_len) return;
    //always calculate xmi MEMs
    for(long i = xmi.start; i <= xmi.end; i++)
        find_LmaximalStrict(P, prefix, SA[i], xmi.depth, matches, min_len, maxLeft);
    //if we need to calculate mli:
    if(!calcMli || (mli.start == xmi.start && mli.end == xmi.end)) return;
    //calc all mli until new end is smaller or equal to nextEndStop or ...
    if(xmi.end+1 < N/K) xmi.depth = max(LCP[xmi.start], LCP[xmi.end+1]);
    else xmi.depth = LCP[xmi.start];
    //iterate over all intervals
    while(xmi.size() < maxCount && prefix+xmi.depth > nextEndStop && xmi.depth >= mli.depth && xmi.depth + prefix >= min_len){
        long prevStart = xmi.start;
        long prevStop = xmi.end;
        // Scan RMEMs to the left, check their left maximality..
        long minStart = max(0L,xmi.start-(maxCount-xmi.size()));
        while(xmi.start >= minStart && LCP[xmi.start] >= xmi.depth)
            xmi.start--;
        // Find RMEMs to the right, check their left maximality.
        long maxEnd = min(N/K,xmi.end+1+(maxCount-xmi.size()));
        while(xmi.end+1 < maxEnd && LCP[xmi.end+1] >= xmi.depth)
            xmi.end++;
        if(xmi.size() < maxCount){
            for(long i = xmi.start; i < prevStart; i++)
                find_LmaximalStrict(P, prefix, SA[i], xmi.depth, matches, min_len, maxLeft);
            for(long i = prevStop+1; i <= xmi.end; i++)
                find_LmaximalStrict(P, prefix, SA[i], xmi.depth, matches, min_len, maxLeft);
            // 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];
        }
    }
    //last possible mli
    if(xmi.size() < maxCount && prefix+xmi.depth == nextEndStop && xmi.depth >= mli.depth && xmi.depth + prefix >= min_len && prefix <= nextEndStopPrefix+K){
        long prevStart = xmi.start;
        long prevStop = xmi.end;
        // Scan RMEMs to the left, check their left maximality..
        long minStart = max(0L,xmi.start-(maxCount-xmi.size()));
        while(xmi.start >= minStart && LCP[xmi.start] >= xmi.depth)
            xmi.start--;
        // Find RMEMs to the right, check their left maximality.
        long maxEnd = min(N/K,xmi.end+(maxCount-xmi.size()));
        while(xmi.end+1 < maxEnd && LCP[xmi.end+1] >= xmi.depth)
            xmi.end++;
        if(xmi.size() < maxCount){
            for(long i = xmi.start; i < prevStart; i++)
                find_LmaximalStrict(P, prefix, SA[i], xmi.depth, matches, min_len, maxLeft);
            for(long i = prevStop+1; i <= xmi.end; i++)
                find_LmaximalStrict(P, prefix, SA[i], xmi.depth, matches, min_len, maxLeft);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, 0x64(%rsp)
movq %rcx, 0x50(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdi, 0x10(%rsp)
movslq 0x30(%rdx), %rax
movl 0x28(%rdx), %r15d
movq %rax, 0x20(%rsp)
addl %r15d, %eax
cmpl 0xb8(%rsp), %eax
jl 0x13c54
movl %r8d, (%rsp)
movl 0x20(%rsp), %eax
movq %rax, 0x48(%rsp)
movq 0x18(%rdx), %rax
movq 0x20(%rdx), %r12
movq (%rdx), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rdx), %rcx
movq %rcx, 0x40(%rsp)
movl 0x10(%rdx), %ecx
movl %ecx, 0x60(%rsp)
movq %rax, 0x8(%rsp)
cmpq %r12, %rax
jg 0x13666
movq 0x20(%rsp), %r14
movl %r14d, %r13d
leaq -0x1(%r14), %rbp
negq %r14
movq 0x8(%rsp), %rbx
cmpl $0x0, 0xc8(%rsp)
jle 0x13656
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%rbx,4), %edx
movq 0x20(%rsp), %rax
cmpl %eax, %edx
cmovbl %edx, %eax
movq 0x48(%rsp), %rcx
subl %eax, %ecx
addl %r15d, %eax
movq 0x58(%rsp), %rdi
movq (%rdi), %r8
addq %rbp, %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xc8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r14
je 0x13631
testq %rsi, %rsi
je 0x13631
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13628
decq %rdi
decl %r10d
jne 0x13606
jmp 0x13656
leal (%rdi,%r13), %ecx
movl %r15d, %eax
subl %edi, %eax
cmpl 0xb8(%rsp), %eax
jl 0x13656
movq %rsi, 0x28(%rsp)
movl %ecx, 0x30(%rsp)
movl %eax, 0x34(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x16a7a
leaq 0x1(%rbx), %rax
cmpq %r12, %rbx
movq %rax, %rbx
jne 0x135b8
cmpb $0x0, (%rsp)
je 0x13c54
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0x13687
cmpq %r12, 0x40(%rsp)
je 0x13c54
movl 0xc0(%rsp), %ebx
leaq 0x1(%r12), %r15
movq 0x10(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %r14
leaq 0xa0(%rcx), %rdi
movq %rdi, 0x18(%rsp)
movq 0x8(%rsp), %rsi
callq 0x15a0e
movq %r15, %rsi
movq %rax, (%rsp)
cmpq %r14, %r15
jge 0x136e7
movq 0x18(%rsp), %rdi
movq %rsi, %r14
callq 0x15a0e
movq %r14, %rsi
movq (%rsp), %rcx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movq %rax, (%rsp)
movslq %ebx, %rcx
subq 0x8(%rsp), %rsi
movq %rcx, 0x38(%rsp)
cmpq %rcx, %rsi
jge 0x13c54
movq 0x20(%rsp), %rbp
movl %ebp, %eax
movq %rax, 0x68(%rsp)
leaq -0x1(%rbp), %rax
movq %rax, 0x40(%rsp)
negq %rbp
movq 0x20(%rsp), %rax
movq (%rsp), %rcx
addl %ecx, %eax
cmpl 0xb8(%rsp), %eax
jl 0x139d0
cmpl 0x64(%rsp), %eax
jle 0x139d0
movl 0x60(%rsp), %ecx
cmpl %ecx, (%rsp)
jl 0x139d0
movq 0x8(%rsp), %rax
movq %rax, %r14
subq 0x38(%rsp), %r14
addq %rsi, %r14
testq %r14, %r14
movl $0x0, %ecx
cmovleq %rcx, %r14
movq %rax, %r13
cmpq %r14, %rax
jl 0x13790
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x15a0e
cmpl (%rsp), %eax
jl 0x1378d
leaq -0x1(%rbx), %r13
cmpq %r14, %rbx
movq %r13, %rbx
jg 0x1376d
jmp 0x13790
movq %rbx, %r13
movq 0x10(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rbx
movq 0x38(%rsp), %rax
addq %r13, %rax
cmpq %rbx, %rax
cmovlq %rax, %rbx
movq %r12, %r14
movq %r14, %r15
incq %r14
cmpq %rbx, %r14
jge 0x137d4
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x15a0e
cmpl (%rsp), %eax
jge 0x137b7
movq %r15, %rax
subq %r13, %rax
incq %rax
cmpq 0x38(%rsp), %rax
jge 0x13c54
movq %rax, 0x70(%rsp)
movl (%rsp), %ebx
cmpq 0x8(%rsp), %r13
jge 0x138ad
movq %r13, %r14
cmpl $0x0, 0xc8(%rsp)
jle 0x1389f
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%r14,4), %edx
movq 0x20(%rsp), %rcx
cmpl %ecx, %edx
movl %ecx, %eax
cmovbl %edx, %eax
subl %eax, %ecx
addl (%rsp), %eax
movq 0x58(%rsp), %rdi
movq (%rdi), %r8
addq 0x40(%rsp), %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xc8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %rbp
je 0x1387a
testq %rsi, %rsi
je 0x1387a
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x1386e
decq %rdi
decl %r10d
jne 0x1384c
jmp 0x1389f
movq 0x68(%rsp), %rax
leal (%rax,%rdi), %ecx
movl %ebx, %eax
subl %edi, %eax
cmpl 0xb8(%rsp), %eax
jl 0x1389f
movq %rsi, 0x28(%rsp)
movl %ecx, 0x30(%rsp)
movl %eax, 0x34(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x16a7a
incq %r14
cmpq 0x8(%rsp), %r14
jne 0x137fe
cmpq %r15, %r12
movq 0x48(%rsp), %r14
jge 0x1396a
incq %r12
cmpl $0x0, 0xc8(%rsp)
jle 0x13961
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%r12,4), %edx
cmpl %r14d, %edx
movl %r14d, %eax
cmovbl %edx, %eax
movq 0x20(%rsp), %rcx
subl %eax, %ecx
addl (%rsp), %eax
movq 0x58(%rsp), %rdi
movq (%rdi), %r8
addq 0x40(%rsp), %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xc8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %rbp
je 0x1393c
testq %rsi, %rsi
je 0x1393c
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13930
decq %rdi
decl %r10d
jne 0x1390e
jmp 0x13961
movq 0x68(%rsp), %rax
leal (%rax,%rdi), %ecx
movl %ebx, %eax
subl %edi, %eax
cmpl 0xb8(%rsp), %eax
jl 0x13961
movq %rsi, 0x28(%rsp)
movl %ecx, 0x30(%rsp)
movl %eax, 0x34(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x16a7a
cmpq %r12, %r15
jne 0x138bb
leaq 0x1(%r15), %r14
movq 0x10(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rbx
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x15a0e
movq %rax, (%rsp)
cmpq %rbx, %r14
jge 0x139b3
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x15a0e
movq (%rsp), %rcx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movq %rax, (%rsp)
movq %r15, %r12
movq %r13, 0x8(%rsp)
movq 0x70(%rsp), %rsi
cmpq 0x38(%rsp), %rsi
jl 0x13715
jmp 0x13c54
cmpl 0xb8(%rsp), %eax
jl 0x13c54
cmpl 0x64(%rsp), %eax
jne 0x13c54
movl 0x60(%rsp), %eax
cmpl %eax, (%rsp)
jl 0x13c54
movslq 0xb0(%rsp), %rax
movq 0x10(%rsp), %rcx
movq 0xe8(%rcx), %rcx
addq %rcx, %rax
cmpq 0x20(%rsp), %rax
jl 0x13c54
movq 0x8(%rsp), %rdx
movq %rdx, %rax
subq 0x38(%rsp), %rax
addq %rsi, %rax
xorl %r14d, %r14d
testq %rax, %rax
cmovgq %rax, %r14
movq %rdx, %r15
cmpq %r14, %rdx
jl 0x13a6c
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x15a0e
cmpl (%rsp), %eax
jl 0x13a5d
leaq -0x1(%rbx), %r15
cmpq %r14, %rbx
movq %r15, %rbx
jg 0x13a3d
jmp 0x13a60
movq %rbx, %r15
movq 0x10(%rsp), %rax
movq 0xe8(%rax), %rcx
movq 0x10(%rsp), %rax
movq 0x38(%rax), %rax
cqto
idivq %rcx
movq %rax, %rbx
movq 0x38(%rsp), %rax
addq %r15, %rax
decq %rax
cmpq %rbx, %rax
cmovlq %rax, %rbx
movq %r12, %rcx
negq %rcx
leaq 0x1(%r12), %r13
movq %rcx, %r14
cmpq %rbx, %r13
jge 0x13abb
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x15a0e
leaq -0x1(%r14), %rcx
incq %r13
cmpl (%rsp), %eax
jge 0x13a9a
movl $0x1, %ecx
subq %r15, %rcx
subq %r14, %rcx
cmpq 0x38(%rsp), %rcx
jge 0x13c54
negq %r14
cmpq 0x8(%rsp), %r15
jge 0x13b96
movl (%rsp), %r13d
leaq 0x28(%rsp), %rbx
cmpl $0x0, 0xc8(%rsp)
jle 0x13b88
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%r15,4), %edx
movq 0x48(%rsp), %rcx
cmpl %ecx, %edx
movl %ecx, %eax
cmovbl %edx, %eax
subl %eax, %ecx
addl (%rsp), %eax
movq 0x58(%rsp), %rdi
movq (%rdi), %r8
addq 0x40(%rsp), %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xc8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %rbp
je 0x13b65
testq %rsi, %rsi
je 0x13b65
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13b58
decq %rdi
decl %r10d
jne 0x13b36
jmp 0x13b88
movq 0x48(%rsp), %rax
leal (%rax,%rdi), %ecx
movl %r13d, %eax
subl %edi, %eax
cmpl 0xb8(%rsp), %eax
jl 0x13b88
movq %rsi, 0x28(%rsp)
movl %ecx, 0x30(%rsp)
movl %eax, 0x34(%rsp)
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x16a7a
incq %r15
cmpq 0x8(%rsp), %r15
jne 0x13ae8
cmpq %r14, %r12
jge 0x13c54
movl (%rsp), %r15d
leaq 0x28(%rsp), %rbx
incq %r12
cmpl $0x0, 0xc8(%rsp)
jle 0x13c4b
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%r12,4), %edx
movq 0x20(%rsp), %rcx
cmpl %ecx, %edx
movl %ecx, %eax
cmovbl %edx, %eax
subl %eax, %ecx
addl (%rsp), %eax
movq 0x58(%rsp), %rdi
movq (%rdi), %r8
addq 0x40(%rsp), %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xc8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %rbp
je 0x13c28
testq %rsi, %rsi
je 0x13c28
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13c1b
decq %rdi
decl %r10d
jne 0x13bf9
jmp 0x13c4b
movq 0x48(%rsp), %rax
leal (%rax,%rdi), %ecx
movl %r15d, %eax
subl %edi, %eax
cmpl 0xb8(%rsp), %eax
jl 0x13c4b
movq %rsi, 0x28(%rsp)
movl %ecx, 0x30(%rsp)
movl %eax, 0x34(%rsp)
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x16a7a
cmpq %r12, %r14
jne 0x13ba8
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop