// File: /workspace/github_cpp_makefile_star2_O2/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, %r13
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x2120
movq %rax, %rbx
movq 0x18(%r13), %r12
movq %r12, 0x8(%rax)
movq %r12, (%rax)
leaq (,%r12,8), %r14
movq %r14, %rdi
callq 0x2280
movq %rax, 0x10(%rbx)
movq %rax, %rdi
movl $0xff, %esi
movq %r14, %rdx
callq 0x20e0
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %eax, %eax
xorl %edi, %edi
movq %r13, (%rsp)
movq 0x10(%rbx), %rbp
cmpq %r12, %r14
jae 0x89177
cmpq $-0x1, (%rbp,%r14,8)
jne 0x8916f
testq %rdi, %rdi
jne 0x8908a
movq %rax, %rdi
pushq $0x10
popq %rsi
callq 0x2370
pushq $0x2
popq %rdi
movq %r14, (%rax)
movq %r14, 0x20(%rsp)
movq %r14, %r8
shlq $0x20, %r8
xorl %esi, %esi
pushq $0x1
popq %r14
subq $0x1, %r14
jb 0x8915e
movq (%rax,%r14,8), %rcx
movq 0x10(%rbx), %rdx
cmpq $-0x1, (%rdx,%rcx,8)
jne 0x8909f
movq %rsi, 0x8(%rsp)
movq %r15, 0x18(%rsp)
movq %rcx, %rsi
movq %r8, 0x10(%rsp)
orq %r8, %rsi
movq %rsi, (%rdx,%rcx,8)
movq 0x10(%r13), %rdx
movq 0x28(%r13), %rsi
movq (%rsi,%rcx,8), %rcx
movl %ecx, %esi
shrq $0x20, %rcx
imulq $0x30, %rsi, %r12
imulq $0x30, %rcx, %rcx
leaq (%rdx,%rcx), %rbp
addq $0x14, %rbp
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x89143
movq 0x10(%rbx), %rdx
movl (%rbp,%r13), %ecx
cmpq $-0x1, (%rdx,%rcx,8)
jne 0x8913d
cmpq %rdi, %r14
jne 0x89136
leaq (%rdi,%rdi), %r15
testq %rdi, %rdi
pushq $0x2
popq %rcx
cmoveq %rcx, %r15
leaq (,%r15,8), %rsi
movq %rax, %rdi
callq 0x2370
movl (%rbp,%r13), %ecx
movq %r15, %rdi
movq %rcx, (%rax,%r14,8)
incq %r14
addq $0x30, %r13
jmp 0x890f6
movq 0x8(%rsp), %rsi
incq %rsi
movq 0x18(%rsp), %r15
movq (%rsp), %r13
movq 0x10(%rsp), %r8
jmp 0x8909f
cmpq $0x2, %rsi
sbbq $-0x1, %r15
movq 0x18(%r13), %r12
movq 0x20(%rsp), %r14
incq %r14
jmp 0x8905e
movq (%rbx), %r14
leaq (,%r14,8), %rsi
addq %rbp, %rsi
movq %rbp, %rdi
movq %rax, %r12
callq 0x66c25
andq $0x0, 0x18(%rbx)
movq %r15, 0x20(%rbx)
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %r12, %rdi
movq %rax, 0x28(%rbx)
pushq $0x1
popq %rcx
xorl %edx, %edx
xorl %esi, %esi
cmpq %r14, %rcx
ja 0x891ef
je 0x891c9
movq (%rbp,%rsi,8), %r8
xorq (%rbp,%rcx,8), %r8
shrq $0x20, %r8
je 0x891ea
movq %rcx, %r8
subq %rsi, %r8
cmpq $0x2, %r8
jb 0x891e7
shlq $0x20, %rsi
orq %rcx, %rsi
movq %rsi, (%rax,%rdx,8)
incq %rdx
movq %rdx, 0x18(%rbx)
movq %rcx, %rsi
incq %rcx
jmp 0x891b2
cmpq %r15, %rdx
jne 0x8920b
callq 0x2220
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15fa87(%rip), %rdi    # 0x1e8c99
leaq 0x15eb78(%rip), %rsi    # 0x1e7d91
leaq 0x15fa88(%rip), %rcx    # 0x1e8ca8
movl $0x3c8a, %edx           # imm = 0x3C8A
callq 0x2110