// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movl $0x1, %edi
movl $0x30, %esi
callq 0x2120
movq %rax, %rbx
movq %r14, (%rsp)
movq 0x18(%r14), %r12
movq %r12, 0x8(%rax)
movq %r12, (%rax)
leaq (,%r12,8), %r14
movq %r14, %rdi
callq 0x2280
movq %rax, %r13
movq %rax, 0x10(%rbx)
movq %rax, %rdi
movl $0xff, %esi
movq %r14, %rdx
callq 0x20e0
testq %r12, %r12
je 0xc54bf
xorl %edi, %edi
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ebp, %ebp
movq (%rsp), %rsi
movq 0x10(%rbx), %rax
cmpq $-0x1, (%rax,%rbp,8)
jne 0xc54a7
testq %rdi, %rdi
jne 0xc53ac
movl $0x10, %esi
movq %r15, %rdi
callq 0x2370
movq (%rsp), %rsi
movq %rax, %r15
movl $0x2, %edi
movq %rbp, (%r15)
movq %rbp, %r8
shlq $0x20, %r8
movl $0x1, %r12d
xorl %r13d, %r13d
subq $0x1, %r12
jb 0xc549b
movq (%r15,%r12,8), %rax
movq 0x10(%rbx), %rcx
cmpq $-0x1, (%rcx,%rax,8)
jne 0xc53bf
movq %rax, %rdx
orq %r8, %rdx
movq %rdx, (%rcx,%rax,8)
incq %r13
movq 0x28(%rsi), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
je 0xc53bf
movq %r14, 0x8(%rsp)
movq 0x10(%rsi), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
shlq $0x4, %rax
leaq (%rax,%rax,2), %r9
leaq (%rdx,%rdx,2), %rax
shlq $0x4, %rax
leaq (%rcx,%rax), %rdx
addq $0x14, %rdx
xorl %r14d, %r14d
movq %r8, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x10(%rbx), %rcx
movl (%rdx,%r14), %eax
cmpq $-0x1, (%rcx,%rax,8)
jne 0xc5488
cmpq %rdi, %r12
jne 0xc5481
leaq (%r12,%r12), %rcx
testq %r12, %r12
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x20(%rsp)
leaq (,%rcx,8), %rsi
movq %r15, %rdi
movq %r9, %r15
callq 0x2370
movq 0x10(%rsp), %rdx
movq %r15, %r9
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %rdi
movq (%rsp), %rsi
movq %rax, %r15
movl (%rdx,%r14), %eax
movq %rax, (%r15,%r12,8)
incq %r12
addq $0x30, %r14
cmpq %r14, %r9
jne 0xc5428
movq 0x8(%rsp), %r14
jmp 0xc53bf
cmpq $0x2, %r13
sbbq $-0x1, %r14
movq 0x18(%rsi), %r12
incq %rbp
cmpq %r12, %rbp
jb 0xc537f
movq %r14, %r12
movq (%rbx), %r14
movq 0x10(%rbx), %r13
jmp 0xc54c8
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %r15d, %r15d
leaq (,%r14,8), %rsi
addq %r13, %rsi
movq %r13, %rdi
callq 0x9dc69
movq $0x0, 0x18(%rbx)
movq %r12, 0x20(%rbx)
movl $0x8, %esi
movq %r12, %rbp
movq %r12, %rdi
callq 0x2120
movq %rax, 0x28(%rbx)
testq %r14, %r14
je 0xc555a
leaq 0x1(%r14), %rdx
cmpq $0x3, %rdx
movl $0x2, %ecx
cmovaeq %rdx, %rcx
movl $0x1, %esi
xorl %edx, %edx
xorl %edi, %edi
cmpq %rsi, %r14
je 0xc552f
movq (%r13,%rdi,8), %r8
xorq (%r13,%rsi,8), %r8
shrq $0x20, %r8
je 0xc5550
movq %rsi, %r8
subq %rdi, %r8
cmpq $0x2, %r8
jb 0xc554d
shlq $0x20, %rdi
orq %rsi, %rdi
movq %rdi, (%rax,%rdx,8)
incq %rdx
movq %rdx, 0x18(%rbx)
movq %rsi, %rdi
incq %rsi
cmpq %rsi, %rcx
jne 0xc551a
jmp 0xc555c
xorl %edx, %edx
cmpq %rbp, %rdx
jne 0xc557b
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 0x171817(%rip), %rdi    # 0x236d99
leaq 0x170908(%rip), %rsi    # 0x235e91
leaq 0x171818(%rip), %rcx    # 0x236da8
movl $0x3c8a, %edx           # imm = 0x3C8A
callq 0x2110