// File: /workspace/github_cpp_makefile_star2_O1/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 0x1cb70a
xorl %r13d, %r13d
xorps %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 0x1cb8c8
movq 0x28(%rbx), %rax
cmpq %rax, 0x20(%rbx)
jne 0x1cb69e
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x28(%rbx)
movq 0x30(%rbx), %rdi
shlq $0x2, %rcx
leaq (%rcx,%rcx,8), %rsi
callq 0x2370
xorps %xmm0, %xmm0
movq %rax, 0x30(%rbx)
leaq (,%r14,8), %rax
addq %rbp, %rax
movq 0x20(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x20(%rbx)
leaq (%rcx,%rcx,8), %rcx
movups %xmm0, (%rdx,%rcx,4)
movups %xmm0, 0x10(%rdx,%rcx,4)
movl $0x0, 0x20(%rdx,%rcx,4)
movl %r13d, (%rdx,%rcx,4)
movl 0x14(%rax), %esi
movl %esi, 0x4(%rdx,%rcx,4)
movl 0x18(%rax), %esi
movl %esi, 0x8(%rdx,%rcx,4)
movl 0x4(%rax), %esi
addl %esi, %esi
sarl %esi
movl %esi, 0xc(%rdx,%rcx,4)
movl 0x4(%rax), %eax
shlq $0x21, %rax
sarq $0x21, %rax
addq %rax, %r15
addq %rax, %r13
incq %r13
cmpq %r12, %r13
jb 0x1cb64a
jmp 0x1cb70d
xorl %r15d, %r15d
movq 0x20(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rax,%rax,8), %rax
leaq (%rdi,%rax,4), %rsi
callq 0x1966c5
movq 0x20(%rbx), %rax
addq %r15, %rax
cmpq %rax, 0x28(%rbx)
jae 0x1cb784
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, 0x28(%rbx)
movq 0x30(%rbx), %rdi
leaq 0x4(,%rcx,4), %rax
leaq (%rax,%rax,8), %rsi
callq 0x2370
movq %rax, 0x30(%rbx)
movq 0x20(%rbx), %rax
leaq (%rax,%rax,8), %rdi
shlq $0x2, %rdi
addq 0x30(%rbx), %rdi
shlq $0x2, %r15
leaq (%r15,%r15,8), %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x1cb8b3
xorl %ecx, %ecx
movq %rax, %rdi
movq 0x30(%rbx), %rsi
leaq (%rcx,%rcx,8), %rdx
movl (%rsi,%rdx,4), %r9d
movl 0xc(%rsi,%rdx,4), %eax
addq %rdi, %rax
movl %edi, 0xc(%rsi,%rdx,4)
movl %eax, 0x10(%rsi,%rdx,4)
movq (%rsp), %rdi
movq (%rdi), %r8
leaq (%r9,%r9,4), %r9
cmpl $-0x1, 0x8(%r8,%r9,8)
jne 0x1cb906
leaq (%rsi,%rdx,4), %rdi
leaq (%r8,%r9,8), %r14
movl 0xc(%rdi), %r10d
movl 0x10(%rdi), %r11d
movl %r11d, %edi
subl %r10d, %edi
movl 0x4(%r14), %ebp
addl %ebp, %ebp
sarl %ebp
cmpl %edi, %ebp
jne 0x1cb8e7
cmpl %r10d, %r11d
je 0x1cb89b
cmpl $0x1, %edi
adcl $0x0, %edi
shlq $0x3, %rdi
leaq (%rdi,%rdi,4), %rdi
leaq (%r10,%r10,8), %r10
leaq (%rsi,%r10,4), %rsi
addq $0x20, %rsi
leaq (%r8,%r9,8), %r8
addq $0x40, %r8
xorl %r9d, %r9d
movl -0x10(%r8,%r9), %r10d
movl %r10d, %r11d
shrl %r11d
movl %r11d, -0x20(%rsi)
movb (%rsi), %r11b
shlb $0x5, %r10b
andb $0x20, %r10b
andb $-0x21, %r11b
orb %r10b, %r11b
movb %r11b, (%rsi)
movl -0x4(%r8,%r9), %r10d
movl %r10d, -0x1c(%rsi)
movl (%r8,%r9), %r10d
movl %r10d, -0x18(%rsi)
movl -0xc(%r8,%r9), %r10d
movl %r10d, -0x14(%rsi)
movl -0x8(%r8,%r9), %r10d
movl %r10d, -0x10(%rsi)
movq 0x30(%rbx), %r10
movl (%r10,%rdx,4), %r10d
movl %r10d, -0x4(%rsi)
addq $0x28, %r9
addq $0x24, %rsi
cmpq %r9, %rdi
jne 0x1cb83b
movq 0x30(%rbx), %rsi
movl $0xffffffff, (%rsi,%rdx,4) # imm = 0xFFFFFFFF
incq %rcx
cmpq 0x20(%rbx), %rcx
jb 0x1cb7b2
cmpq 0x28(%rbx), %rax
ja 0x1cb925
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x68fd8(%rip), %rdi     # 0x2348a7
leaq 0x680b5(%rip), %rsi     # 0x23398b
leaq 0x6b6b5(%rip), %rcx     # 0x236f92
movl $0x3ebe, %edx           # imm = 0x3EBE
callq 0x2110
leaq 0x6b6df(%rip), %rdi     # 0x236fcd
leaq 0x68096(%rip), %rsi     # 0x23398b
leaq 0x6b696(%rip), %rcx     # 0x236f92
movl $0x3ed5, %edx           # imm = 0x3ED5
callq 0x2110
leaq 0x68f9a(%rip), %rdi     # 0x2348a7
leaq 0x68077(%rip), %rsi     # 0x23398b
leaq 0x6b677(%rip), %rcx     # 0x236f92
movl $0x3ed3, %edx           # imm = 0x3ED3
callq 0x2110
leaq 0x6b6ba(%rip), %rdi     # 0x236fe6
leaq 0x68058(%rip), %rsi     # 0x23398b
leaq 0x6b658(%rip), %rcx     # 0x236f92
movl $0x3ee0, %edx           # imm = 0x3EE0
callq 0x2110