// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: connective_conform(integer_aln_t*, ul_chain_t*, long, long, long, unsigned long)
int64_t connective_conform(integer_aln_t *aln, ul_chain_t *idx_a, int64_t idx_n, int64_t str_i0, int64_t occ_thres, uint64_t is_cov_check)
{
    if(str_i0 == 0) return 1;
    int64_t z; ul_chain_t *x; int64_t k, kl, str_k, match, exact; integer_aln_t *a;
    for (z = match = exact = 0; z < idx_n; z++) {
        x = &(idx_a[z]);
        kl = x->e - x->s; str_k = -1; a = aln + x->s; 
        assert(x->sc <= (uint64_t)kl);
        for (k = x->sc; k < kl; k++) {
            str_k = (uint32_t)a[k].tn_rev_qk;
            if(str_k >= str_i0) break;
        }
        x->sc = k;
        if(k >= kl || str_k != str_i0) continue;
        k--;
        if(k >= 0) {
            str_k = (uint32_t)a[k].tn_rev_qk;
            if(str_k+1 == str_i0) {
                match++;
                if(a[k].tk+1 == a[k+1].tk) exact++;
            }
        }
    }

    if(is_cov_check) {
        if(match < occ_thres) return 0;
    } else {
        assert(match >= occ_thres);
    }

    if(exact == match) return 1;
    if(exact > (match*0.51) && exact > (match/2)) return 1;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x329cf7
movq $0x1, -0x8(%rbp)
jmp 0x329f37
movq $0x0, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x329e84
movq -0x18(%rbp), %rax
imulq $0x28, -0x40(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x48(%rbp), %rcx
subl (%rcx), %eax
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq $-0x1, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x58(%rbp), %rax
ja 0x329d6d
jmp 0x329d8c
leaq 0x6d27a(%rip), %rdi     # 0x396fee
leaq 0x6c43e(%rip), %rsi     # 0x3961b9
movl $0x125a, %edx           # imm = 0x125A
leaq 0x6d2d5(%rip), %rcx     # 0x39705c
callq 0x2130
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x329dd4
movq -0x78(%rbp), %rax
imulq $0x18, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl %eax, %eax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x28(%rbp), %rax
jl 0x329dc4
jmp 0x329dd4
jmp 0x329dc6
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x329d98
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x329df4
movq -0x60(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x329df6
jmp 0x329e73
movq -0x50(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jl 0x329e71
movq -0x78(%rbp), %rax
imulq $0x18, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl %eax, %eax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
cmpq -0x28(%rbp), %rax
jne 0x329e6f
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x78(%rbp), %rax
imulq $0x18, -0x50(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
addl $0x1, %eax
movq -0x78(%rbp), %rcx
movq -0x50(%rbp), %rdx
addq $0x1, %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x329e6d
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x329e6f
jmp 0x329e71
jmp 0x329e73
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x329d0f
cmpq $0x0, -0x38(%rbp)
je 0x329ea4
movq -0x68(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x329ea2
movq $0x0, -0x8(%rbp)
jmp 0x329f37
jmp 0x329ed1
movq -0x68(%rbp), %rax
cmpq -0x30(%rbp), %rax
jl 0x329eb0
jmp 0x329ecf
leaq 0x6d204(%rip), %rdi     # 0x3970bb
leaq 0x6c2fb(%rip), %rsi     # 0x3961b9
movl $0x126e, %edx           # imm = 0x126E
leaq 0x6d192(%rip), %rcx     # 0x39705c
callq 0x2130
jmp 0x329ed1
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x329ee5
movq $0x1, -0x8(%rbp)
jmp 0x329f37
cvtsi2sdq -0x70(%rbp), %xmm0
cvtsi2sdq -0x68(%rbp), %xmm1
movsd 0x583bf(%rip), %xmm2    # 0x3822b8
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x329f2f
movq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x68(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jle 0x329f2f
movq $0x1, -0x8(%rbp)
jmp 0x329f37
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)