// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/sparseSA.cpp
// Function: sparseSA::traverse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, interval_t&, int, int) const
void sparseSA::traverse(const string &P, 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 >= min_len || cur.size() <= maxBranching) return;

  while(prefix+cur.depth < (int)P.length()) {
    long start = cur.start; long end = cur.end;
    // If we reach a mismatch, stop.
    if(top_down_faster(P[prefix+cur.depth], cur.depth, start, end) == false) return;

    // Advance to next interval.
    cur.depth += 1; cur.start = start; cur.end = end;

    // If we reach min_len, stop.
    if(cur.depth == min_len || cur.size() <= maxBranching) return;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edx, %r10d
movl 0x10(%rcx), %eax
cmpb $0x1, 0xf8(%rdi)
jne 0x160ea
testl %eax, %eax
setne %dl
cmpl $0xa, %r8d
setl %r11b
orb %dl, %r11b
jne 0x160ea
movslq %r10d, %rax
addq (%rsi), %rax
xorl %r14d, %r14d
leaq 0x2e3a7(%rip), %r11     # 0x44440
xorl %edx, %edx
shll $0x2, %edx
movzbl (%rax,%r14), %ebx
orl (%r11,%rbx,4), %edx
incq %r14
cmpq $0xa, %r14
jne 0x1609b
cmpl $0x100000, %edx         # imm = 0x100000
jae 0x16296
movl %edx, %eax
movq 0x100(%rdi), %r11
movl 0x4(%r11,%rax,8), %edx
testq %rdx, %rdx
je 0x16296
movl $0xa, 0x10(%rcx)
movl (%r11,%rax,8), %eax
movq %rax, (%rcx)
movq %rdx, 0x8(%rcx)
movl $0xa, %eax
cmpl %r8d, %eax
jge 0x16296
movq (%rcx), %rbp
movq 0x8(%rcx), %r14
movq %r14, %rdx
subq %rbp, %rdx
incq %rdx
movslq %r9d, %r9
movq %r9, -0x8(%rsp)
cmpq %r9, %rdx
jle 0x16296
movslq 0x8(%rsi), %rdx
movq (%rsi), %r9
movq %rdx, %rsi
movq 0x50(%rdi), %r11
movq 0x70(%rdi), %rdi
movslq %eax, %rbx
movslq %r10d, %r10
movl %r8d, -0x24(%rsp)
movq %r9, %r8
movq %rdx, -0x10(%rsp)
movq %r9, -0x18(%rsp)
movq %r10, -0x20(%rsp)
leaq (%rbx,%r10), %rax
cmpq %rsi, %rax
jge 0x16296
movb (%r8,%rax), %r15b
movl (%rdi,%rbp,4), %eax
addq %r11, %rax
movb (%rbx,%rax), %al
cmpb %r15b, %al
jg 0x16296
movl (%rdi,%r14,4), %edx
addq %r11, %rdx
movb (%rbx,%rdx), %r13b
cmpb %r15b, %r13b
jl 0x16296
cmpb %r15b, %al
jne 0x1618a
movq %r14, %r12
movq %rbp, %r9
jmp 0x1621f
movq %r14, %rax
subq %rbp, %rax
cmpq $0x2, %rax
jl 0x16215
leaq (%r11,%rbx), %r9
xorl %esi, %esi
movq %r14, %r10
movq %rbp, %rax
movq %r14, %r12
leaq (%r10,%rbp), %r8
movq %r8, %rdx
shrq $0x3f, %rdx
addq %r8, %rdx
sarq %rdx
movl (%rdi,%rdx,4), %r8d
cmpb %r15b, (%r9,%r8)
jge 0x161c5
movq %rdx, %rbp
jmp 0x161e9
setne %r8b
orb %sil, %r8b
testb $0x1, %r8b
cmoveq %r10, %r12
cmoveq %rdx, %rax
movzbl %sil, %esi
movl $0x1, %r8d
cmovel %r8d, %esi
movq %rdx, %r10
movq %r10, %rdx
subq %rbp, %rdx
cmpq $0x1, %rdx
jg 0x161a5
leaq -0x1(%r10), %r9
testb $0x1, %sil
cmovneq %rax, %r9
movq %r10, %rbp
movq -0x10(%rsp), %rsi
movq -0x18(%rsp), %r8
movq -0x20(%rsp), %r10
jmp 0x1621f
leaq -0x1(%r14), %r9
movq %r14, %rbp
movq %r14, %r12
cmpb %r15b, %r13b
je 0x1626b
movq %r12, %rax
subq %r9, %rax
cmpq $0x2, %rax
jl 0x16268
leaq (%r11,%rbx), %rax
leaq (%r12,%r9), %rdx
movq %rdx, %r14
shrq $0x3f, %r14
addq %rdx, %r14
sarq %r14
movl (%rdi,%r14,4), %edx
cmpb %r15b, (%rax,%rdx)
jg 0x16254
movq %r14, %r9
jmp 0x1625a
movq %r14, %r12
movq %r9, %r14
movq %r12, %rdx
subq %r14, %rdx
cmpq $0x1, %rdx
jg 0x16234
jmp 0x1626b
movq %r9, %r14
movq %r14, %rax
subq %rbp, %rax
movl -0x24(%rsp), %edx
jl 0x16296
incq %rbx
movl %ebx, 0x10(%rcx)
movq %rbp, (%rcx)
movq %r14, 0x8(%rcx)
cmpl %edx, %ebx
je 0x16296
incq %rax
cmpq -0x8(%rsp), %rax
jg 0x16143
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop