// File: /workspace/github_cpp_makefile_star2_O2/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 %r8, %r15
movq %rcx, 0x18(%rsp)
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, 0x20(%rsp)
movq $0x0, 0x8(%rsp)
movq %r8, %rbx
movq %r8, 0x10(%rsp)
movq %rbx, %r14
movq (%rbp), %rax
leaq 0x1(%rbx), %rcx
cmpq %rax, %rcx
ja 0x1cd389
movq %rcx, %rbx
je 0x1cd302
movq 0x10(%rbp), %rcx
movq (%rcx,%r14,8), %rdx
xorq (%rcx,%rbx,8), %rdx
shrq $0x20, %rdx
leaq 0x1(%rbx), %rcx
testq %rdx, %rdx
je 0x1cd2db
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %rbx, %rcx
movq 0x68(%rsp), %r8
movq 0x70(%rsp), %r9
movsd 0x2a070(%rip), %xmm0    # 0x1f7390
pushq $0x10
movl 0x88(%rsp), %r13d
pushq %r13
callq 0x1ca8f7
addq $0x10, %rsp
cmpl %r13d, %eax
jae 0x1cd2d0
movl %eax, %eax
subq $0x8, %rsp
movq 0x28(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
movq 0x70(%rsp), %r9
pushq %rax
callq 0x1cd0c7
popq %rcx
popq %rdx
testl %eax, %eax
je 0x1cd2d0
jmp 0x1cd37a
movq 0x10(%rbp), %rax
movq (%rax,%r14,8), %rcx
movq %rcx, (%rax,%r15,8)
incq %r15
incq %r14
cmpq %rbx, %r14
jb 0x1cd368
incq 0x8(%rsp)
jmp 0x1cd2d0
movq %r15, (%rbp)
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
je 0x1cd3c4
movq 0x10(%rbp), %rdx
movq 0x10(%rsp), %rax
leaq (%rdx,%rax,8), %rcx
subq %rax, %r15
movq %r12, %rsi
movq %r15, %r8
movq 0x68(%rsp), %r9
pushq 0x18(%rsp)
pushq 0x80(%rsp)
callq 0x1cbaa6
popq %rax
popq %rcx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq