// File: /workspace/github_c_makefile_star2_O1/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 0x8f6c
movq %rdi, %rbx
movl 0x24(%rdi), %r13d
testl %r13d, %r13d
js 0x8f6c
movq %rsi, %r15
testq %rsi, %rsi
je 0x8f8b
movq %rdx, %r14
testq %rdx, %rdx
je 0x8faa
movq 0x28(%rbx), %r12
movq 0x30(%r15), %rsi
movq %r12, %rdi
callq 0x3330
testl %eax, %eax
jne 0x8fc9
movq 0x30(%r14), %rsi
movq %r12, %rdi
callq 0x3330
testl %eax, %eax
jne 0x8fe8
cmpq %r14, %r15
je 0x9007
cmpl 0x14(%r15), %r13d
jne 0x8e1a
cmpl 0x14(%r14), %ebp
jne 0x8e1a
cmpl (%r14), %r13d
jne 0x8e1a
movl 0x10(%rbx), %eax
cmpl 0x18(%r14), %eax
jne 0x8e1a
cmpl 0x4(%r15), %eax
jne 0x8e1a
movl 0x14(%rbx), %eax
cmpl 0x4(%r14), %eax
jne 0x8e1a
cmpl 0x18(%r15), %eax
je 0x8ea7
movq 0x231d7(%rip), %r12     # 0x2bff8
movq (%r12), %rcx
leaq 0x199ef(%rip), %rdi     # 0x2281b
movl $0x68, %esi
movl $0x1, %edx
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 0x19a26(%rip), %rsi     # 0x22884
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x3350
addq $0x10, %rsp
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 0x19a0f(%rip), %rsi     # 0x2289f
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x3350
addq $0x10, %rsp
movq %rbx, %rdi
callq 0x38cc
movl 0x20(%rbx), %eax
cmpl (%r15), %eax
jne 0x9026
movl 0x24(%rbx), %eax
cmpl (%r14), %eax
jne 0x9045
movl 0x10(%rbx), %eax
cmpl 0x4(%r15), %eax
jne 0x9064
movl 0x14(%rbx), %eax
cmpl 0x4(%r14), %eax
jne 0x9083
cmpl $0x0, 0x18(%rbx)
jns 0x8ef3
movzbl 0xb(%r15), %esi
addq 0x30(%r15), %rsi
movq %r15, %rdi
callq 0xf2c0
movl %eax, 0x18(%rbx)
movl 0x18(%rbx), %ebp
movzbl 0xb(%r15), %esi
addq 0x30(%r15), %rsi
movq %r15, %rdi
callq 0xf2c0
cmpl %eax, %ebp
jne 0x90a2
cmpl $0x0, 0x1c(%rbx)
jns 0x8f29
movzbl 0xb(%r14), %esi
addq 0x30(%r14), %rsi
movq %r14, %rdi
callq 0xf2c0
movl %eax, 0x1c(%rbx)
movl 0x1c(%rbx), %ebp
movzbl 0xb(%r14), %esi
addq 0x30(%r14), %rsi
movq %r14, %rdi
callq 0xf2c0
cmpl %eax, %ebp
jne 0x90c1
movl 0x10(%rbx), %eax
cmpl 0x18(%rbx), %eax
jg 0x90e0
movl 0x14(%rbx), %eax
cmpl 0x1c(%rbx), %eax
jg 0x90ff
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1978b(%rip), %rdi     # 0x226fe
leaq 0x18d8b(%rip), %rsi     # 0x21d05
leaq 0x197bc(%rip), %rcx     # 0x2273d
movl $0x74b, %edx            # imm = 0x74B
callq 0x3230
leaq 0x196c8(%rip), %rdi     # 0x2265a
leaq 0x18d6c(%rip), %rsi     # 0x21d05
leaq 0x1979d(%rip), %rcx     # 0x2273d
movl $0x74c, %edx            # imm = 0x74C
callq 0x3230
leaq 0x197ca(%rip), %rdi     # 0x2277b
leaq 0x18d4d(%rip), %rsi     # 0x21d05
leaq 0x1977e(%rip), %rcx     # 0x2273d
movl $0x74d, %edx            # imm = 0x74D
callq 0x3230
leaq 0x197c0(%rip), %rdi     # 0x22790
leaq 0x18d2e(%rip), %rsi     # 0x21d05
leaq 0x1975f(%rip), %rcx     # 0x2273d
movl $0x74f, %edx            # imm = 0x74F
callq 0x3230
leaq 0x197d8(%rip), %rdi     # 0x227c7
leaq 0x18d0f(%rip), %rsi     # 0x21d05
leaq 0x19740(%rip), %rcx     # 0x2273d
movl $0x750, %edx            # imm = 0x750
callq 0x3230
leaq 0x197f4(%rip), %rdi     # 0x22802
leaq 0x18cf0(%rip), %rsi     # 0x21d05
leaq 0x19721(%rip), %rcx     # 0x2273d
movl $0x751, %edx            # imm = 0x751
callq 0x3230
leaq 0x1988d(%rip), %rdi     # 0x228ba
leaq 0x18cd1(%rip), %rsi     # 0x21d05
leaq 0x19702(%rip), %rcx     # 0x2273d
movl $0x761, %edx            # imm = 0x761
callq 0x3230
leaq 0x1989d(%rip), %rdi     # 0x228e9
leaq 0x18cb2(%rip), %rsi     # 0x21d05
leaq 0x196e3(%rip), %rcx     # 0x2273d
movl $0x762, %edx            # imm = 0x762
callq 0x3230
leaq 0x198b1(%rip), %rdi     # 0x2291c
leaq 0x18c93(%rip), %rsi     # 0x21d05
leaq 0x196c4(%rip), %rcx     # 0x2273d
movl $0x763, %edx            # imm = 0x763
callq 0x3230
leaq 0x198be(%rip), %rdi     # 0x22948
leaq 0x18c74(%rip), %rsi     # 0x21d05
leaq 0x196a5(%rip), %rcx     # 0x2273d
movl $0x764, %edx            # imm = 0x764
callq 0x3230
leaq 0x198cf(%rip), %rdi     # 0x22978
leaq 0x18c55(%rip), %rsi     # 0x21d05
leaq 0x19686(%rip), %rcx     # 0x2273d
movl $0x76a, %edx            # imm = 0x76A
callq 0x3230
leaq 0x198f9(%rip), %rdi     # 0x229c1
leaq 0x18c36(%rip), %rsi     # 0x21d05
leaq 0x19667(%rip), %rcx     # 0x2273d
movl $0x76f, %edx            # imm = 0x76F
callq 0x3230
leaq 0x1992b(%rip), %rdi     # 0x22a12
leaq 0x18c17(%rip), %rsi     # 0x21d05
leaq 0x19648(%rip), %rcx     # 0x2273d
movl $0x771, %edx            # imm = 0x771
callq 0x3230
leaq 0x19939(%rip), %rdi     # 0x22a3f
leaq 0x18bf8(%rip), %rsi     # 0x21d05
leaq 0x19629(%rip), %rcx     # 0x2273d
movl $0x772, %edx            # imm = 0x772
callq 0x3230