// File: /workspace/github_cpp_makefile_star2_O1/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, %r13d
movq %rcx, %r14
movq %rsi, %r15
cmpb $0x1, 0xf8(%rdi)
jne 0x15d7b
cmpl $0xa, %r13d
jl 0x15d7b
cmpl $0x0, 0x10(%r14)
jne 0x15d7b
movslq %edx, %rcx
addq (%r15), %rcx
xorl %eax, %eax
leaq 0x2e710(%rip), %rsi     # 0x44440
xorl %r10d, %r10d
shll $0x2, %eax
movzbl (%rcx,%r10), %r8d
orl (%rsi,%r8,4), %eax
incq %r10
cmpq $0xa, %r10
jne 0x15d33
cmpl $0x100000, %eax         # imm = 0x100000
jae 0x161f1
movl %eax, %eax
movq 0x100(%rdi), %rsi
movl 0x4(%rsi,%rax,8), %ecx
testq %rcx, %rcx
je 0x161f1
movl $0xa, 0x10(%r14)
movl (%rsi,%rax,8), %eax
movq %rax, (%r14)
movq %rcx, 0x8(%r14)
movl 0x10(%r14), %esi
cmpl %r13d, %esi
jge 0x161f1
movq (%r14), %rax
movq 0x8(%r14), %rcx
movq %rcx, %r8
subq %rax, %r8
incq %r8
movslq %r9d, %r9
movq %r9, 0x30(%rsp)
cmpq %r9, %r8
jle 0x161f1
addl %edx, %esi
movslq %esi, %r12
movq 0x8(%r15), %rbx
cmpq %r12, %rbx
seta %bpl
movq 0xd0(%rdi), %rdx
movslq (%rdx,%rcx,4), %rsi
cmpq %rsi, %rax
setl %r8b
cmpq %rsi, %rcx
setge %cl
movq %rdi, 0x10(%rsp)
addq $0xa0, %rdi
movq %rdi, 0x20(%rsp)
testb %cl, %r8b
jne 0x15deb
movslq (%rdx,%rax,4), %rsi
movq 0x20(%rsp), %rdi
callq 0x15b7a
cmpq %r12, %rbx
movl %r13d, 0x2c(%rsp)
movq 0x10(%rsp), %r10
jbe 0x15f28
movq (%r14), %rcx
movq 0x8(%r14), %rsi
movq %rsi, %rdi
subq %rcx, %rdi
incq %rdi
movq (%r15), %rdx
movb (%rdx,%r12), %dl
movb %dl, 0xf(%rsp)
movl 0x10(%r14), %edx
cmpq $0x2, %rdi
jl 0x15eeb
cmpl %edx, %eax
jne 0x15eeb
movq 0xd0(%r10), %rdi
movslq (%rdi,%rsi,4), %rax
cmpq %rax, %rcx
setl %r8b
cmpq %rax, %rsi
setge %sil
testb %sil, %r8b
jne 0x15e5b
movslq (%rdi,%rcx,4), %rax
movq 0x50(%r10), %rsi
movq 0x70(%r10), %rdi
addl (%rdi,%rcx,4), %edx
movb 0xf(%rsp), %cl
cmpb %cl, (%rsi,%rdx)
je 0x15ee2
movq 0x20(%rsp), %rbx
movq %rax, %rbp
movq 0xd0(%r10), %rax
movslq (%rax,%rbp,4), %rax
cmpq %rax, %rbp
jge 0x15f06
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x15b7a
movl %eax, %r13d
movq 0x10(%rsp), %rax
movq 0xd0(%rax), %rax
movslq (%rax,%rbp,4), %rsi
movq %rbx, %rdi
callq 0x15b7a
movq 0x10(%rsp), %r10
cmpl %eax, %r13d
movl 0x2c(%rsp), %r13d
jne 0x15f06
movq 0xd0(%r10), %rax
movslq (%rax,%rbp,4), %rax
movq 0x50(%r10), %rcx
movq 0x70(%r10), %rdx
movl 0x10(%r14), %esi
addl (%rdx,%rbp,4), %esi
movb 0xf(%rsp), %dl
cmpb %dl, (%rcx,%rsi)
jne 0x15e74
movq %rbp, (%r14)
decq %rax
movq %rax, 0x8(%r14)
jmp 0x15f25
movq 0x70(%r10), %rax
movl (%rax,%rcx,4), %eax
addq 0x50(%r10), %rax
movslq %edx, %rcx
movb 0xf(%rsp), %dl
cmpb (%rcx,%rax), %dl
sete %bpl
jmp 0x15f28
movq 0x50(%r10), %rax
movq 0x70(%r10), %rcx
movl 0x10(%r14), %edx
addl (%rcx,%rbp,4), %edx
movb 0xf(%rsp), %cl
cmpb %cl, (%rax,%rdx)
jne 0x16200
movq %rbp, (%r14)
movb $0x1, %bpl
testb %bpl, %bpl
je 0x161f1
xorl %ebx, %ebx
movq %r15, 0x18(%rsp)
testb $0x1, %bl
jne 0x161f1
movq 0x8(%r15), %rcx
cmpq %rcx, %r12
jae 0x161f1
movl 0x10(%r14), %esi
cmpl %r13d, %esi
jge 0x161f1
movq (%r14), %rax
movq 0x8(%r14), %rdx
movq %rdx, %rdi
subq %rax, %rdi
incq %rdi
cmpq 0x30(%rsp), %rdi
jle 0x161f1
leaq 0x1(%r12), %r15
incl %esi
movl %esi, 0x10(%r14)
cmpq %rdx, %rax
jne 0x16002
testb $0x1, %bl
jne 0x161df
cmpq %rcx, %r15
jae 0x161df
movl 0x10(%r14), %edx
cmpl %r13d, %edx
jge 0x161df
movq 0x70(%r10), %rsi
movq 0x38(%r10), %rdi
movq 0x50(%r10), %r8
movq 0x18(%rsp), %r9
movq (%r9), %r9
movl (%rsi,%rax,4), %r11d
movslq %edx, %r10
addq %r11, %r10
movb $0x1, %bl
cmpq %rdi, %r10
jge 0x15fd5
movb (%r8,%r10), %r10b
cmpb (%r9,%r15), %r10b
setne %bl
incq %r15
movl %ebx, %r10d
xorb $0x1, %r10b
movzbl %r10b, %r10d
addl %r10d, %edx
movl %edx, 0x10(%r14)
testb %bl, %bl
jne 0x15ff8
cmpq %rcx, %r15
jae 0x15ff8
cmpl %r13d, %edx
jl 0x15fb9
movq 0x10(%rsp), %r10
jmp 0x161df
movq 0xd0(%r10), %rcx
movslq (%rcx,%rdx,4), %rsi
cmpq %rsi, %rax
setge %dil
cmpq %rsi, %rdx
setl %dl
orb %dil, %dl
je 0x16023
movslq (%rcx,%rax,4), %rsi
movq 0x20(%rsp), %rdi
callq 0x15b7a
cmpl %r13d, %eax
cmovgel %r13d, %eax
testb $0x1, %bl
je 0x16041
movl %ebx, %r9d
jmp 0x160c1
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %rcx
cmpq %rcx, %r15
movq 0x10(%rsp), %r10
jae 0x161b5
movl 0x10(%r14), %ebp
movl %ebx, %r9d
cmpl %eax, %ebp
jge 0x160c6
movq 0x18(%rsp), %rdx
movq (%rdx), %rdx
movq (%r14), %rsi
movq 0x50(%r10), %rdi
movq 0x70(%r10), %r8
addq $0x2, %r12
movq %r12, %r15
movl (%r8,%rsi,4), %r9d
movslq %ebp, %rbx
addq %rdi, %r9
movb (%rbx,%r9), %r10b
movb -0x1(%rdx,%r12), %r11b
xorl %r9d, %r9d
cmpb %r11b, %r10b
sete %r9b
addl %r9d, %ebx
movl %ebx, 0x10(%r14)
cmpb %r11b, %r10b
setne %r9b
jne 0x160bb
cmpq %rcx, %r15
jae 0x160bb
leaq 0x1(%r15), %r12
movl 0x10(%r14), %ebp
cmpl %eax, %ebp
jl 0x1607a
cmpb %r11b, %r10b
setne %bl
movq 0x10(%rsp), %r10
xorl %ebp, %ebp
testb $0x1, %r9b
jne 0x161df
movq 0x18(%rsp), %rax
cmpq 0x8(%rax), %r15
jae 0x161df
movl 0x10(%r14), %ecx
cmpl %r13d, %ecx
jge 0x161dd
movq (%r14), %rdx
movq 0x8(%r14), %rdi
movq 0xd0(%r10), %rsi
movslq (%rsi,%rdi,4), %rax
cmpq %rax, %rdx
setl %r8b
cmpq %rax, %rdi
setge %dil
testb %dil, %r8b
jne 0x16117
movslq (%rsi,%rdx,4), %rax
movq 0x18(%rsp), %rsi
movq (%rsi), %rsi
movb (%rsi,%r15), %r8b
movq 0x50(%r10), %rsi
movq 0x70(%r10), %rdi
addl (%rdi,%rdx,4), %ecx
movb %r8b, 0xf(%rsp)
cmpb %r8b, (%rsi,%rcx)
je 0x161ac
movq %rax, %rbp
movq 0xd0(%r10), %rax
movslq (%rax,%rbp,4), %rax
cmpq %rax, %rbp
jge 0x161bd
movq 0x20(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x15b7a
movl %eax, %r13d
movq 0x10(%rsp), %rax
movq 0xd0(%rax), %rax
movslq (%rax,%rbp,4), %rsi
movq %r12, %rdi
callq 0x15b7a
movq 0x10(%rsp), %r10
cmpl %eax, %r13d
movl 0x2c(%rsp), %r13d
jne 0x161bd
movq 0xd0(%r10), %rax
movslq (%rax,%rbp,4), %rax
movq 0x50(%r10), %rcx
movq 0x70(%r10), %rdx
movl 0x10(%r14), %esi
addl (%rdx,%rbp,4), %esi
movb 0xf(%rsp), %dl
cmpb %dl, (%rcx,%rsi)
jne 0x16139
movq %rbp, (%r14)
decq %rax
movq %rax, 0x8(%r14)
jmp 0x161d8
movl %ebx, %r9d
jmp 0x160c6
movq 0x50(%r10), %rax
movq 0x70(%r10), %rcx
movl 0x10(%r14), %edx
addl (%rcx,%rbp,4), %edx
movb 0xf(%rsp), %cl
cmpb %cl, (%rax,%rdx)
jne 0x161dd
movq %rbp, (%r14)
movb $0x1, %bpl
jmp 0x161df
xorl %ebp, %ebp
movq %r15, %r12
testb $0x1, %bpl
movq 0x18(%rsp), %r15
jne 0x15f38
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x15f28
nop