// File: 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:
subq $0xe8, %rsp
movb %r9b, %al
movl 0x108(%rsp), %r9d
movl 0x100(%rsp), %r9d
movl 0xf8(%rsp), %r9d
movl 0xf0(%rsp), %r9d
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movl %edx, 0xd4(%rsp)
movq %rcx, 0xc8(%rsp)
movq %r8, 0xc0(%rsp)
andb $0x1, %al
movb %al, 0xbf(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x1fc10
movq %rax, %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1fbd0
movl 0xb0(%rsp), %eax
addl 0xd4(%rsp), %eax
cmpl 0xf8(%rsp), %eax
jge 0x1be30
jmp 0x1c190
movq 0xa0(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jg 0x1bedb
movq 0x50(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0xd4(%rsp), %eax
movl %eax, 0x4c(%rsp)
addq $0x70, %rdi
movq 0x98(%rsp), %rsi
callq 0x1fb90
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl 0x4c(%rsp), %edx
movl (%rax), %eax
movl %eax, %ecx
movl 0xb0(%rsp), %r8d
movq 0xc0(%rsp), %r9
movl 0xf8(%rsp), %r10d
movl 0x108(%rsp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1fa80
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x1be40
testb $0x1, 0xbf(%rsp)
je 0x1bef8
movq 0xc8(%rsp), %rdi
callq 0x1fc50
cmpq $0x1, %rax
jne 0x1befd
jmp 0x1c190
movq 0xc8(%rsp), %rdi
callq 0x1fc50
subq $0x2, %rax
movl %eax, 0x94(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x94(%rsp)
movb %al, 0x3f(%rsp)
jl 0x1bfdb
movq 0xc8(%rsp), %rdi
movslq 0x94(%rsp), %rsi
callq 0x1fc70
movq %rax, %rdi
callq 0x1fbb0
movq 0x50(%rsp), %rsi
movq %rax, %rcx
movslq 0x100(%rsp), %rax
cqto
idivq 0xe8(%rsi)
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x3f(%rsp)
jg 0x1bfdb
movl 0xd4(%rsp), %eax
movl %eax, 0x34(%rsp)
movq 0xc8(%rsp), %rdi
movslq 0x94(%rsp), %rsi
callq 0x1fc70
movq 0x50(%rsp), %rcx
movq %rax, %rdx
movl 0x34(%rsp), %eax
addl 0x10(%rdx), %eax
movl %eax, 0x38(%rsp)
movslq 0xf0(%rsp), %rax
subq 0xe8(%rcx), %rax
movl %eax, 0x90(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x14d40
movq %rax, %rcx
movl 0x38(%rsp), %eax
cmpl (%rcx), %eax
setg %al
movb %al, 0x3f(%rsp)
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x1bfe8
jmp 0x1c190
movq 0xc8(%rsp), %rdi
movslq 0x94(%rsp), %rsi
callq 0x1fc70
movq %rax, %rsi
leaq 0x78(%rsp), %rdi
callq 0x1fbd0
movq 0xc8(%rsp), %rdi
movl 0x94(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x1fc70
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movq 0xc8(%rsp), %rdi
movl 0x94(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x1fc70
movq 0x8(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
cmpq 0x70(%rsp), %rax
jge 0x1c0e1
movq 0x50(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0xd4(%rsp), %eax
movl %eax, 0x30(%rsp)
addq $0x70, %rdi
movq 0x60(%rsp), %rsi
callq 0x1fb90
movq 0x50(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x30(%rsp), %edx
movl (%rax), %eax
movl %eax, %ecx
movl 0x88(%rsp), %r8d
movq 0xc0(%rsp), %r9
movl 0xf8(%rsp), %r10d
movl 0x108(%rsp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1fa80
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
jmp 0x1c059
movq 0x68(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jg 0x1c17a
movq 0x50(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0xd4(%rsp), %eax
movl %eax, 0x24(%rsp)
addq $0x70, %rdi
movq 0x58(%rsp), %rsi
callq 0x1fb90
movq 0x50(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x24(%rsp), %edx
movl (%rax), %eax
movl %eax, %ecx
movl 0x88(%rsp), %r8d
movq 0xc0(%rsp), %r9
movl 0xf8(%rsp), %r10d
movl 0x108(%rsp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x1fa80
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
jmp 0x1c0ef
movl 0x94(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x1bf15
addq $0xe8, %rsp
retq
nopl (%rax,%rax)