// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: usg_unique_arcs_cluster_adv(asg64_v*, unsigned long, unsigned long*, unsigned long*, asg64_v*)
uint32_t usg_unique_arcs_cluster_adv(asg64_v *b64, uint64_t a_n, uint64_t *idx, uint64_t *integ_seq, asg64_v *buf)
{
    uint64_t bn = b64->n, k, z, v; buf->n = 0;
    kv_resize(uint64_t, *b64, b64->n + a_n); b64->n += a_n; 
    memset(b64->a + bn, -1, sizeof((*(b64->a)))*a_n);
    uint64_t *cidx = b64->a + bn, i;

    ///b64.a[0, a_n]:: all resolvable paths with unique beg && end
    ///b64.a[a_n, bn]:: (raw unitig/non-unqiue node id)|(resolvable path id)
    ///idx:: the idx for b64.a[a_n, bn]
    for (i = 0; i < a_n; i++) {///available interval with beg/end with unique arcs
        if(cidx[i] != (uint64_t)-1) continue;
        iter_unique_arcs(buf, b64, a_n, idx, integ_seq, cidx, i);
    }

    radix_sort_srt64(cidx, cidx + a_n); b64->n = a_n;
    for (i = 0, k = 1, v = 0; k <= a_n; k++) {
        if(k == a_n || (cidx[i]>>32) != (cidx[k]>>32)) {
            for (z = i; z < k; z++) {
                assert(cidx[z] != (uint64_t)-1);
                ///cluest integer seqs-> (cluster id)|(available interval id) 
                b64->a[b64->n++] = (v<<32)|((uint32_t)cidx[z]);
            }
            i = k; v++;
        }
    }

    buf->n = 0;
    assert(b64->n == (a_n<<1));
    return v;///how many cluster
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %r12
movq %r8, 0x10(%rsp)
movq $0x0, (%r8)
movq (%rdi), %rax
addq %rsi, %rax
cmpq %rax, 0x8(%rdi)
jae 0x20db4e
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%r15)
movq 0x10(%r15), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq %rax, 0x10(%r15)
addq %r14, (%r15)
shlq $0x3, %r12
movq 0x10(%r15), %rdi
addq %r12, %rdi
leaq (,%r14,8), %rdx
movl $0xff, %esi
callq 0x20e0
addq 0x10(%r15), %r12
testq %r14, %r14
je 0x20dba2
xorl %ebx, %ebx
cmpq $-0x1, (%r12,%rbx,8)
jne 0x20db9a
movq %rbx, (%rsp)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x20d5ab
incq %rbx
cmpq %rbx, %r14
jne 0x20db79
leaq (%r12,%r14,8), %rsi
movq %r12, %rdi
callq 0x1e3b6a
movq %r14, (%r15)
testq %r14, %r14
je 0x20dc17
movl $0x1, %ecx
xorl %edx, %edx
xorl %eax, %eax
cmpq %r14, %rcx
je 0x20dbd2
movq (%r12,%rcx,8), %rsi
xorq (%r12,%rdx,8), %rsi
shrq $0x20, %rsi
je 0x20dc0d
cmpq %rcx, %rdx
jae 0x20dc07
movq %rax, %rsi
shlq $0x20, %rsi
movq (%r12,%rdx,8), %rdi
cmpq $-0x1, %rdi
je 0x20dc3c
movl %edi, %edi
orq %rsi, %rdi
movq (%r15), %r8
movq 0x10(%r15), %r9
leaq 0x1(%r8), %r10
movq %r10, (%r15)
movq %rdi, (%r9,%r8,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x20dbde
incq %rax
movq %rcx, %rdx
incq %rcx
cmpq %r14, %rcx
jbe 0x20dbbf
jmp 0x20dc19
xorl %eax, %eax
movq 0x10(%rsp), %rcx
movq $0x0, (%rcx)
addq %r14, %r14
cmpq %r14, (%r15)
jne 0x20dc5b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e94f(%rip), %rdi     # 0x23c592
leaq 0x2b6db(%rip), %rsi     # 0x239325
leaq 0x2e9f6(%rip), %rcx     # 0x23c647
movl $0x2fbc, %edx           # imm = 0x2FBC
callq 0x2110
leaq 0x2e948(%rip), %rdi     # 0x23c5aa
leaq 0x2b6bc(%rip), %rsi     # 0x239325
leaq 0x2e9d7(%rip), %rcx     # 0x23c647
movl $0x2fc5, %edx           # imm = 0x2FC5
callq 0x2110