// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq 0xb0(%rsi), %r12
movq %rsi, 0x18(%rsp)
movq 0xb8(%rsi), %r13
cmpq %r13, %r12
je 0x25f87
movq 0xb0(%rdx), %rax
cmpq 0xb8(%rdx), %rax
je 0x25f87
movq %rdx, 0x8(%rsp)
movq %r13, %rbx
subq %r12, %rbx
movq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x555c(%rip), %rcx     # 0x20682
movq %r12, %rdi
movq %r13, %rsi
callq 0x2f808
leaq 0x8(%r12), %rbp
cmpq $0x81, %rbx
jl 0x25cc2
movq %r13, 0x10(%rsp)
movl $0x8, %r15d
movq %rbp, %r14
movq %r12, %r13
movq %r13, %rcx
leaq (%r12,%r15), %r13
movq (%r12,%r15), %rbx
movq (%r12), %rdx
movl 0x70(%rbx), %eax
cmpl 0x70(%rdx), %eax
jle 0x25c36
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x7570
movq %r12, %rcx
jmp 0x25c5b
movq (%rcx), %rdx
movq %r13, %rcx
cmpl 0x70(%rdx), %eax
jle 0x25c5b
movq %r14, %rdx
leaq -0x8(%rdx), %rcx
movq -0x10(%rdx), %rsi
movq -0x8(%rdx), %rdi
movq %rdi, (%rdx)
movq %rcx, %rdx
cmpl 0x70(%rsi), %eax
jg 0x25c44
movq %rbx, (%rcx)
addq $0x8, %r15
addq $0x8, %r14
cmpq $0x80, %r15
jne 0x25c0c
subq $-0x80, %r12
movq 0x10(%rsp), %r9
cmpq %r9, %r12
movq 0x8(%rsp), %rbx
je 0x25d31
movq -0x8(%r12), %rsi
movq (%r12), %rax
movl 0x70(%rax), %ecx
movq %r12, %rdx
cmpl 0x70(%rsi), %ecx
jle 0x25cb4
movq %r12, %rsi
leaq -0x8(%rsi), %rdx
movq -0x10(%rsi), %rdi
movq -0x8(%rsi), %r8
movq %r8, (%rsi)
movq %rdx, %rsi
cmpl 0x70(%rdi), %ecx
jg 0x25c9d
movq %rax, (%rdx)
addq $0x8, %r12
cmpq %r9, %r12
jne 0x25c86
jmp 0x25d31
cmpq %r13, %rbp
movq 0x8(%rsp), %rbx
je 0x25d31
movq %r12, %r14
movq %r14, %rdi
movq %rbp, %r14
movq (%rbp), %r15
movq (%r12), %rcx
movl 0x70(%r15), %eax
cmpl 0x70(%rcx), %eax
jle 0x25d00
movq %r14, %rdx
subq %r12, %rdx
subq %rdx, %rdi
addq $0x10, %rdi
movq %r12, %rsi
callq 0x7570
movq %r12, %rcx
jmp 0x25d25
movq (%rdi), %rdx
movq %r14, %rcx
cmpl 0x70(%rdx), %eax
jle 0x25d25
movq %r14, %rdx
leaq -0x8(%rdx), %rcx
movq -0x10(%rdx), %rsi
movq -0x8(%rdx), %rdi
movq %rdi, (%rdx)
movq %rcx, %rdx
cmpl 0x70(%rsi), %eax
jg 0x25d0e
movq %r15, (%rcx)
leaq 0x8(%r14), %rbp
cmpq %r13, %rbp
jne 0x25ccf
movq 0xb0(%rbx), %r12
movq 0xb8(%rbx), %r13
cmpq %r13, %r12
je 0x25ebc
movq %r13, %rbx
subq %r12, %rbx
movq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x56e7(%rip), %rcx     # 0x20682
movq %r12, %rdi
movq %r13, %rsi
callq 0x2f808
leaq 0x8(%r12), %rbp
cmpq $0x81, %rbx
jl 0x25e4d
movq %r13, 0x10(%rsp)
movl $0x8, %r15d
movq %rbp, %r14
movq %r12, %r13
movq %r13, %rcx
leaq (%r12,%r15), %r13
movq (%r12,%r15), %rbx
movq (%r12), %rdx
movl 0x70(%rbx), %eax
cmpl 0x70(%rdx), %eax
jle 0x25dc1
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x7570
movq %r12, %rcx
jmp 0x25de6
movq (%rcx), %rdx
movq %r13, %rcx
cmpl 0x70(%rdx), %eax
jle 0x25de6
movq %r14, %rdx
leaq -0x8(%rdx), %rcx
movq -0x10(%rdx), %rsi
movq -0x8(%rdx), %rdi
movq %rdi, (%rdx)
movq %rcx, %rdx
cmpl 0x70(%rsi), %eax
jg 0x25dcf
movq %rbx, (%rcx)
addq $0x8, %r15
addq $0x8, %r14
cmpq $0x80, %r15
jne 0x25d97
subq $-0x80, %r12
movq 0x10(%rsp), %r9
cmpq %r9, %r12
movq 0x8(%rsp), %rbx
je 0x25ebc
movq -0x8(%r12), %rsi
movq (%r12), %rax
movl 0x70(%rax), %ecx
movq %r12, %rdx
cmpl 0x70(%rsi), %ecx
jle 0x25e3f
movq %r12, %rsi
leaq -0x8(%rsi), %rdx
movq -0x10(%rsi), %rdi
movq -0x8(%rsi), %r8
movq %r8, (%rsi)
movq %rdx, %rsi
cmpl 0x70(%rdi), %ecx
jg 0x25e28
movq %rax, (%rdx)
addq $0x8, %r12
cmpq %r9, %r12
jne 0x25e11
jmp 0x25ebc
cmpq %r13, %rbp
movq 0x8(%rsp), %rbx
je 0x25ebc
movq %r12, %r14
movq %r14, %rdi
movq %rbp, %r14
movq (%rbp), %r15
movq (%r12), %rcx
movl 0x70(%r15), %eax
cmpl 0x70(%rcx), %eax
jle 0x25e8b
movq %r14, %rdx
subq %r12, %rdx
subq %rdx, %rdi
addq $0x10, %rdi
movq %r12, %rsi
callq 0x7570
movq %r12, %rcx
jmp 0x25eb0
movq (%rdi), %rdx
movq %r14, %rcx
cmpl 0x70(%rdx), %eax
jle 0x25eb0
movq %r14, %rdx
leaq -0x8(%rdx), %rcx
movq -0x10(%rdx), %rsi
movq -0x8(%rdx), %rdi
movq %rdi, (%rdx)
movq %rcx, %rdx
cmpl 0x70(%rsi), %eax
jg 0x25e99
movq %r15, (%rcx)
leaq 0x8(%r14), %rbp
cmpq %r13, %rbp
jne 0x25e5a
movq 0x18(%rsp), %rcx
movq 0xb0(%rcx), %rax
movq 0xb8(%rcx), %r13
subq %rax, %r13
je 0x25f87
movq (%rax), %rax
movl 0x70(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0xb0(%rbx), %rax
movq 0xb8(%rbx), %rbp
movq (%rax), %rcx
movl 0x70(%rcx), %r14d
subq %rax, %rbp
sarq $0x3, %rbp
sarq $0x3, %r13
cmpq $0x1, %r13
adcq $0x0, %r13
xorl %r12d, %r12d
movq 0x18(%rsp), %rax
movq 0xb0(%rax), %rax
movq (%rax,%r12,8), %rax
movl 0x8(%rsp), %ecx
cmpl %ecx, 0x70(%rax)
jne 0x25f87
movb 0xdc(%rax), %cl
andb 0x40(%rax), %cl
testb $0x1, %cl
jne 0x25f7f
cmpq %rbp, %r12
jae 0x25f7f
movq %r12, %r15
movq 0xb0(%rbx), %rax
movq (%rax,%r15,8), %rax
cmpl %r14d, 0x70(%rax)
jne 0x25f7f
testb $0x1, 0x40(%rax)
je 0x25f5c
testb $0x1, 0xdc(%rax)
jne 0x25f77
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %rbx, %rdx
movl %r12d, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
callq 0x25a0b
incq %r15
cmpq %rbp, %r15
jb 0x25f3c
incq %r12
cmpq %r13, %r12
jne 0x25f0d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq