// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0x1, %eax
testq %rcx, %rcx
je 0x1f4a30
movq %r9, 0x8(%rsp)
movq %r8, (%rsp)
testq %rdx, %rdx
jle 0x1f49d2
leaq 0x28(%rdi), %rax
movq %rax, 0x10(%rsp)
xorl %r10d, %r10d
xorl %r11d, %r11d
xorl %r14d, %r14d
leaq (%r14,%r14,4), %r12
movl (%rsi,%r12,8), %r8d
movl 0x4(%rsi,%r12,8), %ebx
subl %r8d, %ebx
movq 0x10(%rsi,%r12,8), %r13
cmpq %rbx, %r13
ja 0x1f4a3f
leaq (%r8,%r8,2), %r9
leaq (%rdi,%r9,8), %r15
setl %r8b
movq $-0x1, %rbp
jge 0x1f497a
leaq (,%r13,2), %rax
addq %r13, %rax
movl 0x10(%r15,%rax,8), %ebp
cmpq %rcx, %rbp
jge 0x1f497a
incq %r13
shlq $0x3, %r9
leaq (%r9,%rax,8), %r9
addq 0x10(%rsp), %r9
movq %r13, %r8
cmpq %r13, %rbx
je 0x1f4970
movl (%r9), %ebp
leaq 0x1(%r8), %r13
addq $0x18, %r9
cmpq %rcx, %rbp
jl 0x1f4953
decq %r13
jmp 0x1f4973
movq %rbx, %r13
cmpq %rbx, %r8
setl %r8b
leaq (%rsi,%r12,8), %rax
movq %r13, 0x10(%rax)
testb %r8b, %r8b
je 0x1f49c4
testq %r13, %r13
jle 0x1f49c4
cmpq %rcx, %rbp
jne 0x1f49c4
leaq (,%r13,2), %rax
addq %r13, %rax
movl -0x8(%r15,%rax,8), %r8d
incq %r8
cmpq %rcx, %r8
jne 0x1f49c4
leaq (%r15,%rax,8), %rax
incq %r11
movl -0x18(%rax), %r8d
incl %r8d
xorl %r9d, %r9d
cmpl (%rax), %r8d
sete %r9b
addq %r9, %r10
incq %r14
cmpq %rdx, %r14
jne 0x1f48fb
jmp 0x1f49d8
xorl %r11d, %r11d
xorl %r10d, %r10d
cmpq $0x0, 0x8(%rsp)
je 0x1f49ef
cmpq (%rsp), %r11
movl $0x1, %eax
jge 0x1f49fa
xorl %eax, %eax
jmp 0x1f4a30
cmpq (%rsp), %r11
movl $0x1, %eax
jl 0x1f4a5e
cmpq %r11, %r10
je 0x1f4a30
cvtsi2sd %r10, %xmm0
cvtsi2sd %r11, %xmm1
mulsd 0x30b37(%rip), %xmm1    # 0x225548
ucomisd %xmm1, %xmm0
seta %al
movq %r11, %rcx
shrq $0x3f, %rcx
addq %r11, %rcx
sarq %rcx
cmpq %rcx, %r10
setg %cl
andb %al, %cl
movzbl %cl, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x45688(%rip), %rdi     # 0x23a0ce
leaq 0x448d8(%rip), %rsi     # 0x239325
leaq 0x456e8(%rip), %rcx     # 0x23a13c
movl $0x125a, %edx           # imm = 0x125A
callq 0x2110
leaq 0x45736(%rip), %rdi     # 0x23a19b
leaq 0x448b9(%rip), %rsi     # 0x239325
leaq 0x456c9(%rip), %rcx     # 0x23a13c
movl $0x126e, %edx           # imm = 0x126E
callq 0x2110