// File: /workspace/github_cpp_makefile_star2_O1/readmapping[P]alfalfa/src/mapper.cpp
// Function: calculateCandRegions(sparseSA const&, read_t const&, align_opt const&, std::vector<lis_t, std::allocator<lis_t>>&, double)
void calculateCandRegions(const sparseSA& sa, const read_t & read, const align_opt & alnOptions, vector<lis_t> & lisIntervals, double errorPercent){
    const string & P = read.sequence;
    const string & Prc = read.rcSequence;
    int Plength = P.length();
    int editDist = (int)(errorPercent*Plength)+1;
    int min_len = alnOptions.minMemLength;
    if(!alnOptions.fixedMinLength && Plength >= 1000){
        min_len += (20*((int)(Plength/500)))/((int)100*errorPercent);
    }
    if(alnOptions.fixedMinLength && Plength/editDist > min_len){
        min_len = Plength/editDist;
    }
    ////////////////////////////
    //FIND SEEDS
    ///////////////////////////
    vector<match_t> matches;
    vector<match_t> matchesRC;
    //calc seeds
    if(alnOptions.print >= 4) cerr << "calculate seeds" << endl;
    calculateSeedsBothStrands(sa, P, Prc, min_len, alnOptions, matches, matchesRC);
#ifndef NDEBUG
    if(alnOptions.debugFile != NULL){
        printSimRegion(sa, read, alnOptions, editDist);
        fprintf(alnOptions.debugFile,"#MEM %lu %lu\n", matches.size(), matchesRC.size());
        fprintf(alnOptions.debugFile,"#MEMF\n");
        for(size_t i = 0; i < matches.size(); i++)
            fprintf(alnOptions.debugFile,"%d %ld %d\n", matches[i].query, matches[i].ref, matches[i].len);
        fprintf(alnOptions.debugFile,"#MEMR\n");
        for(size_t i = 0; i < matchesRC.size(); i++)
            fprintf(alnOptions.debugFile,"%d %ld %d\n", matchesRC[i].query, matchesRC[i].ref, matchesRC[i].len);
    }
#endif
    if(matches.size()>0 || matchesRC.size()>0){
        /////////////////////////
        //FIND CANDIDATE REGIONS
        /////////////////////////
        if(alnOptions.print >= 4) cerr << "calculate clusters" << endl;
        identifyAndFilter(matches, true, Plength, editDist, lisIntervals, alnOptions);
        size_t lisForward = lisIntervals.size();
        if(alnOptions.print >= 2) cerr << "#LISF " << lisIntervals.size() << endl;
        identifyAndFilter(matchesRC, false, Plength, editDist, lisIntervals, alnOptions);
        if(alnOptions.print >= 2) cerr << "#LISR " << (lisIntervals.size()-lisForward) << endl;
        //fair calculation of len: coverage
        for(size_t i = 0; i < lisIntervals.size(); i++)
            lisIntervals[i].score = coveredBases(lisIntervals[i]);
        sort(lisIntervals.begin(),lisIntervals.end(), compIntervals);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, 0x50(%rsp)
movl 0x28(%rsi), %ebp
cvtsi2sd %ebp, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %esi
movl 0x38(%rdx), %r13d
movb 0x3c(%rdx), %al
cmpl $0x3e8, %ebp            # imm = 0x3E8
setl %cl
orb %al, %cl
jne 0x24efc
movl %ebp, %ecx
imulq $0x10624dd3, %rcx, %rcx # imm = 0x10624DD3
shrq $0x25, %rcx
shll $0x2, %ecx
leal (%rcx,%rcx,4), %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd 0x1fc96(%rip), %xmm0    # 0x44b80
cvtsi2sd %r13d, %xmm2
divsd %xmm0, %xmm1
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %r13d
incl %esi
testb %al, %al
movl %esi, 0xc(%rsp)
je 0x24f12
movl %ebp, %eax
cltd
idivl %esi
cmpl %r13d, %eax
cmovgl %eax, %r13d
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %rax, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
cmpl $0x4, 0x78(%r14)
jl 0x24f7b
movq 0x2f0ac(%rip), %r15     # 0x53fe8
leaq 0x202c2(%rip), %rsi     # 0x45205
movl $0xf, %edx
movq %r15, %rdi
callq 0x7340
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x2f07a(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
leaq 0x20(%r12), %rsi
addq $0x60, %r12
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %r9
movq 0x50(%rsp), %rdi
movq %r12, %rdx
movl %r13d, %ecx
movq %r14, %r8
callq 0x214c3
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x24fc1
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x251b3
cmpl $0x4, 0x78(%r14)
jl 0x2500e
movq 0x2f019(%rip), %r15     # 0x53fe8
leaq 0x2023f(%rip), %rsi     # 0x45215
movl $0x12, %edx
movq %r15, %rdi
callq 0x7340
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x2efe7(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movq %rbx, %r8
movq %r14, %r9
callq 0x21cdf
movq 0x8(%rbx), %r15
movabsq $0x6db6db6db6db6db7, %r13 # imm = 0x6DB6DB6DB6DB6DB7
subq (%rbx), %r15
cmpl $0x2, 0x78(%r14)
jl 0x2509e
movq 0x2efa0(%rip), %rdi     # 0x53fe8
leaq 0x201d9(%rip), %rsi     # 0x45228
movl $0x6, %edx
callq 0x7340
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x3, %rsi
imulq %r13, %rsi
movq 0x2ef79(%rip), %rdi     # 0x53fe8
callq 0x71c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movq %rbx, %r8
movq %r14, %r9
callq 0x21cdf
cmpl $0x2, 0x78(%r14)
jl 0x2512f
movq 0x2ef24(%rip), %rdi     # 0x53fe8
leaq 0x20164(%rip), %rsi     # 0x4522f
movl $0x6, %edx
callq 0x7340
sarq $0x3, %r15
movabsq $-0x6db6db6db6db6db7, %rax # imm = 0x9249249249249249
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
imulq %r15, %rax
sarq $0x3, %rsi
imulq %r13, %rsi
addq %rax, %rsi
movq 0x2eee8(%rip), %rdi     # 0x53fe8
callq 0x71c0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq (%rbx), %r14
movq 0x8(%rbx), %r15
movq %r15, %rax
subq %r14, %rax
je 0x25175
xorl %r12d, %r12d
xorl %ebp, %ebp
addq %r12, %r14
movq %r14, %rdi
callq 0x22643
movq (%rbx), %r14
movl %eax, (%r14,%r12)
incq %rbp
movq 0x8(%rbx), %r15
movq %r15, %rax
subq %r14, %rax
sarq $0x3, %rax
imulq %r13, %rax
addq $0x38, %r12
cmpq %rax, %rbp
jb 0x25143
jmp 0x2517d
sarq $0x3, %rax
imulq %r13, %rax
cmpq %r15, %r14
je 0x251b3
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0xdd4(%rip), %rcx      # 0x243c2
movq %r14, %rdi
movq %r15, %rsi
callq 0x30f1f
leaq -0xde6(%rip), %rdx      # 0x243c2
movq %r14, %rdi
movq %r15, %rsi
callq 0x3106d
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x251ca
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x251e1
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x251f4
jmp 0x251f4
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2520e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x25225
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
movq %rbx, %rdi
callq 0x7600