// File: /workspace/github_cpp_makefile_star2_O2/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, 0x8(%rsp)
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x3, 0x78(%rcx)
jl 0x1e992
movq 0x2b66a(%rip), %rdi     # 0x49fe8
leaq 0x18ab2(%rip), %rsi     # 0x37437
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1d52e
cmpl $0x3, 0x78(%r12)
jl 0x1ea0f
movq 0x2b639(%rip), %rdi     # 0x49fe8
leaq 0x18a99(%rip), %rsi     # 0x3744f
callq 0x72b0
movq 0xb8(%rbx), %rsi
subq 0xb0(%rbx), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x71d0
leaq 0x18c6b(%rip), %rsi     # 0x37647
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
cmpl $0x3, 0x78(%r12)
jl 0x1ea0f
movq 0x2b5ed(%rip), %rdi     # 0x49fe8
leaq 0x18a65(%rip), %rsi     # 0x37467
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movq %r14, 0x30(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1d52e
cmpl $0x3, 0x78(%r12)
jl 0x1ea6e
movq 0x2b5b7(%rip), %rdi     # 0x49fe8
leaq 0x18a48(%rip), %rsi     # 0x37480
callq 0x72b0
movq 0xb8(%r15), %rsi
subq 0xb0(%r15), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x71d0
leaq 0x18be9(%rip), %rsi     # 0x37647
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movq 0xb8(%rbx), %rcx
subq 0xb0(%rbx), %rcx
shrq $0x3, %rcx
movq 0xb8(%r15), %r14
subq 0xb0(%r15), %r14
shrq $0x3, %r14
andl $0x0, 0x4(%rsp)
movl 0x50(%r12), %eax
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
andq $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movq %rcx, 0x68(%rsp)
leal (%r14,%rcx), %eax
movslq %eax, %rsi
callq 0x22bd0
movq %r12, 0x70(%rsp)
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x60(%rsp)
xorl %r12d, %r12d
leaq 0x40(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq 0xb0(%rbx), %rax
movq 0xb8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r12
jae 0x1eb1f
movq (%rax,%r12,8), %rax
movl 0x70(%rax), %eax
movb $0x1, 0x10(%rsp)
movl %r12d, 0x14(%rsp)
movl %eax, 0x18(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x279ba
incq %r12
jmp 0x1eae0
xorl %r12d, %r12d
leaq 0x40(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq 0xb0(%r15), %rax
movq 0xb8(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r12
jae 0x1eb6b
movq (%rax,%r12,8), %rax
movl 0x70(%rax), %eax
movb $0x0, 0x10(%rsp)
movl %r12d, 0x14(%rsp)
movl %eax, 0x18(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x279ba
incq %r12
jmp 0x1eb2c
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
leaq -0xbe2(%rip), %rdx      # 0x1df9a
callq 0x27b9d
movq 0x70(%rsp), %r12
xorl %r13d, %r13d
movl 0x78(%r12), %eax
cmpl $0x0, 0x68(%rsp)
jle 0x1ec67
testl %r14d, %r14d
jle 0x1ec67
cmpl $0x3, %eax
jl 0x1ebee
movq 0x2b43a(%rip), %rdi     # 0x49fe8
leaq 0x188e4(%rip), %rsi     # 0x37499
callq 0x72b0
movq %rax, %rdi
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
pushq $0xc
popq %rcx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x71d0
leaq 0x18a69(%rip), %rsi     # 0x37647
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
leaq 0x4(%rsp), %rax
leaq 0x40(%rsp), %r9
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq 0x8(%rsp), %r8
pushq 0x60(%rsp)
pushq %rax
callq 0x1e6da
popq %rax
popq %rcx
movl 0x78(%r12), %eax
cmpl $0x2, %eax
jle 0x1ec62
movq 0x2b3c0(%rip), %rdi     # 0x49fe8
leaq 0x1888b(%rip), %rsi     # 0x374ba
callq 0x72b0
movl 0x4(%rsp), %r13d
movq %rax, %rdi
movl %r13d, %esi
callq 0x75c0
leaq 0x189f1(%rip), %rsi     # 0x3763c
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movl 0x78(%r12), %eax
jmp 0x1ec67
movl 0x4(%rsp), %r13d
movq 0x68(%rsp), %rcx
cmpl %r14d, %ecx
cmovgl %ecx, %r14d
testl %r14d, %r14d
jle 0x1ed64
movq 0x8(%rsp), %rcx
cmpb $0x0, 0x14(%rcx)
je 0x1ed64
cmpl 0x38(%rsp), %r13d
jg 0x1ed64
cmpl $0x2, %eax
jl 0x1ecd9
movq 0x2b346(%rip), %rdi     # 0x49fe8
leaq 0x18818(%rip), %rsi     # 0x374c1
callq 0x72b0
movq %rax, %rdi
callq 0x7160
cmpl $0x3, 0x78(%r12)
jl 0x1ecd9
movq 0x2b323(%rip), %rdi     # 0x49fe8
leaq 0x18803(%rip), %rsi     # 0x374cf
callq 0x72b0
movq %rax, %rdi
callq 0x7160
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
subq $0x8, %rsp
leaq 0xc(%rsp), %rax
leaq 0x48(%rsp), %r9
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq 0x10(%rsp), %r8
pushq 0x68(%rsp)
pushq %rax
pushq %rbp
callq 0x1e084
addq $0x20, %rsp
cmpl $0x3, 0x78(%r12)
jl 0x1ed55
movq 0x2b2c2(%rip), %rdi     # 0x49fe8
leaq 0x187d6(%rip), %rsi     # 0x37503
callq 0x72b0
movl 0x4(%rsp), %esi
movq %rax, %rdi
callq 0x75c0
leaq 0x188f7(%rip), %rsi     # 0x3763c
movq %rax, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
leaq 0x10(%rsp), %rdi
callq 0x27b78
movl 0x78(%r12), %eax
movl 0xc8(%rbx), %ebp
cmpl $0x2, %eax
jl 0x1ed94
movq 0x2b272(%rip), %rdi     # 0x49fe8
leaq 0x187a4(%rip), %rsi     # 0x37521
callq 0x72b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x8(%rsp), %rax
cmpb $0x1, 0x9(%rax)
jne 0x1edba
movq 0x38(%rsp), %rax
cmpl %eax, 0x4(%rsp)
jg 0x1edba
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1dd6b
cmpl $0x2, 0x78(%r12)
jl 0x1eded
movq 0x2b21f(%rip), %rdi     # 0x49fe8
leaq 0x18763(%rip), %rsi     # 0x37533
callq 0x72b0
movl 0xc8(%rbx), %esi
subl %ebp, %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
leaq 0x40(%rsp), %rdi
callq 0x27b78
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x27b78
jmp 0x1ee1e
jmp 0x1ee1b
jmp 0x1ee1b
jmp 0x1ee1b
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x27b78
movq %rbx, %rdi
callq 0x75e0