// File: 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:
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdx, 0xd8(%rsp)
movq %rsi, %rdx
movq 0xd8(%rsp), %rsi
movb %r8b, %al
movl 0x218(%rsp), %r8d
movl 0x210(%rsp), %r8d
movl 0x208(%rsp), %r8d
movl 0x200(%rsp), %r8d
movq %rdi, 0x1f0(%rsp)
movq %rdx, 0x1e8(%rsp)
movq %rsi, 0x1e0(%rsp)
movq %rcx, 0x1d8(%rsp)
andb $0x1, %al
movb %al, 0x1d7(%rsp)
movl %r9d, 0x1d0(%rsp)
movq 0x1f0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movl 0x30(%rsi), %eax
movl %eax, 0x1cc(%rsp)
addq $0x18, %rsi
leaq 0x1b0(%rsp), %rdi
callq 0x1fbd0
movq 0xd8(%rsp), %rsi
leaq 0x198(%rsp), %rdi
callq 0x1fbd0
movl 0x1c0(%rsp), %eax
addl 0x1cc(%rsp), %eax
cmpl 0x208(%rsp), %eax
jge 0x1b2ea
jmp 0x1bd79
movq 0x1b0(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x190(%rsp), %rax
cmpq 0x1b8(%rsp), %rax
jg 0x1b3a7
movq 0xd0(%rsp), %rdi
movq 0x1e8(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl 0x1cc(%rsp), %eax
movl %eax, 0xcc(%rsp)
addq $0x70, %rdi
movq 0x190(%rsp), %rsi
callq 0x1fb90
movq 0xd0(%rsp), %rdi
movq 0xc0(%rsp), %rsi
movl 0xcc(%rsp), %edx
movl (%rax), %eax
movl %eax, %ecx
movl 0x1c0(%rsp), %r8d
movq 0x1d8(%rsp), %r9
movl 0x208(%rsp), %r10d
movl 0x218(%rsp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1fa80
movq 0x190(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x190(%rsp)
jmp 0x1b2fa
testb $0x1, 0x1d7(%rsp)
je 0x1b3d5
movq 0x198(%rsp), %rax
cmpq 0x1b0(%rsp), %rax
jne 0x1b3da
movq 0x1a0(%rsp), %rax
cmpq 0x1b8(%rsp), %rax
jne 0x1b3da
jmp 0x1bd79
movq 0xd0(%rsp), %rcx
movq 0x1b8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rcx
movq 0xb8(%rsp), %rax
cmpq %rcx, %rax
jge 0x1b47d
movq 0xd0(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x1ed20
movq 0xd0(%rsp), %rdi
movl %eax, 0x18c(%rsp)
addq $0xa0, %rdi
movq 0x1b8(%rsp), %rsi
addq $0x1, %rsi
callq 0x1ed20
movl %eax, 0x188(%rsp)
leaq 0x18c(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x14d40
movl (%rax), %eax
movl %eax, 0x1c0(%rsp)
jmp 0x1b4a0
movq 0xd0(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x1ed20
movl %eax, 0x1c0(%rsp)
jmp 0x1b4a2
leaq 0x1b0(%rsp), %rdi
callq 0x1fbb0
movq %rax, %rcx
movslq 0x210(%rsp), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0xb7(%rsp)
jge 0x1b520
movl 0x1cc(%rsp), %ecx
addl 0x1c0(%rsp), %ecx
xorl %eax, %eax
cmpl 0x1d0(%rsp), %ecx
movb %al, 0xb7(%rsp)
jle 0x1b520
movl 0x1c0(%rsp), %ecx
xorl %eax, %eax
cmpl 0x1a8(%rsp), %ecx
movb %al, 0xb7(%rsp)
jl 0x1b520
movl 0x1c0(%rsp), %eax
addl 0x1cc(%rsp), %eax
cmpl 0x208(%rsp), %eax
setge %al
movb %al, 0xb7(%rsp)
movb 0xb7(%rsp), %al
testb $0x1, %al
jne 0x1b530
jmp 0x1b988
movq 0x1b0(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x178(%rsp)
movq $0x0, 0x168(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0xa8(%rsp)
movslq 0x210(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x1fbb0
movq 0xa0(%rsp), %rcx
movq %rax, %rdx
movq 0xa8(%rsp), %rax
subq %rdx, %rcx
subq %rcx, %rax
movq %rax, 0x160(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x1ec80
movq (%rax), %rax
movq %rax, 0x170(%rsp)
movq 0x1b0(%rsp), %rcx
xorl %eax, %eax
cmpq 0x170(%rsp), %rcx
movb %al, 0x9f(%rsp)
jl 0x1b612
movq 0xd0(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x1ed20
cmpl 0x1c0(%rsp), %eax
setge %al
movb %al, 0x9f(%rsp)
movb 0x9f(%rsp), %al
testb $0x1, %al
jne 0x1b61f
jmp 0x1b635
movq 0x1b0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x1b0(%rsp)
jmp 0x1b5ca
movq 0xd0(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, 0x150(%rsp)
movq 0x1b8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
movslq 0x210(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x1fbb0
movq 0x88(%rsp), %rcx
movq %rax, %rdx
movq 0x90(%rsp), %rax
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, 0x148(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x1efc0
movq (%rax), %rax
movq %rax, 0x158(%rsp)
movq 0x1b8(%rsp), %rcx
addq $0x1, %rcx
xorl %eax, %eax
cmpq 0x158(%rsp), %rcx
movb %al, 0x87(%rsp)
jge 0x1b714
movq 0xd0(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1b8(%rsp), %rsi
addq $0x1, %rsi
callq 0x1ed20
cmpl 0x1c0(%rsp), %eax
setge %al
movb %al, 0x87(%rsp)
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0x1b721
jmp 0x1b737
movq 0x1b8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1b8(%rsp)
jmp 0x1b6c4
leaq 0x1b0(%rsp), %rdi
callq 0x1fbb0
movslq 0x210(%rsp), %rcx
cmpq %rcx, %rax
jge 0x1b983
movq 0x1b0(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rax
cmpq 0x180(%rsp), %rax
jge 0x1b80c
movq 0xd0(%rsp), %rdi
movq 0x1e8(%rsp), %rax
movq %rax, 0x78(%rsp)
movl 0x1cc(%rsp), %eax
movl %eax, 0x80(%rsp)
addq $0x70, %rdi
movq 0x140(%rsp), %rsi
callq 0x1fb90
movq 0xd0(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x80(%rsp), %edx
movl (%rax), %eax
movl %eax, %ecx
movl 0x1c0(%rsp), %r8d
movq 0x1d8(%rsp), %r9
movl 0x208(%rsp), %r10d
movl 0x218(%rsp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1fa80
movq 0x140(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x140(%rsp)
jmp 0x1b765
movq 0x178(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rax
cmpq 0x1b8(%rsp), %rax
jg 0x1b8c1
movq 0xd0(%rsp), %rdi
movq 0x1e8(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0x1cc(%rsp), %eax
movl %eax, 0x74(%rsp)
addq $0x70, %rdi
movq 0x138(%rsp), %rsi
callq 0x1fb90
movq 0xd0(%rsp), %rdi
movq 0x68(%rsp), %rsi
movl 0x74(%rsp), %edx
movl (%rax), %eax
movl %eax, %ecx
movl 0x1c0(%rsp), %r8d
movq 0x1d8(%rsp), %r9
movl 0x208(%rsp), %r10d
movl 0x218(%rsp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1fa80
movq 0x138(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x138(%rsp)
jmp 0x1b820
movq 0xd0(%rsp), %rcx
movq 0x1b8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
jge 0x1b95e
movq 0xd0(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x1ed20
movq 0xd0(%rsp), %rdi
movl %eax, 0x134(%rsp)
addq $0xa0, %rdi
movq 0x1b8(%rsp), %rsi
addq $0x1, %rsi
callq 0x1ed20
movl %eax, 0x130(%rsp)
leaq 0x134(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x14d40
movl (%rax), %eax
movl %eax, 0x1c0(%rsp)
jmp 0x1b981
movq 0xd0(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x1ed20
movl %eax, 0x1c0(%rsp)
jmp 0x1b983
jmp 0x1b4a2
leaq 0x1b0(%rsp), %rdi
callq 0x1fbb0
movslq 0x210(%rsp), %rcx
cmpq %rcx, %rax
jge 0x1bd79
movl 0x1cc(%rsp), %eax
addl 0x1c0(%rsp), %eax
cmpl 0x1d0(%rsp), %eax
jne 0x1bd79
movl 0x1c0(%rsp), %eax
cmpl 0x1a8(%rsp), %eax
jl 0x1bd79
movl 0x1c0(%rsp), %eax
addl 0x1cc(%rsp), %eax
cmpl 0x208(%rsp), %eax
jl 0x1bd79
movq 0xd0(%rsp), %rdx
movslq 0x1cc(%rsp), %rax
movslq 0x200(%rsp), %rcx
addq 0xe8(%rdx), %rcx
cmpq %rcx, %rax
jg 0x1bd79
movq 0x1b0(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x120(%rsp)
movq $0x0, 0x110(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x58(%rsp)
movslq 0x210(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x1fbb0
movq 0x50(%rsp), %rcx
movq %rax, %rdx
movq 0x58(%rsp), %rax
subq %rdx, %rcx
subq %rcx, %rax
movq %rax, 0x108(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x1ec80
movq (%rax), %rax
movq %rax, 0x118(%rsp)
movq 0x1b0(%rsp), %rcx
xorl %eax, %eax
cmpq 0x118(%rsp), %rcx
movb %al, 0x4f(%rsp)
jl 0x1bae8
movq 0xd0(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x1ed20
cmpl 0x1c0(%rsp), %eax
setge %al
movb %al, 0x4f(%rsp)
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x1baf2
jmp 0x1bb08
movq 0x1b0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x1b0(%rsp)
jmp 0x1baa6
movq 0xd0(%rsp), %rcx
movq 0x38(%rcx), %rax
cqto
idivq 0xe8(%rcx)
movq %rax, 0xf8(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x40(%rsp)
movslq 0x210(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x1fbb0
movq 0x38(%rsp), %rcx
movq %rax, %rdx
movq 0x40(%rsp), %rax
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x1efc0
movq (%rax), %rax
movq %rax, 0x100(%rsp)
movq 0x1b8(%rsp), %rcx
addq $0x1, %rcx
xorl %eax, %eax
cmpq 0x100(%rsp), %rcx
movb %al, 0x37(%rsp)
jge 0x1bbd1
movq 0xd0(%rsp), %rdi
addq $0xa0, %rdi
movq 0x1b8(%rsp), %rsi
addq $0x1, %rsi
callq 0x1ed20
cmpl 0x1c0(%rsp), %eax
setge %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x1bbdb
jmp 0x1bbf1
movq 0x1b8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1b8(%rsp)
jmp 0x1bb87
leaq 0x1b0(%rsp), %rdi
callq 0x1fbb0
movslq 0x210(%rsp), %rcx
cmpq %rcx, %rax
jge 0x1bd77
movq 0x1b0(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
cmpq 0x128(%rsp), %rax
jge 0x1bcc0
movq 0xd0(%rsp), %rdi
movq 0x1e8(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0x1cc(%rsp), %eax
movl %eax, 0x30(%rsp)
addq $0x70, %rdi
movq 0xe8(%rsp), %rsi
callq 0x1fb90
movq 0xd0(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x30(%rsp), %edx
movl (%rax), %eax
movl %eax, %ecx
movl 0x1c0(%rsp), %r8d
movq 0x1d8(%rsp), %r9
movl 0x208(%rsp), %r10d
movl 0x218(%rsp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1fa80
movq 0xe8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe8(%rsp)
jmp 0x1bc1f
movq 0x120(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
cmpq 0x1b8(%rsp), %rax
jg 0x1bd75
movq 0xd0(%rsp), %rdi
movq 0x1e8(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x1cc(%rsp), %eax
movl %eax, 0x24(%rsp)
addq $0x70, %rdi
movq 0xe0(%rsp), %rsi
callq 0x1fb90
movq 0xd0(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x24(%rsp), %edx
movl (%rax), %eax
movl %eax, %ecx
movl 0x1c0(%rsp), %r8d
movq 0x1d8(%rsp), %r9
movl 0x208(%rsp), %r10d
movl 0x218(%rsp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1fa80
movq 0xe0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe0(%rsp)
jmp 0x1bcd4
jmp 0x1bd77
jmp 0x1bd79
addq $0x1f8, %rsp            # imm = 0x1F8
retq
nopw %cs:(%rax,%rax)