// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/inter.cpp
// Function: debug_intermediate_chain(ma_ug_t*, mg_lchain_t*, long, long, long)
void debug_intermediate_chain(ma_ug_t *ug, mg_lchain_t *a, int64_t a_n, int64_t is_uovlp, int64_t debug_i)
{
	int64_t k; mg_lchain_t *p, *c;
	int64_t prs, pre, pqs, pqe, crs, cre, cqs, cqe;
	int64_t tot = 0, fal = 0;
	for (k = a_n-1; k >= 0; k--) {
		c = &(a[k]); 
		if(c->v!=(uint32_t)-1) {
			fprintf(stderr, "+(%ld) [M::utg%.6u%c::%c] qs:%d, qe:%d, rs:%d, re:%d, off:%d\n", k, (c->v>>1)+1, "lc"[ug->u.a[c->v>>1].circ], "+-"[c->v&1],
			c->qs, c->qe, c->rs, c->re, c->off);
		}
		
		
		if(c->hash_pre != (uint32_t)-1) {
			p = &(a[c->hash_pre]); tot++;
			if(is_uovlp) {
				get_u_offset(ug, p, &prs, &pre, &pqs, &pqe);
			} else {
				get_r_offset(ug, p, &prs, &pre, &pqs, &pqe);
			}
			if(is_uovlp) {
				get_u_offset(ug, c, &crs, &cre, &cqs, &cqe);
			} else {
				get_r_offset(ug, c, &crs, &cre, &cqs, &cqe);
			}

			fprintf(stderr, "cur (%ld) [M::utg%.6u%c::%c] qs:%ld, qe:%ld, rs:%ld, re:%ld, pidx:%u\n", 
			k, (c->v>>1)+1, "lc"[ug->u.a[c->v>>1].circ], "+-"[c->v&1], cqs, cqe, crs, cre, c->hash_pre);

			fprintf(stderr, "pre (%ld) [M::utg%.6u%c::%c] qs:%ld, qe:%ld, rs:%ld, re:%ld, pidx:%u\n", 
			k, (p->v>>1)+1, "lc"[ug->u.a[p->v>>1].circ], "+-"[p->v&1], pqs, pqe, prs, pre, p->hash_pre);
			
			if((!(prs<=crs&&pre<=cre&&pqs<=cqs&&pqe<=cqe)) || (!(prs<=pre&&pqs<=pqe&&crs<=cre&&cqs<=cqe))) {
				fal++;
				// fprintf(stderr, "[M::%s::a_n->%ld, k->%ld]p->dist_pre:%d, c->dist_pre:%d, c->pre_idx:%u\n", __func__, a_n, k, p->dist_pre, c->dist_pre, c->hash_pre);
				// fprintf(stderr, "[M::%s::]prs->%ld, pre->%ld, pqs->%ld, pqe->%ld, crs->%ld, cre->%ld, cqs->%ld, cqe->%ld\n", 
				// __func__, prs, pre, pqs, pqe, crs, cre, cqs, cqe);
			}
			assert(prs<=pre&&pqs<=pqe&&crs<=cre&&cqs<=cqe);
			// assert(prs<=crs&&pre<=cre&&pqs<=cqs&&pqe<=cqe);
		}
	}	
	if(fal) fprintf(stderr, "[M::%s::tot->%ld, fal->%ld] ulid->%ld\n", __func__, tot, fal, debug_i);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
testq %rdx, %rdx
jle 0x1a6d97
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, (%rsp)
leaq 0x10(%rdi), %rax
movq %rax, 0x70(%rsp)
leaq (%rdx,%rdx,4), %rax
incq %r15
leaq (%rsi,%rax,8), %r12
addq $-0x28, %r12
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq $0x0, 0x38(%rsp)
xorl %ebp, %ebp
movq %rsi, 0x50(%rsp)
leaq -0x2(%r15), %r14
movl 0x8(%r12), %edi
cmpl $-0x1, %edi
jne 0x1a6b5e
movl 0x24(%r12), %r13d
cmpq %rax, %r13
jne 0x1a6b75
decq %r15
addq $-0x28, %r12
cmpq $0x1, %r15
jg 0x1a6b34
jmp 0x1a6da2
movq 0x70(%rsp), %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x29fcb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1a6b42
leaq (,%r13,4), %rax
addq %r13, %rax
leaq (%rbx,%rax,8), %rbx
cmpq $0x0, 0x60(%rsp)
jne 0x1a6bae
movq (%rsp), %rdi
movq %rbx, %rsi
leaq 0x48(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x28(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0x1a5e4b
jmp 0x1a6bce
movq (%rsp), %rdi
movq %rbx, %rsi
leaq 0x48(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x28(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0x1a5eda
movq %rbp, 0x58(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x1a6c00
movq (%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x40(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x8(%rsp), %r9
callq 0x1a5e4b
jmp 0x1a6c23
movq (%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x40(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x8(%rsp), %r9
callq 0x1a5eda
movq 0xe33b6(%rip), %rax     # 0x289fe0
movq (%rax), %rdi
movl 0x8(%r12), %eax
movl %eax, %ecx
shrl %ecx
leaq (%rcx,%rcx,4), %rdx
incl %ecx
movq 0x10(%rbp), %rsi
movl (%rsi,%rdx,8), %edx
shrl $0x1f, %edx
leaq 0x819de(%rip), %rsi     # 0x22862b
movsbl (%rdx,%rsi), %r8d
andl $0x1, %eax
leaq 0x7f567(%rip), %rdx     # 0x2261c3
movsbl (%rax,%rdx), %r9d
subq $0x8, %rsp
leaq 0x8dd2b(%rip), %rsi     # 0x234997
movq %r14, %rdx
xorl %eax, %eax
pushq %r13
pushq 0x28(%rsp)
pushq 0x58(%rsp)
pushq 0x28(%rsp)
pushq 0x38(%rsp)
callq 0x22b0
addq $0x30, %rsp
movq 0xe334d(%rip), %rax     # 0x289fe0
movq (%rax), %rdi
movl 0x8(%rbx), %eax
movl 0x24(%rbx), %r10d
movl %eax, %ecx
shrl %ecx
leaq (%rcx,%rcx,4), %rdx
incl %ecx
movq 0x10(%rbp), %rsi
movl (%rsi,%rdx,8), %edx
shrl $0x1f, %edx
leaq 0x81973(%rip), %rsi     # 0x22862b
movsbl (%rdx,%rsi), %r8d
andl $0x1, %eax
leaq 0x7f4fc(%rip), %rdx     # 0x2261c3
movsbl (%rax,%rdx), %r9d
subq $0x8, %rsp
leaq 0x8dd06(%rip), %rsi     # 0x2349dd
movq %r14, %rdx
xorl %eax, %eax
pushq %r10
pushq 0x40(%rsp)
pushq 0x60(%rsp)
pushq 0x40(%rsp)
pushq 0x50(%rsp)
callq 0x22b0
addq $0x30, %rsp
movq 0x48(%rsp), %rcx
movq 0x40(%rsp), %rax
cmpq %rax, %rcx
jg 0x1a6d24
movq 0x30(%rsp), %rdx
movq 0x18(%rsp), %rdi
cmpq %rdi, %rdx
jg 0x1a6d24
movq 0x28(%rsp), %r8
movq 0x10(%rsp), %r9
cmpq %r9, %r8
jle 0x1a6d72
incq 0x38(%rsp)
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %rbp
cmpq 0x30(%rsp), %rcx
jg 0x1a6de4
movq 0x28(%rsp), %rcx
cmpq 0x20(%rsp), %rcx
jg 0x1a6de4
cmpq 0x18(%rsp), %rax
jg 0x1a6de4
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rax
jg 0x1a6de4
incq %rbp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1a6b4c
movq 0x8(%rsp), %rsi
cmpq %rsi, %r9
jg 0x1a6d24
cmpq %rdi, %rax
jg 0x1a6d24
movq 0x20(%rsp), %rdi
cmpq %rdi, %r8
jg 0x1a6d24
cmpq %rdx, %rcx
jg 0x1a6d24
cmpq %rsi, %rdi
jle 0x1a6d29
jmp 0x1a6d24
xorl %ebp, %ebp
movq $0x0, 0x38(%rsp)
movq 0x38(%rsp), %r8
testq %r8, %r8
jne 0x1a6dbb
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xe321e(%rip), %rax     # 0x289fe0
movq (%rax), %rdi
leaq 0x8dcd1(%rip), %rsi     # 0x234a9d
leaq 0x8dcf1(%rip), %rdx     # 0x234ac4
movq %rbp, %rcx
movq 0x68(%rsp), %r9
xorl %eax, %eax
callq 0x22b0
jmp 0x1a6dac
leaq 0x8dc38(%rip), %rdi     # 0x234a23
leaq 0x8cb99(%rip), %rsi     # 0x23398b
leaq 0x8dc51(%rip), %rcx     # 0x234a4a
movl $0x1286, %edx           # imm = 0x1286
callq 0x2110