// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::traverse_faster(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, interval_t&, int, int) const
void sparseSA::traverse_faster(const string &P,const int prefix, interval_t &cur, int min_len, int maxBranching) const{
        if(hasKmer && cur.depth == 0 && min_len >= KMERSIZE){//free match first bases
            unsigned int index = 0;
            for(long i = 0; i < KMERSIZE; i++)
                index = (index << 2 ) | BITADD[ (unsigned char) P[prefix + i]];
            if(index < TABLESIZE && KMR[index].right>0){
                cur.depth = KMERSIZE;
                cur.start = KMR[index].left;
                cur.end = KMR[index].right;
            }
            else{
                return;//this results in no found seeds where the first KMERSIZE bases contain a non-ACGT character
            }
        }
        if(cur.depth >= (int) min_len || cur.size() <= maxBranching) return;
        size_t c = prefix + cur.depth;
        bool intervalFound = c < 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);
        else if(intervalFound)
            intervalFound = P[c] == S[((long)SA[cur.start])+(long)cur.depth];
        bool mismatchFound = false;
        while(intervalFound && !mismatchFound && c < P.length() && 
                (cur.depth < min_len && cur.size() > maxBranching)){
            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 < P.length() && cur.depth < minimum){
                    mismatchFound = S[((long)SA[cur.start])+(long)cur.depth] != P[c];
                    c++;
                    cur.depth += !mismatchFound;
                }
                intervalFound = c < P.length() && !mismatchFound &&
                        cur.depth < min_len && top_down_child(P[c], cur);
            }
            else{
                while(!mismatchFound && c < 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;
                }
            }
        }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r8d, %ebp
