// File: /workspace/github_cpp_makefile_star2_O2/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)
andq $0x0, (%r8)
movq (%rdi), %rcx
addq %rsi, %rcx
cmpq %rcx, 0x8(%rdi)
jae 0x1ca799
decq %rcx
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r15)
movq 0x10(%r15), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x2370
movq %rax, 0x10(%r15)
movq (%r15), %rcx
addq %r14, %rcx
jmp 0x1ca79d
movq 0x10(%r15), %rax
movq %rcx, (%r15)
leaq (%rax,%r12,8), %rdi
shlq $0x3, %r12
leaq (,%r14,8), %rdx
movl $0xff, %esi
callq 0x20e0
addq 0x10(%r15), %r12
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x1ca7eb
cmpq $-0x1, (%r12,%rbx,8)
jne 0x1ca7e6
movq %rbx, (%rsp)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x1ca242
incq %rbx
jmp 0x1ca7c0
leaq (%r12,%r14,8), %rsi
movq %r12, %rdi
callq 0x1a3def
movq %r14, (%r15)
pushq $0x1
popq %rcx
xorl %eax, %eax
xorl %edx, %edx
cmpq %r14, %rcx
ja 0x1ca853
je 0x1ca816
movq (%r12,%rcx,8), %rsi
xorq (%r12,%rdx,8), %rsi
shrq $0x20, %rsi
je 0x1ca84e
movq %rax, %rsi
shlq $0x20, %rsi
cmpq %rcx, %rdx
jae 0x1ca848
movq (%r12,%rdx,8), %rdi
cmpq $-0x1, %rdi
je 0x1ca873
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
jmp 0x1ca81d
incq %rax
movq %rcx, %rdx
incq %rcx
jmp 0x1ca801
movq 0x10(%rsp), %rcx
andq $0x0, (%rcx)
addq %r14, %r14
cmpq %r14, (%r15)
jne 0x1ca892
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2ffbb(%rip), %rdi     # 0x1fa835
leaq 0x2cc58(%rip), %rsi     # 0x1f74d9
leaq 0x30062(%rip), %rcx     # 0x1fa8ea
movl $0x2fbc, %edx           # imm = 0x2FBC
callq 0x2110
leaq 0x2ffb4(%rip), %rdi     # 0x1fa84d
leaq 0x2cc39(%rip), %rsi     # 0x1f74d9
leaq 0x30043(%rip), %rcx     # 0x1fa8ea
movl $0x2fc5, %edx           # imm = 0x2FC5
callq 0x2110