// File: /workspace/github_cpp_makefile_star2_O2/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
movl 0x28(%rsi), %ebp
cvtsi2sd %ebp, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r15d
movl 0x38(%rdx), %r13d
movb 0x3c(%rdx), %cl
cmpl $0x3e8, %ebp            # imm = 0x3E8
setl %al
orb %cl, %al
movq %rdi, 0x50(%rsp)
jne 0x1d333
movl $0x1f4, %esi            # imm = 0x1F4
movl %ebp, %eax
xorl %edx, %edx
divl %esi
imull $0x14, %eax, %eax
cvtsi2sd %eax, %xmm1
mulsd 0x1985f(%rip), %xmm0    # 0x36b80
cvtsi2sd %r13d, %xmm2
divsd %xmm0, %xmm1
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %r13d
incl %r15d
testb %cl, %cl
je 0x1d347
movl %ebp, %eax
cltd
idivl %r15d
cmpl %r13d, %eax
cmovgl %eax, %r13d
andq $0x0, 0x40(%rsp)
xorpd %xmm0, %xmm0
andq $0x0, 0x20(%rsp)
movapd %xmm0, 0x30(%rsp)
movapd %xmm0, 0x10(%rsp)
cmpl $0x4, 0x78(%r14)
jl 0x1d385
movq 0x2cc77(%rip), %rdi     # 0x49fe8
leaq 0x19e4d(%rip), %rsi     # 0x371c5
callq 0x72b0
movq %rax, %rdi
callq 0x7160
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 0x1a8ac
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x1d3cb
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x1d4e8
cmpl $0x4, 0x78(%r14)
jl 0x1d3ed
movq 0x2cc0f(%rip), %rdi     # 0x49fe8
leaq 0x19df5(%rip), %rsi     # 0x371d5
callq 0x72b0
movq %rax, %rdi
callq 0x7160
leaq 0x30(%rsp), %rdi
pushq $0x1
popq %rsi
movl %ebp, %edx
movl %r15d, %ecx
movq %rbx, %r8
movq %r14, %r9
callq 0x1acf8
movq 0x8(%rbx), %rax
subq (%rbx), %rax
pushq $-0x38
popq %rcx
cqto
idivq %rcx
movq %rax, %r12
cmpl $0x2, 0x78(%r14)
pushq $0x38
popq %r13
jl 0x1d454
movq 0x2cbbf(%rip), %rdi     # 0x49fe8
leaq 0x19db8(%rip), %rsi     # 0x371e8
callq 0x72b0
movq %rax, %rdi
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %r13
movq %rax, %rsi
callq 0x71d0
movq %rax, %rdi
callq 0x7160
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
movl %ebp, %edx
movl %r15d, %ecx
movq %rbx, %r8
movq %r14, %r9
callq 0x1acf8
cmpl $0x2, 0x78(%r14)
jl 0x1d4a7
movq 0x2cb6f(%rip), %rdi     # 0x49fe8
leaq 0x19d6f(%rip), %rsi     # 0x371ef
callq 0x72b0
movq %rax, %rdi
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %r13
addq %rax, %r12
movq %r12, %rsi
callq 0x71d0
movq %rax, %rdi
callq 0x7160
movq (%rbx), %rdi
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x8(%rbx), %rsi
movq %rsi, %rax
subq %rdi, %rax
cqto
idivq %r13
cmpq %rax, %r15
jae 0x1d4dc
addq %r14, %rdi
callq 0x1b363
movq (%rbx), %rdi
movl %eax, (%rdi,%r14)
incq %r15
addq $0x38, %r14
jmp 0x1d4b0
leaq -0xa72(%rip), %rdx      # 0x1ca71
callq 0x2719b
leaq 0x10(%rsp), %rdi
callq 0x9fce
leaq 0x30(%rsp), %rdi
callq 0x9fce
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1d50f
jmp 0x1d50f
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x9fce
leaq 0x30(%rsp), %rdi
callq 0x9fce
movq %rbx, %rdi
callq 0x75e0