// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, (%rcx)
movq %rdx, %rbx
andq $0x0, (%rdx)
movq %rdi, 0x8(%rsp)
movq 0x1e0(%rdi), %rdi
pushq $0x78
popq %rax
movq %rdi, %rcx
subq $0x1, %rcx
jb 0x1cf01d
movq 0x8(%rsp), %rdx
movq 0x1d8(%rdx), %rdx
andq $0x0, (%rdx,%rax)
andq $0x0, 0x18(%rdx,%rax)
andq $0x0, 0x288(%rdx,%rax)
addq $0x328, %rax            # imm = 0x328
jmp 0x1cefef
movq 0x8(%rsp), %rdx
movq 0x230(%rdx), %rax
movq (%rax), %rcx
leaq -0xa0(%rip), %rsi       # 0x1cef93
callq 0xc67c0
andq $0x0, (%r14)
andq $0x0, (%rbx)
xorl %r12d, %r12d
xorl %ecx, %ecx
movq 0x8(%rsp), %rax
cmpq 0x1e0(%rax), %rcx
jae 0x1cf13a
movq %rcx, 0x10(%rsp)
imulq $0x328, %rcx, %rbp      # imm = 0x328
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
movq 0x1d8(%rax), %rax
cmpq 0x300(%rax,%rbp), %r13
jae 0x1cf12d
addq %rbp, %rax
addq $0x300, %rax            # imm = 0x300
movq 0x10(%rax), %rax
movq (%rax,%r13,8), %r15
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x1cf0c3
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
movq %r15, (%rax,%rcx,8)
testq %r15, %r15
js 0x1cf0d8
incq %r12
jmp 0x1cf125
movabsq $0x7fffffff00000000, %rax # imm = 0x7FFFFFFF00000000
andq %rax, %r15
orq (%rbx), %r15
movq (%r14), %rcx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rcx
jne 0x1cf11a
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movq %r15, (%rax,%rcx,8)
incq %r13
jmp 0x1cf066
movq 0x10(%rsp), %rcx
incq %rcx
jmp 0x1cf045
movq (%r14), %rax
movq 0x10(%r14), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x1a3def
movq (%r14), %rcx
addq %rcx, %r12
movq 0x10(%r14), %rax
cmpq %r12, 0x8(%r14)
jae 0x1cf1ad
decq %r12
movq %r12, %rcx
shrq %rcx
orq %r12, %rcx
movq %rcx, %rdx
shrq $0x2, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x4, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x8, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x10, %rcx
orq %rdx, %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
leaq 0x8(,%rcx,8), %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq (%rax,%rcx,8), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq %rcx, %r13
jae 0x1cf1fe
movq 0x10(%rbx), %rcx
movq (%rax,%r13,8), %rax
leal -0x1(%rax), %edx
movl (%rcx,%rdx,8), %ebp
leaq (%r15,%r12,8), %rdi
movl %eax, %eax
leaq (%rcx,%rax,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
movq (%r14), %rcx
jmp 0x1cf1b7
cmpq (%rbx), %r12
ja 0x1cf229
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 0x2bef8(%rip), %rdi     # 0x1fb128
leaq 0x282a2(%rip), %rsi     # 0x1f74d9
leaq 0x2bf78(%rip), %rcx     # 0x1fb1b6
movl $0x35d9, %edx           # imm = 0x35D9
callq 0x2110