// File: /workspace/github_c_makefile_star2_O2/sc932[P]ALE/src/ALElike.c
// Function: validateAlignmentMates
void validateAlignmentMates(alignSet_t *thisAlignment, bam1_t *thisRead, bam1_t *thisReadMate) {

    assert(thisAlignment->contigId1 >= 0 && thisAlignment->contigId2 >= 0);
    assert(thisRead != NULL);
    assert(thisReadMate != NULL);

    assert(strcmp(thisAlignment->name, bam1_qname(thisRead)) == 0);
    assert(strcmp(thisAlignment->name, bam1_qname(thisReadMate)) == 0);
    assert(thisRead != thisReadMate);

    if ( ! (   (thisAlignment->contigId2 == thisRead->core.mtid) 
            && (thisAlignment->contigId1 == thisReadMate->core.mtid)
            && (thisAlignment->contigId2 == thisReadMate->core.tid)
            && (thisAlignment->start1    == thisReadMate->core.mpos)
            && (thisAlignment->start1    == thisRead->core.pos)
            && (thisAlignment->start2    == thisReadMate->core.pos) 
            && (thisAlignment->start2    == thisRead->core.mpos) 
           ) ) {
        fprintf(stderr, "WARNING: The following read and its mate do not agree on the contigs and/or positions of their mappings:");
        fprintf(stderr, "read1: %s %d: %d %d %d %d\t", bam1_qname(thisRead), thisRead->core.flag, thisRead->core.tid, thisRead->core.mtid, thisRead->core.pos, thisRead->core.mpos);
        fprintf(stderr, "read2: %s %d: %d %d %d %d\t", bam1_qname(thisReadMate), thisReadMate->core.flag, thisReadMate->core.tid, thisReadMate->core.mtid, thisReadMate->core.pos, thisReadMate->core.mpos);
        printAlignment(thisAlignment);
    }

    assert(thisAlignment->contigId1 == thisRead->core.tid);
    assert(thisAlignment->contigId2 == thisReadMate->core.tid);
    assert(thisAlignment->start1 == thisRead->core.pos);
    assert(thisAlignment->start2 == thisReadMate->core.pos);

    // assign the end position, if not set already
    if (thisAlignment->end1 < 0){
        thisAlignment->end1 = bam_calend(&thisRead->core, bam1_cigar(thisRead));
    }
    assert(thisAlignment->end1 == bam_calend(&thisRead->core, bam1_cigar(thisRead)));

    if (thisAlignment->end2 < 0){
        thisAlignment->end2 = bam_calend(&thisReadMate->core, bam1_cigar(thisReadMate));
    }
    assert(thisAlignment->end2 == bam_calend(&thisReadMate->core, bam1_cigar(thisReadMate)));

    assert(thisAlignment->start1 <= thisAlignment->end1);
    assert(thisAlignment->start2 <= thisAlignment->end2);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x20(%rdi), %ebp
testl %ebp, %ebp
js 0x7213
movq %rdi, %rbx
movl 0x24(%rdi), %r13d
testl %r13d, %r13d
js 0x7213
movq %rsi, %r15
testq %rsi, %rsi
je 0x7232
movq %rdx, %r14
testq %rdx, %rdx
je 0x7251
movq 0x28(%rbx), %r12
movq 0x30(%r15), %rsi
movq %r12, %rdi
callq 0x3330
testl %eax, %eax
jne 0x7270
movq 0x30(%r14), %rsi
movq %r12, %rdi
callq 0x3330
testl %eax, %eax
jne 0x728f
cmpq %r14, %r15
je 0x72ae
cmpl 0x14(%r15), %r13d
jne 0x70c0
cmpl 0x14(%r14), %ebp
jne 0x70c0
cmpl (%r14), %r13d
jne 0x70c0
movl 0x10(%rbx), %eax
cmpl 0x18(%r14), %eax
jne 0x70c0
cmpl 0x4(%r15), %eax
jne 0x70c0
movl 0x14(%rbx), %eax
cmpl 0x4(%r14), %eax
jne 0x70c0
cmpl 0x18(%r15), %eax
je 0x7148
movq 0x21f31(%rip), %r12     # 0x28ff8
movq (%r12), %rcx
leaq 0x17779(%rip), %rdi     # 0x1e84b
pushq $0x68
popq %rsi
pushq $0x1
popq %rdx
callq 0x35e0
movq (%r12), %rdi
movq 0x30(%r15), %rdx
movzwl 0xc(%r15), %ecx
movl 0x14(%r15), %r9d
movl (%r15), %r8d
movl 0x4(%r15), %r10d
movl 0x18(%r15), %r11d
leaq 0x177b4(%rip), %rsi     # 0x1e8b4
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x3350
popq %rcx
popq %rdx
movq (%r12), %rdi
movq 0x30(%r14), %rdx
movzwl 0xc(%r14), %ecx
movl 0x14(%r14), %r9d
movl (%r14), %r8d
movl 0x4(%r14), %r10d
movl 0x18(%r14), %r11d
leaq 0x1779f(%rip), %rsi     # 0x1e8cf
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x3350
popq %rcx
popq %rdx
movq %rbx, %rdi
callq 0x910f
movl 0x20(%rbx), %ebp
cmpl (%r15), %ebp
jne 0x72cd
movl 0x24(%rbx), %eax
cmpl (%r14), %eax
jne 0x72ec
movl 0x10(%rbx), %eax
cmpl 0x4(%r15), %eax
jne 0x730b
movl 0x14(%rbx), %eax
cmpl 0x4(%r14), %eax
jne 0x732a
movl 0x18(%rbx), %ebp
movq 0x30(%r15), %rsi
testl %ebp, %ebp
jns 0x719b
movzbl 0xb(%r15), %eax
addq %rax, %rsi
movq %r15, %rdi
callq 0xd54c
movl %eax, %ebp
movl %eax, 0x18(%rbx)
movq 0x30(%r15), %rsi
movzbl 0xb(%r15), %eax
addq %rsi, %rax
movq %r15, %rdi
movq %rax, %rsi
callq 0xd54c
cmpl %eax, %ebp
jne 0x7349
movl 0x1c(%rbx), %ebp
testl %ebp, %ebp
jns 0x71d3
movzbl 0xb(%r14), %esi
addq 0x30(%r14), %rsi
movq %r14, %rdi
callq 0xd54c
movl %eax, %ebp
movl %eax, 0x1c(%rbx)
movzbl 0xb(%r14), %esi
addq 0x30(%r14), %rsi
movq %r14, %rdi
callq 0xd54c
cmpl %eax, %ebp
jne 0x7368
movl 0x10(%rbx), %eax
cmpl 0x18(%rbx), %eax
jg 0x7387
movl 0x14(%rbx), %eax
cmpl 0x1c(%rbx), %eax
jg 0x73a6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17514(%rip), %rdi     # 0x1e72e
leaq 0x16b14(%rip), %rsi     # 0x1dd35
leaq 0x17545(%rip), %rcx     # 0x1e76d
movl $0x74b, %edx            # imm = 0x74B
callq 0x3230
leaq 0x17451(%rip), %rdi     # 0x1e68a
leaq 0x16af5(%rip), %rsi     # 0x1dd35
leaq 0x17526(%rip), %rcx     # 0x1e76d
movl $0x74c, %edx            # imm = 0x74C
callq 0x3230
leaq 0x17553(%rip), %rdi     # 0x1e7ab
leaq 0x16ad6(%rip), %rsi     # 0x1dd35
leaq 0x17507(%rip), %rcx     # 0x1e76d
movl $0x74d, %edx            # imm = 0x74D
callq 0x3230
leaq 0x17549(%rip), %rdi     # 0x1e7c0
leaq 0x16ab7(%rip), %rsi     # 0x1dd35
leaq 0x174e8(%rip), %rcx     # 0x1e76d
movl $0x74f, %edx            # imm = 0x74F
callq 0x3230
leaq 0x17561(%rip), %rdi     # 0x1e7f7
leaq 0x16a98(%rip), %rsi     # 0x1dd35
leaq 0x174c9(%rip), %rcx     # 0x1e76d
movl $0x750, %edx            # imm = 0x750
callq 0x3230
leaq 0x1757d(%rip), %rdi     # 0x1e832
leaq 0x16a79(%rip), %rsi     # 0x1dd35
leaq 0x174aa(%rip), %rcx     # 0x1e76d
movl $0x751, %edx            # imm = 0x751
callq 0x3230
leaq 0x17616(%rip), %rdi     # 0x1e8ea
leaq 0x16a5a(%rip), %rsi     # 0x1dd35
leaq 0x1748b(%rip), %rcx     # 0x1e76d
movl $0x761, %edx            # imm = 0x761
callq 0x3230
leaq 0x17626(%rip), %rdi     # 0x1e919
leaq 0x16a3b(%rip), %rsi     # 0x1dd35
leaq 0x1746c(%rip), %rcx     # 0x1e76d
movl $0x762, %edx            # imm = 0x762
callq 0x3230
leaq 0x1763a(%rip), %rdi     # 0x1e94c
leaq 0x16a1c(%rip), %rsi     # 0x1dd35
leaq 0x1744d(%rip), %rcx     # 0x1e76d
movl $0x763, %edx            # imm = 0x763
callq 0x3230
leaq 0x17647(%rip), %rdi     # 0x1e978
leaq 0x169fd(%rip), %rsi     # 0x1dd35
leaq 0x1742e(%rip), %rcx     # 0x1e76d
movl $0x764, %edx            # imm = 0x764
callq 0x3230
leaq 0x17658(%rip), %rdi     # 0x1e9a8
leaq 0x169de(%rip), %rsi     # 0x1dd35
leaq 0x1740f(%rip), %rcx     # 0x1e76d
movl $0x76a, %edx            # imm = 0x76A
callq 0x3230
leaq 0x17682(%rip), %rdi     # 0x1e9f1
leaq 0x169bf(%rip), %rsi     # 0x1dd35
leaq 0x173f0(%rip), %rcx     # 0x1e76d
movl $0x76f, %edx            # imm = 0x76F
callq 0x3230
leaq 0x176b4(%rip), %rdi     # 0x1ea42
leaq 0x169a0(%rip), %rsi     # 0x1dd35
leaq 0x173d1(%rip), %rcx     # 0x1e76d
movl $0x771, %edx            # imm = 0x771
callq 0x3230
leaq 0x176c2(%rip), %rdi     # 0x1ea6f
leaq 0x16981(%rip), %rsi     # 0x1dd35
leaq 0x173b2(%rip), %rcx     # 0x1e76d
movl $0x772, %edx            # imm = 0x772
callq 0x3230