// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq %r8, 0x8(%rsp)
movl %edx, %r15d
movq %rsi, 0x10(%rsp)
movl 0x78(%rsp), %edx
movq %rcx, 0x18(%rsp)
movq 0x8(%rcx), %rax
movl -0x8(%rax), %r14d
leal (%r14,%r15), %ecx
cmpl %edx, %ecx
jl 0xfb36
movq %rdi, %r13
movl %r9d, %ebx
movq -0x10(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq -0x18(%rax), %r12
movq 0x8(%rsp), %rbp
cmpq 0x20(%rsp), %r12
jg 0xfb20
movq 0x70(%r13), %rax
movl (%rax,%r12,4), %ecx
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl %r15d, %edx
movl %r14d, %r8d
movq %rbp, %r9
movl 0x88(%rsp), %eax
pushq %rax
movl 0x80(%rsp), %eax
pushq %rax
callq 0x1123a
popq %rax
popq %rcx
incq %r12
jmp 0xfae4
testb %bl, %bl
je 0xfb36
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cmpq $0x18, %rax
jne 0xfb45
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %r9
addl $-0x2, %r9d
movslq 0x80(%rsp), %rax
movq %rax, 0x28(%rsp)
testl %r9d, %r9d
js 0xfb36
movl %r9d, %eax
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
imulq $0x18, %rax, %rdi
movq (%rcx,%rdi), %rbp
movq 0x8(%rcx,%rdi), %r8
subq %rbp, %r8
incq %r8
movq 0xe8(%r13), %rsi
movq 0x28(%rsp), %rax
cqto
idivq %rsi
cmpq %rax, %r8
jg 0xfb36
addq %rdi, %rcx
movl 0x10(%rcx), %r14d
leal (%r14,%r15), %eax
movl 0x70(%rsp), %edx
subl %esi, %edx
movl 0x78(%rsp), %esi
cmpl %esi, %edx
cmovlel %esi, %edx
cmpl %edx, %eax
jle 0xfb36
movq %r9, 0x30(%rsp)
movq 0x18(%rcx), %r12
movq 0x20(%rcx), %rbx
cmpq %r12, %rbp
jge 0xfc04
movq 0x70(%r13), %rax
movl (%rax,%rbp,4), %ecx
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl %r15d, %edx
movl %r14d, %r8d
movq 0x8(%rsp), %r9
movl 0x88(%rsp), %eax
pushq %rax
movl 0x80(%rsp), %eax
pushq %rax
callq 0x1123a
popq %rax
popq %rcx
incq %rbp
jmp 0xfbc9
movq 0x8(%rsp), %r12
movq 0x20(%rsp), %rbp
cmpq %rbp, %rbx
jge 0xfc4a
movq 0x70(%r13), %rax
movl 0x4(%rax,%rbx,4), %ecx
incq %rbx
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl %r15d, %edx
movl %r14d, %r8d
movq %r12, %r9
movl 0x88(%rsp), %eax
pushq %rax
movl 0x80(%rsp), %eax
pushq %rax
callq 0x1123a
addq $0x10, %rsp
jmp 0xfc0e
movq 0x30(%rsp), %r9
decl %r9d
jmp 0xfb61
nop