// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
pushq $0x1
popq %rax
testq %rcx, %rcx
je 0x1b3d71
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
xorl %ebx, %ebx
testq %rdx, %rdx
cmovleq %rbx, %rdx
leaq 0x10(%rdi), %r14
pushq $-0x1
popq %rax
xorl %r10d, %r10d
xorl %r8d, %r8d
cmpq %rdx, %rbx
je 0x1b3d1d
imulq $0x28, %rbx, %r13
movl (%rsi,%r13), %r9d
movl 0x4(%rsi,%r13), %ebp
subl %r9d, %ebp
movq 0x10(%rsi,%r13), %r11
cmpq %rbp, %r11
ja 0x1b3d80
addq %rsi, %r13
imulq $0x18, %r9, %r15
leaq (%rdi,%r15), %r12
imulq $0x18, %r11, %r9
addq %r15, %r9
addq %r14, %r9
movq %rax, %r15
cmpq %r11, %rbp
je 0x1b3ccd
movl (%r9), %r15d
cmpq %rcx, %r15
jge 0x1b3cd2
incq %r11
addq $0x18, %r9
jmp 0x1b3cb7
movq %rbp, %r9
jmp 0x1b3cd5
movq %r11, %r9
movq %r9, 0x10(%r13)
cmpq %rbp, %r11
jge 0x1b3d15
testq %r9, %r9
jle 0x1b3d15
cmpq %rcx, %r15
jne 0x1b3d15
imulq $0x18, %r9, %r9
movl -0x8(%r12,%r9), %r11d
incq %r11
cmpq %rcx, %r11
jne 0x1b3d15
addq %r9, %r12
incq %r10
movl -0x18(%r12), %r9d
incl %r9d
xorl %r11d, %r11d
cmpl (%r12), %r9d
sete %r11b
addq %r11, %r8
incq %rbx
jmp 0x1b3c78
cmpq $0x0, 0x10(%rsp)
je 0x1b3d33
cmpq 0x8(%rsp), %r10
pushq $0x1
popq %rax
jge 0x1b3d3d
xorl %eax, %eax
jmp 0x1b3d71
cmpq 0x8(%rsp), %r10
pushq $0x1
popq %rax
jl 0x1b3d9f
cmpq %r10, %r8
je 0x1b3d71
cvtsi2sd %r8, %xmm0
cvtsi2sd %r10, %xmm1
mulsd 0x2f844(%rip), %xmm1    # 0x1e3598
ucomisd %xmm1, %xmm0
seta %cl
pushq $0x2
popq %rsi
movq %r10, %rax
cqto
idivq %rsi
cmpq %rax, %r8
setg %al
andb %cl, %al
movzbl %al, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x44587(%rip), %rdi     # 0x1f830e
leaq 0x4374b(%rip), %rsi     # 0x1f74d9
leaq 0x445e7(%rip), %rcx     # 0x1f837c
movl $0x125a, %edx           # imm = 0x125A
callq 0x2110
leaq 0x44635(%rip), %rdi     # 0x1f83db
leaq 0x4372c(%rip), %rsi     # 0x1f74d9
leaq 0x445c8(%rip), %rcx     # 0x1f837c
movl $0x126e, %edx           # imm = 0x126E
callq 0x2110