// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: push_ctg_res(ul_vec_t*, vec_mg_lchain_t*, unsigned long)
void push_ctg_res(ul_vec_t *rch, vec_mg_lchain_t *uc, uint64_t id)
{
	// fprintf(stderr, "\n++[M::%s::%.*s(id:%ld), len:%u]\n", __func__, 
	// UL_INF.nid.a[ulid].n, UL_INF.nid.a[ulid].a, ulid, rch->rlen);

	uint64_t k, ucn = uc->n; uint64_t tt, s, e, z, rrn; mg_lchain_t *ix; uc_block_t *p; uc_block_t *rr; mg_lchain_t *src; 
	for (k = 0, rch->bb.n = 0, tt = 0; k < ucn; k += ix->cnt + 1) {
		ix = &(uc->a[k]); assert(ix->v == (uint32_t)-1);
		kv_pushp(uc_block_t, rch->bb, &p); memset(p, 0, sizeof((*p))); 
		p->hid = k/**(uint32_t)-1**/; p->qs = ix->qs; p->qe = ix->qe; p->ts = ix->cnt; tt += ix->cnt;

		// if(id == 206) {
		// 	fprintf(stderr, "init->[M::%s::ucn->%lu, k->%lu, kcnt->%d]\n", __func__, ucn, k, ix->cnt);
		// }
	}
	radix_sort_uc_block_t_qe_srt(rch->bb.a, rch->bb.a + rch->bb.n);

	kv_resize(uc_block_t, rch->bb, rch->bb.n + tt); 
	memset(rch->bb.a + rch->bb.n, 0, tt * sizeof(*(rch->bb.a)));
	for (k = 0, tt = rch->bb.n; k < rch->bb.n; k++) {
		s = tt; e = tt + rch->bb.a[k].ts; 
		rch->bb.a[k].ts = s; rch->bb.a[k].te = e;
		tt = e; 
		// if(id == 206) {
		// 	fprintf(stderr, "mid->[M::%s::rch->bb.n->%u, k->%lu] [%lu, %lu)\n", 
		// 	__func__, (uint32_t)rch->bb.n, k, s, e);
		// }

		ix = &(uc->a[rch->bb.a[k].hid]); assert(ix->v == (uint32_t)-1);
		rr = rch->bb.a + rch->bb.a[k].ts; rrn = rch->bb.a[k].te - rch->bb.a[k].ts;
		src = uc->a + rch->bb.a[k].hid + 1; assert((uint32_t)ix->cnt == rrn);
		for(z = 0; z < rrn; z++) {
			rr[z].hid = src[z].v>>1;
			rr[z].rev = src[z].v&1;
			rr[z].qs = src[z].qs; rr[z].qe = src[z].qe;
			rr[z].ts = src[z].rs; rr[z].te = src[z].re; 
			rr[z].aidx = rch->bb.a[k].hid;
		}
		rch->bb.a[k].hid = (uint32_t)-1;

	}
	assert(tt <= rch->bb.m);

	// for (k = 0, tt = 0; k < ucn; k += ix->cnt + 1, tt++) {
	// 	ix = &(uc->a[k]); assert(ix->v == (uint32_t)-1);
	// 	rr = rch->bb.a + rch->bb.a[tt].ts; rrn = rch->bb.a[tt].te - rch->bb.a[tt].ts;
	// 	src = uc->a + k + 1; 
	// 	if(!((uint32_t)ix->cnt == rrn)) {
	// 		fprintf(stderr, "\n++[M::%s::(id::%lu)] ix->cnt::%d, rrn::%lu\n", __func__, id, ix->cnt, rrn);
	// 	}
	// 	assert((uint32_t)ix->cnt == rrn);
	// 	for(z = 0; z < rrn; z++) {
	// 		rr[z].hid = src[z].v>>1;
	// 		rr[z].rev = src[z].v&1;
	// 		rr[z].qs = src[z].qs; rr[z].qe = src[z].qe;
	// 		rr[z].ts = src[z].rs; rr[z].te = src[z].re; 
	// 		rr[z].aidx = k;
	// 	}
	// }
	///up to now, given a <x> in swap
	///x->ts and x->te are the coordinates in unitig (x->score>>1), instead of HiFi read (x->v>>1)
	///x->qs and x->qe are the coordinates in UL
	///x->dist_pre is the idx of this chain at rch 
	// debug_intermediate_chain(uref->ug, swap->a, swap->n);
	// dd_ul_vec_t(uref, swap->a, swap->n, rch, ulid);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rsi, (%rsp)
movq 0x8(%rsi), %r12
movq $0x0, 0x20(%rdi)
testq %r12, %r12
je 0x1d56c5
xorl %r13d, %r13d
pxor %xmm0, %xmm0
xorl %r15d, %r15d
movq (%rsp), %rax
movq (%rax), %rbp
leaq (,%r13,4), %r14
addq %r13, %r14
cmpl $-0x1, 0x8(%rbp,%r14,8)
jne 0x1d5864
movq 0x20(%rbx), %rcx
movq 0x30(%rbx), %rax
cmpq 0x28(%rbx), %rcx
jne 0x1d5667
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x28(%rbx)
shlq $0x2, %rdx
leaq (%rdx,%rdx,8), %rsi
movq %rax, %rdi
callq 0x2370
pxor %xmm0, %xmm0
movq %rax, 0x30(%rbx)
movq 0x20(%rbx), %rcx
leaq (,%r14,8), %rdx
addq %rbp, %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x20(%rbx)
leaq (%rcx,%rcx,8), %rcx
movdqu %xmm0, 0x14(%rax,%rcx,4)
movdqu %xmm0, 0x4(%rax,%rcx,4)
movl %r13d, (%rax,%rcx,4)
movq 0x14(%rdx), %rsi
movq %rsi, 0x4(%rax,%rcx,4)
movl 0x4(%rdx), %esi
addl %esi, %esi
sarl %esi
movl %esi, 0xc(%rax,%rcx,4)
movl 0x4(%rdx), %eax
shlq $0x21, %rax
sarq $0x21, %rax
addq %rax, %r15
addq %rax, %r13
incq %r13
cmpq %r12, %r13
jb 0x1d560b
movq 0x20(%rbx), %rax
jmp 0x1d56ca
xorl %eax, %eax
xorl %r15d, %r15d
movq 0x30(%rbx), %rdi
leaq (%rax,%rax,8), %rax
leaq (%rdi,%rax,4), %rsi
callq 0x19f452
movq 0x20(%rbx), %rcx
leaq (%rcx,%r15), %rdx
movq 0x30(%rbx), %rax
cmpq %rdx, 0x28(%rbx)
jae 0x1d5745
decq %rdx
movq %rdx, %rcx
shrq %rcx
orq %rdx, %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, 0x28(%rbx)
leaq 0x4(,%rcx,4), %rcx
leaq (%rcx,%rcx,8), %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x30(%rbx)
movq 0x20(%rbx), %rcx
leaq (%rcx,%rcx,8), %rcx
leaq (%rax,%rcx,4), %rdi
shlq $0x2, %r15
leaq (%r15,%r15,8), %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x1d5855
movq 0x30(%rbx), %rsi
xorl %eax, %eax
movq %rdi, %r8
leaq (%rax,%rax,8), %rdx
movl (%rsi,%rdx,4), %r11d
movl 0xc(%rsi,%rdx,4), %r9d
leaq (%r8,%r9), %rcx
movl %r8d, 0xc(%rsi,%rdx,4)
movl %ecx, 0x10(%rsi,%rdx,4)
movq (%rsp), %r10
movq (%r10), %r10
leaq (%r11,%r11,4), %r11
cmpl $-0x1, 0x8(%r10,%r11,8)
jne 0x1d58a2
leaq (%r10,%r11,8), %r14
movl 0x4(%r14), %ebp
addl %ebp, %ebp
sarl %ebp
cmpl %r9d, %ebp
jne 0x1d5883
cmpl %r8d, %ecx
je 0x1d5839
movl %r8d, %r8d
cmpq $0x1, %r9
adcq $0x0, %r9
shlq $0x3, %r9
leaq (%r9,%r9,4), %rdi
leaq (%r8,%r8,8), %r8
leaq (%rsi,%r8,4), %r8
addq $0x20, %r8
leaq (%r10,%r11,8), %r9
addq $0x34, %r9
xorl %r10d, %r10d
movl -0x4(%r9,%r10), %esi
movl %esi, %r11d
shrl %r11d
movl %r11d, -0x20(%r8)
movb (%r8), %r11b
shlb $0x5, %sil
andb $0x20, %sil
andb $-0x21, %r11b
orb %sil, %r11b
movb %r11b, (%r8)
movdqu (%r9,%r10), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movdqu %xmm0, -0x1c(%r8)
movq 0x30(%rbx), %rsi
movl (%rsi,%rdx,4), %r11d
movl %r11d, -0x4(%r8)
addq $0x28, %r10
addq $0x24, %r8
cmpq %r10, %rdi
jne 0x1d57e7
movq 0x20(%rbx), %rdi
movl $0xffffffff, (%rsi,%rdx,4) # imm = 0xFFFFFFFF
incq %rax
movq %rcx, %r8
cmpq %rdi, %rax
jb 0x1d5772
cmpq 0x28(%rbx), %rcx
ja 0x1d58c1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6b30c(%rip), %rdi     # 0x240b77
leaq 0x6a3e9(%rip), %rsi     # 0x23fc5b
leaq 0x6d9e9(%rip), %rcx     # 0x243262
movl $0x3ebe, %edx           # imm = 0x3EBE
callq 0x2110
leaq 0x6da13(%rip), %rdi     # 0x24329d
leaq 0x6a3ca(%rip), %rsi     # 0x23fc5b
leaq 0x6d9ca(%rip), %rcx     # 0x243262
movl $0x3ed5, %edx           # imm = 0x3ED5
callq 0x2110
leaq 0x6b2ce(%rip), %rdi     # 0x240b77
leaq 0x6a3ab(%rip), %rsi     # 0x23fc5b
leaq 0x6d9ab(%rip), %rcx     # 0x243262
movl $0x3ed3, %edx           # imm = 0x3ED3
callq 0x2110
leaq 0x6d9ee(%rip), %rdi     # 0x2432b6
leaq 0x6a38c(%rip), %rsi     # 0x23fc5b
leaq 0x6d98c(%rip), %rcx     # 0x243262
movl $0x3ee0, %edx           # imm = 0x3EE0
callq 0x2110