// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/inter.cpp
// Function: gen_contain_consensus_chain(ul_vec_t*, unsigned int, kv_ul_ov_t*, kv_ul_ov_t*, ug_opt_t const*, asg_t const*, R_to_U*, long, double, long, Chain_Data*)
void gen_contain_consensus_chain(ul_vec_t *rch, uint32_t rch_i, kv_ul_ov_t *idx, kv_ul_ov_t *dump,
const ug_opt_t *uopt, const asg_t *rg, R_to_U *ri, int64_t bw, double diff_ec_ul, int64_t ulid, Chain_Data* dp)
{
	uint64_t dn = dump->n, i, mqs, mqe; int64_t iqs, iqe, its, ite; idx->n = 0;
	collect_nc_ovlps(rch, rch_i, idx, uopt, rg, ri, ulid, &mqs, &mqe);
	// assert(idx->n > 1); assert((mqs != ((uint64_t)-1)) && (mqe != ((uint64_t)-1)) && (mqe > mqs));
	if((idx->n <= 1) || (mqs == ((uint64_t)-1)) || (mqe == ((uint64_t)-1)) || (mqe <= mqs)) return;
	
	gen_linear_rchains(idx, dump, rg, uopt, bw, diff_ec_ul, rch->rlen, dp, ulid);
	assert(idx->n);
	idx->n = gen_cns_chain_linear(idx->a, idx->n, /**dump->a+dn,**/ rg, ri, rch->rlen, bw, diff_ec_ul, dp, UG_SKIP_N, UG_ITER_N, UG_DIS_N, mqs, mqe, ulid);
	// fprintf(stderr, "[M::%s::] idx->n::%u, mqs::%lu, mqe::%lu\n", __func__, (uint32_t)idx->n, mqs, mqe);
	if(idx->n) {
		kv_resize(ul_ov_t, *dump, dn + idx->n);
		///mask existing overlaps
		for (i = rch_i; (i != (uint32_t)-1) && (!rg->seq[rch->bb.a[i].hid].del); i = rch->bb.a[i].pidx) {
			dump->a[i].tn = dump->a[i].qn = (uint32_t)-1;
		}
		for (i = 0; i < idx->n; i++) {
			dump->a[dn] = idx->a[i];
			extend_end_coord(NULL, &(dump->a[dn]), rch->rlen, rg->seq[dump->a[dn].tn].len, &iqs, &iqe, &its, &ite);
			dump->a[dn].qs = iqs; dump->a[dn].qe = iqe; dump->a[dn].ts = its; dump->a[dn].te = ite;
			dump->a[dn].qn = ((i>0)?(dn-1):((uint32_t)-1)); dn++;
		}
		dump->n = dn;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movsd %xmm0, 0x20(%rsp)
movq %r9, %r10
movq %rcx, %rbx
movq %rdx, %r15
movl %esi, %ebp
movq 0x90(%rsp), %r9
movq 0x8(%rcx), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x8(%rdx)
subq $0x20, %rsp
leaq 0x68(%rsp), %r14
movq %r14, 0x10(%rsp)
leaq 0x70(%rsp), %r12
movq %r12, 0x8(%rsp)
movq %rdi, 0x38(%rsp)
movq %r8, %rcx
movq %r10, 0x20(%rsp)
movq %r10, %r8
callq 0x1d0cf8
addq $0x20, %rsp
cmpq $0x2, 0x8(%r15)
setae %al
movq (%r12), %r12
cmpq $-0x1, %r12
setne %cl
movq (%r14), %r13
cmpq $-0x1, %r13
setne %dl
andb %cl, %dl
andb %al, %dl
cmpq %r12, %r13
seta %al
andb %dl, %al
cmpb $0x1, %al
jne 0x1d2828
movq 0xa8(%rsp), %r14
movq 0x98(%rsp), %rax
subq $0x8, %rsp
movq %r15, %rdi
movq %rbx, 0x18(%rsp)
movq %rbx, %rsi
movq %rax, %rbx
movq 0x8(%rsp), %rdx
movq %rax, %r8
movsd 0x28(%rsp), %xmm0
pushq %r14
callq 0x1d196f
addq $0x10, %rsp
movq 0x8(%r15), %rsi
testq %rsi, %rsi
je 0x1d2837
movq (%r15), %rdi
movq 0x18(%rsp), %rax
movl 0x18(%rax), %r8d
subq $0x10, %rsp
movq 0x10(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movq %rbx, %r9
movsd 0x30(%rsp), %xmm0
pushq %r13
pushq %r12
pushq $0xc350                 # imm = 0xC350
pushq $0x1388                 # imm = 0x1388
pushq $0x64
pushq %r14
callq 0x1d1bfc
addq $0x40, %rsp
movq %rax, 0x8(%r15)
testq %rax, %rax
movq 0x10(%rsp), %r14
je 0x1d2828
movq 0x8(%rsp), %r10
addq %r10, %rax
cmpq %rax, 0x10(%r14)
jae 0x1d2700
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, 0x10(%r14)
movq (%r14), %rdi
leaq (%rax,%rax,8), %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax), %rsi
incq %rsi
callq 0x2370
movq 0x8(%rsp), %r10
movq %rax, (%r14)
cmpl $-0x1, %ebp
movq (%rsp), %r11
movq 0x18(%rsp), %rbx
je 0x1d2747
movq 0x20(%r11), %rax
movq 0x30(%rbx), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %edi
leaq (%rdi,%rdi,8), %rsi
movl (%rcx,%rsi,4), %r8d
cmpl $0x0, (%rax,%r8,8)
js 0x1d2747
movq (%r14), %r8
leaq (%rsi,%rsi,2), %r9
addq %rdi, %r9
movl %edx, (%r8,%r9)
movl %edx, 0xc(%r8,%r9)
movl 0x14(%rcx,%rsi,4), %ebp
cmpl %edx, %ebp
jne 0x1d271b
cmpq $0x0, 0x8(%r15)
je 0x1d2824
leaq (%r10,%r10,8), %rax
leaq (%rax,%rax,2), %r13
addq %r10, %r13
xorl %r12d, %r12d
xorl %ebp, %ebp
movq (%r15), %rax
movq (%r14), %rcx
addq %r13, %rcx
movups (%rax,%r12), %xmm0
movups 0xc(%rax,%r12), %xmm1
movups %xmm1, 0xc(%r12,%rcx)
movups %xmm0, (%r12,%rcx)
movq 0x10(%rsp), %rax
movq (%rax), %r14
addq %r13, %r14
leaq (%r14,%r12), %rsi
movl 0x18(%rbx), %edx
movq 0x20(%r11), %rax
movl 0xc(%r12,%r14), %ecx
movl (%rax,%rcx,8), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edi, %edi
leaq 0x40(%rsp), %r8
leaq 0x38(%rsp), %r9
leaq 0x28(%rsp), %rax
pushq %rax
leaq 0x38(%rsp), %rax
pushq %rax
callq 0x1c62a4
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %r10
addq $0x10, %rsp
movl 0x40(%rsp), %eax
movl %eax, 0x4(%r12,%r14)
movl 0x38(%rsp), %eax
movl %eax, 0x8(%r12,%r14)
movl 0x30(%rsp), %eax
movl %eax, 0x10(%r12,%r14)
movl 0x28(%rsp), %eax
movl %eax, 0x14(%r12,%r14)
leal (%r10,%rbp), %eax
decl %eax
cmpq $0x1, %rbp
movl $0x0, %ecx
sbbl %ecx, %ecx
orl %eax, %ecx
movl %ecx, (%r12,%r14)
movq 0x10(%rsp), %r14
incq %rbp
addq $0x1c, %r12
cmpq 0x8(%r15), %rbp
jb 0x1d2762
addq %rbp, %r10
movq %r10, 0x8(%r14)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x64869(%rip), %rdi     # 0x2370a7
leaq 0x61146(%rip), %rsi     # 0x23398b
leaq 0x64cb4(%rip), %rcx     # 0x237500
movl $0x470f, %edx           # imm = 0x470F
callq 0x2110