// File: /workspace/github_cpp_makefile_star2_O1/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, 0x18(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, 0x70(%rsp)
movq %r8, 0x10(%rsp)
movq %rcx, 0x20(%rsp)
cmpq %r8, %rcx
jge 0x1c77fe
movq 0xd0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movq 0xd8(%rsp), %rax
movq (%rax), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq $-0x1, %rsi
movq 0x20(%rsp), %rdi
leaq (%rdi,%rdi,4), %r8
movq 0x18(%rsp), %rax
movslq (%rax,%r8,8), %r8
leaq (%r8,%r8,8), %r9
leaq (%r9,%r9,2), %r9
addq %r8, %r9
movq 0x8(%rsp), %rax
leaq (%rax,%r9), %r8
movl (%rax,%r9), %r14d
leaq (%r14,%r14,8), %r9
leaq (%r9,%r9,2), %r11
addq %r14, %r11
movl 0x4(%rcx,%r11), %ebx
movl 0x8(%rcx,%r11), %r9d
movl 0x10(%rcx,%r11), %r10d
movl 0x14(%rcx,%r11), %r11d
movq %rbx, %r15
movq %r9, %r12
movq %r10, %r13
movq %r11, %rbp
leaq (%r14,%r14,8), %r9
leaq (%r9,%r9,2), %rax
addq %r14, %rax
movl 0x4(%rcx,%rax), %r14d
movl 0x8(%rcx,%rax), %r9d
cmpq %r14, %rbx
movq %r14, %rbx
cmovbq %r15, %rbx
movl 0x10(%rcx,%rax), %r10d
cmpq %r10, %r13
cmovbq %r13, %r10
cmpq %r9, %r12
cmovaq %r12, %r9
movl 0x14(%rcx,%rax), %r11d
cmpq %r11, %rbp
cmovaq %rbp, %r11
orl $0x80000000, %r14d      # imm = 0x80000000
movl %r14d, 0x4(%rcx,%rax)
movl 0xc(%rcx,%rax), %r14d
cmpq %rdx, %r14
cmoveq %rsi, %r14
jne 0x1c7758
movl 0x4(%r8), %eax
cmpq %rax, %rbx
jne 0x1c7cf7
movl 0x8(%r8), %eax
cmpq %rax, %r9
jne 0x1c7cf7
movl 0x10(%r8), %eax
cmpq %rax, %r10
jne 0x1c7cf7
movl 0x14(%r8), %eax
cmpq %rax, %r11
jne 0x1c7cf7
incq %rdi
cmpq 0x10(%rsp), %rdi
jne 0x1c7714
cmpq $0x0, 0x28(%rsp)
jle 0x1c7b97
movq 0xe0(%rsp), %r11
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x30(%rsp), %rax
movq %rdx, 0x68(%rsp)
movl (%rax,%rdx,8), %eax
testq %rax, %rax
movq %rcx, 0x60(%rsp)
je 0x1c7b5f
addq %rcx, %rax
xorl %esi, %esi
movq %rcx, %rdx
movq %rax, 0x80(%rsp)
movq %rsi, 0x90(%rsp)
movq 0xd0(%rsp), %rax
movq (%rax), %rcx
movq %rdx, 0x88(%rsp)
leaq (%rdx,%rdx,4), %rax
movq 0x18(%rsp), %rdx
leaq (%rdx,%rax,8), %rax
movq %rax, 0x8(%rsp)
movslq (%rax), %rax
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
leaq (%rcx,%rdx), %rax
movq %rax, (%rsp)
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
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq $-0x1, %r14
movq %r11, %rbp
movq %r8, %r11
movq %rdi, %rbx
movq %r9, %r15
movq %r10, %r12
leaq (%rdx,%rdx,8), %rdi
leaq (%rdi,%rdi,2), %r13
addq %rdx, %r13
movl 0x4(%rsi,%r13), %r8d
movl 0x8(%rsi,%r13), %edi
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
cmpq %r8, %r11
cmovbq %r11, %r8
movq %rbp, %r11
movl 0x10(%rsi,%r13), %r9d
cmpq %r9, %r15
cmovbq %r15, %r9
cmpq %rdi, %rbx
cmovaq %rbx, %rdi
movl 0x14(%rsi,%r13), %r10d
cmpq %r10, %r12
cmovaq %r12, %r10
movq %rdx, (%rbp,%rcx,8)
incq %rcx
movl 0xc(%rsi,%r13), %edx
cmpq %rax, %rdx
cmoveq %r14, %rdx
jne 0x1c78c5
movq (%rsp), %rax
movl 0x4(%rax), %edx
cmpq %rdx, %r8
jne 0x1c7cd8
movl 0x8(%rax), %edx
cmpq %rdx, %rdi
jne 0x1c7cd8
movl 0x10(%rax), %edx
cmpq %rdx, %r9
jne 0x1c7cd8
movl 0x14(%rax), %edx
cmpq %rdx, %r10
jne 0x1c7cd8
movl 0xc(%rax), %r8d
subq $0x8, %rsp
movq 0x78(%rsp), %rbx
movq %rbx, %rdi
movq %r11, %rdx
movq 0xf0(%rsp), %r9
movsd 0x80(%rsp), %xmm0
leaq 0x40(%rsp), %rax
pushq %rax
callq 0x1c73c8
addq $0x10, %rsp
movq 0xd0(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rsp), %r14
movslq (%r14), %rax
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl 0xc(%rcx,%rdx), %esi
movl 0x18(%rcx,%rdx), %eax
shrdl $0x1f, %esi, %eax
movl %eax, 0x40(%rsp)
movq (%rbx), %rsi
movq 0x18(%rsi), %rsi
movq 0x20(%rsi), %rsi
movl 0xc(%rcx,%rdx), %ecx
movl (%rsi,%rcx,8), %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movslq 0x4c(%rsp), %rcx
movslq 0x44(%rsp), %rdx
movslq 0x48(%rsp), %rdi
movq %r13, %rsi
subq %rdi, %rsi
movq %r13, %r8
subq %rdx, %r8
testb $0x1, %al
cmoveq %rdx, %rsi
cmoveq %rdi, %r8
movslq 0x50(%rsp), %rdi
movl %esi, %edx
subl %ecx, %edx
movq 0xf0(%rsp), %r11
movq %r11, %r9
subq %rdi, %r9
movq %r13, %r10
subq %r8, %r10
addl %r9d, %r8d
leal (%r10,%rdi), %r12d
movl %ecx, %r15d
subl %esi, %r15d
cmpq %r10, %r9
cmovgl %r13d, %r8d
cmovlel %r11d, %r12d
cmpq %rcx, %rsi
movl $0x0, %ecx
cmovll %ecx, %edx
cmovgel %ecx, %r15d
movl %r13d, %ebx
subl %edx, %ebx
testb $0x1, %al
cmovel %r8d, %ebx
subl %r8d, %r13d
testb $0x1, %al
movl %r15d, 0x4c(%rsp)
movl %r12d, 0x50(%rsp)
cmovel %edx, %r13d
movl %r13d, 0x44(%rsp)
movl %ebx, 0x48(%rsp)
movl 0x1c(%r14), %ecx
movslq 0x54(%rsp), %r8
cmpl %r8d, %ecx
jne 0x1c7a94
cmpl %r15d, 0x14(%r14)
jne 0x1c7a94
cmpl %r12d, 0x18(%r14)
jne 0x1c7a94
cmpl %r13d, 0xc(%r14)
jne 0x1c7a94
cmpl %ebx, 0x10(%r14)
je 0x1c7b01
movq 0xc2545(%rip), %r14     # 0x289fe0
movq (%r14), %rdi
leaq 0x6eb87(%rip), %rsi     # 0x23662c
leaq 0x6ebae(%rip), %rdx     # 0x23665a
movq %r8, (%rsp)
movq (%rsp), %r8
xorl %eax, %eax
callq 0x22b0
movq (%r14), %rdi
movq 0x8(%rsp), %r14
movl 0x14(%r14), %ecx
movl 0x18(%r14), %r9d
movl 0xc(%r14), %r10d
movl 0x10(%r14), %r11d
subq $0x8, %rsp
leaq 0x6eb8c(%rip), %rsi     # 0x23666a
leaq 0x6eb75(%rip), %rdx     # 0x23665a
movl %r15d, %r8d
xorl %eax, %eax
pushq %rbx
pushq %r11
pushq %r13
pushq %r10
pushq %r12
callq 0x22b0
movq 0x30(%rsp), %r8
addq $0x30, %rsp
cmpl %r8d, 0x1c(%r14)
jne 0x1c7cb9
cmpl %r15d, 0x14(%r14)
jne 0x1c7cb9
cmpl %r12d, 0x18(%r14)
jne 0x1c7cb9
cmpl %r13d, 0xc(%r14)
jne 0x1c7cb9
cmpl %ebx, 0x10(%r14)
jne 0x1c7cb9
movq 0x90(%rsp), %rsi
addq %r8, %rsi
movq 0x88(%rsp), %rdx
incq %rdx
movq 0x80(%rsp), %rax
cmpq %rax, %rdx
movq %rbp, %r11
jb 0x1c7841
jmp 0x1c7b61
xorl %esi, %esi
movq 0x30(%rsp), %rax
movq 0x68(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rax, %rcx
shrq $0x20, %rcx
cmpq %rcx, %rsi
jl 0x1c7d35
movl %eax, %eax
movq 0x60(%rsp), %rcx
addq %rax, %rcx
incq %rdx
cmpq 0x28(%rsp), %rdx
jne 0x1c7816
movq 0x20(%rsp), %r15
cmpq 0x10(%rsp), %r15
jge 0x1c7ca7
movq 0xd0(%rsp), %rax
movq (%rax), %rax
movq 0xd8(%rsp), %rcx
movq (%rcx), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq $-0x1, %rsi
leaq (%r15,%r15,4), %rdi
movq 0x18(%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), %r8
addq %rbx, %r8
movl 0x4(%rcx,%r8), %r11d
movl 0x8(%rcx,%r8), %r9d
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
movl 0x10(%rcx,%r8), %r10d
movl 0x14(%rcx,%r8), %r8d
leaq (%rbx,%rbx,8), %r14
leaq (%r14,%r14,2), %r14
addq %rbx, %r14
leaq (%rcx,%r14), %rbx
addq $0x4, %rbx
movl (%rbx), %ebp
testl %ebp, %ebp
jns 0x1c7c30
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl %ebp, (%rbx)
movl (%rbx), %ebx
cmpq %rbx, %r11
cmovaeq %rbx, %r11
movl 0x10(%rcx,%r14), %ebx
cmpq %rbx, %r10
cmovaeq %rbx, %r10
movl 0x8(%rcx,%r14), %ebx
cmpq %rbx, %r9
cmovbeq %rbx, %r9
movl 0x14(%rcx,%r14), %ebx
cmpq %rbx, %r8
cmovbeq %rbx, %r8
movl 0xc(%rcx,%r14), %ebx
cmpq %rdx, %rbx
cmoveq %rsi, %rbx
jne 0x1c7c0f
movl 0x4(%rdi), %ebx
cmpq %rbx, %r11
jne 0x1c7d16
movl 0x8(%rdi), %r11d
cmpq %r11, %r9
jne 0x1c7d16
movl 0x10(%rdi), %r9d
cmpq %r9, %r10
jne 0x1c7d16
movl 0x14(%rdi), %edi
cmpq %rdi, %r8
jne 0x1c7d16
incq %r15
cmpq 0x10(%rsp), %r15
jne 0x1c7bc9
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6ea2c(%rip), %rdi     # 0x2366ec
leaq 0x6bcc4(%rip), %rsi     # 0x23398b
leaq 0x6e8bf(%rip), %rcx     # 0x23658d
movl $0x39ee, %edx           # imm = 0x39EE
callq 0x2110
leaq 0x6e815(%rip), %rdi     # 0x2364f4
leaq 0x6bca5(%rip), %rsi     # 0x23398b
leaq 0x6e8a0(%rip), %rcx     # 0x23658d
movl $0x39e0, %edx           # imm = 0x39E0
callq 0x2110
leaq 0x6e7f6(%rip), %rdi     # 0x2364f4
leaq 0x6bc86(%rip), %rsi     # 0x23398b
leaq 0x6e881(%rip), %rcx     # 0x23658d
movl $0x39c5, %edx           # imm = 0x39C5
callq 0x2110
leaq 0x6e7d7(%rip), %rdi     # 0x2364f4
leaq 0x6bc67(%rip), %rsi     # 0x23398b
leaq 0x6e862(%rip), %rcx     # 0x23658d
movl $0x3a0a, %edx           # imm = 0x3A0A
callq 0x2110
leaq 0x6ea35(%rip), %rdi     # 0x236771
leaq 0x6bc48(%rip), %rsi     # 0x23398b
leaq 0x6e843(%rip), %rcx     # 0x23658d
movl $0x39f1, %edx           # imm = 0x39F1
callq 0x2110