// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/apps/parasail_aligner.cpp
// Function: process(unsigned long&, std::set<std::pair<int, int>, std::less<std::pair<int, int>>, std::allocator<std::pair<int, int>>>&, quad const&, int const*, unsigned char const*, int const*, std::vector<int, std::allocator<int>> const&, char const&, int const&)
inline static void process(
        unsigned long &count_generated,
        PairSet &pairs,
        const quad &q,
        const int * const restrict SA,
        const unsigned char * const restrict BWT,
        const int * const restrict SID,
        const vector<int> &DB,
        const char &sentinal,
        const int &cutoff)
{
    const size_t n_children = q.children.size();
    size_t child_index = 0;

    if (q.lcp < cutoff) return;

    if (n_children) {
        for (int i=q.lb; i<=q.rb; ++i) {
            int j = i+1;
            if (child_index < n_children) {
                if (i >= q.children[child_index].lb) {
                    j = q.children[child_index].rb+1;
                    if (i >= q.children[child_index].rb) {
                        ++child_index;
                    }
                }
            }
            for (/*nope*/; j<=q.rb; ++j) {
                pair_check(count_generated, pairs, i, j, SA, BWT, SID, DB, sentinal);
            }
        }
    }
    else {
        for (int i=q.lb; i<=q.rb; ++i) {
            for (int j=i+1; j<=q.rb; ++j) {
                pair_check(count_generated, pairs, i, j, SA, BWT, SID, DB, sentinal);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %r10
movq %rcx, %r9
movq 0x90(%rsp), %rax
movl (%rdx), %ecx
cmpl (%rax), %ecx
jl 0x30141c
movq %rdx, %r12
movq 0x88(%rsp), %r11
movq 0x18(%rdx), %rax
movq 0x10(%rdx), %rcx
cmpq %rcx, %rax
movq %r10, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %r9, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r14
je 0x301377
movl 0x4(%r12), %edi
movl %edi, 0x4(%rsp)
cmpl 0x8(%r12), %edi
jg 0x30141c
subq %rcx, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rcx
movq %rcx, 0x40(%rsp)
xorl %esi, %esi
leaq 0x4(%rsp), %r13
movq %rsp, %rbp
leal 0x1(%rdi), %eax
movl %eax, 0x1c(%rsp)
movl %eax, (%rsp)
cmpq 0x40(%rsp), %rsi
movq %rdi, 0x10(%rsp)
jae 0x3012f0
movq 0x10(%r12), %rax
leaq (%rsi,%rsi,4), %r8
cmpl 0x4(%rax,%r8,8), %edi
jl 0x3012f0
leaq (%rax,%r8,8), %rax
movl 0x8(%rax), %eax
leal 0x1(%rax), %r8d
movl %r8d, (%rsp)
xorl %r8d, %r8d
cmpl %eax, %edi
setge %r8b
addq %r8, %rsi
movq %rsi, 0x8(%rsp)
movl (%rsp), %ebx
cmpl 0x8(%r12), %ebx
movq 0x80(%rsp), %r15
jg 0x301353
decl %ebx
subq $0x8, %rsp
movq %r14, %rdi
movq 0x28(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %r9, %r8
movq 0x38(%rsp), %r9
pushq %r11
pushq %r15
pushq %r10
callq 0x302b18
movq 0xa8(%rsp), %r11
movq 0x48(%rsp), %r9
movq 0x58(%rsp), %r10
addq $0x20, %rsp
leal 0x2(%rbx), %eax
movl %eax, (%rsp)
incl %ebx
cmpl 0x8(%r12), %ebx
jl 0x301309
movl 0x1c(%rsp), %esi
movl %esi, 0x4(%rsp)
movq 0x10(%rsp), %rax
cmpl 0x8(%r12), %eax
movl %esi, %edi
movq 0x8(%rsp), %rsi
jl 0x3012af
jmp 0x30141c
movl 0x4(%r12), %ecx
movl %ecx, 0x4(%rsp)
cmpl 0x8(%r12), %ecx
jg 0x30141c
leaq 0x4(%rsp), %r13
movq %rsp, %rbp
leal 0x1(%rcx), %eax
movl %eax, 0x10(%rsp)
movl %eax, (%rsp)
movq %rcx, 0x8(%rsp)
cmpl 0x8(%r12), %ecx
movq 0x80(%rsp), %r15
jge 0x301402
movl (%rsp), %ebx
incl %ebx
subq $0x8, %rsp
movq %r14, %rdi
movq 0x28(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %r9, %r8
movq 0x38(%rsp), %r9
pushq %r11
pushq %r15
pushq %r10
callq 0x302b18
movq 0xa8(%rsp), %r11
movq 0x48(%rsp), %r9
movq 0x58(%rsp), %r10
addq $0x20, %rsp
movl %ebx, (%rsp)
leal 0x1(%rbx), %eax
decl %ebx
cmpl 0x8(%r12), %ebx
movl %eax, %ebx
jl 0x3013b6
movl 0x10(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rcx
cmpl 0x8(%r12), %ecx
movl %eax, %ecx
jl 0x301393
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq