// File: /workspace/github_cpp_makefile_star2_O2/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, 0x70(%rsp)
movq %rdx, %r15
movq %rdi, %r13
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq $0x0, 0x58(%rsp)
movq $0x0, 0x60(%rsp)
movq %rsi, 0x30(%rsp)
imulq $0x28, %r15, %rbx
addq %rsi, %rbx
testq %r15, %r15
jle 0x16734b
decq %r15
movl -0x20(%rbx), %eax
cmpq %r14, %rax
jne 0x1670f3
movl -0x4(%rbx), %r12d
addq $-0x28, %rbx
cmpq %r14, %r12
je 0x1670d0
jmp 0x167172
movq 0xebee6(%rip), %rcx     # 0x252fe0
movq (%rcx), %rdi
movl %eax, %ecx
shrl %ecx
imulq $0x28, %rcx, %rdx
incl %ecx
movq 0x10(%r13), %rsi
movl (%rsi,%rdx), %edx
shrl $0x1f, %edx
leaq 0x7f573(%rip), %rsi     # 0x1e668b
movsbl (%rdx,%rsi), %r8d
andl $0x1, %eax
leaq 0x7d0fc(%rip), %rdx     # 0x1e4223
movsbl (%rax,%rdx), %r9d
movl -0x14(%rbx), %eax
movq %rax, 0x38(%rsp)
movl -0x10(%rbx), %r11d
movl -0x28(%rbx), %r12d
movl -0x1c(%rbx), %ebp
movq %r13, %r10
movl -0x18(%rbx), %r13d
subq $0x8, %rsp
leaq 0x8b9a0(%rip), %rsi     # 0x1f2af1
movq %r15, %rdx
xorl %eax, %eax
pushq %r12
pushq %r13
movq %r10, %r13
pushq %rbp
pushq %r11
pushq 0x60(%rsp)
callq 0x22b0
addq $0x30, %rsp
jmp 0x1670e4
imulq $0x28, %r12, %rsi
addq 0x30(%rsp), %rsi
cmpq $0x0, 0x70(%rsp)
movq %rsi, 0x38(%rsp)
movq %r13, %rdi
leaq 0x50(%rsp), %rdx
leaq 0x48(%rsp), %rcx
leaq 0x28(%rsp), %r8
leaq 0x20(%rsp), %r9
jne 0x1671c5
callq 0x166527
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x40(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x8(%rsp), %r9
callq 0x166527
jmp 0x1671e9
callq 0x1665b6
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x40(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x8(%rsp), %r9
callq 0x1665b6
movq 0xebdf0(%rip), %rbp     # 0x252fe0
movq (%rbp), %rdi
movl 0x8(%rbx), %eax
movl %eax, %ecx
shrl %ecx
imulq $0x28, %rcx, %rdx
incl %ecx
movq 0x10(%r13), %rsi
movl (%rsi,%rdx), %edx
shrl $0x1f, %edx
leaq 0x7f479(%rip), %rbx     # 0x1e668b
movsbl (%rdx,%rbx), %r8d
andl $0x1, %eax
leaq 0x7d002(%rip), %rdx     # 0x1e4223
movsbl (%rax,%rdx), %r9d
subq $0x8, %rsp
leaq 0x8b8fe(%rip), %rsi     # 0x1f2b2f
movq %r15, %rdx
xorl %eax, %eax
pushq %r12
pushq 0x28(%rsp)
pushq 0x58(%rsp)
pushq 0x28(%rsp)
pushq 0x38(%rsp)
callq 0x22b0
addq $0x30, %rsp
movq (%rbp), %rdi
movq 0x38(%rsp), %rcx
movl 0x8(%rcx), %eax
movl 0x24(%rcx), %r10d
movl %eax, %ecx
shrl %ecx
imulq $0x28, %rcx, %rdx
incl %ecx
movq 0x10(%r13), %rsi
movl (%rsi,%rdx), %edx
shrl $0x1f, %edx
movsbl (%rdx,%rbx), %r8d
andl $0x1, %eax
leaq 0x7cf9f(%rip), %rdx     # 0x1e4223
movsbl (%rax,%rdx), %r9d
subq $0x8, %rsp
leaq 0x8b8e1(%rip), %rsi     # 0x1f2b75
movq %r15, %rdx
xorl %eax, %eax
pushq %r10
pushq 0x58(%rsp)
pushq 0x68(%rsp)
pushq 0x40(%rsp)
pushq 0x50(%rsp)
callq 0x22b0
addq $0x30, %rsp
movq 0x50(%rsp), %rcx
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
cmpq %rax, %rcx
jg 0x1672e1
movq 0x18(%rsp), %rdi
cmpq %rdi, %rdx
jg 0x1672e1
movq 0x28(%rsp), %r8
movq 0x10(%rsp), %r9
cmpq %r9, %r8
jle 0x167326
incq 0x60(%rsp)
movq 0x30(%rsp), %rsi
cmpq %rdx, %rcx
jg 0x16738f
movq 0x28(%rsp), %rcx
cmpq 0x20(%rsp), %rcx
jg 0x16738f
cmpq 0x18(%rsp), %rax
jg 0x16738f
incq 0x58(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rax
jle 0x1670c9
jmp 0x16738f
movq 0x8(%rsp), %rsi
cmpq %rsi, %r9
jg 0x1672e1
cmpq %rdi, %rax
jg 0x1672e1
movq 0x20(%rsp), %rdi
cmpq %rdi, %r8
jg 0x1672e1
cmpq %rdx, %rcx
jg 0x1672e1
cmpq %rsi, %rdi
jle 0x1672e6
jmp 0x1672e1
movq 0x60(%rsp), %r8
testq %r8, %r8
jne 0x167364
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xebc75(%rip), %rax     # 0x252fe0
movq (%rax), %rdi
leaq 0x8b8c0(%rip), %rsi     # 0x1f2c35
leaq 0x8b8e0(%rip), %rdx     # 0x1f2c5c
movq 0x58(%rsp), %rcx
movq 0x68(%rsp), %r9
xorl %eax, %eax
callq 0x22b0
jmp 0x167355
leaq 0x8b825(%rip), %rdi     # 0x1f2bbb
leaq 0x8a786(%rip), %rsi     # 0x1f1b23
leaq 0x8b83e(%rip), %rcx     # 0x1f2be2
movl $0x1286, %edx           # imm = 0x1286
callq 0x2110