// File: 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:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movl %edx, 0x104(%rsp)
movq %rcx, 0xf8(%rsp)
movl %r8d, 0xf4(%rsp)
movl %r9d, 0xf0(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0xb8(%rsp)
testb $0x1, 0xf8(%rax)
je 0x1fe35
movq 0xf8(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1fe35
movslq 0xf4(%rsp), %rax
cmpq $0xa, %rax
jl 0x1fe35
movl $0x0, 0xec(%rsp)
movq $0x0, 0xe0(%rsp)
cmpq $0xa, 0xe0(%rsp)
jge 0x1fd8d
movl 0xec(%rsp), %eax
shll $0x2, %eax
movl %eax, 0xb4(%rsp)
movq 0x108(%rsp), %rdi
movslq 0x104(%rsp), %rsi
addq 0xe0(%rsp), %rsi
callq 0x8410
movq %rax, %rcx
movl 0xb4(%rsp), %eax
movzbl (%rcx), %ecx
movl %ecx, %edx
leaq 0x5d6c3(%rip), %rcx     # 0x7d430
orl (%rcx,%rdx,4), %eax
movl %eax, 0xec(%rsp)
movq 0xe0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe0(%rsp)
jmp 0x1fd1e
movl 0xec(%rsp), %eax
cmpq $0x100000, %rax         # imm = 0x100000
jge 0x1fe2e
movq 0xb8(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movl 0xec(%rsp), %eax
movl %eax, %esi
callq 0x23790
cmpl $0x0, 0x4(%rax)
jbe 0x1fe2e
movq 0xb8(%rsp), %rdi
movq 0xf8(%rsp), %rax
movl $0xa, 0x10(%rax)
addq $0x100, %rdi            # imm = 0x100
movl 0xec(%rsp), %eax
movl %eax, %esi
callq 0x23790
movq 0xb8(%rsp), %rdi
movl (%rax), %eax
movl %eax, %ecx
movq 0xf8(%rsp), %rax
movq %rcx, (%rax)
addq $0x100, %rdi            # imm = 0x100
movl 0xec(%rsp), %eax
movl %eax, %esi
callq 0x23790
movl 0x4(%rax), %eax
movl %eax, %ecx
movq 0xf8(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x1fe33
jmp 0x205cf
jmp 0x1fe35
movq 0xf8(%rsp), %rax
movl 0x10(%rax), %eax
cmpl 0xf4(%rsp), %eax
jge 0x1fe63
movq 0xf8(%rsp), %rdi
callq 0x1fbb0
movslq 0xf0(%rsp), %rcx
cmpq %rcx, %rax
jg 0x1fe68
jmp 0x205cf
movl 0x104(%rsp), %eax
movq 0xf8(%rsp), %rcx
addl 0x10(%rcx), %eax
cltq
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x108(%rsp), %rdi
callq 0x8630
movq 0xb8(%rsp), %rdi
movq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rcx, %rax
setb %al
andb $0x1, %al
movb %al, 0xd7(%rsp)
movq 0xf8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
addq $0xd0, %rdi
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x237b0
movq %rax, %rcx
movq 0xa8(%rsp), %rax
movslq (%rcx), %rcx
cmpq %rcx, %rax
jge 0x1ff7c
movq 0xb8(%rsp), %rdi
addq $0xd0, %rdi
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x237b0
movslq (%rax), %rax
movq 0xf8(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jg 0x1ff7c
movq 0xb8(%rsp), %rdi
movq %rdi, %rax
addq $0xa0, %rax
movq %rax, 0x98(%rsp)
addq $0xd0, %rdi
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x237b0
movq 0x98(%rsp), %rdi
movslq (%rax), %rsi
callq 0x1ed20
movl %eax, 0xd0(%rsp)
jmp 0x1ffc3
movq 0xb8(%rsp), %rdi
movq %rdi, %rax
addq $0xa0, %rax
movq %rax, 0x90(%rsp)
addq $0xd0, %rdi
movq 0xf8(%rsp), %rax
movq (%rax), %rsi
callq 0x237b0
movq 0x90(%rsp), %rdi
movslq (%rax), %rsi
callq 0x1ed20
movl %eax, 0xd0(%rsp)
testb $0x1, 0xd7(%rsp)
je 0x20031
movq 0xf8(%rsp), %rdi
callq 0x1fbb0
cmpq $0x1, %rax
jle 0x20031
movl 0xd0(%rsp), %eax
movq 0xf8(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x20031
movq 0x108(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x8410
movq 0xb8(%rsp), %rdi
movb (%rax), %al
movq 0xf8(%rsp), %rdx
movsbl %al, %esi
callq 0x237d0
andb $0x1, %al
movb %al, 0xd7(%rsp)
jmp 0x200c6
testb $0x1, 0xd7(%rsp)
je 0x200c4
movq 0x108(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x8410
movq 0xb8(%rsp), %rdi
movsbl (%rax), %eax
movl %eax, 0x8c(%rsp)
movq %rdi, %rax
addq $0x50, %rax
movq %rax, 0x80(%rsp)
addq $0x70, %rdi
movq 0xf8(%rsp), %rax
movq (%rax), %rsi
callq 0x1fb90
movq 0x80(%rsp), %rdi
movl (%rax), %eax
movl %eax, %esi
movq 0xf8(%rsp), %rax
movslq 0x10(%rax), %rax
addq %rax, %rsi
callq 0x8410
movq %rax, %rcx
movl 0x8c(%rsp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movb %al, 0xd7(%rsp)
jmp 0x200c6
movb $0x0, 0xcf(%rsp)
xorl %eax, %eax
testb $0x1, 0xd7(%rsp)
movb %al, 0x7f(%rsp)
je 0x2015c
xorl %eax, %eax
testb $0x1, 0xcf(%rsp)
movb %al, 0x7f(%rsp)
jne 0x2015c
movq 0xd8(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x108(%rsp), %rdi
callq 0x8630
movq 0x70(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x7f(%rsp)
jae 0x2015c
movq 0xf8(%rsp), %rax
movl 0x10(%rax), %ecx
xorl %eax, %eax
cmpl 0xf4(%rsp), %ecx
movb %al, 0x6f(%rsp)
jge 0x20154
movq 0xf8(%rsp), %rdi
callq 0x1fbb0
movslq 0xf0(%rsp), %rcx
cmpq %rcx, %rax
setg %al
movb %al, 0x6f(%rsp)
movb 0x6f(%rsp), %al
movb %al, 0x7f(%rsp)
movb 0x7f(%rsp), %al
testb $0x1, %al
jne 0x20169
jmp 0x205cf
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
movq 0xf8(%rsp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq 0xf8(%rsp), %rax
movq (%rax), %rax
movq 0xf8(%rsp), %rcx
cmpq 0x8(%rcx), %rax
je 0x2046c
movq 0xb8(%rsp), %rdi
movq 0xf8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x60(%rsp)
addq $0xd0, %rdi
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x237b0
movq %rax, %rcx
movq 0x60(%rsp), %rax
movslq (%rcx), %rcx
cmpq %rcx, %rax
jge 0x20260
movq 0xb8(%rsp), %rdi
addq $0xd0, %rdi
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x237b0
movslq (%rax), %rax
movq 0xf8(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jg 0x20260
movq 0xb8(%rsp), %rdi
movq %rdi, %rax
addq $0xa0, %rax
movq %rax, 0x58(%rsp)
addq $0xd0, %rdi
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x237b0
movq 0x58(%rsp), %rdi
movslq (%rax), %rsi
callq 0x1ed20
movl %eax, 0xc8(%rsp)
jmp 0x202a1
movq 0xb8(%rsp), %rdi
movq %rdi, %rax
addq $0xa0, %rax
movq %rax, 0x50(%rsp)
addq $0xd0, %rdi
movq 0xf8(%rsp), %rax
movq (%rax), %rsi
callq 0x237b0
movq 0x50(%rsp), %rdi
movslq (%rax), %rsi
callq 0x1ed20
movl %eax, 0xc8(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xf4(%rsp), %rsi
callq 0xc080
movl (%rax), %eax
movl %eax, 0xc4(%rsp)
xorl %eax, %eax
testb $0x1, 0xcf(%rsp)
movb %al, 0x4f(%rsp)
jne 0x20315
movq 0xd8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x108(%rsp), %rdi
callq 0x8630
movq 0x40(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x4f(%rsp)
jae 0x20315
movq 0xf8(%rsp), %rax
movl 0x10(%rax), %eax
cmpl 0xc4(%rsp), %eax
setl %al
movb %al, 0x4f(%rsp)
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x20322
jmp 0x203d0
movq 0xb8(%rsp), %rdi
movq %rdi, %rax
addq $0x50, %rax
movq %rax, 0x30(%rsp)
addq $0x70, %rdi
movq 0xf8(%rsp), %rax
movq (%rax), %rsi
callq 0x1fb90
movq 0x30(%rsp), %rdi
movl (%rax), %eax
movl %eax, %esi
movq 0xf8(%rsp), %rax
movslq 0x10(%rax), %rax
addq %rax, %rsi
callq 0x8410
movsbl (%rax), %eax
movl %eax, 0x3c(%rsp)
movq 0x108(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x8410
movq %rax, %rcx
movl 0x3c(%rsp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
setne %al
andb $0x1, %al
movb %al, 0xcf(%rsp)
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
movb 0xcf(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movq 0xf8(%rsp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
jmp 0x202bf
movq 0xd8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x108(%rsp), %rdi
callq 0x8630
movq 0x20(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x2f(%rsp)
jae 0x2045a
xorl %eax, %eax
testb $0x1, 0xcf(%rsp)
movb %al, 0x2f(%rsp)
jne 0x2045a
movq 0xf8(%rsp), %rax
movl 0x10(%rax), %ecx
xorl %eax, %eax
cmpl 0xf4(%rsp), %ecx
movb %al, 0x2f(%rsp)
jge 0x2045a
movq 0x108(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x8410
movq 0xb8(%rsp), %rdi
movb (%rax), %al
movq 0xf8(%rsp), %rdx
movsbl %al, %esi
callq 0x237d0
movb %al, 0x2f(%rsp)
movb 0x2f(%rsp), %al
andb $0x1, %al
movb %al, 0xd7(%rsp)
jmp 0x205ca
jmp 0x2046e
xorl %eax, %eax
testb $0x1, 0xcf(%rsp)
movb %al, 0x1f(%rsp)
jne 0x204c4
movq 0xd8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x108(%rsp), %rdi
callq 0x8630
movq 0x10(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x1f(%rsp)
jae 0x204c4
movq 0xf8(%rsp), %rax
movl 0x10(%rax), %eax
cmpl 0xf4(%rsp), %eax
setl %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x204d1
jmp 0x205c8
movq 0xb8(%rsp), %rdi
addq $0x70, %rdi
movq 0xf8(%rsp), %rax
movq (%rax), %rsi
callq 0x1fb90
movq 0xb8(%rsp), %rdx
movl (%rax), %eax
movl %eax, %ecx
movq 0xf8(%rsp), %rax
movslq 0x10(%rax), %rax
addq %rax, %rcx
movb $0x1, %al
cmpq 0x38(%rdx), %rcx
movb %al, 0xf(%rsp)
jge 0x20586
movq 0xb8(%rsp), %rdi
movq %rdi, %rax
addq $0x50, %rax
movq %rax, (%rsp)
addq $0x70, %rdi
movq 0xf8(%rsp), %rax
movq (%rax), %rsi
callq 0x1fb90
movq (%rsp), %rdi
movl (%rax), %eax
movl %eax, %esi
movq 0xf8(%rsp), %rax
movslq 0x10(%rax), %rax
addq %rax, %rsi
callq 0x8410
movsbl (%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x108(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x8410
movq %rax, %rcx
movl 0x8(%rsp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0xcf(%rsp)
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
movb 0xcf(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movq 0xf8(%rsp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
jmp 0x2046e
jmp 0x205ca
jmp 0x200ce
addq $0x118, %rsp            # imm = 0x118
retq
nopw (%rax,%rax)