movq %rcx, %r14
movq %rsi, %r13
movq %rdi, %r12
movl 0x10(%rcx), %eax
cmpb $0x1, 0xf8(%rdi)
jne 0x15c1f
testl %eax, %eax
setne %cl
cmpl $0xa, %ebp
setl %sil
orb %cl, %sil
jne 0x15c1f
movslq %edx, %rcx
addq (%r13), %rcx
xorl %eax, %eax
leaq 0x2e871(%rip), %rsi     # 0x44440
xorl %edi, %edi
shll $0x2, %eax
movzbl (%rcx,%rdi), %r8d
orl (%rsi,%r8,4), %eax
incq %rdi
cmpq $0xa, %rdi
jne 0x15bd1
cmpl $0x100000, %eax         # imm = 0x100000
jae 0x1603f
movl %eax, %eax
movq 0x100(%r12), %rsi
movl 0x4(%rsi,%rax,8), %ecx
testq %rcx, %rcx
je 0x1603f
movl $0xa, 0x10(%r14)
movl (%rsi,%rax,8), %eax
movq %rax, (%r14)
movq %rcx, 0x8(%r14)
movl $0xa, %eax
cmpl %ebp, %eax
jge 0x1603f
movq (%r14), %rcx
movq 0x8(%r14), %rdi
movq %rdi, %rsi
subq %rcx, %rsi
incq %rsi
movslq %r9d, %r8
movq %r8, 0x30(%rsp)
cmpq %r8, %rsi
jle 0x1603f
addl %edx, %eax
movslq %eax, %r15
movq 0x8(%r13), %rbx
movq 0xd0(%r12), %rax
movslq (%rax,%rdi,4), %rsi
cmpq %rsi, %rcx
setl %dl
cmpq %rsi, %rdi
setge %dil
leaq 0xa0(%r12), %r8
movq %r8, 0x28(%rsp)
testb %dil, %dl
jne 0x15c80
movslq (%rax,%rcx,4), %rsi
movq 0x28(%rsp), %rdi
callq 0x15a0e
cmpq %r15, %rbx
jbe 0x1603f
movq %r12, 0x10(%rsp)
movq (%r14), %rcx
movq 0x8(%r14), %rdx
movq %rdx, %rdi
subq %rcx, %rdi
incq %rdi
movq (%r13), %rsi
movb (%rsi,%r15), %r8b
movl 0x10(%r14), %esi
cmpq $0x2, %rdi
movq %r13, 0x20(%rsp)
movl %ebp, 0xc(%rsp)
jl 0x15d1a
cmpl %esi, %eax
jne 0x15d1a
movq 0x10(%rsp), %rsi
movq 0xd0(%rsi), %rdi
movslq (%rdi,%rdx,4), %rbp
cmpq %rbp, %rcx
setl %sil
cmpq %rbp, %rdx
setge %dl
testb %dl, %sil
jne 0x15ced
movslq (%rdi,%rcx,4), %rbp
movq 0x10(%rsp), %rsi
movq 0x50(%rsi), %rdx
movq 0x70(%rsi), %rsi
movl (%rsi,%rcx,4), %ecx
addl %eax, %ecx
cmpb %r8b, (%rdx,%rcx)
jne 0x15d3e
decq %rbp
movq %rbp, 0x8(%r14)
movl 0xc(%rsp), %ebp
movq 0x10(%rsp), %r12
jmp 0x15de8
movslq %esi, %rax
movq 0x10(%rsp), %r12
movq 0x70(%r12), %rdx
movl (%rdx,%rcx,4), %ecx
addq 0x50(%r12), %rcx
cmpb (%rax,%rcx), %r8b
je 0x15de8
jmp 0x1603f
movslq (%rdi,%rbp,4), %rcx
cmpq %rcx, %rbp
jge 0x15dbc
movq 0x28(%rsp), %rbx
movq 0x10(%rsp), %r12
movl %r8d, %r13d
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x15a0e
movl %eax, 0x1c(%rsp)
movq 0xd0(%r12), %rax
movslq (%rax,%rbp,4), %rsi
movq %rbx, %rdi
callq 0x15a0e
movl %eax, %ecx
movq 0x50(%r12), %rdx
movq 0x70(%r12), %rsi
movl 0x10(%r14), %eax
cmpl %ecx, 0x1c(%rsp)
jne 0x15dc1
movq 0xd0(%r12), %rdi
movslq (%rdi,%rbp,4), %rcx
movl (%rsi,%rbp,4), %r8d
addl %eax, %r8d
cmpb %r13b, (%rdx,%r8)
movl %r13d, %r8d
movq 0x20(%rsp), %r13
je 0x1604e
movq %rcx, %rbp
cmpl (%rdi,%rcx,4), %ecx
jl 0x15d51
jmp 0x15dcf
movq %rbp, %rcx
jmp 0x15dcf
movq %rbp, %rcx
movq 0x20(%rsp), %rdi
movl %r13d, %r8d
movq %rdi, %r13
addl (%rsi,%rcx,4), %eax
cmpb %r8b, (%rdx,%rax)
movl 0xc(%rsp), %ebp
movq 0x10(%rsp), %r12
jne 0x1603f
movq %rcx, (%r14)
xorl %ebx, %ebx
movq 0x8(%r13), %rax
cmpq %rax, %r15
jae 0x1603f
movl 0x10(%r14), %ecx
cmpl %ebp, %ecx
jge 0x1603f
movq (%r14), %rdi
movq 0x8(%r14), %rdx
movq %rdx, %rsi
subq %rdi, %rsi
incq %rsi
cmpq 0x30(%rsp), %rsi
jle 0x1603f
incq %r15
incl %ecx
movl %ecx, 0x10(%r14)
cmpq %rdx, %rdi
jne 0x15e9b
cmpq %rax, %r15
jae 0x1601f
cmpl %ebp, %ecx
jge 0x1601f
movq 0x70(%r12), %rsi
movq 0x38(%r12), %rdi
movq 0x50(%r12), %r8
movq (%r13), %r9
movl (%rsi,%rdx,4), %r11d
movslq %ecx, %r10
addq %r11, %r10
movb $0x1, %bl
cmpq %rdi, %r10
jge 0x15e6c
movb (%r8,%r10), %r10b
cmpb (%r9,%r15), %r10b
setne %bl
incq %r15
movl %ebx, %r10d
xorb $0x1, %r10b
movzbl %r10b, %r10d
addl %r10d, %ecx
movl %ecx, 0x10(%r14)
testb %bl, %bl
jne 0x1601f
cmpq %rax, %r15
jae 0x1601f
cmpl %ebp, %ecx
jl 0x15e50
jmp 0x1601f
movq 0xd0(%r12), %rax
movslq (%rax,%rdx,4), %rsi
cmpq %rsi, %rdi
setl %cl
cmpq %rsi, %rdx
setge %dl
testb %dl, %cl
jne 0x15ebb
movslq (%rax,%rdi,4), %rsi
movq 0x28(%rsp), %rdi
callq 0x15a0e
cmpl %ebp, %eax
cmovgel %ebp, %eax
movq 0x8(%r13), %rsi
movq (%r14), %rdx
movl 0x10(%r14), %ecx
cmpq %rsi, %r15
jae 0x15f23
cmpl %eax, %ecx
jge 0x15f23
movq (%r13), %rdi
movq 0x50(%r12), %r8
movq 0x70(%r12), %r9
movl (%r9,%rdx,4), %r10d
movslq %ecx, %rcx
addq %r8, %r10
movb (%rcx,%r10), %r10b
movb (%rdi,%r15), %r11b
xorl %ebx, %ebx
cmpb %r11b, %r10b
sete %bl
addl %ebx, %ecx
movl %ecx, 0x10(%r14)
cmpb %r11b, %r10b
jne 0x1603f
incq %r15
xorl %ebx, %ebx
cmpq %rsi, %r15
jae 0x15f23
cmpl %eax, %ecx
jl 0x15eec
cmpq %rsi, %r15
jae 0x1603f
cmpl %ebp, %ecx
jge 0x1603f
movq 0x8(%r14), %rsi
movq 0xd0(%r12), %rax
movslq (%rax,%rsi,4), %rbp
cmpq %rbp, %rdx
setl %dil
cmpq %rbp, %rsi
setge %sil
testb %sil, %dil
jne 0x15f5b
movslq (%rax,%rdx,4), %rbp
movq (%r13), %rsi
movb (%rsi,%r15), %r8b
movq 0x50(%r12), %rsi
movq 0x70(%r12), %rdi
movl (%rdi,%rdx,4), %edx
addl %ecx, %edx
movb %r8b, 0x1c(%rsp)
cmpb %r8b, (%rsi,%rdx)
jne 0x15f8d
decq %rbp
movq %rbp, 0x8(%r14)
movl 0xc(%rsp), %ebp
jmp 0x1601f
movslq (%rax,%rbp,4), %rdx
movq %rbp, %rax
cmpq %rdx, %rbp
jge 0x16007
movq 0x28(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x15a0e
movl %eax, %r13d
movq 0x10(%rsp), %rax
movq 0xd0(%rax), %rax
movslq (%rax,%rbp,4), %rsi
movq %r12, %rdi
movq 0x10(%rsp), %r12
callq 0x15a0e
movq 0x50(%r12), %rsi
movq 0x70(%r12), %rdi
movl 0x10(%r14), %ecx
cmpl %eax, %r13d
jne 0x16004
movq 0xd0(%r12), %rdx
movslq (%rdx,%rbp,4), %rax
movl (%rdi,%rbp,4), %r8d
addl %ecx, %r8d
movb 0x1c(%rsp), %r9b
cmpb %r9b, (%rsi,%r8)
je 0x1602a
movq %rax, %rbp
cmpl (%rdx,%rax,4), %eax
jl 0x15f99
jmp 0x16007
movq %rbp, %rax
addl (%rdi,%rax,4), %ecx
movb 0x1c(%rsp), %dl
cmpb %dl, (%rsi,%rcx)
movl 0xc(%rsp), %ebp
movq 0x20(%rsp), %r13
jne 0x1603f
movq %rax, (%r14)
testb $0x1, %bl
je 0x15dea
jmp 0x1603f
movq %rbp, (%r14)
decq %rax
movq %rax, 0x8(%r14)
movl 0xc(%rsp), %ebp
movq 0x20(%rsp), %r13
jmp 0x1601f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, (%r14)
decq %rcx
movq %rcx, 0x8(%r14)
jmp 0x15d0c
nop