// File: /workspace/github_cpp_makefile_star2_O3/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, 0x60(%rsp)
movq %rcx, 0x70(%rsp)
testq %rdx, %rdx
jle 0x1affdd
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, 0x40(%rsp)
leaq 0x10(%rdi), %r13
leaq (%rdx,%rdx,4), %rax
incq %r15
leaq (%rsi,%rax,8), %rbx
addq $-0x28, %rbx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq $0x0, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %r13, 0x68(%rsp)
leaq -0x2(%r15), %r12
movl 0x8(%rbx), %edi
cmpl $-0x1, %edi
jne 0x1afdb3
movl 0x24(%rbx), %ebp
cmpq %rax, %rbp
jne 0x1afdc8
decq %r15
addq $-0x28, %rbx
cmpq $0x1, %r15
ja 0x1afd8d
jmp 0x1affd3
movq %r13, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2938a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1afd99
leaq (,%rbp,4), %rax
addq %rbp, %rax
leaq (%r14,%rax,8), %r14
cmpq $0x0, 0x70(%rsp)
jne 0x1afe22
movq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq 0x38(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x20(%rsp), %r8
leaq 0x18(%rsp), %r9
callq 0x1af0c9
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x28(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %rsp, %r9
callq 0x1af0c9
jmp 0x1afe63
movq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq 0x38(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x20(%rsp), %r8
leaq 0x18(%rsp), %r9
callq 0x1af158
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x28(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %rsp, %r9
callq 0x1af158
movq 0xe5176(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
movl 0x8(%rbx), %eax
movl %eax, %ecx
shrl %ecx
leaq (%rcx,%rcx,4), %rdx
incl %ecx
movq 0x68(%rsp), %r13
movq (%r13), %rsi
movl (%rsi,%rdx,8), %edx
shrl $0x1f, %edx
leaq 0x848ab(%rip), %rsi     # 0x23473b
movsbl (%rdx,%rsi), %r8d
andl $0x1, %eax
leaq 0x82434(%rip), %rdx     # 0x2322d3
movsbl (%rax,%rdx), %r9d
subq $0x8, %rsp
leaq 0x90db8(%rip), %rsi     # 0x240c67
movq %r12, %rdx
xorl %eax, %eax
pushq %rbp
pushq 0x20(%rsp)
pushq 0x40(%rsp)
pushq 0x20(%rsp)
pushq 0x30(%rsp)
callq 0x22b0
addq $0x30, %rsp
movq 0xe510b(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
movl 0x8(%r14), %eax
movl 0x24(%r14), %r10d
movl %eax, %ecx
shrl %ecx
leaq (%rcx,%rcx,4), %rdx
incl %ecx
movq (%r13), %rsi
movl (%rsi,%rdx,8), %edx
shrl $0x1f, %edx
leaq 0x84840(%rip), %rsi     # 0x23473b
movsbl (%rdx,%rsi), %r8d
andl $0x1, %eax
leaq 0x823c9(%rip), %rdx     # 0x2322d3
movsbl (%rax,%rdx), %r9d
subq $0x8, %rsp
leaq 0x90d93(%rip), %rsi     # 0x240cad
movq %r12, %rdx
xorl %eax, %eax
pushq %r10
pushq 0x40(%rsp)
pushq 0x50(%rsp)
pushq 0x38(%rsp)
pushq 0x48(%rsp)
callq 0x22b0
addq $0x30, %rsp
movq 0x38(%rsp), %rcx
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rdx
cmpq %rax, %rcx
jg 0x1aff67
movq 0x10(%rsp), %rdi
cmpq %rdi, %rdx
jg 0x1aff67
movq 0x20(%rsp), %r8
movq 0x8(%rsp), %r9
cmpq %r9, %r8
jle 0x1affaf
incq 0x58(%rsp)
movq 0x48(%rsp), %r14
cmpq %rdx, %rcx
jg 0x1b0017
movq 0x20(%rsp), %rcx
cmpq 0x18(%rsp), %rcx
jg 0x1b0017
cmpq 0x10(%rsp), %rax
jg 0x1b0017
movq 0x8(%rsp), %rax
cmpq (%rsp), %rax
jg 0x1b0017
incq 0x50(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1afda1
movq (%rsp), %rsi
cmpq %rsi, %r9
jg 0x1aff67
cmpq %rdi, %rax
jg 0x1aff67
movq 0x18(%rsp), %rdi
cmpq %rdi, %r8
jg 0x1aff67
cmpq %rdx, %rcx
jg 0x1aff67
cmpq %rsi, %rdi
jle 0x1aff6c
jmp 0x1aff67
movq 0x58(%rsp), %r8
testq %r8, %r8
jne 0x1affec
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xe4fed(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
leaq 0x90d70(%rip), %rsi     # 0x240d6d
leaq 0x90d90(%rip), %rdx     # 0x240d94
movq 0x50(%rsp), %rcx
movq 0x60(%rsp), %r9
xorl %eax, %eax
callq 0x22b0
jmp 0x1affdd
leaq 0x90cd5(%rip), %rdi     # 0x240cf3
leaq 0x8fc36(%rip), %rsi     # 0x23fc5b
leaq 0x90cee(%rip), %rcx     # 0x240d1a
movl $0x1286, %edx           # imm = 0x1286
callq 0x2110