// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: u2g_hybrid_aln(ul_resolve_t*, usg_t*, asg64_v*, asg64_v*)
void u2g_hybrid_aln(ul_resolve_t *uidx, usg_t *ng, asg64_v *ob, asg64_v *ub)
{
    uint64_t k, m, i, x, *tmp, sn;
    ob->n = ub->n = 0;
    for (k = 0; k < uidx->str_b.n_thread; k++) {
        uidx->str_b.buf[k].res_dump.n = uidx->str_b.buf[k].u.n = uidx->str_b.buf[k].o.n = 0;
    }
    kt_for(uidx->str_b.n_thread, worker_integer_realign_g, uidx, uidx->uovl.i_ug->u.n);

    for (k = ob->n = ub->n = m = 0; k < uidx->str_b.n_thread; k++) {
        for (i = 0; i < uidx->str_b.buf[k].res_dump.n; i++) {
            x = uidx->str_b.buf[k].res_dump.a[i];
            kv_push(uint64_t, *ob, x);//aln details
            if(x&((uint64_t)0x8000000000000000)) {
                x -= ((uint64_t)0x8000000000000000); x >>= 32; x <<= 32;//seq_id
                x |= ob->n;//offset
                kv_push(uint64_t, *ub, x);///idx:: seq_id|offset_in_ob
            } else {
                m++;
            }
        }
    }

    radix_sort_srt64(ub->a, ub->a + ub->n);
    kv_resize(uint64_t, *ub, ub->n+m); tmp = ub->a + ub->n; m = 0;
    for (k = 0; k < ub->n; k++) {
        sn = ((uint32_t)(ob->a[((uint32_t)ub->a[k])-1]));
        memcpy(tmp + m, ob->a + ((uint32_t)ub->a[k]), sn*sizeof((*tmp))); 
        ub->a[k] = m; ub->a[k] <<= 32; ub->a[k] |= sn;//offset_in_ob|occ
        m += sn;
    }
    assert(m <= ob->n);
    memcpy(ob->a, tmp, m*sizeof((*tmp))); ob->n = m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movq %rdi, %rsi
xorl %eax, %eax
movq %rax, (%rcx)
movq %rax, (%rdx)
movq 0x1e0(%rdi), %rdi
testq %rdi, %rdi
je 0x212994
movq 0x1d8(%rsi), %rax
addq $0x78, %rax
xorl %ecx, %ecx
movq %rdi, %rdx
movq %rcx, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x288(%rax)
addq $0x328, %rax            # imm = 0x328
decq %rdx
jne 0x21297b
movq 0x230(%rsi), %rax
movq (%rax), %rcx
movq %rsi, 0x8(%rsp)
leaq -0x9c(%rip), %rsi       # 0x21290e
movq 0x8(%rsp), %rdx
callq 0x1047b4
movq 0x8(%rsp), %rsi
xorl %r12d, %r12d
movq %r12, (%r14)
movq %r12, (%rbx)
cmpq %r12, 0x1e0(%rsi)
je 0x212ad6
xorl %ecx, %ecx
xorl %r12d, %r12d
movq 0x1d8(%rsi), %rax
movq %rcx, 0x10(%rsp)
imulq $0x328, %rcx, %rbp      # imm = 0x328
cmpq $0x0, 0x300(%rax,%rbp)
je 0x212ac1
xorl %r13d, %r13d
movq 0x310(%rax,%rbp), %rax
movq (%rax,%r13,8), %r15
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0x212a38
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x8(%rsp), %rsi
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movq %r15, (%rcx,%rax,8)
testq %r15, %r15
js 0x212a54
incq %r12
jmp 0x212aa9
movabsq $0x7fffffff00000000, %rax # imm = 0x7FFFFFFF00000000
andq %rax, %r15
orq (%rbx), %r15
movq 0x8(%r14), %rax
cmpq %rax, (%r14)
jne 0x212a97
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r14)
movq 0x10(%r14), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x8(%rsp), %rsi
movq %rax, 0x10(%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
movq %r15, (%rcx,%rax,8)
incq %r13
movq 0x1d8(%rsi), %rax
cmpq 0x300(%rax,%rbp), %r13
jb 0x2129f9
movq 0x10(%rsp), %rcx
incq %rcx
cmpq 0x1e0(%rsi), %rcx
jb 0x2129d4
movq (%r14), %rax
movq 0x10(%r14), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x1e3b6a
addq (%r14), %r12
cmpq %r12, 0x8(%r14)
jae 0x212b40
decq %r12
movq %r12, %rax
shrq %rax
orq %r12, %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(%r14)
movq 0x10(%r14), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rax
leaq (,%rax,8), %r15
addq 0x10(%r14), %r15
testq %rax, %rax
je 0x212ba2
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x10(%rbx), %rax
movq 0x10(%r14), %rcx
movq (%rcx,%r13,8), %rcx
leal -0x1(%rcx), %edx
movl (%rax,%rdx,8), %ebp
leaq (%r15,%r12,8), %rdi
movl %ecx, %ecx
leaq (%rax,%rcx,8), %rsi
leaq (,%rbp,8), %rdx
callq 0x2160
movq 0x10(%r14), %rax
movq %r12, %rcx
shlq $0x20, %rcx
orq %rbp, %rcx
movq %rcx, (%rax,%r13,8)
addq %rbp, %r12
incq %r13
cmpq (%r14), %r13
jb 0x212b5a
jmp 0x212ba5
xorl %r12d, %r12d
cmpq (%rbx), %r12
ja 0x212bd0
movq 0x10(%rbx), %rdi
leaq (,%r12,8), %rdx
movq %r15, %rsi
callq 0x2160
movq %r12, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2a2ae(%rip), %rdi     # 0x23ce85
leaq 0x26747(%rip), %rsi     # 0x239325
leaq 0x2a32e(%rip), %rcx     # 0x23cf13
movl $0x35d9, %edx           # imm = 0x35D9
callq 0x2110