// File: /workspace/github_cpp_makefile_star2_O2/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 0x8(%rsi), %r12
andq $0x0, 0x20(%rdi)
xorl %r15d, %r15d
pxor %xmm0, %xmm0
xorl %ebp, %ebp
movq %rsi, (%rsp)
cmpq %r12, %rbp
jae 0x188e5c
movq (%rsi), %r13
imulq $0x28, %rbp, %r14
cmpl $-0x1, 0x8(%r13,%r14)
jne 0x188fd1
movq 0x20(%rbx), %rcx
movq 0x30(%rbx), %rax
cmpq 0x28(%rbx), %rcx
jne 0x188e0f
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x28(%rbx)
imulq $0x24, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
pxor %xmm0, %xmm0
movq (%rsp), %rsi
movq %rax, 0x30(%rbx)
movq 0x20(%rbx), %rcx
addq %r14, %r13
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rbx)
imulq $0x24, %rcx, %rcx
movdqu %xmm0, 0x14(%rax,%rcx)
movdqu %xmm0, 0x4(%rax,%rcx)
movl %ebp, (%rax,%rcx)
movq 0x14(%r13), %rdx
movq %rdx, 0x4(%rax,%rcx)
movl 0x4(%r13), %edx
addl %edx, %edx
sarl %edx
movl %edx, 0xc(%rax,%rcx)
movl 0x4(%r13), %eax
shlq $0x21, %rax
sarq $0x21, %rax
addq %rax, %r15
addq %rax, %rbp
incq %rbp
jmp 0x188db7
movq 0x30(%rbx), %rdi
imulq $0x24, 0x20(%rbx), %rsi
addq %rdi, %rsi
callq 0x1580d5
movq 0x20(%rbx), %rcx
leaq (%rcx,%r15), %rdx
movq 0x30(%rbx), %rax
cmpq %rdx, 0x28(%rbx)
jae 0x188ece
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
incq %rcx
movq %rcx, 0x28(%rbx)
imulq $0x24, %rcx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x30(%rbx)
movq 0x20(%rbx), %rcx
imulq $0x24, %rcx, %rdi
addq %rax, %rdi
imulq $0x24, %r15, %rdx
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x20e0
movq 0x20(%rbx), %rcx
movq %rcx, %rsi
movq (%rsp), %r11
cmpq %rcx, %r15
jae 0x188fbc
movq 0x30(%rbx), %rdx
imulq $0x24, %r15, %rcx
movl (%rdx,%rcx), %r9d
movl 0xc(%rdx,%rcx), %edi
leaq (%rsi,%rdi), %rax
movl %esi, 0xc(%rdx,%rcx)
movl %eax, 0x10(%rdx,%rcx)
movq (%r11), %r8
imulq $0x28, %r9, %r9
cmpl $-0x1, 0x8(%r8,%r9)
jne 0x188ff0
leaq (%r8,%r9), %r10
movl 0x4(%r10), %r10d
addl %r10d, %r10d
sarl %r10d
cmpl %edi, %r10d
jne 0x18900f
movl %esi, %r10d
imulq $0x24, %rdi, %rsi
leaq (%r8,%r9), %rdi
addq $0x34, %rdi
imulq $0x24, %r10, %r8
addq %rdx, %r8
addq $0x20, %r8
xorl %r9d, %r9d
cmpq %r9, %rsi
je 0x188fa9
movl -0x4(%rdi), %edx
movl %edx, %r10d
shrl %r10d
movl %r10d, -0x20(%r8,%r9)
movb (%r8,%r9), %r10b
shlb $0x5, %dl
andb $0x20, %dl
andb $-0x21, %r10b
orb %dl, %r10b
movb %r10b, (%r8,%r9)
movdqu (%rdi), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movdqu %xmm0, -0x1c(%r8,%r9)
movq 0x30(%rbx), %rdx
movl (%rdx,%rcx), %r10d
movl %r10d, -0x4(%r8,%r9)
addq $0x24, %r9
addq $0x28, %rdi
jmp 0x188f5a
orl $-0x1, (%rdx,%rcx)
incq %r15
movq 0x20(%rbx), %rcx
movq %rax, %rsi
jmp 0x188eee
cmpq 0x28(%rbx), %rsi
ja 0x18902e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x69a67(%rip), %rdi     # 0x1f2a3f
leaq 0x68b44(%rip), %rsi     # 0x1f1b23
leaq 0x6c144(%rip), %rcx     # 0x1f512a
movl $0x3ebe, %edx           # imm = 0x3EBE
callq 0x2110
leaq 0x69a48(%rip), %rdi     # 0x1f2a3f
leaq 0x68b25(%rip), %rsi     # 0x1f1b23
leaq 0x6c125(%rip), %rcx     # 0x1f512a
movl $0x3ed3, %edx           # imm = 0x3ED3
callq 0x2110
leaq 0x6c14f(%rip), %rdi     # 0x1f5165
leaq 0x68b06(%rip), %rsi     # 0x1f1b23
leaq 0x6c106(%rip), %rcx     # 0x1f512a
movl $0x3ed5, %edx           # imm = 0x3ED5
callq 0x2110
leaq 0x6c149(%rip), %rdi     # 0x1f517e
leaq 0x68ae7(%rip), %rsi     # 0x1f1b23
leaq 0x6c0e7(%rip), %rcx     # 0x1f512a
movl $0x3ee0, %edx           # imm = 0x3EE0
callq 0x2110