// File: /workspace/github_cpp_makefile_star2_O1/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 0x87a94
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x14(%rdi), %r9d
movl 0x18(%rdi), %r10d
subl %r10d, %r9d
movl 0x14(%rdx), %edi
movl 0x18(%rdx), %r11d
setne %dl
subl %r11d, %edi
setne %bl
andb %dl, %bl
xorps %xmm0, %xmm0
movaps %xmm0, -0x18(%rsp)
cmpb $0x1, %bl
jne 0x87a71
leaq (%r10,%r10,2), %rdx
leaq (%r8,%rdx,8), %rdx
movl %r11d, %r10d
leaq (%r10,%r10,2), %r10
leaq (%r8,%r10,8), %r8
addq $0x4, %r8
xorl %ebx, %ebx
xorl %r11d, %r11d
leaq (%r11,%r11,2), %r15
movl 0x4(%rdx,%r15,8), %ebp
leaq 0x1(%rbx), %r12
cmpq %rdi, %r12
cmovleq %rdi, %r12
leaq (%rbx,%rbx,2), %r10
leaq (%r8,%r10,8), %r14
cmpl %ebp, (%r14)
jae 0x879cc
incq %rbx
addq $0x18, %r14
cmpq %rdi, %rbx
jl 0x879b3
movq %r12, %rbx
jmp 0x87a60
movl (%r14), %r10d
cmpl 0x4(%rdx,%r15,8), %r10d
jne 0x87a60
leaq (%rdx,%r15,8), %r15
xorl %r13d, %r13d
testb $0x1, 0xc(%r15)
movl $0x0, %ebp
je 0x879fc
movl 0x8(%r15), %r10d
cmpq %rsi, %r10
setne %r13b
leal 0x1(%r13), %ebp
xorl %r10d, %r10d
testb $0x1, 0x8(%r14)
movl $0x0, %r12d
je 0x87a1b
movl 0x4(%r14), %r10d
cmpq %rcx, %r10
setne %r10b
leal 0x1(%r10), %r12d
andb %r10b, %r13b
cmpb $0x1, %r13b
jne 0x87a46
cmpl $-0x1, 0x8(%r15)
je 0x87a46
cmpl $-0x1, 0x4(%r14)
movzbl %bpl, %ebp
movl $0x0, %r10d
cmovnel %r10d, %ebp
movzbl %r12b, %r12d
cmovnel %r10d, %r12d
cmpb %r12b, %bpl
jne 0x87a8a
cmpb $0x2, %bpl
je 0x87a8a
cmpb $0x2, %r12b
je 0x87a8a
movzbl %bpl, %r10d
incq -0x18(%rsp,%r10,8)
incq %r11
cmpq %r9, %r11
jae 0x87a71
cmpq %rdi, %rbx
jl 0x87997
cmpq $0x0, -0x10(%rsp)
movl $0x1, %ecx
cmovleq %rax, %rcx
cmpq $0x0, -0x18(%rsp)
cmovgq %rcx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq