// File: readmapping[P]alfalfa/src/mapper.cpp
// Function: calculateDiscordantAlignments(sparseSA const&, read_t&, read_t&)
void calculateDiscordantAlignments(const sparseSA& sa, read_t & mate1, read_t & mate2){
    if(!mate1.alignments.empty() && !mate2.alignments.empty()){
        sort(mate1.alignments.begin(),mate1.alignments.end(), compAlignments);
        sort(mate2.alignments.begin(),mate2.alignments.end(), compAlignments);
        //FIND MAX SCORE OF BOTH MATES
        int maxScoreFirst = mate1.alignments[0]->alignmentScore;
        int maxScoreSecond = mate2.alignments[0]->alignmentScore;
        //DISCORDANT ONLY BETWEEN UNPAIRED MAX SCORE ALIGNMENTS
        size_t mate1AlnCount = mate1.alignments.size();
        size_t mate2AlnCount = mate2.alignments.size();
        size_t i = 0;
        while(i < mate1AlnCount && mate1.alignments[i]->alignmentScore == maxScoreFirst){
            if(!mate1.alignments[i]->concordant()){
                size_t j = i;
                while(j < mate2AlnCount && mate2.alignments[j]->alignmentScore == maxScoreSecond){
                    if(!mate2.alignments[j]->concordant())
                        setPaired(sa, mate1,mate2,i,j,false);
                    j++;
                }
            }
            i++;
        }
    }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
callq 0xbe60
testb $0x1, %al
jne 0x43f97
movq 0x50(%rsp), %rdi
addq $0xb0, %rdi
callq 0xbe60
testb $0x1, %al
jne 0x43f97
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
callq 0x4c270
movq %rax, 0x48(%rsp)
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
callq 0x4c2a0
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
leaq -0x7812(%rip), %rdx     # 0x3c5a0
callq 0x4c220
movq 0x50(%rsp), %rdi
addq $0xb0, %rdi
callq 0x4c270
movq %rax, 0x38(%rsp)
movq 0x50(%rsp), %rdi
addq $0xb0, %rdi
callq 0x4c2a0
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
leaq -0x7854(%rip), %rdx     # 0x3c5a0
callq 0x4c220
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xdae0
movq (%rax), %rax
movl 0x70(%rax), %eax
movl %eax, 0x2c(%rsp)
movq 0x50(%rsp), %rdi
addq $0xb0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xdae0
movq (%rax), %rax
movl 0x70(%rax), %eax
movl %eax, 0x28(%rsp)
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rcx
xorl %eax, %eax
cmpq 0x20(%rsp), %rcx
movb %al, 0x7(%rsp)
jae 0x43ea5
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
movq 0x10(%rsp), %rsi
callq 0xdae0
movq (%rax), %rax
movl 0x70(%rax), %eax
cmpl 0x2c(%rsp), %eax
sete %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x43eb2
jmp 0x43f95
movq 0x58(%rsp), %rdi
addq $0xb0, %rdi
movq 0x10(%rsp), %rsi
callq 0xdae0
movq (%rax), %rdi
callq 0x4e570
testb $0x1, %al
jne 0x43f82
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rcx
xorl %eax, %eax
cmpq 0x18(%rsp), %rcx
movb %al, 0x6(%rsp)
jae 0x43f1b
movq 0x50(%rsp), %rdi
addq $0xb0, %rdi
movq 0x8(%rsp), %rsi
callq 0xdae0
movq (%rax), %rax
movl 0x70(%rax), %eax
cmpl 0x28(%rsp), %eax
sete %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
testb $0x1, %al
jne 0x43f25
jmp 0x43f80
movq 0x50(%rsp), %rdi
addq $0xb0, %rdi
movq 0x8(%rsp), %rsi
callq 0xdae0
movq (%rax), %rdi
callq 0x4e570
testb $0x1, %al
jne 0x43f6d
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x10(%rsp), %rax
movl %eax, %ecx
movq 0x8(%rsp), %rax
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x43b50
movq 0x8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0x43ee2
jmp 0x43f82
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x43e6c
jmp 0x43f97
addq $0x68, %rsp
retq
nopl (%rax)