// File: /workspace/github_cpp_makefile_star2_O1/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
cmpb $0x1, 0xf8(%rdi)
jne 0x16287
cmpl $0xa, %r8d
jl 0x16287
cmpl $0x0, 0x10(%rcx)
jne 0x16287
movslq %edx, %rax
addq (%rsi), %rax
xorl %r11d, %r11d
leaq 0x2e209(%rip), %rbx     # 0x44440
xorl %r10d, %r10d
shll $0x2, %r10d
movzbl (%rax,%r11), %r14d
orl (%rbx,%r14,4), %r10d
incq %r11
cmpq $0xa, %r11
jne 0x1623a
cmpl $0x100000, %r10d        # imm = 0x100000
jae 0x16455
movl %r10d, %eax
movq 0x100(%rdi), %r11
movl 0x4(%r11,%rax,8), %r10d
testq %r10, %r10
je 0x16455
movl $0xa, 0x10(%rcx)
movl (%r11,%rax,8), %eax
movq %rax, (%rcx)
movq %r10, 0x8(%rcx)
cmpl %r8d, 0x10(%rcx)
jge 0x16455
movq 0x8(%rcx), %rax
subq (%rcx), %rax
incq %rax
movslq %r9d, %r11
cmpq %r11, %rax
jle 0x16455
movslq 0x8(%rsi), %r15
movslq 0x10(%rcx), %r10
movq (%rcx), %r14
movq 0x8(%rcx), %rax
movq (%rsi), %r9
movq 0x50(%rdi), %r12
movq 0x70(%rdi), %rdi
movslq %edx, %r13
movq %r12, -0x28(%rsp)
movq %r13, -0x20(%rsp)
leaq (%r10,%r13), %rdx
cmpq %r15, %rdx
jge 0x16455
movb (%r9,%rdx), %bpl
movl (%rdi,%r14,4), %edx
addq %r12, %rdx
movb (%r10,%rdx), %dl
cmpb %bpl, %dl
jle 0x162fa
movq %r14, %rax
incq %r14
jmp 0x1642b
movl (%rdi,%rax,4), %esi
addq %r12, %rsi
movb (%r10,%rsi), %bl
cmpb %bpl, %bl
jge 0x16312
leaq 0x1(%rax), %r14
jmp 0x1642b
movb $0x1, %sil
cmpb %bpl, %dl
jne 0x16325
movq %rax, %r12
movq %r14, %r13
jmp 0x163bf
movq %rax, %rdx
subq %r14, %rdx
cmpq $0x2, %rdx
jl 0x163b7
movq %r9, -0x18(%rsp)
movq %r15, -0x10(%rsp)
movq %r11, -0x8(%rsp)
leaq (%r12,%r10), %r9
xorl %esi, %esi
movq %rax, %r13
movq %r14, %rdx
movq %rax, %r12
leaq (%r14,%r13), %r11
movq %r11, %r15
shrq $0x3f, %r15
addq %r11, %r15
sarq %r15
movl (%rdi,%r15,4), %r11d
cmpb %bpl, (%r9,%r11)
jge 0x16373
movq %r15, %r14
jmp 0x16397
setne %r11b
orb %sil, %r11b
testb $0x1, %r11b
cmoveq %r13, %r12
cmoveq %r15, %rdx
movzbl %sil, %esi
movl $0x1, %r11d
cmovel %r11d, %esi
movq %r15, %r13
movq %r13, %r11
subq %r14, %r11
cmpq $0x1, %r11
jg 0x16353
movq %rdx, %r14
movq -0x8(%rsp), %r11
movq -0x10(%rsp), %r15
movq -0x18(%rsp), %r9
jmp 0x163bf
xorl %esi, %esi
movq %rax, %r12
movq %rax, %r13
cmpb %bpl, %bl
je 0x1641e
leaq -0x1(%r13), %rax
testb $0x1, %sil
cmovneq %r14, %rax
movq %r12, %rdx
subq %rax, %rdx
cmpq $0x2, %rdx
jl 0x1641e
movq %r9, %rbx
movq -0x28(%rsp), %rdx
addq %r10, %rdx
leaq (%r12,%rax), %r9
movq %r9, %rsi
shrq $0x3f, %rsi
addq %r9, %rsi
sarq %rsi
movl (%rdi,%rsi,4), %r9d
cmpb %bpl, (%rdx,%r9)
jg 0x16407
movq %rsi, %rax
jmp 0x1640a
movq %rsi, %r12
movq %r12, %rsi
subq %rax, %rsi
cmpq $0x1, %rsi
jg 0x163e7
movq %r13, %r14
movq %rbx, %r9
jmp 0x16421
movq %r13, %r14
movq -0x28(%rsp), %r12
movq -0x20(%rsp), %r13
cmpq %rax, %r14
jg 0x16455
incq %r10
movl %r10d, 0x10(%rcx)
movq %r14, (%rcx)
movq %rax, 0x8(%rcx)
cmpl %r8d, %r10d
je 0x16455
movq %rax, %rdx
subq %r14, %rdx
incq %rdx
cmpq %r11, %rdx
jg 0x162ce
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq