// File: /workspace/github_cpp_makefile_star2_O2/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, %rax
movq %rcx, %r14
movq %rdx, %r12
movl %esi, %ebp
movq 0x90(%rsp), %r9
movq 0x8(%rcx), %r13
andq $0x0, 0x8(%rdx)
subq $0x20, %rsp
leaq 0x68(%rsp), %r15
movq %r15, 0x10(%rsp)
leaq 0x70(%rsp), %rbx
movq %rbx, 0x8(%rsp)
movq %rdi, 0x38(%rsp)
movq %r8, %rcx
movq %rax, 0x30(%rsp)
movq %rax, %r8
callq 0x18d9b4
movq %r12, %rdi
addq $0x20, %rsp
cmpq $0x2, 0x8(%r12)
setae %al
movq (%rbx), %rbx
cmpq $-0x1, %rbx
setne %cl
movq (%r15), %r12
cmpq $-0x1, %r12
setne %dl
andb %cl, %dl
andb %al, %dl
cmpq %rbx, %r12
seta %al
andb %dl, %al
cmpb $0x1, %al
jne 0x18ef57
movq 0xa8(%rsp), %r15
movq 0x98(%rsp), %r8
subq $0x8, %rsp
movq %r14, %rsi
movq 0x18(%rsp), %rdx
movsd 0x28(%rsp), %xmm0
pushq %r15
movq %rdi, 0x18(%rsp)
callq 0x18e2e5
movq 0x18(%rsp), %rax
addq $0x10, %rsp
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x18ef66
movq (%rax), %rdi
movq 0x18(%rsp), %rax
movl 0x18(%rax), %r8d
subq $0x10, %rsp
movq 0x20(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %r9
movsd 0x30(%rsp), %xmm0
pushq %r12
pushq %rbx
pushq $0xc350                 # imm = 0xC350
pushq $0x1388                 # imm = 0x1388
pushq $0x64
pushq %r15
callq 0x18e4da
movq 0x48(%rsp), %r9
addq $0x40, %rsp
movq %rax, 0x8(%r9)
testq %rax, %rax
je 0x18ef57
addq %r13, %rax
cmpq %rax, 0x10(%r14)
jae 0x18ee52
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
incq %rcx
movq %rcx, 0x10(%r14)
movq (%r14), %rdi
imulq $0x1c, %rcx, %rsi
callq 0x2370
movq 0x8(%rsp), %r9
movq %rax, (%r14)
movq 0x10(%rsp), %r8
cmpl $-0x1, %ebp
je 0x18ee8e
movl %ebp, %eax
movq 0x20(%r8), %rsi
movq 0x18(%rsp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x24, %rax, %rdx
movl (%rcx,%rdx), %edi
cmpl $0x0, (%rsi,%rdi,8)
js 0x18ee8e
movq (%r14), %rsi
imulq $0x1c, %rax, %rax
orl $-0x1, (%rsi,%rax)
orl $-0x1, 0xc(%rsi,%rax)
movl 0x14(%rcx,%rdx), %ebp
jmp 0x18ee57
imulq $0x1c, %r13, %rbp
xorl %r12d, %r12d
xorl %ebx, %ebx
cmpq 0x8(%r9), %rbx
jae 0x18ef53
movq (%r9), %rax
movq (%r14), %rcx
movups (%rax,%r12), %xmm0
movups 0xc(%rax,%r12), %xmm1
movups %xmm1, 0xc(%rcx,%rbp)
movups %xmm0, (%rcx,%rbp)
movq (%r14), %r15
leaq (%r15,%rbp), %rsi
movq 0x18(%rsp), %rax
movl 0x18(%rax), %edx
movq 0x20(%r8), %rax
movl 0xc(%r15,%rbp), %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 0x184214
movq 0x18(%rsp), %r9
movq 0x20(%rsp), %r8
addq $0x10, %rsp
movl 0x40(%rsp), %eax
movl %eax, 0x4(%r15,%rbp)
movl 0x38(%rsp), %eax
movl %eax, 0x8(%r15,%rbp)
movl 0x30(%rsp), %eax
movl %eax, 0x10(%r15,%rbp)
movl 0x28(%rsp), %eax
movl %eax, 0x14(%r15,%rbp)
leal -0x1(%r13), %eax
cmpq $0x1, %rbx
movl $0x0, %ecx
sbbl %ecx, %ecx
orl %eax, %ecx
movl %ecx, (%r15,%rbp)
incq %r13
incq %rbx
addq $0x1c, %rbp
addq $0x1c, %r12
jmp 0x18ee97
movq %r13, 0x8(%r14)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x662d2(%rip), %rdi     # 0x1f523f
leaq 0x62baf(%rip), %rsi     # 0x1f1b23
leaq 0x6671d(%rip), %rcx     # 0x1f5698
movl $0x470f, %edx           # imm = 0x470F
callq 0x2110