// File: /workspace/github_cpp_makefile_star2_O3/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), %rcx
addq %rsi, %rcx
cmpq %rcx, 0x8(%rdi)
jae 0x218e29
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 0x218e2d
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
testq %r14, %r14
je 0x218ef2
xorl %ebx, %ebx
cmpq $-0x1, (%r12,%rbx,8)
jne 0x218e7a
movq %rbx, (%rsp)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x2188a5
incq %rbx
cmpq %rbx, %r14
jne 0x218e59
leaq (%r12,%r14,8), %rsi
movq %r12, %rdi
callq 0x1ee586
movq %r14, (%r15)
movl $0x1, %ecx
xorl %edx, %edx
xorl %eax, %eax
cmpq %r14, %rcx
je 0x218ead
movq (%r12,%rcx,8), %rsi
xorq (%r12,%rdx,8), %rsi
shrq $0x20, %rsi
je 0x218ee8
cmpq %rcx, %rdx
jae 0x218ee2
movq %rax, %rsi
shlq $0x20, %rsi
movq (%r12,%rdx,8), %rdi
cmpq $-0x1, %rdi
je 0x218f26
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 0x218eb9
incq %rax
movq %rcx, %rdx
incq %rcx
cmpq %r14, %rcx
jbe 0x218e9a
jmp 0x218f03
leaq (%r12,%r14,8), %rsi
movq %r12, %rdi
callq 0x1ee586
movq %r14, (%r15)
xorl %eax, %eax
movq 0x10(%rsp), %rcx
movq $0x0, (%rcx)
addq %r14, %r14
cmpq %r14, (%r15)
jne 0x218f45
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f949(%rip), %rdi     # 0x248876
leaq 0x2c6d5(%rip), %rsi     # 0x245609
leaq 0x2f9f0(%rip), %rcx     # 0x24892b
movl $0x2fbc, %edx           # imm = 0x2FBC
callq 0x2110
leaq 0x2f942(%rip), %rdi     # 0x24888e
leaq 0x2c6b6(%rip), %rsi     # 0x245609
leaq 0x2f9d1(%rip), %rcx     # 0x24892b
movl $0x2fc5, %edx           # imm = 0x2FC5
callq 0x2110