// File: /workspace/github_cpp_makefile_star2_O1/readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::traverse_keep(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, std::vector<interval_t, std::allocator<interval_t>>&, int, int) const
void sparseSA::traverse_keep(const string &P,const int prefix, vector<interval_t> &current, int min_len, int maxBranching) const{
    interval_t cur = current.back();
    if(cur.size() > maxBranching ) current.pop_back();
    if(cur.depth >= min_len || cur.size() <= -1) return;
    int c = prefix + cur.depth;
    bool intervalFound = c < (int) P.length();
    int curLCP; //check if this is correct for root interval (unlikely case)
    if (cur.start < CHILD[cur.end] && CHILD[cur.end] <= cur.end)
        curLCP = LCP[CHILD[cur.end]];
    else
        curLCP = LCP[CHILD[cur.start]];
    if (intervalFound && cur.size() > 1 && curLCP == cur.depth){
        intervalFound = top_down_child(P[c], cur);
        if(intervalFound && cur.size() <= maxBranching) current.push_back(cur);
    }
    else if(intervalFound)
        intervalFound = P[c] == S[((long)SA[cur.start])+cur.depth];
    bool mismatchFound = false;
    while(intervalFound && !mismatchFound &&
            c < (int) P.length() && (cur.depth < min_len && cur.size() > -1)){
        c++;
        cur.depth++;
        if(cur.start != cur.end){
            int childLCP;
            //calculate LCP of child node, which is now cur. the LCP value
            //of the parent is currently c - prefix
            if(cur.start < (long) CHILD[cur.end] && (long) CHILD[cur.end] <= cur.end)
                childLCP = LCP[CHILD[cur.end]];
            else
                childLCP = LCP[CHILD[cur.start]];
            int minimum = min(childLCP,min_len);
            //match along branch, note: no cur.size() restriction as this does not change 
            while(!mismatchFound && c < (int) P.length() && cur.depth < minimum){
                mismatchFound = S[((long)SA[cur.start])+cur.depth] != P[c];
                c++;
                cur.depth += !mismatchFound;
            }
            intervalFound = c < (int) P.length() && !mismatchFound &&
                    cur.depth < min_len && top_down_child(P[c], cur);
            if(intervalFound && cur.size() <= maxBranching) current.push_back(cur);
        }
        else{
            while(!mismatchFound && c < (int) P.length() && cur.depth < min_len){
                mismatchFound = (long) SA[cur.start]+cur.depth >= N ||
                        S[((long)SA[cur.start])+cur.depth] != P[c];
                c++;
                cur.depth += !mismatchFound;
            }
        }
    }
    if(!current.empty() && current.back().start == cur.start && current.back().end == cur.end && current.back().depth < cur.depth)
        current.back().depth = cur.depth;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %r13d
movq %rsi, %r12
movq 0x8(%rcx), %rsi
movq -0x18(%rsi), %rax
movq %rax, 0x18(%rsp)
movq -0x10(%rsi), %r10
movq %r10, 0x20(%rsp)
movl -0x8(%rsi), %r15d
movl %r15d, 0x28(%rsp)
movq %r10, %r8
subq %rax, %r8
incq %r8
movslq %r9d, %r14
cmpq %r14, %r8
jle 0x1656a
addq $-0x18, %rsi
movq %rsi, 0x8(%rcx)
cmpl %r13d, %r15d
setge %sil
testq %r8, %r8
sets %r8b
orb %sil, %r8b
jne 0x16ad1
movq %rcx, 0x48(%rsp)
addl %edx, %r15d
movl 0x8(%r12), %ebp
cmpl %ebp, %r15d
setl %bl
movq 0xd0(%rdi), %rdx
movslq (%rdx,%r10,4), %rsi
cmpq %rsi, %rax
setl %r8b
cmpq %rsi, %r10
setge %cl
movq %rdi, 0x10(%rsp)
addq $0xa0, %rdi
movq %rdi, 0x38(%rsp)
testb %cl, %r8b
jne 0x165c6
movslq (%rdx,%rax,4), %rsi
movq 0x38(%rsp), %rdi
callq 0x15b7a
cmpl %ebp, %r15d
movq 0x10(%rsp), %r11
movq %r14, 0x40(%rsp)
jge 0x1673b
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rsi
movq %rsi, %rdi
subq %rcx, %rdi
incq %rdi
movslq %r15d, %rdx
movq (%r12), %r8
movb (%r8,%rdx), %bpl
movl 0x28(%rsp), %edx
cmpq $0x2, %rdi
jl 0x16651
cmpl %edx, %eax
jne 0x16651
movq 0xd0(%r11), %rdi
movslq (%rdi,%rsi,4), %rax
cmpq %rax, %rcx
setl %r8b
cmpq %rax, %rsi
setge %sil
testb %sil, %r8b
jne 0x16631
movslq (%rdi,%rcx,4), %rax
movq 0x50(%r11), %rsi
movq 0x70(%r11), %rdi
addl (%rdi,%rcx,4), %edx
cmpb %bpl, (%rsi,%rdx)
jne 0x1666b
decq %rax
movq %rax, 0x20(%rsp)
movb $0x1, %bl
jmp 0x16711
movq 0x70(%r11), %rax
movl (%rax,%rcx,4), %eax
addq 0x50(%r11), %rax
movslq %edx, %rcx
cmpb (%rcx,%rax), %bpl
sete %bl
jmp 0x1673b
movl %r13d, 0xc(%rsp)
movq 0x38(%rsp), %r14
movq %rax, %r13
movq 0xd0(%r11), %rax
movslq (%rax,%r13,4), %rax
cmpq %rax, %r13
jge 0x166e6
movq %r14, %rdi
movq %r13, %rsi
callq 0x15b7a
movl %eax, %ebx
movq 0x10(%rsp), %rax
movq 0xd0(%rax), %rax
movslq (%rax,%r13,4), %rsi
movq %r14, %rdi
callq 0x15b7a
movq 0x10(%rsp), %r11
cmpl %eax, %ebx
jne 0x166e6
movq 0xd0(%r11), %rax
movslq (%rax,%r13,4), %rax
movq 0x50(%r11), %rcx
movq 0x70(%r11), %rdx
movl 0x28(%rsp), %esi
addl (%rdx,%r13,4), %esi
cmpb %bpl, (%rcx,%rsi)
jne 0x16675
movq %r13, 0x18(%rsp)
decq %rax
movq %rax, 0x20(%rsp)
jmp 0x16701
movq 0x50(%r11), %rax
movq 0x70(%r11), %rcx
movl 0x28(%rsp), %edx
addl (%rcx,%r13,4), %edx
cmpb %bpl, (%rax,%rdx)
jne 0x16705
movq %r13, 0x18(%rsp)
movb $0x1, %bl
jmp 0x16707
xorl %ebx, %ebx
movl 0xc(%rsp), %r13d
movq 0x40(%rsp), %r14
testb %bl, %bl
je 0x1673b
movq 0x20(%rsp), %rax
subq 0x18(%rsp), %rax
incq %rax
cmpq %r14, %rax
jg 0x1673b
leaq 0x18(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x164f8
movq 0x10(%rsp), %r11
testb %bl, %bl
je 0x16aa1
xorl %ebp, %ebp
movl %r13d, 0xc(%rsp)
movq %r12, 0x30(%rsp)
testb $0x1, %bpl
jne 0x16aa1
movq 0x8(%r12), %r9
cmpl %r9d, %r15d
jge 0x16aa1
movl 0x28(%rsp), %edx
cmpl %r13d, %edx
jge 0x16aa1
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, %rsi
subq %rax, %rsi
incq %rsi
js 0x16aa1
movslq %r15d, %r10
leaq 0x1(%r10), %r14
incl %edx
movl %edx, 0x28(%rsp)
cmpq %rcx, %rax
jne 0x16830
testb $0x1, %bpl
jne 0x16a95
cmpl %r9d, %r14d
jge 0x16a95
movl 0x28(%rsp), %ecx
cmpl %r13d, %ecx
jge 0x16917
movq 0x70(%r11), %rdx
movq 0x38(%r11), %rsi
movq 0x50(%r11), %rdi
movq (%r12), %r8
movslq %r9d, %r9
addq $0x2, %r10
movq %r10, %r14
movl (%rdx,%rax,4), %r11d
movslq %ecx, %r10
addq %r11, %r10
movb $0x1, %bpl
cmpq %rsi, %r10
jge 0x167fc
movb (%rdi,%r10), %r10b
cmpb -0x1(%r8,%r14), %r10b
setne %bpl
movl %ebp, %r10d
xorb $0x1, %r10b
movzbl %r10b, %r10d
addl %r10d, %ecx
movl %ecx, 0x28(%rsp)
testb %bpl, %bpl
jne 0x16a90
cmpq %r9, %r14
jge 0x16a90
incq %r14
cmpl %r13d, %ecx
jl 0x167dd
decl %r14d
jmp 0x16a90
movq 0xd0(%r11), %rdx
movslq (%rdx,%rcx,4), %rsi
cmpq %rsi, %rax
setge %dil
cmpq %rsi, %rcx
setl %cl
orb %dil, %cl
je 0x16851
movslq (%rdx,%rax,4), %rsi
movq 0x38(%rsp), %rdi
callq 0x15b7a
testb $0x1, %bpl
je 0x16869
movl %ebp, %r9d
jmp 0x1693d
cmpl %r13d, %eax
cmovgel %r13d, %eax
movslq 0x8(%r12), %rcx
cmpq %r14, %rcx
jle 0x16861
movl 0x28(%rsp), %r11d
movl %ebp, %r9d
cmpl %eax, %r11d
jge 0x1693d
movq %r15, 0x50(%rsp)
movslq %r11d, %rdx
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %r9
movq 0x70(%r9), %rdi
cltq
movq (%r12), %r8
addq %r14, %r8
movq 0x50(%r9), %r10
addq %rdx, %r10
movl %r11d, %r11d
xorl %ebx, %ebx
movl (%rdi,%rsi,4), %r9d
addq %r10, %r9
movb (%rbx,%r9), %bpl
movb (%r8,%rbx), %r13b
xorl %r9d, %r9d
cmpb %r13b, %bpl
sete %r9b
addl %r11d, %r9d
addl %ebx, %r9d
movl %r9d, 0x28(%rsp)
cmpb %r13b, %bpl
setne %r9b
jne 0x16922
leaq (%rbx,%r14), %r12
incq %r12
leaq 0x1(%rbx), %r15
cmpq %rcx, %r12
jge 0x16902
leaq (%rbx,%rdx), %r12
incq %r12
movq %r15, %rbx
cmpq %rax, %r12
jl 0x168b6
cmpb %r13b, %bpl
setne %bpl
movq 0x50(%rsp), %rax
leal (%rax,%r15), %r14d
incl %r14d
jmp 0x16933
incl %r15d
movl %r15d, %r14d
jmp 0x16a95
setne %bpl
movq 0x50(%rsp), %rax
leal (%rax,%rbx), %r14d
addl $0x2, %r14d
movl 0xc(%rsp), %r13d
movq 0x30(%rsp), %r12
xorl %ebx, %ebx
testb $0x1, %r9b
jne 0x16a33
cmpl 0x8(%r12), %r14d
movq 0x10(%rsp), %r11
jge 0x16a69
movl 0x28(%rsp), %ecx
cmpl %r13d, %ecx
jge 0x16a3a
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rdi
movq 0xd0(%r11), %rsi
movslq (%rsi,%rdi,4), %rax
cmpq %rax, %rdx
setl %r8b
cmpq %rax, %rdi
setge %dil
testb %dil, %r8b
jne 0x16992
movslq (%rsi,%rdx,4), %rax
movslq %r14d, %rsi
movq (%r12), %rdi
movb (%rdi,%rsi), %r12b
movq 0x50(%r11), %rsi
movq 0x70(%r11), %rdi
addl (%rdi,%rdx,4), %ecx
cmpb %r12b, (%rsi,%rcx)
jne 0x169bd
decq %rax
movq %rax, 0x20(%rsp)
movb $0x1, %bl
jmp 0x16a64
movq %rax, %r13
movq 0xd0(%r11), %rax
movslq (%rax,%r13,4), %rax
cmpq %rax, %r13
jge 0x16a3e
movq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x15b7a
movl %eax, %ebx
movq 0x10(%rsp), %rax
movq 0xd0(%rax), %rax
movslq (%rax,%r13,4), %rsi
movq %r15, %rdi
callq 0x15b7a
movq 0x10(%rsp), %r11
cmpl %eax, %ebx
jne 0x16a3e
movq 0xd0(%r11), %rax
movslq (%rax,%r13,4), %rax
movq 0x50(%r11), %rcx
movq 0x70(%r11), %rdx
movl 0x28(%rsp), %esi
addl (%rdx,%r13,4), %esi
cmpb %r12b, (%rcx,%rsi)
jne 0x169bd
movq %r13, 0x18(%rsp)
decq %rax
movq %rax, 0x20(%rsp)
jmp 0x16a59
movq 0x10(%rsp), %r11
jmp 0x16a69
xorl %ebx, %ebx
jmp 0x16a69
movq 0x50(%r11), %rax
movq 0x70(%r11), %rcx
movl 0x28(%rsp), %edx
addl (%rcx,%r13,4), %edx
cmpb %r12b, (%rax,%rdx)
jne 0x16a5d
movq %r13, 0x18(%rsp)
movb $0x1, %bl
jmp 0x16a5f
xorl %ebx, %ebx
movl 0xc(%rsp), %r13d
movq 0x30(%rsp), %r12
testb %bl, %bl
je 0x16a95
movq 0x20(%rsp), %rax
subq 0x18(%rsp), %rax
incq %rax
cmpq 0x40(%rsp), %rax
jg 0x16a95
movq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x164f8
movq 0x10(%rsp), %r11
movl %r14d, %r15d
testb $0x1, %bl
jne 0x1674f
movq 0x48(%rsp), %rcx
movq 0x8(%rcx), %rax
cmpq %rax, (%rcx)
je 0x16ad1
movq -0x18(%rax), %rcx
cmpq 0x18(%rsp), %rcx
jne 0x16ad1
movq -0x10(%rax), %rcx
cmpq 0x20(%rsp), %rcx
jne 0x16ad1
movl 0x28(%rsp), %ecx
cmpl %ecx, -0x8(%rax)
jge 0x16ad1
movl %ecx, -0x8(%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq