// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/mapper.cpp
// Function: pairedMatch1(sparseSA const&, read_t&, read_t&, align_opt const&, paired_opt const&)
void pairedMatch1(const sparseSA& sa, read_t & mate1, read_t & mate2, const align_opt & alnOptions, const paired_opt & pairedOpt){
    //Calculate the mappings for read 1 and 2
    if(alnOptions.print >= 3) cerr << "matching first mate ..." << endl;
    unpairedMatch(sa, mate1, alnOptions);
    if(alnOptions.print >= 3) cerr << "first mate resulted in " << mate1.alignments.size() << " alignments" << endl;
    if(alnOptions.print >= 3) cerr << "matching second mate ..." << endl;
    unpairedMatch(sa, mate2, alnOptions);
    if(alnOptions.print >= 3) cerr << "second mate resulted in " << mate2.alignments.size() << " alignments" << endl;
    int alnCount1 = mate1.alignmentCount();
    int alnCount2 = mate2.alignmentCount();
    int alnCount = 0;
    int maxPairedAlignments = alnOptions.alignmentCount+1;
    //ORDER ALIGNMENTS ACCORDING TO SCORE
    vector<alnScoreInfo_t> pairedOrder;
    pairedOrder.reserve(alnCount1+alnCount2);
    for(size_t i = 0; i < mate1.alignments.size(); i++)
        pairedOrder.push_back(alnScoreInfo_t(true, i,mate1.alignments[i]->alignmentScore ));
    for(size_t i = 0; i < mate2.alignments.size(); i++)
        pairedOrder.push_back(alnScoreInfo_t(false, i,mate2.alignments[i]->alignmentScore ));
    sort(pairedOrder.begin(),pairedOrder.end(),compAlnScorePaired);
    //TRY AND PAIR THE ALIGNMENTS
    if(alnCount1>0 && alnCount2>0){
        if(alnOptions.print >= 3) cerr << "search concordant alignments of " << pairedOrder.size() << " alignments" << endl;
        pairAlignmentsOrdered(sa, mate1, mate2, alnOptions, pairedOpt, 
        pairedOrder, alnCount, maxPairedAlignments);
        if(alnOptions.print >= 3) cerr << "found " << alnCount << " concordant alignments" << endl;
    }
    //RESCUE PROCEDURE IF NO CONCORDANT ALIGNMENTS WERE FOUND
    if(pairedOpt.pairedRescue && alnCount < maxPairedAlignments && max(alnCount1,alnCount2)>0){
        if(alnOptions.print >= 2) cerr << "#PAIREDRESCUE" << endl;
        if(alnOptions.print >= 3) cerr << "try to recover concordant alignments using windows " << endl;
        vector<alnScoreInfo_t> newAlnFromWindow;
        pairAlignmentToWindow(sa, mate1, mate2, alnOptions, pairedOpt, pairedOrder, 
        newAlnFromWindow, alnCount, maxPairedAlignments);
        if(alnOptions.print >= 3) cerr << "rescue procedure resulted in " << alnCount << " concordant alignments" << endl;
    }
    //FIND DISCORDANT ALIGNMENTS AMONGST HIGHEST SCORING UNPAIRED ALIGNMENTS
    int pairedAlignments = mate1.pairedAlignmentCount;
    if(alnOptions.print >= 2) cerr << "#CONCORDANTCOUNT " << pairedAlignments << endl;
    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 $0x78, %rsp
movq %r8, 0x50(%rsp)
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x3, 0x78(%rcx)
jl 0x26c78
movq 0x2d3ac(%rip), %r13     # 0x53fe8
leaq 0x1e834(%rip), %rsi     # 0x45477
movl $0x17, %edx
movq %r13, %rdi
callq 0x7340
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2512f
cmpl $0x3, 0x78(%r12)
jl 0x26d4a
movq 0x2d34f(%rip), %rbp     # 0x53fe8
leaq 0x1e7ef(%rip), %rsi     # 0x4548f
movl $0x17, %edx
movq %rbp, %rdi
callq 0x7340
movq 0xb8(%rbx), %rsi
subq 0xb0(%rbx), %rsi
sarq $0x3, %rsi
movq %rbp, %rdi
callq 0x71c0
movq %rax, %r13
leaq 0x1e9b6(%rip), %rsi     # 0x45687
movl $0xb, %edx
movq %rax, %rdi
callq 0x7340
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
cmpl $0x3, 0x78(%r12)
jl 0x26d4a
leaq 0x1e792(%rip), %rsi     # 0x454a7
movl $0x18, %edx
movq %rbp, %rdi
callq 0x7340
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq %r14, 0x48(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2512f
cmpl $0x3, 0x78(%r12)
jl 0x26dd9
movq 0x2d27c(%rip), %r13     # 0x53fe8
leaq 0x1e74d(%rip), %rsi     # 0x454c0
movl $0x18, %edx
movq %r13, %rdi
callq 0x7340
movq 0xb8(%r15), %rsi
subq 0xb0(%r15), %rsi
sarq $0x3, %rsi
movq %r13, %rdi
callq 0x71c0
movq %rax, %r13
leaq 0x1e8e3(%rip), %rsi     # 0x45687
movl $0xb, %edx
movq %rax, %rdi
callq 0x7340
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0xb8(%rbx), %rcx
subq 0xb0(%rbx), %rcx
shrq $0x3, %rcx
movq 0xb8(%r15), %r14
subq 0xb0(%r15), %r14
shrq $0x3, %r14
movl $0x0, 0xc(%rsp)
movl 0x50(%r12), %eax
movq %rax, 0x58(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rcx, 0x68(%rsp)
leal (%r14,%rcx), %eax
movslq %eax, %rsi
callq 0x2c688
movq %r12, 0x70(%rsp)
movq 0xb0(%rbx), %rax
cmpq %rax, 0xb8(%rbx)
je 0x26eb5
xorl %r12d, %r12d
leaq 0x10(%rsp), %rbp
leaq 0x30(%rsp), %r13
movq (%rax,%r12,8), %rax
movl 0x70(%rax), %eax
movb $0x1, 0x30(%rsp)
movl %r12d, 0x34(%rsp)
movl %eax, 0x38(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x26e8d
movl 0x38(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x30(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x18(%rsp)
jmp 0x26e98
movq %rbp, %rdi
movq %r13, %rdx
callq 0x3185c
incq %r12
movq 0xb0(%rbx), %rax
movq 0xb8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r12
jb 0x26e55
movq 0xb0(%r15), %rax
cmpq %rax, 0xb8(%r15)
je 0x26f32
xorl %r12d, %r12d
leaq 0x10(%rsp), %rbp
leaq 0x30(%rsp), %r13
movq (%rax,%r12,8), %rax
movl 0x70(%rax), %eax
movb $0x0, 0x30(%rsp)
movl %r12d, 0x34(%rsp)
movl %eax, 0x38(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x26f0a
movl 0x38(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x30(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x18(%rsp)
jmp 0x26f15
movq %rbp, %rdi
movq %r13, %rdx
callq 0x3185c
incq %r12
movq 0xb0(%r15), %rax
movq 0xb8(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r12
jb 0x26ed2
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbp
cmpq %rbp, %r13
movq 0x70(%rsp), %r12
je 0x26f8f
movq %rbp, %rax
subq %r13, %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
bsrq %rcx, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0xf96(%rip), %rcx      # 0x25fdc
movq %r13, %rdi
movq %rbp, %rsi
callq 0x319eb
leaq -0xfa8(%rip), %rdx      # 0x25fdc
movq %r13, %rdi
movq %rbp, %rsi
callq 0x31b46
movq 0x58(%rsp), %rax
incl %eax
movq %rax, 0x60(%rsp)
xorl %ebp, %ebp
movl 0x78(%r12), %eax
cmpl $0x0, 0x68(%rsp)
jle 0x270e3
testl %r14d, %r14d
jle 0x270e3
cmpl $0x3, %eax
jl 0x2703a
movq 0x2d026(%rip), %rdi     # 0x53fe8
leaq 0x1e510(%rip), %rsi     # 0x454d9
movl $0x20, %edx
callq 0x7340
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
movq 0x2cff2(%rip), %rdi     # 0x53fe8
callq 0x71c0
movq %rax, %r13
leaq 0x1e682(%rip), %rsi     # 0x45687
movl $0xb, %edx
movq %rax, %rdi
callq 0x7340
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
leaq 0xc(%rsp), %rax
leaq 0x10(%rsp), %r9
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq 0x50(%rsp), %r8
pushq 0x60(%rsp)
pushq %rax
callq 0x268cd
addq $0x10, %rsp
movl 0x78(%r12), %eax
cmpl $0x2, %eax
jle 0x270df
movq 0x2cf72(%rip), %rdi     # 0x53fe8
leaq 0x1e47d(%rip), %rsi     # 0x454fa
movl $0x6, %edx
callq 0x7340
movl 0xc(%rsp), %ebp
movq 0x2cf56(%rip), %rdi     # 0x53fe8
movl %ebp, %esi
callq 0x75d0
movq %rax, %r13
leaq 0x1e5d9(%rip), %rsi     # 0x4567c
movl $0x16, %edx
movq %rax, %rdi
callq 0x7340
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movl 0x78(%r12), %eax
jmp 0x270e3
movl 0xc(%rsp), %ebp
movq 0x68(%rsp), %rcx
cmpl %r14d, %ecx
cmovgl %ecx, %r14d
testl %r14d, %r14d
jle 0x27289
movq 0x50(%rsp), %rcx
cmpb $0x0, 0x14(%rcx)
movq 0x48(%rsp), %r14
je 0x2728e
cmpl 0x58(%rsp), %ebp
jg 0x2728e
cmpl $0x2, %eax
jl 0x271b5
movq 0x2cec2(%rip), %r13     # 0x53fe8
leaq 0x1e3d4(%rip), %rsi     # 0x45501
movl $0xd, %edx
movq %r13, %rdi
callq 0x7340
movq (%r13), %rax
addq -0x18(%rax), %r13
movq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x2ce8f(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
cmpl $0x3, 0x78(%r12)
jl 0x271b5
movq 0x2ce73(%rip), %r13     # 0x53fe8
leaq 0x1e393(%rip), %rsi     # 0x4550f
movl $0x33, %edx
movq %r13, %rdi
callq 0x7340
movq (%r13), %rax
addq -0x18(%rax), %r13
movq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x2ce40(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
subq $0x8, %rsp
leaq 0x14(%rsp), %r10
leaq 0x18(%rsp), %r9
movq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq 0x58(%rsp), %r8
pushq 0x68(%rsp)
pushq %r10
pushq %rax
callq 0x26072
addq $0x20, %rsp
cmpl $0x3, 0x78(%r12)
jl 0x2726b
movq 0x2cddd(%rip), %rdi     # 0x53fe8
leaq 0x1e331(%rip), %rsi     # 0x45543
movl $0x1d, %edx
callq 0x7340
movl 0xc(%rsp), %esi
movq 0x2cdc1(%rip), %rdi     # 0x53fe8
callq 0x75d0
movq %rax, %r13
leaq 0x1e446(%rip), %rsi     # 0x4567c
movl $0x16, %edx
movq %rax, %rdi
callq 0x7340
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x27282
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
movl 0x78(%r12), %eax
jmp 0x2728e
movq 0x48(%rsp), %r14
movl 0xc8(%rbx), %ebp
cmpl $0x2, %eax
jl 0x272e9
movq 0x2cd48(%rip), %rdi     # 0x53fe8
leaq 0x1e2ba(%rip), %rsi     # 0x45561
movl $0x11, %edx
callq 0x7340
movq 0x2cd30(%rip), %rdi     # 0x53fe8
movl %ebp, %esi
callq 0x75d0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x50(%rsp), %rax
cmpb $0x1, 0x9(%rax)
jne 0x2730d
movq 0x58(%rsp), %rax
cmpl %eax, 0xc(%rsp)
jg 0x2730d
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x25a9b
cmpl $0x2, 0x78(%r12)
jl 0x2736b
movq 0x2cccc(%rip), %rdi     # 0x53fe8
leaq 0x1e250(%rip), %rsi     # 0x45573
movl $0x11, %edx
callq 0x7340
movl 0xc8(%rbx), %esi
subl %ebp, %esi
movq 0x2ccac(%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
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x27382
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x273b6
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
jmp 0x273b6
jmp 0x273b3
jmp 0x273b3
jmp 0x273b3
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x273cd
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x72f0
movq %rbx, %rdi
callq 0x7600