// File: /workspace/github_cpp_makefile_star2_O3/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 0x13fbd
movq %rdi, %r13
movl %r9d, 0x18(%rsp)
movq -0x18(%rax), %r14
movq -0x10(%rax), %rax
movq %rax, 0x40(%rsp)
cmpq %rax, %r14
jg 0x13d76
movslq %r15d, %r12
movl %r12d, %eax
movq %rax, (%rsp)
leaq -0x1(%r12), %rbp
negq %r12
cmpl $0x0, 0xa8(%rsp)
jle 0x13d64
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 0x13d3f
testq %rsi, %rsi
je 0x13d3f
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13d34
decq %rdi
decl %r10d
jne 0x13d12
jmp 0x13d64
movq (%rsp), %rax
leal (%rax,%rdi), %ecx
movl %ebx, %eax
subl %edi, %eax
cmpl 0x98(%rsp), %eax
jl 0x13d64
movq %rsi, 0x8(%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16a7a
leaq 0x1(%r14), %rax
cmpq 0x40(%rsp), %r14
movq %rax, %r14
jne 0x13ccc
cmpb $0x0, 0x18(%rsp)
je 0x13fbd
movq 0x30(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cmpq $0x18, %rax
je 0x13fbd
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %r9d # imm = 0xAAAAAAAB
addl $-0x2, %r9d
js 0x13fbd
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 %r9d, %eax
movq 0x30(%rsp), %rcx
movq (%rcx), %rsi
leaq (%rax,%rax,2), %rdi
movq (%rsi,%rdi,8), %rbp
movq 0x8(%rsi,%rdi,8), %r8
subq %rbp, %r8
incq %r8
movq 0xe8(%r13), %rcx
movq 0x48(%rsp), %rax
cqto
idivq %rcx
cmpq %rax, %r8
jg 0x13fbd
leaq (%rsi,%rdi,8), %rax
movl 0x10(%rax), %edx
movq %rdx, (%rsp)
addl %r15d, %edx
movl 0x90(%rsp), %esi
subl %ecx, %esi
movl 0x98(%rsp), %ecx
cmpl %ecx, %esi
cmovlel %ecx, %esi
cmpl %esi, %edx
jle 0x13fbd
movq %r9, 0x50(%rsp)
movq 0x18(%rax), %rbx
movq 0x20(%rax), %r12
cmpq %rbx, %rbp
jge 0x13ef2
cmpl $0x0, 0xa8(%rsp)
jle 0x13ee6
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 0x13ec1
testq %rsi, %rsi
je 0x13ec1
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13eb3
decq %rdi
decl %r10d
jne 0x13e91
jmp 0x13ee6
movq 0x38(%rsp), %rax
leal (%rax,%rdi), %ecx
movq (%rsp), %rax
subl %edi, %eax
cmpl 0x98(%rsp), %eax
jl 0x13ee6
movq %rsi, 0x8(%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16a7a
incq %rbp
cmpq %rbx, %rbp
jne 0x13e49
movq 0x40(%rsp), %rbx
cmpq %rbx, %r12
jge 0x13faa
incq %r12
cmpl $0x0, 0xa8(%rsp)
jle 0x13fa1
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 0x13f7c
testq %rsi, %rsi
je 0x13f7c
movb (%r8,%rdi), %r11b
cmpb (%r9,%rdi), %r11b
jne 0x13f6e
decq %rdi
decl %r10d
jne 0x13f4c
jmp 0x13fa1
movq 0x38(%rsp), %rax
leal (%rax,%rdi), %ecx
movq (%rsp), %rax
subl %edi, %eax
cmpl 0x98(%rsp), %eax
jl 0x13fa1
movq %rsi, 0x8(%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16a7a
cmpq %rbx, %r12
jne 0x13f00
movq 0x50(%rsp), %rcx
leal -0x1(%rcx), %eax
testl %ecx, %ecx
movl %eax, %r9d
jg 0x13dd0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq