// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movq %r9, %rbx
movq %rcx, %r13
movq %rdx, %r15
movl %esi, %ebp
movq 0x90(%rsp), %r9
movq 0x8(%rcx), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x8(%rdx)
subq $0x20, %rsp
leaq 0x68(%rsp), %r12
movq %r12, 0x10(%rsp)
leaq 0x70(%rsp), %r14
movq %r14, 0x8(%rsp)
movq %rdi, 0x38(%rsp)
movq %r8, %rcx
movq %rbx, %r8
callq 0x1dadf7
addq $0x20, %rsp
cmpq $0x2, 0x8(%r15)
setae %al
movq (%r14), %r14
cmpq $-0x1, %r14
setne %cl
movq (%r12), %r12
cmpq $-0x1, %r12
setne %dl
andb %cl, %dl
andb %al, %dl
cmpq %r14, %r12
seta %al
andb %dl, %al
cmpb $0x1, %al
jne 0x1dc8b5
movq 0x98(%rsp), %r8
subq $0x8, %rsp
movq %r15, %rdi
movq %r13, 0x28(%rsp)
movq %r13, %rsi
movq %rbx, %rdx
movsd 0x10(%rsp), %xmm0
pushq 0xb0(%rsp)
callq 0x1db9db
addq $0x10, %rsp
movq 0x8(%r15), %rsi
testq %rsi, %rsi
je 0x1dc8c4
movq %rbx, %r13
movq (%r15), %rdi
movq 0x18(%rsp), %rax
movl 0x18(%rax), %r8d
subq $0x10, %rsp
movq %rbx, %rdx
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %r9
movsd 0x18(%rsp), %xmm0
pushq %r12
pushq %r14
pushq $0xc350                 # imm = 0xC350
pushq $0x1388                 # imm = 0x1388
pushq $0x64
pushq 0xe0(%rsp)
callq 0x1dbc62
addq $0x40, %rsp
movq %rax, 0x8(%r15)
testq %rax, %rax
movq 0x20(%rsp), %rbx
je 0x1dc8b5
movq 0x10(%rsp), %r10
addq %r10, %rax
cmpq %rax, 0x10(%rbx)
jae 0x1dc78f
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(%rbx)
movq (%rbx), %rdi
leaq (%rax,%rax,8), %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax), %rsi
incq %rsi
callq 0x2370
movq 0x10(%rsp), %r10
movq %rax, (%rbx)
cmpl $-0x1, %ebp
movq 0x18(%rsp), %r11
je 0x1dc7d2
movq 0x20(%r13), %rax
movq 0x30(%r11), %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 0x1dc7d2
movq (%rbx), %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 0x1dc7a6
cmpq $0x0, 0x8(%r15)
je 0x1dc8b1
movq %r13, 0x8(%rsp)
movq (%rbx), %r13
leaq (%r10,%r10,8), %rax
leaq (%rax,%rax,2), %r12
addq %r10, %r12
xorl %ebp, %ebp
xorl %r14d, %r14d
movq (%r15), %rax
addq %r12, %r13
movups (%rax,%rbp), %xmm0
movups 0xc(%rax,%rbp), %xmm1
movups %xmm1, 0xc(%rbp,%r13)
movups %xmm0, (%rbp,%r13)
movq (%rbx), %r13
leaq (%r13,%r12), %rbx
leaq (%rbx,%rbp), %rsi
movl 0x18(%r11), %edx
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl 0xc(%rbp,%rbx), %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 0x1d0301
movq 0x28(%rsp), %r11
movq 0x20(%rsp), %r10
addq $0x10, %rsp
movl 0x40(%rsp), %eax
movl %eax, 0x4(%rbp,%rbx)
movl 0x38(%rsp), %eax
movl %eax, 0x8(%rbp,%rbx)
movl 0x30(%rsp), %eax
movl %eax, 0x10(%rbp,%rbx)
movl 0x28(%rsp), %eax
movl %eax, 0x14(%rbp,%rbx)
leal (%r10,%r14), %eax
decl %eax
cmpq $0x1, %r14
movl $0x0, %ecx
sbbl %ecx, %ecx
orl %eax, %ecx
movl %ecx, (%rbp,%rbx)
movq 0x20(%rsp), %rbx
incq %r14
addq $0x1c, %rbp
cmpq 0x8(%r15), %r14
jb 0x1dc7f5
addq %r14, %r10
movq %r10, 0x8(%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x66aac(%rip), %rdi     # 0x243377
leaq 0x63389(%rip), %rsi     # 0x23fc5b
leaq 0x66ef7(%rip), %rcx     # 0x2437d0
movl $0x470f, %edx           # imm = 0x470F
callq 0x2110