// File: chhylp123[P]hifiasm/inter.cpp
// Function: debug_gchain(void*, asg_t const*, mg_lchain_t*, unsigned long, st_mt_t*, vec_sp_node_t*)
void debug_gchain(void *km, const asg_t *g, mg_lchain_t *a, uint64_t n, st_mt_t *dst_done, vec_sp_node_t *out)
{
	uint64_t k, i, v, w, nv; int64_t dd; asg_arc_t *av; mg_path_dst_t dst; uint64_t dst_group;
	for (k = 1; k < n; k++) {
		v = a[k].v^1; w = a[k-1].v^1;
		nv = asg_arc_n(g, v); av = asg_arc_a(g, v);
		for (i = 0; i < nv; i++) {
			if(av[i].v == w) break;
		}
		// if(i >= nv) {
		// 	// fprintf(stderr, "[M::%s::]\n", __func__);
		// 	fprintf(stderr, "[M::%s::]\tutg%.6dl(%c)\t->\tutg%.6dl(%c)\n", __func__, (int32_t)(v>>1)+1, "+-"[v&1], (int32_t)(w>>1)+1, "+-"[w&1]);
		// }
		if(i < nv) {
			dd = (int64_t)((uint32_t)(av[i].ul));
		} else {
			memset(&dst, 0, sizeof(dst));
            dst.v = w; 
            dst.target_dist = a[k-1].dist_pre;
            dst.target_hash = 0; dst.check_hash = 0;
			hc_shortest_k(km, g, v, 1, &dst, dst.target_dist, MG_MAX_SHORT_K, dst_done, &dst_group, out, NULL, 1, 0, 0);
			dd = dst.dist;
		}
		if(a[k-1].dist_pre != dd) {
			fprintf(stderr, "[M::%s::]\tutg%.6dl(%c)\t->\tutg%.6dl(%c)\tdist_pre:%d\td:%ld\n", __func__, (int32_t)(v>>1)+1, "+-"[v&1], 
			(int32_t)(w>>1)+1, "+-"[w&1], a[k-1].dist_pre, dd);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0xd8, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x2d47d6
movq -0x20(%rbp), %rax
imulq $0x28, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
subq $0x1, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x2d4627
movq -0x70(%rbp), %rax
imulq $0x18, -0x48(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpq -0x58(%rbp), %rax
jne 0x2d4617
jmp 0x2d4627
jmp 0x2d4619
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x2d45f6
movq -0x48(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x2d464b
movq -0x70(%rbp), %rax
imulq $0x18, -0x48(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %eax
movq %rax, -0x68(%rbp)
jmp 0x2d4718
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2100
movq -0x58(%rbp), %rax
movl %eax, -0xa0(%rbp)
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
subq $0x1, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movl %eax, -0x9c(%rbp)
movl $0x0, -0x98(%rbp)
movl -0x94(%rbp), %eax
andl $0xbfffffff, %eax       # imm = 0xBFFFFFFF
orl $0x0, %eax
movl %eax, -0x94(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x50(%rbp), %rax
movl %eax, %edx
movl -0x9c(%rbp), %r9d
movq -0x30(%rbp), %r11
movq -0x38(%rbp), %rax
movl $0x1, %ecx
leaq -0xa0(%rbp), %r8
leaq -0xa8(%rbp), %r10
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movl $0xf, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x1, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
callq 0x29be70
movslq -0x84(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
subq $0x1, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq 0x20(%rax), %rax
cmpq -0x68(%rbp), %rax
je 0x2d47c3
movq 0xef8a0(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
movq -0x50(%rbp), %rax
shrq %rax
movl %eax, %ecx
addl $0x1, %ecx
movq -0x50(%rbp), %rdx
andq $0x1, %rdx
leaq 0xae73d(%rip), %rax     # 0x382e9b
movsbl (%rax,%rdx), %r8d
movq -0x58(%rbp), %rax
shrq %rax
movl %eax, %r9d
addl $0x1, %r9d
movq -0x58(%rbp), %rdx
andq $0x1, %rdx
leaq 0xae71b(%rip), %rax     # 0x382e9b
movsbl (%rax,%rdx), %r11d
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rdx
subq $0x1, %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl 0x20(%rax), %r10d
movq -0x68(%rbp), %rax
leaq 0xbd4d2(%rip), %rsi     # 0x391c79
leaq 0xbf57c(%rip), %rdx     # 0x393d2a
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x22a0
jmp 0x2d47c5
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2d456c
addq $0xd8, %rsp
popq %rbx
popq %rbp
retq