// File: /workspace/github_cpp_makefile_star2_O1/readmapping[P]alfalfa/src/mapper.cpp
// Function: pairedMatch6(sparseSA const&, read_t&, read_t&, align_opt const&, paired_opt const&)
void pairedMatch6(const sparseSA& sa, read_t & mate1, read_t & mate2, const align_opt & alnOptions, const paired_opt & pairedOpt){
    int editDist1 = (int)(alnOptions.errorPercent*mate1.sequence.length())+1;
    int editDist2 = (int)(alnOptions.errorPercent*mate2.sequence.length())+1;
    //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);
    //FILTER LIS: ONLY THOSE THAT PAIR : PUT IN LIST OF LISCOUPLE 
    vector<LIScouple_t>  lisIntervalsFiltered;
    if(alnOptions.print >= 3) cerr << "filter LIS of both mates using pairing"  << endl;
    for(size_t i = 0; i < lisIntervals1.size(); i++){
        for(size_t j = 0; j < lisIntervals2.size(); j++){
            if(!(lisIntervals1[i].extended && lisIntervals2[j].extended) && isConcordantLIS(lisIntervals1[i], lisIntervals2[j], editDist1, editDist2, pairedOpt, alnOptions.print))
                lisIntervalsFiltered.push_back(LIScouple_t(i,j,lisIntervals1[i].score+lisIntervals2[j].score));
        }
    }
    if(alnOptions.print >= 3) cerr << "number of paired LIS in filtered list " << lisIntervalsFiltered.size()  << endl;
    //RESCUE IF NO PAIRED LIS WERE FOUND
    if(lisIntervalsFiltered.empty()){
        if(alnOptions.print >= 2) cerr << "#EMPTYFILTEREDLIST"  << endl;
        pairedMatch1(sa, mate1, mate2, alnOptions, pairedOpt);
    }
    else{
        sort(lisIntervalsFiltered.begin(),lisIntervalsFiltered.end(),compLIScouple);
        //FIND ALIGNMENTS FOR FILTERED LIST OF ALIGNMENTS
        //BE NICE AND GIVE THE OPTION OF LOWER MINSCORE
        int minScore1 = (int) (mate1.sequence.length()*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*(editDist1*1.5));
        int minScore2 = (int) (mate2.sequence.length()*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*(editDist2*1.5));
        processLisIntervalsSimultaneous(sa, mate1, mate2, alnOptions, pairedOpt, lisIntervals1, lisIntervals2, lisIntervalsFiltered, 
                alnOptions.maxAlnCount, 0, 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;
        if(pairedOpt.discordant && pairedAlignments < maxPairedAlignments){
            if(alnOptions.print >= 3) cerr << "search discordant alignments" << endl;
            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 $0xc8, %rsp
movq %r8, 0x38(%rsp)
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
movsd 0x30(%rcx), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x28(%rsi), %xmm0
movaps %xmm0, 0xa0(%rsp)
movsd 0x28(%rdx), %xmm0
movapd %xmm0, 0xb0(%rsp)
xorl %eax, %eax
movq %rax, 0x50(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq %rax, 0x90(%rsp)
movapd %xmm0, 0x80(%rsp)
movq %rcx, 0x8(%rsp)
cmpl $0x3, 0x78(%rcx)
jl 0x284e3
movq 0x2bb44(%rip), %rbx     # 0x53fe8
leaq 0x1d11e(%rip), %rsi     # 0x455c9
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x7340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x2bb12(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x8(%rsp), %rdx
movsd 0x30(%rdx), %xmm0
leaq 0x40(%rsp), %rcx
movq %r12, %rdi
movq %r14, %rsi
callq 0x24e89
movq 0x8(%rsp), %rdx
movsd 0x30(%rdx), %xmm0
leaq 0x80(%rsp), %rcx
movq %r12, %rdi
movq %r15, %rsi
callq 0x24e89
movq %r12, 0x60(%rsp)
movq %r15, 0x68(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x3, 0x78(%rax)
jl 0x28588
movq 0x2ba9f(%rip), %rbx     # 0x53fe8
leaq 0x1d095(%rip), %rsi     # 0x455e5
movl $0x26, %edx
movq %rbx, %rdi
callq 0x7340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x2ba6d(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq %r14, 0x98(%rsp)
movsd 0x1c778(%rip), %xmm1    # 0x44d10
movapd 0xa0(%rsp), %xmm3
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
movapd 0x1c774(%rip), %xmm2    # 0x44d20
subpd %xmm2, %xmm3
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
addsd %xmm3, %xmm0
movsd 0x30(%rsp), %xmm3
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %r12d
incl %r12d
movapd 0xb0(%rsp), %xmm4
unpcklps %xmm1, %xmm4            # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
subpd %xmm2, %xmm4
movapd %xmm4, %xmm0
unpckhpd %xmm4, %xmm0            # xmm0 = xmm0[1],xmm4[1]
addsd %xmm4, %xmm0
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %eax
incl %eax
movl %eax, 0x30(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x2870a
xorl %r15d, %r15d
movabsq $0x6db6db6db6db6db7, %rbx # imm = 0x6DB6DB6DB6DB6DB7
movq 0x80(%rsp), %rsi
cmpq %rsi, 0x88(%rsp)
je 0x286ec
imulq $0x38, %r15, %r14
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x40(%rsp), %rdi
cmpb $0x1, 0x18(%rdi,%r14)
jne 0x28649
cmpb $0x0, 0x18(%rsi,%r13)
jne 0x286c1
addq %r14, %rdi
addq %r13, %rsi
movq 0x8(%rsp), %rax
movl 0x78(%rax), %r9d
movl %r12d, %edx
movl 0x30(%rsp), %ecx
movq 0x38(%rsp), %r8
callq 0x27414
testb %al, %al
je 0x286c1
movq 0x40(%rsp), %rax
movq 0x80(%rsp), %rcx
movl (%rcx,%r13), %ecx
addl (%rax,%r14), %ecx
movl %r15d, 0x74(%rsp)
movl %ebp, 0x78(%rsp)
movl %ecx, 0x7c(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x286b2
movl 0x7c(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x74(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x18(%rsp)
jmp 0x286c1
leaq 0x10(%rsp), %rdi
leaq 0x74(%rsp), %rdx
callq 0x32364
incq %rbp
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rax
subq %rsi, %rax
sarq $0x3, %rax
imulq %rbx, %rax
addq $0x38, %r13
cmpq %rax, %rbp
jb 0x28634
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
incq %r15
sarq $0x3, %rax
imulq %rbx, %rax
cmpq %rax, %r15
jb 0x28615
movq 0x8(%rsp), %rax
cmpl $0x2, 0x78(%rax)
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x98(%rsp), %r13
jle 0x28787
movq 0x2b8ba(%rip), %rdi     # 0x53fe8
leaq 0x1cf7b(%rip), %rsi     # 0x456b0
movl $0x26, %edx
callq 0x7340
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x2, %rsi
imulq %r14, %rsi
movq 0x2b890(%rip), %rdi     # 0x53fe8
callq 0x71c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpq %r15, %rbx
je 0x28af5
movq %r15, %rax
subq %rbx, %rax
sarq $0x2, %rax
imulq %r14, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x39b(%rip), %rcx      # 0x28421
movq %rbx, %rdi
movq %r15, %rsi
callq 0x324f3
leaq -0x3ad(%rip), %rdx      # 0x28421
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3264e
movq 0x8(%rsp), %rcx
movslq (%rcx), %rdx
movq 0x28(%r13), %rax
imulq %rdx, %rax
movq %rax, %xmm0
movq 0x1c51a(%rip), %xmm4    # 0x44d10
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
movapd 0x1c51e(%rip), %xmm5    # 0x44d20
subpd %xmm5, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movl 0x4(%rcx), %eax
subl %edx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cvtsi2sd %r12d, %xmm2
movsd 0x1c365(%rip), %xmm3    # 0x44b90
mulsd %xmm3, %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %r10d
movl 0x60(%rcx), %eax
movq 0x68(%rsp), %r14
imulq 0x28(%r14), %rdx
movq %rdx, %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm5, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtsi2sdl 0x30(%rsp), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
cvttsd2si %xmm1, %r11d
subq $0x8, %rsp
leaq 0x18(%rsp), %rbx
leaq 0x48(%rsp), %r9
xorpd %xmm0, %xmm0
movq 0x68(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq 0x40(%rsp), %r8
pushq %r11
pushq %r10
pushq %rax
pushq %rbx
leaq 0xa8(%rsp), %rax
pushq %rax
callq 0x2c8b8
addq $0x30, %rsp
movq 0x8(%rsp), %rax
cmpl $0x3, 0x78(%rax)
jl 0x28935
movq 0x2b720(%rip), %rdi     # 0x53fe8
leaq 0x1cd8e(%rip), %rsi     # 0x4565d
movl $0x18, %edx
callq 0x7340
movq 0xb8(%r13), %rsi
subq 0xb0(%r13), %rsi
sarq $0x3, %rsi
movq 0x2b6f6(%rip), %rdi     # 0x53fe8
callq 0x71c0
movq %rax, %rbx
leaq 0x1cd86(%rip), %rsi     # 0x45687
movl $0xb, %edx
movq %rax, %rdi
callq 0x7340
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x8(%rsp), %rax
cmpl $0x3, 0x78(%rax)
jl 0x289b4
movq 0x2b6a1(%rip), %rdi     # 0x53fe8
leaq 0x1cb72(%rip), %rsi     # 0x454c0
movl $0x18, %edx
callq 0x7340
movq 0xb8(%r14), %rsi
subq 0xb0(%r14), %rsi
sarq $0x3, %rsi
movq 0x2b677(%rip), %rdi     # 0x53fe8
callq 0x71c0
movq %rax, %rbx
leaq 0x1cd07(%rip), %rsi     # 0x45687
movl $0xb, %edx
movq %rax, %rdi
callq 0x7340
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x8(%rsp), %rax
movl 0x50(%rax), %r14d
movl 0xc8(%r13), %ebp
cmpl $0x2, 0x78(%rax)
jl 0x28a1a
movq 0x2b617(%rip), %rdi     # 0x53fe8
leaq 0x1cb89(%rip), %rsi     # 0x45561
movl $0x11, %edx
callq 0x7340
movq 0x2b5ff(%rip), %rdi     # 0x53fe8
movl %ebp, %esi
callq 0x75d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x38(%rsp), %rax
cmpb $0x1, 0x9(%rax)
jne 0x28a8d
cmpl %r14d, %ebp
jg 0x28a8d
movq 0x8(%rsp), %rax
cmpl $0x3, 0x78(%rax)
jl 0x28a7b
movq 0x2b5ac(%rip), %rbx     # 0x53fe8
leaq 0x1cc50(%rip), %rsi     # 0x45693
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x7340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x2b57a(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x60(%rsp), %rdi
movq %r13, %rsi
movq 0x68(%rsp), %rdx
callq 0x25b75
movq 0x8(%rsp), %rax
cmpl $0x2, 0x78(%rax)
jl 0x28b62
movq 0x2b545(%rip), %rdi     # 0x53fe8
leaq 0x1cac9(%rip), %rsi     # 0x45573
movl $0x11, %edx
callq 0x7340
movl 0xc8(%r13), %esi
subl %ebp, %esi
movq 0x2b524(%rip), %rdi     # 0x53fe8
callq 0x75d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
jmp 0x28b62
movq 0x8(%rsp), %rax
cmpl $0x2, 0x78(%rax)
jl 0x28b46
movq 0x2b4e1(%rip), %rbx     # 0x53fe8
leaq 0x1cb3c(%rip), %rsi     # 0x4564a
movl $0x12, %edx
movq %rbx, %rdi
callq 0x7340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x2b4af(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x60(%rsp), %rdi
movq %r13, %rsi
movq 0x68(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq 0x38(%rsp), %r8
callq 0x26c48
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x28b79
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
leaq 0x80(%rsp), %rdi
callq 0x2c768
leaq 0x40(%rsp), %rdi
callq 0x2c768
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x28bc9
jmp 0x28baf
jmp 0x28baf
jmp 0x28baf
jmp 0x28baf
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x28bc9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
leaq 0x80(%rsp), %rdi
callq 0x2c768
leaq 0x40(%rsp), %rdi
callq 0x2c768
movq %rbx, %rdi
callq 0x7600