// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
ja 0x35c97f
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
je 0x35c896
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x40(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x35c96c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq 0x18(%rbp), %r8
movq 0x20(%rbp), %r9
movl 0x30(%rbp), %eax
movsd 0x2276f(%rip), %xmm0    # 0x37f028
movq %rax, (%rsp)
movq $0x10, 0x8(%rsp)
callq 0x3571f0
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movl 0x30(%rbp), %ecx
cmpq %rcx, %rax
jae 0x35c964
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
movq 0x18(%rbp), %r9
movq -0x58(%rbp), %rax
movq %rax, (%rsp)
callq 0x35c490
cmpl $0x0, %eax
je 0x35c962
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x35c956
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x50(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x35c913
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x35c964
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x35c96e
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x35c847
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x30(%rbp)
jbe 0x35c9d9
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq (%rax), %r8
subq -0x28(%rbp), %r8
movq 0x18(%rbp), %r9
movq 0x28(%rbp), %r10
movq -0x20(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x359a30
movq -0x30(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)