// File: /workspace/github_cpp_makefile_star2_O2/readmapping[P]alfalfa/src/mapper.cpp
// Function: pairedMatch5(sparseSA const&, read_t&, read_t&, align_opt const&, paired_opt const&)
void pairedMatch5(const sparseSA& sa, read_t & mate1, read_t & mate2, const align_opt & alnOptions, const paired_opt & pairedOpt){
    //FIND CANDIDATE REGIONS FOR BOTH MATES
    vector<lis_t>  lisIntervals1;
    vector<lis_t>  lisIntervals2;
    if(alnOptions.print >= 3) cerr << "calculate LIS of both mates"  << endl;
    calculateCandRegions(sa, mate1, alnOptions, lisIntervals1, alnOptions.errorPercent);
    calculateCandRegions(sa, mate2, alnOptions, lisIntervals2, alnOptions.errorPercent);
    //SORT ALL LIS
    if(alnOptions.print >= 3) cerr << "first mate resulted in " << lisIntervals1.size() << " intervals" << endl;
    if(alnOptions.print >= 3) cerr << "second mate resulted in " << lisIntervals2.size() << " intervals" << endl;
    vector<alnScoreInfo_t> pairedOrder;
    pairedOrder.reserve(lisIntervals1.size()+lisIntervals2.size());
    for(size_t i = 0; i < lisIntervals1.size(); i++)
        pairedOrder.push_back(alnScoreInfo_t(true, i,lisIntervals1[i].score));
    for(size_t i = 0; i < lisIntervals2.size(); i++)
        pairedOrder.push_back(alnScoreInfo_t(false, i,lisIntervals2[i].score));
    sort(pairedOrder.begin(),pairedOrder.end(),compAlnScorePaired);
    //TRY TO EXTEND LIS
    int Plength1 = mate1.sequence.length();
    int editDist1 = (int)(alnOptions.errorPercent*Plength1)+1;
    int minScore1 = (int) (Plength1*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*editDist1);
    int Plength2 = mate2.sequence.length();
    int editDist2 = (int)(alnOptions.errorPercent*Plength2)+1;
    int minScore2 = (int) (Plength2*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*editDist2);
    processLisIntervalsAndPair(sa, mate1, mate2, alnOptions, pairedOpt, lisIntervals1, lisIntervals2, 
    pairedOrder, alnOptions.maxAlnCount, alnOptions.minCoverage, minScore1, minScore2);
    if(mate1.alignments.empty() && !mate2.alignments.empty() && alnOptions.rescue){
        if(alnOptions.print >= 2) cerr << "#RESCUE" << endl;
        minScore1 = max(0,(int)(Plength1*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*0.2*Plength1));
        int maxAlignmentCount = 20;
        int minCoverage = Plength1*0.01;
        processLisIntervals(sa, mate1, alnOptions, lisIntervals1, editDist1, maxAlignmentCount, minCoverage, minScore1);
    }
    else if(mate2.alignments.empty() && !mate1.alignments.empty() && alnOptions.rescue){
        if(alnOptions.print >= 2) cerr << "#RESCUE" << endl;
        minScore2 = max(0,(int)(Plength2*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*0.2*Plength2));
        int maxAlignmentCount = 20;
        int minCoverage = Plength1*0.01;
        processLisIntervals(sa, mate2, alnOptions, lisIntervals2, editDist2, maxAlignmentCount, minCoverage, minScore2);
    }
    if(alnOptions.print >= 3) cerr << "first  mate resulted in " << mate1.alignments.size() << " alignments" << endl;
    if(alnOptions.print >= 3) cerr << "second mate resulted in " << mate2.alignments.size() << " alignments" << endl;
    if(mate1.alignments.empty() && mate2.alignments.empty() && pairedOpt.pairedRescue){
        minScore1 = max(0,(int)(Plength1*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*0.2*Plength1));
        minScore2 = max(0,(int)(Plength2*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*0.2*Plength2));
        processLisIntervalsAndPair(sa, mate1, mate2, alnOptions, pairedOpt, lisIntervals1, lisIntervals2, 
    pairedOrder, 20, 0.01, minScore1, minScore2);
    }
    if(alnOptions.print >= 3) cerr << "first mate resulted in " << mate1.alignments.size() << " alignments" << endl;
    if(alnOptions.print >= 3) cerr << "second mate resulted in " << mate2.alignments.size() << " alignments" << endl;
    //FIND DISCORDANT ALIGNMENTS AMONGST HIGHEST SCORING UNPAIRED ALIGNMENTS
    int maxPairedAlignments = alnOptions.alignmentCount+1;
    int pairedAlignments = mate1.pairedAlignmentCount;
    if(alnOptions.print >= 2) cerr << "#CONCORDANTCOUNT " << pairedAlignments << endl;
    int alnCount = max(mate1.pairedAlignmentCount, mate2.pairedAlignmentCount);
    if(pairedOpt.discordant && alnCount < maxPairedAlignments)
        calculateDiscordantAlignments(sa, mate1, mate2);
    if(alnOptions.print >= 2) cerr << "#DISCORDANTCOUNT " << mate1.pairedAlignmentCount-pairedAlignments << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r8, 0x28(%rsp)
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, %r12
andq $0x0, 0x60(%rsp)
xorpd %xmm0, %xmm0
andq $0x0, 0x40(%rsp)
movapd %xmm0, 0x50(%rsp)
movapd %xmm0, 0x30(%rsp)
cmpl $0x3, 0x78(%rcx)
jl 0x20970
movq 0x2968c(%rip), %rdi     # 0x49fe8
leaq 0x16c26(%rip), %rsi     # 0x37589
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movsd 0x30(%r14), %xmm0
leaq 0x50(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1d2c7
movsd 0x30(%r14), %xmm0
leaq 0x30(%rsp), %rcx
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x1d2c7
cmpl $0x3, 0x78(%r14)
pushq $0x38
popq %r15
jl 0x20a42
movq 0x2962e(%rip), %rdi     # 0x49fe8
leaq 0x16a8e(%rip), %rsi     # 0x3744f
callq 0x72b0
movq %rax, %rdi
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
cqto
idivq %r15
movq %rax, %rsi
callq 0x71d0
leaq 0x16cdb(%rip), %rsi     # 0x376c2
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
cmpl $0x3, 0x78(%r14)
jl 0x20a42
movq 0x295e3(%rip), %rdi     # 0x49fe8
leaq 0x16a74(%rip), %rsi     # 0x37480
callq 0x72b0
movq %rax, %rdi
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
cqto
idivq %r15
movq %rax, %rsi
callq 0x71d0
leaq 0x16c90(%rip), %rsi     # 0x376c2
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movq %r12, 0x10(%rsp)
movq %rbx, 0xa0(%rsp)
xorpd %xmm0, %xmm0
leaq 0x80(%rsp), %rdi
andq $0x0, 0x10(%rdi)
movapd %xmm0, (%rdi)
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
cqto
idivq %r15
movq %rax, %rsi
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
cqto
idivq %r15
addq %rax, %rsi
callq 0x22bd0
xorl %ebp, %ebp
leaq 0x80(%rsp), %r12
leaq 0x1c(%rsp), %r13
xorl %ebx, %ebx
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r15
cmpq %rax, %rbx
jae 0x20ad9
movl (%rcx,%rbp), %eax
movb $0x1, 0x1c(%rsp)
movl %ebx, 0x20(%rsp)
movl %eax, 0x24(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x279ba
incq %rbx
addq $0x38, %rbp
jmp 0x20a9e
xorl %r13d, %r13d
leaq 0x80(%rsp), %rbp
leaq 0x1c(%rsp), %r12
xorl %ebx, %ebx
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r15
cmpq %rax, %rbx
jae 0x20b27
movl (%rcx,%r13), %eax
movb $0x0, 0x1c(%rsp)
movl %ebx, 0x20(%rsp)
movl %eax, 0x24(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x279ba
incq %rbx
addq $0x38, %r13
jmp 0x20aeb
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
leaq -0x2ba4(%rip), %rdx     # 0x1df9a
callq 0x27b9d
movq 0xa0(%rsp), %rbx
movl 0x28(%rbx), %r15d
movsd 0x30(%r14), %xmm0
cvtsi2sd %r15d, %xmm2
movapd %xmm0, %xmm1
movsd %xmm2, 0x70(%rsp)
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %r13d
incl %r13d
movl (%r14), %ecx
movl 0x4(%r14), %eax
movl %ecx, %edx
imull %r15d, %edx
subl %ecx, %eax
movl %r13d, %r10d
imull %eax, %r10d
addl %edx, %r10d
movq 0x8(%rsp), %rdx
movl 0x28(%rdx), %esi
cvtsi2sd %esi, %xmm1
movsd %xmm1, 0x78(%rsp)
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %r12d
incl %r12d
movl %esi, 0x18(%rsp)
imull %esi, %ecx
imull %r12d, %eax
addl %ecx, %eax
movl 0x60(%r14), %r11d
movsd 0x68(%r14), %xmm0
subq $0x8, %rsp
leaq 0x58(%rsp), %r9
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rcx
movq 0x30(%rsp), %r8
pushq %rax
pushq %r10
pushq %r11
pushq %rbp
leaq 0x58(%rsp), %rax
pushq %rax
callq 0x23c75
addq $0x30, %rsp
movq 0xb0(%rbx), %rdx
movq 0x8(%rsp), %rcx
movq 0xb0(%rcx), %rax
movq 0xb8(%rcx), %rcx
cmpq 0xb8(%rbx), %rdx
je 0x20cb8
cmpq %rcx, %rax
jne 0x20d57
cmpb $0x1, 0x71(%r14)
jne 0x20d57
cmpl $0x2, 0x78(%r14)
jl 0x20c49
movq 0x293b3(%rip), %rdi     # 0x49fe8
leaq 0x165ba(%rip), %rsi     # 0x371f6
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movl (%r14), %eax
movl 0x4(%r14), %ecx
subl %eax, %ecx
imull 0x18(%rsp), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sd %ecx, %xmm1
mulsd 0x15f21(%rip), %xmm1    # 0x36b88
mulsd 0x78(%rsp), %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
xorl %r10d, %r10d
testl %eax, %eax
cmovgl %eax, %r10d
movsd 0x11ca2(%rip), %xmm0    # 0x32928
mulsd 0x70(%rsp), %xmm0
cvttsd2si %xmm0, %eax
leaq 0x30(%rsp), %rcx
pushq $0x14
popq %r9
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movl %r12d, %r8d
pushq %r10
pushq %rax
callq 0x1ca79
popq %rax
popq %rcx
jmp 0x20d57
cmpq %rcx, %rax
je 0x20d57
cmpb $0x1, 0x71(%r14)
jne 0x20d57
cmpl $0x2, 0x78(%r14)
jl 0x20cee
movq 0x2930e(%rip), %rdi     # 0x49fe8
leaq 0x16515(%rip), %rsi     # 0x371f6
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movl (%r14), %eax
movl 0x4(%r14), %ecx
subl %eax, %ecx
imull %r15d, %eax
cvtsi2sd %eax, %xmm0
cvtsi2sd %ecx, %xmm1
mulsd 0x15e7d(%rip), %xmm1    # 0x36b88
movsd 0x70(%rsp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
xorl %r10d, %r10d
testl %eax, %eax
cmovgl %eax, %r10d
movsd 0x11bfa(%rip), %xmm0    # 0x32928
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %eax
leaq 0x50(%rsp), %rcx
pushq $0x14
popq %r9
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl %r13d, %r8d
pushq %r10
pushq %rax
callq 0x1ca79
popq %rax
popq %rcx
cmpl $0x3, 0x78(%r14)
jl 0x20df6
movq 0x2927f(%rip), %rdi     # 0x49fe8
leaq 0x168ad(%rip), %rsi     # 0x3761d
callq 0x72b0
movq 0xb8(%rbx), %rsi
subq 0xb0(%rbx), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x71d0
leaq 0x168b1(%rip), %rsi     # 0x37647
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
cmpl $0x3, 0x78(%r14)
jl 0x20df6
movq 0x29234(%rip), %rdi     # 0x49fe8
leaq 0x166c5(%rip), %rsi     # 0x37480
callq 0x72b0
movq 0x8(%rsp), %rcx
movq 0xb8(%rcx), %rsi
subq 0xb0(%rcx), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x71d0
leaq 0x16861(%rip), %rsi     # 0x37647
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movq 0xb0(%rbx), %rax
cmpq 0xb8(%rbx), %rax
jne 0x20ec5
movq 0x8(%rsp), %rcx
movq 0xb0(%rcx), %rax
cmpq 0xb8(%rcx), %rax
jne 0x20ec5
movq 0x28(%rsp), %rax
cmpb $0x1, 0x14(%rax)
jne 0x20ec5
movl (%r14), %ecx
movl 0x4(%r14), %eax
imull %ecx, %r15d
cvtsi2sd %r15d, %xmm0
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd 0x15d38(%rip), %xmm1    # 0x36b88
movsd 0x70(%rsp), %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %eax
xorl %r10d, %r10d
testl %eax, %eax
cmovlel %r10d, %eax
movl 0x18(%rsp), %edx
imull %ecx, %edx
cvtsi2sd %edx, %xmm0
mulsd 0x78(%rsp), %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
testl %ecx, %ecx
cmovgl %ecx, %r10d
subq $0x8, %rsp
leaq 0x58(%rsp), %r9
movsd 0x11a8d(%rip), %xmm0    # 0x32928
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rcx
movq 0x30(%rsp), %r8
pushq %r10
pushq %rax
pushq $0x14
pushq %rbp
leaq 0x58(%rsp), %rax
pushq %rax
callq 0x23c75
addq $0x30, %rsp
movl 0x78(%r14), %eax
cmpl $0x3, %eax
jl 0x20f6c
movq 0x2910f(%rip), %rdi     # 0x49fe8
leaq 0x1656f(%rip), %rsi     # 0x3744f
callq 0x72b0
movq 0xb8(%rbx), %rsi
subq 0xb0(%rbx), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x71d0
leaq 0x16741(%rip), %rsi     # 0x37647
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movl 0x78(%r14), %eax
cmpl $0x3, %eax
jl 0x20f6c
movq 0x290c2(%rip), %rdi     # 0x49fe8
leaq 0x16553(%rip), %rsi     # 0x37480
callq 0x72b0
movq 0x8(%rsp), %rcx
movq 0xb8(%rcx), %rsi
subq 0xb0(%rcx), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x71d0
leaq 0x166ef(%rip), %rsi     # 0x37647
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movl 0x78(%r14), %eax
movl 0x50(%r14), %r15d
movl 0xc8(%rbx), %ebp
movl %ebp, %ecx
cmpl $0x2, %eax
jl 0x20fa8
movq 0x29064(%rip), %rdi     # 0x49fe8
leaq 0x16596(%rip), %rsi     # 0x37521
callq 0x72b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movl 0xc8(%rbx), %ecx
movq 0x8(%rsp), %rax
movl 0xc8(%rax), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movq 0x28(%rsp), %rcx
cmpb $0x1, 0x9(%rcx)
jne 0x20fda
cmpl %r15d, %eax
jg 0x20fda
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
callq 0x1dd6b
cmpl $0x2, 0x78(%r14)
jl 0x2100c
movq 0x29000(%rip), %rdi     # 0x49fe8
leaq 0x16544(%rip), %rsi     # 0x37533
callq 0x72b0
movl 0xc8(%rbx), %esi
subl %ebp, %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
leaq 0x80(%rsp), %rdi
callq 0x27b78
leaq 0x30(%rsp), %rdi
callq 0x22b92
leaq 0x50(%rsp), %rdi
callq 0x22b92
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x21052
jmp 0x21052
jmp 0x21052
jmp 0x21052
jmp 0x21052
movq %rax, %rbx
jmp 0x21062
jmp 0x21052
jmp 0x21052
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x27b78
leaq 0x30(%rsp), %rdi
callq 0x22b92
leaq 0x50(%rsp), %rdi
callq 0x22b92
movq %rbx, %rdi
callq 0x75e0