// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: debug_ll_chains(ul_idx_t const*, unsigned long*, long, long, long, mg_lchain_t*, kv_ul_ov_t*, kv_ul_ov_t*, unsigned long*, long, double, long)
void debug_ll_chains(const ul_idx_t *uref, uint64_t *ix, int64_t ix_n, int64_t p_sidx, int64_t p_eidx, mg_lchain_t *chain_a,
kv_ul_ov_t *raw_idx, kv_ul_ov_t *raw_chn, uint64_t *b, int64_t bw, double diff_ec_ul, int64_t qlen)
{
	int64_t k, i, z, a_n, ss, ee, b_n; uint64_t qs, qe, ts, te; uint32_t mk = 0x80000000; mg_lchain_t nn;
	int64_t iqs, iqe, its, ite, tsc;
	
	for (k = p_sidx; k < p_eidx; k++) {
		i = raw_idx->a[chain_a[k].off].qn; 
		qs = raw_chn->a[i].qs; qe = raw_chn->a[i].qe;
		ts = raw_chn->a[i].ts; te = raw_chn->a[i].te;
		// fprintf(stderr, "++++++++++++[M::%s::idx:%ld]\n", __func__, i);
		for (;i>=0;) {
			// fprintf(stderr, "--[M::%s::i->%ld]\n", __func__, i);
			if(raw_chn->a[i].qs < qs) qs = raw_chn->a[i].qs;
        	if(raw_chn->a[i].ts < ts) ts = raw_chn->a[i].ts;
        	if(raw_chn->a[i].qe > qe) qe = raw_chn->a[i].qe;
        	if(raw_chn->a[i].te > te) te = raw_chn->a[i].te;
			raw_chn->a[i].qs |= mk;

			if(raw_chn->a[i].tn == (uint32_t)-1) i = -1;
			else i = raw_chn->a[i].tn;
		}
		assert(raw_idx->a[chain_a[k].off].qs == qs && raw_idx->a[chain_a[k].off].qe == qe && 
				raw_idx->a[chain_a[k].off].ts == ts && raw_idx->a[chain_a[k].off].te == te);
	}


	///dedup
	for (z = a_n = 0; z < ix_n; ++z) {
		ss = a_n; ee = a_n + ((uint32_t)ix[z]); tsc = 0;
		/**if(ss != p_sidx || ee != p_eidx)**/ {
			for (k = ss; k < ee; k++) {
				i = raw_idx->a[chain_a[k].off].qn; b_n = 0;
				qs = ((raw_chn->a[i].qs<<1)>>1); qe = raw_chn->a[i].qe;
				ts = raw_chn->a[i].ts; te = raw_chn->a[i].te;
				// fprintf(stderr, "++++++++++++[M::%s::idx:%ld]\n", __func__, i);
				for (;i>=0;) {
					// fprintf(stderr, "--[M::%s::i->%ld]\n", __func__, i);
					if(((raw_chn->a[i].qs<<1)>>1) < qs) qs = ((raw_chn->a[i].qs<<1)>>1);
					if(raw_chn->a[i].ts < ts) ts = raw_chn->a[i].ts;
					if(raw_chn->a[i].qe > qe) qe = raw_chn->a[i].qe;
					if(raw_chn->a[i].te > te) te = raw_chn->a[i].te;
					// raw_chn->a[i].qs |= mk;
					//update here!!!!!!!
					// if(!(raw_chn->a[i].qs&mk)) b[b_n++] = i;
					b[b_n++] = i;
					if(raw_chn->a[i].tn == (uint32_t)-1) i = -1;
					else i = raw_chn->a[i].tn;
				}
				assert(raw_idx->a[chain_a[k].off].qs == qs && raw_idx->a[chain_a[k].off].qe == qe && 
						raw_idx->a[chain_a[k].off].ts == ts && raw_idx->a[chain_a[k].off].te == te);
				
				update_exist_chain(uref, raw_chn->a, b, b_n, raw_idx->a[chain_a[k].off].tn, bw, diff_ec_ul, &nn);
				nn.v = (raw_idx->a[chain_a[k].off].tn<<1)|raw_idx->a[chain_a[k].off].rev;
				extend_end_coord(&nn, NULL, qlen, uref->ug->g->seq[raw_idx->a[chain_a[k].off].tn].len, 
				&iqs, &iqe, &its, &ite);
				nn.qs = iqs; nn.qe = iqe; nn.rs = its; nn.re = ite;
				if(!(chain_a[k].score == nn.score && chain_a[k].qs == nn.qs && chain_a[k].qe == nn.qe 
															&& chain_a[k].rs == nn.rs && chain_a[k].re == nn.re)){
					fprintf(stderr, "[M::%s::] chain_a[k].score->%d, nn.score->%d\n", __func__, chain_a[k].score, nn.score);
					fprintf(stderr, "[M::%s::] chain_a[k].qs->%d, nn.qs->%d, chain_a[k].qe->%d, nn.qe->%d, chain_a[k].rs->%d, nn.rs->%d, chain_a[k].re->%d, nn.re->%d\n", __func__, 
					chain_a[k].qs, nn.qs, chain_a[k].qe, nn.qe, chain_a[k].rs, nn.rs, chain_a[k].re, nn.re);
				}
				assert(chain_a[k].score == nn.score && chain_a[k].qs == nn.qs && chain_a[k].qe == nn.qe 
															&& chain_a[k].rs == nn.rs && chain_a[k].re == nn.re);
				tsc += nn.score;
			}
			assert(tsc >= ((int64_t)(ix[z]>>32)));
		}

		a_n += ((uint32_t)ix[z]);
	}



	for (k = p_sidx; k < p_eidx; k++) {
		i = raw_idx->a[chain_a[k].off].qn; 
		qs = ((raw_chn->a[i].qs<<1)>>1); qe = raw_chn->a[i].qe;
		ts = raw_chn->a[i].ts; te = raw_chn->a[i].te;
		for (;i>=0;) {
			// fprintf(stderr, "--[M::%s::i->%ld]\n", __func__, i);
			if(raw_chn->a[i].qs&mk) raw_chn->a[i].qs -= mk;
			if(raw_chn->a[i].qs < qs) qs = raw_chn->a[i].qs;
        	if(raw_chn->a[i].ts < ts) ts = raw_chn->a[i].ts;
        	if(raw_chn->a[i].qe > qe) qe = raw_chn->a[i].qe;
        	if(raw_chn->a[i].te > te) te = raw_chn->a[i].te;
			

			if(raw_chn->a[i].tn == (uint32_t)-1) i = -1;
			else i = raw_chn->a[i].tn;
		}
		assert(raw_idx->a[chain_a[k].off].qs == qs && raw_idx->a[chain_a[k].off].qe == qe && 
				raw_idx->a[chain_a[k].off].ts == ts && raw_idx->a[chain_a[k].off].te == te);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movsd %xmm0, 0x78(%rsp)
movq %r9, 0x10(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, 0x70(%rsp)
movq %r8, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
cmpq %r8, %rcx
jge 0x1d17b0
movq 0xd0(%rsp), %rax
movq (%rax), %rax
movq 0xd8(%rsp), %rcx
movq (%rcx), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rsi
leaq (%rsi,%rsi,4), %rdi
movq 0x10(%rsp), %r8
movslq (%r8,%rdi,8), %rdi
leaq (%rdi,%rdi,8), %r8
leaq (%r8,%r8,2), %r8
addq %rdi, %r8
leaq (%rax,%r8), %rdi
movl (%rax,%r8), %ebx
leaq (%rbx,%rbx,8), %r8
leaq (%r8,%r8,2), %r10
addq %rbx, %r10
movl 0x4(%rcx,%r10), %r11d
movl 0x8(%rcx,%r10), %r8d
movl 0x10(%rcx,%r10), %r9d
movl 0x14(%rcx,%r10), %r10d
movq %r11, %r14
movq %r8, %r15
movq %r9, %r12
movq %r10, %r13
leaq (%rbx,%rbx,8), %r8
leaq (%r8,%r8,2), %rbp
addq %rbx, %rbp
movl 0x4(%rcx,%rbp), %ebx
movl 0x8(%rcx,%rbp), %r8d
cmpq %rbx, %r11
movq %rbx, %r11
cmovbq %r14, %r11
movl 0x10(%rcx,%rbp), %r9d
cmpq %r9, %r12
cmovbq %r12, %r9
cmpq %r8, %r15
cmovaq %r15, %r8
movl 0x14(%rcx,%rbp), %r10d
cmpq %r10, %r13
cmovaq %r13, %r10
orl $0x80000000, %ebx       # imm = 0x80000000
movl %ebx, 0x4(%rcx,%rbp)
movl 0xc(%rcx,%rbp), %ebx
cmpq %rdx, %rbx
jne 0x1d1714
movl 0x4(%rdi), %ebx
cmpq %rbx, %r11
jne 0x1d1c97
movl 0x8(%rdi), %r11d
cmpq %r11, %r8
jne 0x1d1c97
movl 0x10(%rdi), %r8d
cmpq %r8, %r9
jne 0x1d1c97
movl 0x14(%rdi), %edi
cmpq %rdi, %r10
jne 0x1d1c97
incq %rsi
cmpq 0x8(%rsp), %rsi
jne 0x1d16d5
cmpq $0x0, 0x28(%rsp)
movq 0x20(%rsp), %rdx
jle 0x1d1b3c
movq 0xe0(%rsp), %r14
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %edi, %edi
movq (%rdx,%rsi,8), %rax
movl %eax, %ecx
testq %rcx, %rcx
je 0x1d1b16
movq %rsi, 0x60(%rsp)
addq %rdi, %rcx
xorl %r9d, %r9d
movq %rdi, 0x58(%rsp)
movq %rcx, 0x80(%rsp)
movq %r9, 0x90(%rsp)
movq 0xd0(%rsp), %rax
movq (%rax), %rcx
movq %rdi, 0x88(%rsp)
leaq (%rdi,%rdi,4), %rax
movq 0x10(%rsp), %rdx
leaq (%rdx,%rax,8), %rax
movq %rax, (%rsp)
movslq (%rax), %rax
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
leaq (%rcx,%rdx), %rax
movl (%rcx,%rdx), %edx
movq 0xd8(%rsp), %rcx
movq (%rcx), %rsi
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
movl 0x4(%rsi,%rcx), %r8d
movl 0x8(%rsi,%rcx), %edi
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl 0x10(%rsi,%rcx), %r9d
movl 0x14(%rsi,%rcx), %r10d
xorl %ecx, %ecx
movq %r8, %r11
movq %rdi, %rbx
movq %r9, %r15
movq %r10, %r13
leaq (%rdx,%rdx,8), %rdi
leaq (%rdi,%rdi,2), %rbp
addq %rdx, %rbp
movl 0x4(%rsi,%rbp), %r8d
movl 0x8(%rsi,%rbp), %edi
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
cmpq %r8, %r11
cmovbq %r11, %r8
movl 0x10(%rsi,%rbp), %r9d
cmpq %r9, %r15
cmovbq %r15, %r9
cmpq %rdi, %rbx
cmovaq %rbx, %rdi
movl 0x14(%rsi,%rbp), %r10d
cmpq %r10, %r13
cmovaq %r13, %r10
movq %rdx, (%r14,%rcx,8)
incq %rcx
movl 0xc(%rsi,%rbp), %edx
cmpq %r12, %rdx
jne 0x1d186d
movl 0x4(%rax), %edx
cmpq %rdx, %r8
jne 0x1d1c78
movl 0x8(%rax), %edx
cmpq %rdx, %rdi
jne 0x1d1c78
movl 0x10(%rax), %edx
cmpq %rdx, %r9
jne 0x1d1c78
movl 0x14(%rax), %edx
cmpq %rdx, %r10
jne 0x1d1c78
movl 0xc(%rax), %r8d
subq $0x8, %rsp
movq 0x78(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rdx
movq 0xf0(%rsp), %r9
movsd 0x80(%rsp), %xmm0
leaq 0x38(%rsp), %rax
pushq %rax
callq 0x1d13a4
addq $0x10, %rsp
movq 0xd0(%rsp), %rax
movq (%rax), %rax
movq (%rsp), %rcx
movslq (%rcx), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0xc(%rax,%rdx), %ecx
movl 0x18(%rax,%rdx), %eax
shrdl $0x1f, %ecx, %eax
movl %eax, 0x38(%rsp)
movq (%rbx), %rdx
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rdx
movl (%rdx,%rcx,8), %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movslq 0x44(%rsp), %rcx
movslq 0x3c(%rsp), %rdx
movslq 0x40(%rsp), %rdi
movq %rbp, %rsi
subq %rdi, %rsi
movq %rbp, %r8
subq %rdx, %r8
testb $0x1, %al
cmoveq %rdx, %rsi
cmoveq %rdi, %r8
movslq 0x48(%rsp), %rdi
movl %esi, %edx
subl %ecx, %edx
movq 0xf0(%rsp), %r11
movq %r11, %r9
subq %rdi, %r9
movq %rbp, %r10
subq %r8, %r10
addl %r9d, %r8d
leal (%r10,%rdi), %r13d
movl %ecx, %r15d
subl %esi, %r15d
cmpq %r10, %r9
cmovgl %ebp, %r8d
cmovlel %r11d, %r13d
cmpq %rcx, %rsi
movl $0x0, %ecx
cmovll %ecx, %edx
cmovgel %ecx, %r15d
movl %ebp, %ebx
subl %edx, %ebx
testb $0x1, %al
cmovel %r8d, %ebx
subl %r8d, %ebp
testb $0x1, %al
movq (%rsp), %rax
movl %r15d, 0x44(%rsp)
movl %r13d, 0x48(%rsp)
cmovel %edx, %ebp
movl %ebp, 0x3c(%rsp)
movl %ebx, 0x40(%rsp)
movl 0x1c(%rax), %ecx
movslq 0x4c(%rsp), %r8
cmpl %r8d, %ecx
jne 0x1d1a26
cmpl %r15d, 0x14(%rax)
jne 0x1d1a26
cmpl %r13d, 0x18(%rax)
jne 0x1d1a26
cmpl %ebp, 0xc(%rax)
jne 0x1d1a26
cmpl %ebx, 0x10(%rax)
je 0x1d1aab
movq 0xc35b3(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
leaq 0x70ec5(%rip), %rsi     # 0x2428fc
leaq 0x70eec(%rip), %rdx     # 0x24292a
xorl %eax, %eax
movq %r8, 0x68(%rsp)
callq 0x22b0
movq 0xc358f(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
movq (%rsp), %rax
movl 0x14(%rax), %ecx
movq (%rsp), %rax
movl 0x18(%rax), %r9d
movq (%rsp), %rax
movl 0xc(%rax), %r10d
movq (%rsp), %rax
movl 0x10(%rax), %r11d
subq $0x8, %rsp
leaq 0x70ebc(%rip), %rsi     # 0x24293a
leaq 0x70ea5(%rip), %rdx     # 0x24292a
movl %r15d, %r8d
xorl %eax, %eax
pushq %rbx
pushq %r11
pushq %rbp
pushq %r10
pushq %r13
callq 0x22b0
movq 0x98(%rsp), %r8
movq 0x30(%rsp), %rax
addq $0x30, %rsp
movl 0x1c(%rax), %ecx
cmpl %r8d, %ecx
jne 0x1d1c59
cmpl %r15d, 0x14(%rax)
jne 0x1d1c59
cmpl %r13d, 0x18(%rax)
jne 0x1d1c59
cmpl %ebp, 0xc(%rax)
jne 0x1d1c59
cmpl %ebx, 0x10(%rax)
jne 0x1d1c59
movq 0x90(%rsp), %r9
addq %r8, %r9
movq 0x88(%rsp), %rdi
incq %rdi
movq 0x80(%rsp), %rcx
cmpq %rcx, %rdi
jb 0x1d17fa
movq 0x20(%rsp), %rdx
movq 0x60(%rsp), %rsi
movq (%rdx,%rsi,8), %rax
movq 0x58(%rsp), %rdi
jmp 0x1d1b19
xorl %r9d, %r9d
movq %rax, %rcx
shrq $0x20, %rcx
cmpq %rcx, %r9
jl 0x1d1cd5
movl %eax, %eax
addq %rax, %rdi
incq %rsi
cmpq 0x28(%rsp), %rsi
jne 0x1d17d3
movq 0x18(%rsp), %r15
cmpq 0x8(%rsp), %r15
jge 0x1d1c47
movq 0xd0(%rsp), %rax
movq (%rax), %rax
movq 0xd8(%rsp), %rcx
movq (%rcx), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq (%r15,%r15,4), %rsi
movq 0x10(%rsp), %rdi
movslq (%rdi,%rsi,8), %rsi
leaq (%rsi,%rsi,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rsi, %rdi
leaq (%rax,%rdi), %rsi
movl (%rax,%rdi), %r11d
leaq (%r11,%r11,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %r11, %rdi
movl 0x4(%rcx,%rdi), %r10d
movl 0x8(%rcx,%rdi), %r8d
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
movl 0x10(%rcx,%rdi), %r9d
movl 0x14(%rcx,%rdi), %edi
leaq (%r11,%r11,8), %rbx
leaq (%rbx,%rbx,2), %rbx
addq %r11, %rbx
movl 0x4(%rcx,%rbx), %r11d
testl %r11d, %r11d
jns 0x1d1bd3
leaq (%rcx,%rbx), %r14
addq $0x4, %r14
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
movl %r11d, (%r14)
movl %r11d, %r11d
cmpq %r11, %r10
cmovaeq %r11, %r10
movl 0x10(%rcx,%rbx), %r11d
cmpq %r11, %r9
cmovaeq %r11, %r9
movl 0x8(%rcx,%rbx), %r11d
cmpq %r11, %r8
cmovbeq %r11, %r8
movl 0xc(%rcx,%rbx), %r11d
movl 0x14(%rcx,%rbx), %ebx
cmpq %rbx, %rdi
cmovbeq %rbx, %rdi
cmpq %rdx, %r11
jne 0x1d1bac
movl 0x4(%rsi), %r11d
cmpq %r11, %r10
jne 0x1d1cb6
movl 0x8(%rsi), %r10d
cmpq %r10, %r8
jne 0x1d1cb6
movl 0x10(%rsi), %r8d
cmpq %r8, %r9
jne 0x1d1cb6
movl 0x14(%rsi), %esi
cmpq %rsi, %rdi
jne 0x1d1cb6
incq %r15
cmpq 0x8(%rsp), %r15
jne 0x1d1b67
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x70d5c(%rip), %rdi     # 0x2429bc
leaq 0x6dff4(%rip), %rsi     # 0x23fc5b
leaq 0x70bef(%rip), %rcx     # 0x24285d
movl $0x39ee, %edx           # imm = 0x39EE
callq 0x2110
leaq 0x70b45(%rip), %rdi     # 0x2427c4
leaq 0x6dfd5(%rip), %rsi     # 0x23fc5b
leaq 0x70bd0(%rip), %rcx     # 0x24285d
movl $0x39e0, %edx           # imm = 0x39E0
callq 0x2110
leaq 0x70b26(%rip), %rdi     # 0x2427c4
leaq 0x6dfb6(%rip), %rsi     # 0x23fc5b
leaq 0x70bb1(%rip), %rcx     # 0x24285d
movl $0x39c5, %edx           # imm = 0x39C5
callq 0x2110
leaq 0x70b07(%rip), %rdi     # 0x2427c4
leaq 0x6df97(%rip), %rsi     # 0x23fc5b
leaq 0x70b92(%rip), %rcx     # 0x24285d
movl $0x3a0a, %edx           # imm = 0x3A0A
callq 0x2110
leaq 0x70d65(%rip), %rdi     # 0x242a41
leaq 0x6df78(%rip), %rsi     # 0x23fc5b
leaq 0x70b73(%rip), %rcx     # 0x24285d
movl $0x39f1, %edx           # imm = 0x39F1
callq 0x2110