// File: /workspace/github_cpp_makefile_star2_O1/readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::collectIntervals(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, std::vector<interval_t, std::allocator<interval_t>>&, std::vector<match_t, std::allocator<match_t>>&, bool, int, int, int, int) const
void sparseSA::collectIntervals(const string &P, int prefix, vector<interval_t> & intervals, 
  vector<match_t> &matches, bool calcMli, int nextEndStop, int min_len, int maxCount, int maxLeft) const{
    interval_t xmi = intervals.back();
    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 || intervals.size()==1) return;
    //iterate over all intervals
    int index = intervals.size()-2;
    
    while(index >= 0 && intervals[index].size() <= (maxCount)/K && prefix+intervals[index].depth > max((int)(nextEndStop-K),min_len)){
        interval_t mli = intervals[index];
        long prevStart = intervals[index+1].start;
        long prevStop = intervals[index+1].end;
        for(long i = mli.start; i < prevStart; i++)
            find_LmaximalStrict(P, prefix, SA[i], mli.depth, matches, min_len, maxLeft);
        for(long i = prevStop+1; i <= xmi.end; i++)
            find_LmaximalStrict(P, prefix, SA[i], mli.depth, matches, min_len, maxLeft);
        index--;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, 0x20(%rsp)
movl %edx, %r15d
movq %rsi, 0x28(%rsp)
movq %rcx, 0x30(%rsp)
movq 0x8(%rcx), %rax
movl -0x8(%rax), %ebx
leal (%rbx,%r15), %ecx
cmpl 0x98(%rsp), %ecx
jl 0x1420d
movq %rdi, %r13
movl %r9d, 0x18(%rsp)
movq -0x18(%rax), %r14
movq -0x10(%rax), %rax
movq %rax, 0x40(%rsp)
cmpq %rax, %r14
jg 0x13fc0
movslq %r15d, %r12
movl %r12d, %eax
movq %rax, (%rsp)
leaq -0x1(%r12), %rbp
negq %r12
cmpl $0x0, 0xa8(%rsp)
jle 0x13fae
movq 0x50(%r13), %rsi
movq 0x70(%r13), %rax
movl (%rax,%r14,4), %edx
cmpl %r15d, %edx
movl %r15d, %eax
cmovbl %edx, %eax
movl %r15d, %ecx
subl %eax, %ecx
addl %ebx, %eax
movq 0x28(%rsp), %rdi
movq (%rdi), %r8
addq %rbp, %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xa8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r12
je 0x13f89
testq %rsi, %rsi
je 0x13f89
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13f7e
decq %rdi
decl %r10d
jne 0x13f5c
jmp 0x13fae
movq (%rsp), %rax
leal (%rax,%rdi), %ecx
movl %ebx, %eax
subl %edi, %eax
cmpl 0x98(%rsp), %eax
jl 0x13fae
movq %rsi, 0x8(%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16cc0
leaq 0x1(%r14), %rax
cmpq 0x40(%rsp), %r14
movq %rax, %r14
jne 0x13f16
cmpb $0x0, 0x18(%rsp)
je 0x1420d
movq 0x30(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cmpq $0x18, %rax
je 0x1420d
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %r10d # imm = 0xAAAAAAAB
addl $-0x2, %r10d
js 0x1420d
movslq 0xa0(%rsp), %rax
movq %rax, 0x48(%rsp)
movslq %r15d, %r14
movl %r15d, %eax
movq %rax, 0x38(%rsp)
leaq -0x1(%r14), %rax
movq %rax, 0x18(%rsp)
negq %r14
movl %r10d, %esi
movq 0x30(%rsp), %rax
movq (%rax), %rcx
leaq (%rsi,%rsi,2), %r8
movq (%rcx,%r8,8), %rbp
movq 0x8(%rcx,%r8,8), %r9
subq %rbp, %r9
incq %r9
movq 0xe8(%r13), %rdi
movq 0x48(%rsp), %rax
cqto
idivq %rdi
cmpq %rax, %r9
jg 0x1420d
leaq (%rcx,%r8,8), %rax
movl 0x10(%rax), %eax
movq %rax, (%rsp)
addl %r15d, %eax
movl 0x90(%rsp), %edx
subl %edi, %edx
movl 0x98(%rsp), %edi
cmpl %edi, %edx
cmovlel %edi, %edx
cmpl %edx, %eax
jle 0x1420d
movq %r10, 0x50(%rsp)
leaq (%rsi,%rsi,2), %rax
movq 0x18(%rcx,%rax,8), %rbx
movq 0x20(%rcx,%rax,8), %r12
cmpq %rbx, %rbp
jge 0x14142
cmpl $0x0, 0xa8(%rsp)
jle 0x14136
movq 0x50(%r13), %rsi
movq 0x70(%r13), %rax
movl (%rax,%rbp,4), %edx
cmpl %r15d, %edx
movl %r15d, %eax
cmovbl %edx, %eax
movl %r15d, %ecx
subl %eax, %ecx
addl (%rsp), %eax
movq 0x28(%rsp), %rdi
movq (%rdi), %r8
addq 0x18(%rsp), %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xa8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r14
je 0x14111
testq %rsi, %rsi
je 0x14111
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x14103
decq %rdi
decl %r10d
jne 0x140e1
jmp 0x14136
movq 0x38(%rsp), %rax
leal (%rax,%rdi), %ecx
movq (%rsp), %rax
subl %edi, %eax
cmpl 0x98(%rsp), %eax
jl 0x14136
movq %rsi, 0x8(%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16cc0
incq %rbp
cmpq %rbx, %rbp
jne 0x14099
movq 0x40(%rsp), %rbx
cmpq %rbx, %r12
jge 0x141fa
incq %r12
cmpl $0x0, 0xa8(%rsp)
jle 0x141f1
movq 0x50(%r13), %rsi
movq 0x70(%r13), %rax
movl (%rax,%r12,4), %edx
cmpl %r15d, %edx
movl %r15d, %eax
cmovbl %edx, %eax
movl %r15d, %ecx
subl %eax, %ecx
addl (%rsp), %eax
movq 0x28(%rsp), %rdi
movq (%rdi), %r8
addq 0x18(%rsp), %r8
leaq (%rsi,%rdx), %r9
decq %r9
movl 0xa8(%rsp), %r10d
xorl %edi, %edi
leaq (%rdx,%rdi), %rsi
cmpq %rdi, %r14
je 0x141cc
testq %rsi, %rsi
je 0x141cc
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x141be
decq %rdi
decl %r10d
jne 0x1419c
jmp 0x141f1
movq 0x38(%rsp), %rax
leal (%rax,%rdi), %ecx
movq (%rsp), %rax
subl %edi, %eax
cmpl 0x98(%rsp), %eax
jl 0x141f1
movq %rsi, 0x8(%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16cc0
cmpq %rbx, %r12
jne 0x14150
movq 0x50(%rsp), %rcx
leal -0x1(%rcx), %eax
testl %ecx, %ecx
movl %eax, %r10d
jg 0x1401a
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq