// File: /workspace/github_c_makefile_star2_O3/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 0x924b
movq %rdi, %rbx
movl 0x24(%rdi), %r13d
testl %r13d, %r13d
js 0x924b
movq %rsi, %r15
testq %rsi, %rsi
je 0x926a
movq %rdx, %r14
testq %rdx, %rdx
je 0x9289
movq 0x28(%rbx), %r12
movq 0x30(%r15), %rsi
movq %r12, %rdi
callq 0x3330
testl %eax, %eax
jne 0x92a8
movq 0x30(%r14), %rsi
movq %r12, %rdi
callq 0x3330
testl %eax, %eax
jne 0x92c7
cmpq %r14, %r15
je 0x92e6
cmpl 0x14(%r15), %r13d
jne 0x90f0
cmpl 0x14(%r14), %ebp
jne 0x90f0
cmpl (%r14), %r13d
jne 0x90f0
movl 0x10(%rbx), %eax
cmpl 0x18(%r14), %eax
jne 0x90f0
cmpl 0x4(%r15), %eax
jne 0x90f0
movl 0x14(%rbx), %eax
cmpl 0x4(%r14), %eax
jne 0x90f0
cmpl 0x18(%r15), %eax
je 0x9180
movq 0x22f01(%rip), %r12     # 0x2bff8
movq (%r12), %rcx
leaq 0x19779(%rip), %rdi     # 0x2287b
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 0x197b0(%rip), %rsi     # 0x228e4
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 0x19799(%rip), %rsi     # 0x228ff
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x3350
addq $0x10, %rsp
movq %rbx, %rdi
callq 0x386a
movl 0x20(%rbx), %ebp
cmpl (%r15), %ebp
jne 0x9305
movl 0x24(%rbx), %eax
cmpl (%r14), %eax
jne 0x9324
movl 0x10(%rbx), %eax
cmpl 0x4(%r15), %eax
jne 0x9343
movl 0x14(%rbx), %eax
cmpl 0x4(%r14), %eax
jne 0x9362
movl 0x18(%rbx), %ebp
movq 0x30(%r15), %rsi
testl %ebp, %ebp
jns 0x91d3
movzbl 0xb(%r15), %eax
addq %rax, %rsi
movq %r15, %rdi
callq 0xf6d8
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 0xf6d8
cmpl %eax, %ebp
jne 0x9381
movl 0x1c(%rbx), %ebp
testl %ebp, %ebp
jns 0x920b
movzbl 0xb(%r14), %esi
addq 0x30(%r14), %rsi
movq %r14, %rdi
callq 0xf6d8
movl %eax, %ebp
movl %eax, 0x1c(%rbx)
movzbl 0xb(%r14), %esi
addq 0x30(%r14), %rsi
movq %r14, %rdi
callq 0xf6d8
cmpl %eax, %ebp
jne 0x93a0
movl 0x10(%rbx), %eax
cmpl 0x18(%rbx), %eax
jg 0x93bf
movl 0x14(%rbx), %eax
cmpl 0x1c(%rbx), %eax
jg 0x93de
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1950c(%rip), %rdi     # 0x2275e
leaq 0x18b0c(%rip), %rsi     # 0x21d65
leaq 0x1953d(%rip), %rcx     # 0x2279d
movl $0x74b, %edx            # imm = 0x74B
callq 0x3230
leaq 0x19449(%rip), %rdi     # 0x226ba
leaq 0x18aed(%rip), %rsi     # 0x21d65
leaq 0x1951e(%rip), %rcx     # 0x2279d
movl $0x74c, %edx            # imm = 0x74C
callq 0x3230
leaq 0x1954b(%rip), %rdi     # 0x227db
leaq 0x18ace(%rip), %rsi     # 0x21d65
leaq 0x194ff(%rip), %rcx     # 0x2279d
movl $0x74d, %edx            # imm = 0x74D
callq 0x3230
leaq 0x19541(%rip), %rdi     # 0x227f0
leaq 0x18aaf(%rip), %rsi     # 0x21d65
leaq 0x194e0(%rip), %rcx     # 0x2279d
movl $0x74f, %edx            # imm = 0x74F
callq 0x3230
leaq 0x19559(%rip), %rdi     # 0x22827
leaq 0x18a90(%rip), %rsi     # 0x21d65
leaq 0x194c1(%rip), %rcx     # 0x2279d
movl $0x750, %edx            # imm = 0x750
callq 0x3230
leaq 0x19575(%rip), %rdi     # 0x22862
leaq 0x18a71(%rip), %rsi     # 0x21d65
leaq 0x194a2(%rip), %rcx     # 0x2279d
movl $0x751, %edx            # imm = 0x751
callq 0x3230
leaq 0x1960e(%rip), %rdi     # 0x2291a
leaq 0x18a52(%rip), %rsi     # 0x21d65
leaq 0x19483(%rip), %rcx     # 0x2279d
movl $0x761, %edx            # imm = 0x761
callq 0x3230
leaq 0x1961e(%rip), %rdi     # 0x22949
leaq 0x18a33(%rip), %rsi     # 0x21d65
leaq 0x19464(%rip), %rcx     # 0x2279d
movl $0x762, %edx            # imm = 0x762
callq 0x3230
leaq 0x19632(%rip), %rdi     # 0x2297c
leaq 0x18a14(%rip), %rsi     # 0x21d65
leaq 0x19445(%rip), %rcx     # 0x2279d
movl $0x763, %edx            # imm = 0x763
callq 0x3230
leaq 0x1963f(%rip), %rdi     # 0x229a8
leaq 0x189f5(%rip), %rsi     # 0x21d65
leaq 0x19426(%rip), %rcx     # 0x2279d
movl $0x764, %edx            # imm = 0x764
callq 0x3230
leaq 0x19650(%rip), %rdi     # 0x229d8
leaq 0x189d6(%rip), %rsi     # 0x21d65
leaq 0x19407(%rip), %rcx     # 0x2279d
movl $0x76a, %edx            # imm = 0x76A
callq 0x3230
leaq 0x1967a(%rip), %rdi     # 0x22a21
leaq 0x189b7(%rip), %rsi     # 0x21d65
leaq 0x193e8(%rip), %rcx     # 0x2279d
movl $0x76f, %edx            # imm = 0x76F
callq 0x3230
leaq 0x196ac(%rip), %rdi     # 0x22a72
leaq 0x18998(%rip), %rsi     # 0x21d65
leaq 0x193c9(%rip), %rcx     # 0x2279d
movl $0x771, %edx            # imm = 0x771
callq 0x3230
leaq 0x196ba(%rip), %rdi     # 0x22a9f
leaq 0x18979(%rip), %rsi     # 0x21d65
leaq 0x193aa(%rip), %rcx     # 0x2279d
movl $0x772, %edx            # imm = 0x772
callq 0x3230