// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: old_path_ext(ul_resolve_t*, usg_t*, asg64_v*, asg64_v*, unsigned long, unsigned long, unsigned long*, unsigned long*, unsigned char*, unsigned int*, unsigned int)
uint64_t old_path_ext(ul_resolve_t *uidx, usg_t *ng, asg64_v *b64, asg64_v *ub64, uint64_t a_n, uint64_t n_clus, uint64_t *i_idx, uint64_t *int_a, 
uint8_t *ff, uint32_t *ng_occ, uint32_t max_ext)
{
    uint64_t k, i, z, /**s, e,**/ mm, tip_l;
    /**
    for (k = a_n + 1, i = a_n, mm = a_n; k <= b64->n; k++) {
        if(k == b64->n || (b64->a[k]>>32) != (b64->a[i]>>32)) {
            for (z = i; z < k; z++) {///all intger seqs within the same cluster
                s = b64->a[((uint32_t)b64->a[z])]>>32; 
                e = ((uint32_t)b64->a[((uint32_t)b64->a[z])]); assert(e > s);
                ///[s, e]:: available interval
                if(!ava_pass_unique_bridge(i_idx, int_a, s, e)) break;
            }
            if(z >= k) {///all arcs in this cluster is fine -> each of arch is reliable
                for (z = i; z < k; z++) b64->a[mm++] = b64->a[z];
            }
            i = k; n_clus--;
        }
    }
    assert(n_clus == 0);
    b64->n = mm; 
    **/
    // prt_thread_info(b64.a, a_n, NULL, 0, "tt5");
    // fprintf(stderr, "**4**[M::%s::] a_n::%lu, n_clus::%lu\n", __func__, a_n, n_clus);
    n_clus = 0;
    for (k = a_n + 1, i = a_n, mm = a_n; k <= b64->n; k++) {
        if(k == b64->n || (b64->a[k]>>32) != (b64->a[i]>>32)) {
            tip_l = ava_pass_unique_bridge_tips(ng, b64, i, k, int_a, ff, max_ext, 0.03, 16);
            if(tip_l < max_ext) {///no long tip
                if(/**(!tip_l) || (**/ava_pass_unique_bridge_cov(uidx, ng, b64, i, k, int_a, tip_l)) {
                    for (z = i; z < k; z++) {
                        b64->a[mm++] = b64->a[z];
                    }
                    n_clus++;
                }
            }
            i = k; 
        }
    }
    // prt_thread_info(b64.a, a_n, NULL, 0, "tt6");
    b64->n = mm;
    // fprintf(stderr, "**5**[M::%s::] a_n::%lu, n_clus::%lu, ng->n::%lu\n", __func__, a_n, n_clus, ng->n);
    // prt_thread_info(b64.a, a_n, b64.a + a_n, b64.n - a_n, "thred");
    if(n_clus > 0) {
        update_usg_t_threading(uidx, ng, b64->a, b64->a + a_n, b64->n - a_n, int_a, ng_occ, ub64);
    }
    // fprintf(stderr, "**6**[M::%s::] a_n::%lu, n_clus::%lu, ng->n::%lu\n", __func__, a_n, n_clus, ng->n);
    return n_clus;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x18(%rsp)
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, 0x20(%rsp)
movq 0x68(%rsp), %r13
leaq 0x1(%r8), %r14
movq (%rdx), %rax
cmpq %rax, %r14
movq %r8, 0x10(%rsp)
jbe 0x210b6b
movq $0x0, (%rsp)
movq %r8, %r15
jmp 0x210c49
movq $0x0, (%rsp)
movq %r8, %r15
movq %r8, %rbx
movq %r12, 0x8(%rsp)
cmpq %rax, %r14
je 0x210b99
movq 0x10(%rbp), %rax
movq (%rax,%rbx,8), %rcx
xorq (%rax,%r14,8), %rcx
shrq $0x20, %rcx
je 0x210c39
movq %r12, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
movq %r13, %r8
movq 0x70(%rsp), %r9
movsd 0x28643(%rip), %xmm0    # 0x2391f8
pushq $0x10
movl 0x88(%rsp), %eax
pushq %rax
callq 0x20dcc0
addq $0x10, %rsp
cmpl 0x80(%rsp), %eax
jae 0x210c1d
movl %eax, %eax
subq $0x8, %rsp
movq 0x28(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
movq %r14, %r8
movq %r13, %r12
movq %r13, %r9
pushq %rax
callq 0x210941
addq $0x10, %rsp
testl %eax, %eax
je 0x210c22
cmpq %r14, %rbx
jae 0x210c2a
movq 0x10(%rbp), %rax
movq %r12, %r13
movq (%rax,%rbx,8), %rcx
movq %rcx, (%rax,%r15,8)
incq %r15
incq %rbx
cmpq %r14, %rbx
jb 0x210c08
jmp 0x210c2d
movq %r14, %rbx
jmp 0x210c39
movq %r14, %rbx
movq %r12, %r13
jmp 0x210c34
movq %r12, %r13
incq (%rsp)
movq %r14, %rbx
movq 0x8(%rsp), %r12
incq %r14
movq (%rbp), %rax
cmpq %rax, %r14
jbe 0x210b7e
movq %r15, (%rbp)
movq (%rsp), %rbx
testq %rbx, %rbx
je 0x210c83
movq 0x10(%rbp), %rdx
movq 0x10(%rsp), %rax
leaq (%rdx,%rax,8), %rcx
subq %rax, %r15
movq %r12, %rsi
movq %r15, %r8
movq %r13, %r9
pushq 0x18(%rsp)
pushq 0x80(%rsp)
callq 0x20f009
addq $0x10, %rsp
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq