// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: comput_sc_rphase(SnpStats*, unsigned long, SnpStats*, unsigned long, haplotype_evdience*, unsigned long)
inline int64_t comput_sc_rphase(SnpStats *ai, uint64_t id, SnpStats *aj, uint64_t jd, haplotype_evdience *za, uint64_t occ0_cut)
{
    if(ai->site == aj->site) return INT64_MIN;
    // if(ai->occ_0 < occ0_cut || aj->occ_0 < occ0_cut) return INT64_MIN;
    haplotype_evdience *iz = NULL, *jz = NULL; int64_t in, jn, ik, jk, nn[2]; uint8_t fi, fj;
    iz = za + ai->non_homopolymer_num; in = ai->homopolymer_num - ai->non_homopolymer_num;
    jz = za + aj->non_homopolymer_num; jn = aj->homopolymer_num - aj->non_homopolymer_num;

    for (ik = jk = nn[0] = nn[1] = 0; (ik < in) && (jk < jn); ik++) {
        for (; (jk < jn) && (jz[jk].overlapID < iz[ik].overlapID); jk++);
        if((jk < jn) && (jz[jk].overlapID == iz[ik].overlapID)) {

            fi = 2;
            if(hh_tp(iz[ik]) == 0) {
                fi = 0;
            } else if(iz[ik].overlapSite == id){
                fi = 1;
            }

            fj = 2;
            if(hh_tp(jz[jk]) == 0) {
                fj = 0;
            } else if(jz[jk].overlapSite == jd){
                fj = 1;
            }

            if((fi == 2) && (fj == 2) && (iz[ik].overlapSite != ((uint32_t)-1)) && (jz[jk].overlapSite != ((uint32_t)-1))) {///for rare cases
                fi = fj = 0;
            }

            if(fi == 2 || fj == 2) return INT64_MIN;
            if(fi != fj) return INT64_MIN;
            nn[fi]++;
        }
    }

    if(nn[0] > 0 && nn[1] > 0) return 1;
    return INT64_MIN;
}

// Assembly:
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movl 0x20(%rdi), %r9d
cmpl 0x20(%rdx), %r9d
je 0x53c1e
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x14(%rdi), %r9d
movl 0x18(%rdi), %r10d
imulq $0x18, %r10, %rdi
addq %r8, %rdi
subl %r10d, %r9d
movl 0x14(%rdx), %r10d
movl 0x18(%rdx), %edx
subl %edx, %r10d
xorps %xmm0, %xmm0
movaps %xmm0, -0x18(%rsp)
imulq $0x18, %rdx, %rdx
addq %r8, %rdx
addq $0xc, %rdx
xorl %r11d, %r11d
xorl %ebx, %ebx
cmpq %r9, %r11
jae 0x53bf6
cmpq %r10, %rbx
jge 0x53bf6
imulq $0x18, %r11, %r14
leaq (%rdi,%r14), %r12
addq $0x4, %r12
imulq $0x18, %rbx, %r15
addq %rdx, %r15
cmpq %rbx, %r10
je 0x53b60
movl -0x8(%r15), %ebp
movl (%r12), %r13d
cmpl %r13d, %ebp
jae 0x53b68
incq %rbx
addq $0x18, %r15
jmp 0x53b45
movq %r10, %rbx
jmp 0x53bee
jne 0x53bee
addq %rdi, %r14
xorl %r12d, %r12d
testb $0x1, 0xc(%r14)
movl $0x0, %ebp
je 0x53b90
movl 0x8(%r14), %r12d
cmpq %rsi, %r12
setne %r12b
leal 0x1(%r12), %ebp
testb $0x1, (%r15)
jne 0x53b9b
xorl %r15d, %r15d
jmp 0x53bd4
movl -0x4(%r15), %r13d
cmpq %rcx, %r13
setne %r8b
leal 0x1(%r8), %r15d
andb %r8b, %r12b
cmpb $0x1, %r12b
jne 0x53bd4
cmpl $-0x1, 0x8(%r14)
je 0x53bd4
cmpl $-0x1, %r13d
movzbl %bpl, %ebp
movl $0x0, %r8d
cmovnel %r8d, %ebp
movzbl %r15b, %r15d
cmovnel %r8d, %r15d
cmpb %r15b, %bpl
jne 0x53c14
cmpb $0x2, %bpl
je 0x53c14
cmpb $0x2, %r15b
je 0x53c14
movzbl %bpl, %r8d
incq -0x18(%rsp,%r8,8)
incq %r11
jmp 0x53b20
cmpq $0x0, -0x10(%rsp)
movabsq $0x1, %rcx
cmovleq %rax, %rcx
cmpq $0x0, -0x18(%rsp)
cmovgq %rcx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq