// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: dump_cns_res(poa_g_t*, ma_ug_t*, unsigned int*, unsigned int, all_ul_t*, ul_str_t*, unsigned int, integer_t*, unsigned long*, unsigned long)
void dump_cns_res(poa_g_t *pg, ma_ug_t *ug, uint32_t *cns_seq, uint32_t cns_occ, all_ul_t *ul_idx, ul_str_t *str, uint32_t qid, integer_t *buf,
uint64_t *arc_idx, uint64_t arc_idx_n)
{   
    uint64_t t, dd, k, i; uint32_t e_s, e_e, is_rev, is_g_connect, con_occ; emap_t *g_arc;
    if(cns_occ > 0) {
        t = qid; t <<= 32; t |= ((uint64_t)(0xffffffff));
        kv_push(uint64_t, buf->res_dump, t);

        t = pg->seq.a[cns_seq[0]>>1].nid; 
        // t = pg->seq.a[cns_seq[0]>>1].nid; t |= ((uint64_t)(0xffffffff00000000));
        t |= ((uint64_t)(ug->g->seq[pg->seq.a[cns_seq[0]>>1].nid>>1].len))<<32;
        kv_push(uint64_t, buf->res_dump, t);
        buf->n_correct++;
    }
    for (k = 0; k < arc_idx_n; k++) {
        // csn_v = pg->seq.a[cns_seq[k]>>1].nid; cns_w = pg->seq.a[cns_seq[k+1]>>1].nid;
        e_s = arc_idx[k]>>32; e_e = (uint32_t)arc_idx[k]; 
        // fprintf(stderr, "[M::%s::] k::%lu, arc_idx_n::%lu, e_s::%u, e_e::%u\n", __func__, k, arc_idx_n, e_s, e_e);
        assert(poa_g_arc_w(pg, cns_seq[k], cns_seq[k+1]) == (e_e - e_s)); assert(e_e > e_s); 
        buf->o.n = 0; kv_resize(uint64_t, buf->o, e_e - e_s); con_occ = 0;
        for (i = e_s; i < e_e; i++) {
            g_arc = &(pg->e_idx.a[i]);
            assert((g_arc->pge>>32) == (cns_seq[k]>>1) && ((uint32_t)g_arc->pge) == (cns_seq[k+1]>>1));
            is_rev = ((g_arc->ule>>32) > ((uint32_t)g_arc->ule)?1:0);
            assert((pg->seq.a[g_arc->pge>>32].nid^(is_rev?1:0)) == ((uint32_t)str[g_arc->ulid].a[g_arc->ule>>32]));
            assert((pg->seq.a[(uint32_t)g_arc->pge].nid^(is_rev?1:0)) == ((uint32_t)str[g_arc->ulid].a[(uint32_t)g_arc->ule]));
            // fprintf(stderr, "+++i::%lu, target_ulid::%u, str_sidx::%u, str_eidx::%u, str_cn::%u, ul_idx->a[g_arc->ulid].bb.n::%u\n", 
            // i - e_s, g_arc->ulid, (uint32_t)(g_arc->ule>>32), (uint32_t)g_arc->ule, str[g_arc->ulid].cn, (uint32_t)ul_idx->a[g_arc->ulid].bb.n);
            dd = cal_integer_match_dis(ug, ul_idx->a[g_arc->ulid].bb.a, str[g_arc->ulid].a[g_arc->ule>>32]>>32, 
                                                                    str[g_arc->ulid].a[(uint32_t)g_arc->ule]>>32, is_rev, &is_g_connect);
            // fprintf(stderr, "---i::%lu, dd::%lu, is_g_connect::%u\n", i - e_s, dd, is_g_connect);
            dd <<= 1; if(is_rev) dd += 1; 
            if(is_g_connect) {
                con_occ++; buf->o.a[buf->o.n] = dd;
            } else {
                buf->o.a[buf->o.n] = dd; buf->o.a[buf->o.n] |= ((uint64_t)(0x8000000000000000));
            } 
            buf->o.n++;
        }

        radix_sort_srt64(buf->o.a, buf->o.a + buf->o.n);
        if(con_occ > 0) buf->o.n = con_occ;
        dd = cal_integer_most_dis(qid, buf->o.a, buf->o.n, 0.08);


        t = pg->seq.a[cns_seq[k+1]>>1].nid; t |= ((uint64_t)(dd<<32)); 
        if(con_occ > 0) t |= ((uint64_t)(0x8000000000000000));
        kv_push(uint64_t, buf->res_dump, t);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %rdx, %rbp
movq %rsi, 0x20(%rsp)
movq %rdi, (%rsp)
movq 0x78(%rsp), %rbx
testl %ecx, %ecx
je 0x205387
movl 0x70(%rsp), %eax
shlq $0x20, %rax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
orq %rax, %r14
movq 0x300(%rbx), %rcx
cmpq 0x308(%rbx), %rcx
jne 0x2052e7
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x308(%rbx)
movq 0x310(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x310(%rbx)
movq 0x300(%rbx), %rcx
jmp 0x2052ee
movq 0x310(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x300(%rbx)
movq %r14, (%rax,%rcx,8)
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
movl (%rbp), %edx
shrl %edx
movl 0x4(%rcx,%rdx,8), %ecx
movq 0x20(%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rdx
movl %ecx, %esi
shrl %esi
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andl (%rdx,%rsi,8), %r14d
shlq $0x20, %r14
orq %rcx, %r14
movq 0x300(%rbx), %rcx
cmpq 0x308(%rbx), %rcx
jne 0x205371
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rdx, %rsi
movq %rsi, 0x308(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x310(%rbx)
movq 0x300(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x300(%rbx)
movq %r14, (%rax,%rcx,8)
incq 0x318(%rbx)
cmpq $0x0, 0x88(%rsp)
je 0x2056d8
xorl %r14d, %r14d
movq %rbp, 0x8(%rsp)
movl (%rbp,%r14,4), %eax
movq (%rsp), %rcx
movq 0x40(%rcx), %rcx
movq (%rcx,%rax,8), %rax
movq %rax, %rcx
movl $0x0, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rcx
je 0x2053fd
movl 0x4(%rbp,%r14,4), %esi
movq (%rsp), %rdx
movq 0x28(%rdx), %rdx
shrq $0x20, %rax
shlq $0x4, %rcx
shlq $0x4, %rax
leaq (%rdx,%rax), %r8
addq $0x8, %r8
xorl %edi, %edi
cmpl %esi, (%r8,%rdi)
je 0x2053f7
addq $0x10, %rdi
cmpq %rdi, %rcx
jne 0x2053e4
xorl %edx, %edx
jmp 0x2053fd
addq %rax, %rdx
movl (%rdi,%rdx), %edx
movq 0x80(%rsp), %rax
movq (%rax,%r14,8), %r12
movq %r12, %r15
shrq $0x20, %r15
movl %r12d, %eax
subl %r15d, %eax
cmpl %eax, %edx
jne 0x20574d
cmpl %r15d, %r12d
jbe 0x205744
movq $0x0, 0x78(%rbx)
movl %edx, %eax
cmpq %rax, 0x80(%rbx)
jae 0x205494
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x80(%rbx)
movq 0x88(%rbx), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq %rax, 0x88(%rbx)
leaq 0x1(%r14), %rax
movq %rax, 0x10(%rsp)
movl %r12d, %r13d
subq %r15, %r13
jbe 0x2055fe
leaq (%r15,%r15,2), %rax
leaq 0x10(,%rax,8), %r12
xorl %r15d, %r15d
movq (%rsp), %rax
movq 0xd8(%rax), %rcx
movq -0x10(%rcx,%r12), %rax
movq %rax, %rdx
shrq $0x20, %rdx
movl (%rbp,%r14,4), %esi
shrl %esi
cmpq %rsi, %rdx
jne 0x2056e7
movq 0x10(%rsp), %rsi
movl (%rbp,%rsi,4), %esi
shrl %esi
cmpl %eax, %esi
jne 0x2056e7
movq -0x8(%rcx,%r12), %rdi
movl %edi, %esi
shrq $0x20, %rdi
xorl %r9d, %r9d
cmpq %rsi, %rdi
seta %r9b
movq (%rsp), %r8
movq 0x10(%r8), %r10
movl 0x4(%r10,%rdx,8), %r11d
xorl %r9d, %r11d
movl (%rcx,%r12), %r8d
movq %r8, %rcx
shlq $0x5, %rcx
movq 0x30(%rsp), %rdx
movq 0x10(%rdx,%rcx), %rcx
movq (%rcx,%rdi,8), %rdx
cmpl %edx, %r11d
jne 0x205706
movl %eax, %eax
xorl 0x4(%r10,%rax,8), %r9d
movq (%rcx,%rsi,8), %rcx
cmpl %ecx, %r9d
jne 0x205725
xorl %ebp, %ebp
cmpl %esi, %edi
seta %bpl
movq 0x28(%rsp), %rax
movq 0x48(%rax), %rax
imulq $0x58, %r8, %rsi
movq 0x30(%rax,%rsi), %rsi
shrq $0x20, %rdx
shrq $0x20, %rcx
movq 0x20(%rsp), %rdi
movq %rbp, %r8
leaq 0x1c(%rsp), %r9
callq 0x204c56
leaq (,%rax,2), %rax
addq %rbp, %rax
cmpl $0x0, 0x1c(%rsp)
je 0x2055a7
incl %r15d
movq 0x78(%rbx), %rcx
movq 0x88(%rbx), %rdi
movq %rax, (%rdi,%rcx,8)
jmp 0x2055c8
movq 0x78(%rbx), %rcx
movq 0x88(%rbx), %rdi
movq %rax, (%rdi,%rcx,8)
movq 0x78(%rbx), %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
orq %rcx, (%rdi,%rax,8)
movq 0x8(%rsp), %rbp
movq 0x78(%rbx), %rax
incq %rax
movq %rax, 0x78(%rbx)
addq $0x18, %r12
decq %r13
jne 0x2054b8
leaq (%rdi,%rax,8), %rsi
callq 0x1ee586
testl %r15d, %r15d
je 0x205612
movl %r15d, %edx
movq %rdx, 0x78(%rbx)
xorl %ebp, %ebp
jmp 0x205619
movq 0x78(%rbx), %rax
movq 0x88(%rbx), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x1ee586
movq 0x78(%rbx), %rdx
movb $0x1, %bpl
movq 0x88(%rbx), %rsi
movsd 0x2bfe0(%rip), %xmm0    # 0x231608
callq 0x204e28
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
movl (%rdx,%rsi,4), %edx
shrl %edx
movl 0x4(%rcx,%rdx,8), %ecx
shlq $0x20, %rax
orq %rcx, %rax
movq %rax, %r14
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
orq %rcx, %r14
testb %bpl, %bpl
cmovneq %rax, %r14
movq 0x300(%rbx), %rcx
movq 0x310(%rbx), %rax
cmpq 0x308(%rbx), %rcx
jne 0x2056ae
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x308(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x310(%rbx)
movq 0x300(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x300(%rbx)
movq %r14, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movq %rax, %r14
cmpq 0x88(%rsp), %rax
movq 0x8(%rsp), %rbp
jne 0x20539e
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x41c36(%rip), %rdi     # 0x247324
leaq 0x3ff14(%rip), %rsi     # 0x245609
leaq 0x41b9b(%rip), %rcx     # 0x247297
movl $0x18d7, %edx           # imm = 0x18D7
callq 0x2110
leaq 0x41c6a(%rip), %rdi     # 0x247377
leaq 0x3fef5(%rip), %rsi     # 0x245609
leaq 0x41b7c(%rip), %rcx     # 0x247297
movl $0x18d9, %edx           # imm = 0x18D9
callq 0x2110
leaq 0x41caa(%rip), %rdi     # 0x2473d6
leaq 0x3fed6(%rip), %rsi     # 0x245609
leaq 0x41b5d(%rip), %rcx     # 0x247297
movl $0x18da, %edx           # imm = 0x18DA
callq 0x2110
leaq 0x41bcf(%rip), %rdi     # 0x24731a
jmp 0x205754
leaq 0x41b0a(%rip), %rdi     # 0x24725e
leaq 0x3feae(%rip), %rsi     # 0x245609
leaq 0x41b35(%rip), %rcx     # 0x247297
movl $0x18d3, %edx           # imm = 0x18D3
callq 0x2110