// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: gen_u_trans_cluster(kv_u_trans_t*)
u_trans_cluster* gen_u_trans_cluster(kv_u_trans_t *ta)
{
    u_trans_cluster *p; CALLOC(p, 1);
    p->z.n = p->z.m = ta->idx.n; MALLOC(p->z.a, p->z.n); 
    memset(p->z.a, -1, sizeof(*(p->z.a))*p->z.n);
    u_trans_t *a = NULL; uint64_t n, v, k, l, i, cn, m; asg64_v b; kv_init(b);
    for (i = b.n = cn = 0; i < ta->idx.n; i++) {
        v = i;
        if(p->z.a[v] != ((uint64_t)-1)) continue;
        kv_push(uint64_t, b, v); m = 0;
        while(b.n) {
            v = b.a[--b.n];
            if(p->z.a[v] != ((uint64_t)-1)) continue;
            p->z.a[v] = i; p->z.a[v] <<= 32; p->z.a[v] |= v; m++;
            a = u_trans_a(*ta, v); n = u_trans_n(*ta, v);
            for (k = 0; k < n; k++) {
                if(p->z.a[a[k].tn] != ((uint64_t)-1)) continue;
                kv_push(uint64_t, b, a[k].tn);
            }   
        }
        if(m > 1) cn++;
    }
    radix_sort_arch64(p->z.a, p->z.a + p->z.n);
    p->idx.n = 0; p->idx.m = cn; CALLOC(p->idx.a, p->idx.m);
    for (l = 0, k = 1; k <= p->z.n; k++) {
        if(k == p->z.n || (p->z.a[k]>>32) != (p->z.a[l]>>32)) {
            if(k - l > 1) p->idx.a[p->idx.n++] = (l<<32)|(k);
            l = k;
        }
    }
    assert(p->idx.n == cn);
    free(b.a);
    return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r15
movl $0x1, %edi
movl $0x30, %esi
callq 0x2120
movq %rax, %rbx
movq 0x18(%r15), %r14
movq %r14, 0x8(%rax)
movq %r14, (%rax)
shlq $0x3, %r14
movq %r14, %rdi
callq 0x2280
movq %rax, 0x10(%rbx)
movq %rax, %rdi
movl $0xff, %esi
movq %r14, %rdx
callq 0x20e0
cmpq $0x0, 0x18(%r15)
je 0xc468f
movq %r15, %rdi
xorl %eax, %eax
xorl %r15d, %r15d
xorl %r13d, %r13d
xorl %ebp, %ebp
movq %rdi, (%rsp)
movq 0x10(%rbx), %rcx
cmpq $-0x1, (%rcx,%rbp,8)
jne 0xc4680
testq %rax, %rax
jne 0xc4589
movl $0x10, %esi
movq %r15, %rdi
callq 0x2370
movq (%rsp), %rdi
movq %rax, %r15
movl $0x2, %eax
movq %rbp, (%r15)
movq %rbp, %r8
shlq $0x20, %r8
movl $0x1, %r14d
xorl %r12d, %r12d
subq $0x1, %r14
jb 0xc4678
movq (%r15,%r14,8), %rcx
movq 0x10(%rbx), %rdx
cmpq $-0x1, (%rdx,%rcx,8)
jne 0xc459c
movq %rcx, %rsi
orq %r8, %rsi
movq %rsi, (%rdx,%rcx,8)
incq %r12
movq 0x28(%rdi), %rdx
movq (%rdx,%rcx,8), %rcx
testl %ecx, %ecx
je 0xc459c
movq %r13, 0x8(%rsp)
movq 0x10(%rdi), %rdx
movq %rcx, %rsi
shrq $0x20, %rsi
movl %ecx, %ecx
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %r9
leaq (%rsi,%rsi,2), %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rsi
addq $0x14, %rsi
xorl %r13d, %r13d
movq %r9, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq 0x10(%rbx), %rcx
movl (%rsi,%r13), %edx
cmpq $-0x1, (%rcx,%rdx,8)
jne 0xc4665
cmpq %rax, %r14
jne 0xc465a
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x20(%rsp)
leaq (,%rcx,8), %rsi
movq %r15, %rdi
movq %r8, %r15
callq 0x2370
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %r9
movq %r15, %r8
movq (%rsp), %rdi
movq %rax, %r15
movq 0x20(%rsp), %rax
movl (%rsi,%r13), %ecx
movq %rcx, (%r15,%r14,8)
incq %r14
addq $0x30, %r13
cmpq %r13, %r9
jne 0xc4605
movq 0x8(%rsp), %r13
jmp 0xc459c
cmpq $0x2, %r12
sbbq $-0x1, %r13
incq %rbp
cmpq 0x18(%rdi), %rbp
jb 0xc455c
jmp 0xc4695
xorl %r13d, %r13d
xorl %r15d, %r15d
movq (%rbx), %r14
movq 0x10(%rbx), %r12
leaq (%r12,%r14,8), %rsi
movq %r12, %rdi
callq 0x9d53f
movq $0x0, 0x18(%rbx)
movq %r13, 0x20(%rbx)
movl $0x8, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, 0x28(%rbx)
testq %r14, %r14
je 0xc472e
leaq 0x1(%r14), %rdx
cmpq $0x3, %rdx
movl $0x2, %ecx
cmovaeq %rdx, %rcx
movl $0x1, %edx
xorl %esi, %esi
cmpq %rdx, %r14
je 0xc46fa
movq (%r12,%rsi,8), %rdi
xorq (%r12,%rdx,8), %rdi
shrq $0x20, %rdi
jne 0xc46fa
movq %rsi, %rdi
jmp 0xc4723
movq %rdx, %r8
subq %rsi, %r8
movq %rdx, %rdi
cmpq $0x2, %r8
jb 0xc4723
shlq $0x20, %rsi
orq %rdx, %rsi
movq 0x18(%rbx), %rdi
leaq 0x1(%rdi), %r8
movq %r8, 0x18(%rbx)
movq %rsi, (%rax,%rdi,8)
movq %rdx, %rdi
incq %rdx
movq %rdi, %rsi
cmpq %rdx, %rcx
jne 0xc46e2
cmpq %r13, 0x18(%rbx)
jne 0xc474e
movq %r15, %rdi
callq 0x2220
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x166454(%rip), %rdi    # 0x22aba9
leaq 0x165545(%rip), %rsi    # 0x229ca1
leaq 0x166455(%rip), %rcx    # 0x22abb8
movl $0x3c8a, %edx           # imm = 0x3C8A
callq 0x2110