// File: /workspace/github_cpp_makefile_star2_O1/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 $0x98, %rsp
movl %r9d, 0x54(%rsp)
movq %rcx, 0x58(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdi, 0x28(%rsp)
movslq 0x30(%rdx), %rax
movl 0x28(%rdx), %r15d
movq %rax, 0x8(%rsp)
addl %r15d, %eax
cmpl 0xd8(%rsp), %eax
jl 0x13e9b
movl %r8d, 0x18(%rsp)
movl 0x8(%rsp), %eax
movq %rax, 0x60(%rsp)
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %r12
movq (%rdx), %rax
movq %rax, 0x70(%rsp)
movq 0x8(%rdx), %rax
movq %rax, 0x30(%rsp)
movl 0x10(%rdx), %eax
movl %eax, 0x50(%rsp)
movq %rcx, 0x20(%rsp)
cmpq %r12, %rcx
jg 0x137ba
movq 0x8(%rsp), %r14
movl %r14d, %r13d
leaq -0x1(%r14), %rbp
negq %r14
movq 0x20(%rsp), %rbx
cmpl $0x0, 0xe8(%rsp)
jle 0x137aa
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%rbx,4), %edx
movq 0x60(%rsp), %rax
cmpl %eax, %edx
cmovbl %edx, %eax
movq 0x8(%rsp), %rcx
subl %eax, %ecx
addl %r15d, %eax
movq 0x68(%rsp), %rdi
movq (%rdi), %r8
addq %rbp, %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xe8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r14
je 0x13785
testq %rsi, %rsi
je 0x13785
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x1377c
decq %rdi
decl %r10d
jne 0x1375a
jmp 0x137aa
leal (%rdi,%r13), %ecx
movl %r15d, %eax
subl %edi, %eax
cmpl 0xd8(%rsp), %eax
jl 0x137aa
movq %rsi, 0x38(%rsp)
movl %ecx, 0x40(%rsp)
movl %eax, 0x44(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x16cc0
leaq 0x1(%rbx), %rax
cmpq %r12, %rbx
movq %rax, %rbx
jne 0x1370c
cmpb $0x0, 0x18(%rsp)
movq 0x20(%rsp), %rsi
je 0x13e9b
cmpq %rsi, 0x70(%rsp)
jne 0x137dc
cmpq %r12, 0x30(%rsp)
je 0x13e9b
movl 0xe0(%rsp), %ebp
leaq 0x1(%r12), %rbx
movq 0x28(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %r14
leaq 0xa0(%rcx), %rdi
movq %rdi, 0x18(%rsp)
callq 0x15b7a
movl %eax, %r15d
cmpq %r14, %rbx
jge 0x1382d
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x15b7a
cmpl %eax, %r15d
cmovgl %r15d, %eax
movl %eax, %r15d
movq %r15, 0x10(%rsp)
movslq %ebp, %rcx
movq %r12, %rdi
movq 0x20(%rsp), %rdx
subq %rdx, %rdi
incq %rdi
movq %rcx, 0x30(%rsp)
cmpq %rcx, %rdi
setl %al
jge 0x13e9b
movq 0x60(%rsp), %rcx
movq 0x10(%rsp), %r13
addl %r13d, %ecx
cmpl 0xd8(%rsp), %ecx
jl 0x13bdd
cmpl 0x54(%rsp), %ecx
jle 0x13bdd
cmpl 0x50(%rsp), %r13d
jl 0x13bdd
movq 0x8(%rsp), %r15
movl %r15d, %eax
movq %rax, 0x90(%rsp)
leaq -0x1(%r15), %rax
movq %rax, 0x70(%rsp)
negq %r15
movq %rdx, %rsi
movq %rdx, %r14
subq 0x30(%rsp), %r14
addq %rdi, %r14
testq %r14, %r14
movl $0x0, %eax
cmovleq %rax, %r14
movq %rdx, 0x20(%rsp)
cmpq %r14, %rdx
jl 0x138eb
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x15b7a
cmpl %r13d, %eax
jl 0x138e8
leaq -0x1(%rbx), %rsi
cmpq %r14, %rbx
movq %rsi, %rbx
jg 0x138c8
jmp 0x138eb
movq %rbx, %rsi
movq 0x28(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rbx
movq %rsi, 0x48(%rsp)
movq 0x30(%rsp), %rax
addq %rsi, %rax
cmpq %rbx, %rax
cmovlq %rax, %rbx
movq %r12, %rcx
negq %rcx
leaq 0x1(%r12), %rdx
movq %rcx, %rbp
movq %rdx, %r14
cmpq %rbx, %rdx
jge 0x13944
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x15b7a
leaq -0x1(%rbp), %rcx
leaq 0x1(%r14), %rdx
cmpl %r13d, %eax
jge 0x1391f
movq 0x48(%rsp), %rsi
leaq (%rsi,%rbp), %r8
movl $0x1, %edi
subq %r8, %rdi
movq %rbp, %rax
negq %rax
movq %rax, 0x88(%rsp)
cmpq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rax
jge 0x13b5f
movq %r8, 0x78(%rsp)
movq %rdi, 0x80(%rsp)
movq %r13, %rbx
cmpq %rax, %rsi
jge 0x13a4f
movl %ebx, %eax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %r13
cmpl $0x0, 0xe8(%rsp)
jle 0x13a41
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%r13,4), %edx
movq 0x8(%rsp), %rax
cmpl %eax, %edx
cmovbl %edx, %eax
movq 0x60(%rsp), %rcx
subl %eax, %ecx
addl %ebx, %eax
movq 0x68(%rsp), %rdi
movq (%rdi), %r8
addq 0x70(%rsp), %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xe8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r15
je 0x13a1c
testq %rsi, %rsi
je 0x13a1c
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13a0a
decq %rdi
decl %r10d
jne 0x139e8
jmp 0x13a41
movq 0x90(%rsp), %rax
leal (%rax,%rdi), %ecx
movq 0x10(%rsp), %rax
subl %edi, %eax
cmpl 0xd8(%rsp), %eax
jl 0x13a41
movq %rsi, 0x38(%rsp)
movl %ecx, 0x40(%rsp)
movl %eax, 0x44(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x16cc0
incq %r13
cmpq 0x20(%rsp), %r13
jne 0x13998
movq 0x88(%rsp), %r13
cmpq %r13, %r12
jge 0x13b19
movl %ebx, %eax
movq %rax, 0x20(%rsp)
incq %r12
cmpl $0x0, 0xe8(%rsp)
jle 0x13b10
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%r12,4), %edx
movq 0x8(%rsp), %rcx
cmpl %ecx, %edx
movl %ecx, %eax
cmovbl %edx, %eax
subl %eax, %ecx
addl %ebx, %eax
movq 0x68(%rsp), %rdi
movq (%rdi), %r8
addq 0x70(%rsp), %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xe8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r15
je 0x13aeb
testq %rsi, %rsi
je 0x13aeb
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13ad9
decq %rdi
decl %r10d
jne 0x13ab7
jmp 0x13b10
movq 0x90(%rsp), %rax
leal (%rax,%rdi), %ecx
movq 0x20(%rsp), %rax
subl %edi, %eax
cmpl 0xd8(%rsp), %eax
jl 0x13b10
movq %rsi, 0x38(%rsp)
movl %ecx, 0x40(%rsp)
movl %eax, 0x44(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x16cc0
cmpq %r12, %r13
jne 0x13a67
movq 0x28(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
cmpq %rax, %r14
jge 0x13b66
movq 0x18(%rsp), %r13
movq %r13, %rdi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0x15b7a
movl %eax, %r12d
movq %r13, %rdi
movq %r14, %rsi
callq 0x15b7a
movq %rbx, %rsi
cmpl %eax, %r12d
cmovgl %r12d, %eax
jmp 0x13b7b
movq %r13, 0x10(%rsp)
jmp 0x13b8d
movq 0x18(%rsp), %rdi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0x15b7a
movq %rbx, %rsi
movq %rax, 0x10(%rsp)
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %r8
cmpq 0x30(%rsp), %rdi
setl %al
jge 0x13e9b
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r13
addl %r13d, %ecx
cmpl 0xd8(%rsp), %ecx
jl 0x13bcd
cmpl 0x54(%rsp), %ecx
jle 0x13bcd
movq %rsi, %rdx
movq 0x88(%rsp), %r12
cmpl 0x50(%rsp), %r13d
jge 0x138a2
negq %rbp
movl $0x1, %edi
subq %r8, %rdi
movq %rbp, %r12
jmp 0x13be0
movq %rdx, %rsi
testb %al, %al
je 0x13e9b
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
addl %ecx, %eax
cmpl 0xd8(%rsp), %eax
jl 0x13e9b
cmpl 0x54(%rsp), %eax
jne 0x13e9b
movl 0x50(%rsp), %eax
cmpl %eax, 0x10(%rsp)
jl 0x13e9b
movslq 0xd0(%rsp), %rax
movq 0x28(%rsp), %rcx
addq 0xe8(%rcx), %rax
cmpq 0x8(%rsp), %rax
jl 0x13e9b
movq %rsi, %rax
subq 0x30(%rsp), %rax
addq %rdi, %rax
xorl %r14d, %r14d
testq %rax, %rax
cmovgq %rax, %r14
movq %rsi, %rbp
movq %rsi, 0x48(%rsp)
cmpq %r14, %rsi
movq 0x10(%rsp), %r13
jl 0x13c87
movq 0x48(%rsp), %rbx
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x15b7a
cmpl %r13d, %eax
jl 0x13c84
leaq -0x1(%rbx), %rbp
cmpq %r14, %rbx
movq %rbp, %rbx
jg 0x13c64
jmp 0x13c87
movq %rbx, %rbp
movq 0x28(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rbx
movq 0x30(%rsp), %rax
addq %rbp, %rax
decq %rax
cmpq %rbx, %rax
cmovlq %rax, %rbx
movq %r12, %rcx
negq %rcx
leaq 0x1(%r12), %r14
movq %rcx, %r15
cmpq %rbx, %r14
jge 0x13cda
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x15b7a
leaq -0x1(%r15), %rcx
incq %r14
cmpl %r13d, %eax
jge 0x13cb9
movl $0x1, %ecx
subq %rbp, %rcx
subq %r15, %rcx
cmpq 0x30(%rsp), %rcx
movq 0x48(%rsp), %rax
jge 0x13e9b
negq %r15
movq 0x10(%rsp), %r13
movl %r13d, %ecx
movq %rcx, 0x18(%rsp)
cmpq %rax, %rbp
jge 0x13dd4
movq 0x8(%rsp), %r14
movl %r14d, %eax
movq %rax, 0x20(%rsp)
leaq -0x1(%r14), %rbx
negq %r14
cmpl $0x0, 0xe8(%rsp)
jle 0x13dc6
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%rbp,4), %edx
movq 0x60(%rsp), %rax
cmpl %eax, %edx
cmovbl %edx, %eax
movq 0x8(%rsp), %rcx
subl %eax, %ecx
addl %r13d, %eax
movq 0x68(%rsp), %rdi
movq (%rdi), %r8
addq %rbx, %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xe8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r14
je 0x13da1
testq %rsi, %rsi
je 0x13da1
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13d92
decq %rdi
decl %r10d
jne 0x13d70
jmp 0x13dc6
movq 0x20(%rsp), %rax
leal (%rax,%rdi), %ecx
movq 0x18(%rsp), %rax
subl %edi, %eax
cmpl 0xd8(%rsp), %eax
jl 0x13dc6
movq %rsi, 0x38(%rsp)
movl %ecx, 0x40(%rsp)
movl %eax, 0x44(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x16cc0
incq %rbp
cmpq 0x48(%rsp), %rbp
jne 0x13d22
cmpq %r15, %r12
jge 0x13e9b
movq 0x8(%rsp), %r13
leaq -0x1(%r13), %r14
negq %r13
leaq 0x38(%rsp), %rbx
incq %r12
cmpl $0x0, 0xe8(%rsp)
jle 0x13e92
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rsi
movq 0x70(%rax), %rax
movl (%rax,%r12,4), %edx
movq 0x8(%rsp), %rcx
cmpl %ecx, %edx
movl %ecx, %eax
cmovbl %edx, %eax
subl %eax, %ecx
addl 0x10(%rsp), %eax
movq 0x68(%rsp), %rdi
movq (%rdi), %r8
addq %r14, %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xe8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r13
je 0x13e6f
testq %rsi, %rsi
je 0x13e6f
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13e60
decq %rdi
decl %r10d
jne 0x13e3e
jmp 0x13e92
movq 0x60(%rsp), %rax
leal (%rax,%rdi), %ecx
movq 0x18(%rsp), %rax
subl %edi, %eax
cmpl 0xd8(%rsp), %eax
jl 0x13e92
movq %rsi, 0x38(%rsp)
movl %ecx, 0x40(%rsp)
movl %eax, 0x44(%rsp)
movq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x16cc0
cmpq %r12, %r15
jne 0x13dee
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop