// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, 0x18(%rsp)
movq %r8, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
movq %rdi, 0x8(%rsp)
movq %rcx, 0x28(%rsp)
cmpq $0x2, %rcx
jb 0x1d120b
movl $0x1, %r12d
movq %rsi, (%rsp)
leaq (%r12,%r12,4), %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,8), %r13
movl -0x20(%r13), %r15d
movl 0x8(%r13), %ebp
movq %rbp, %r14
xorq $0x1, %r14
movq %r15, %rbx
xorq $0x1, %rbx
movq 0x28(%rsi), %rax
movq (%rax,%r14,8), %rcx
movq %rcx, %rdi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %rdi
je 0x1d112c
movq 0x8(%rsi), %rax
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdx
addq $0x8, %rdx
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %rdi
xorl %r8d, %r8d
cmpl %ebx, (%rdx,%r8)
je 0x1d1191
addq $0x18, %r8
cmpq %r8, %rdi
jne 0x1d111d
leaq 0x48(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movl %ebx, 0x38(%rsp)
movl -0x8(%r13), %r9d
movl %r9d, 0x3c(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
subq $0x8, %rsp
xorps %xmm0, %xmm0
movq 0x10(%rsp), %rdi
movl %r14d, %edx
movl $0x1, %ecx
leaq 0x40(%rsp), %r8
pushq %rax
pushq $0x1
pushq %rax
pushq 0x38(%rsp)
leaq 0x58(%rsp), %rax
pushq %rax
pushq 0x40(%rsp)
pushq $0xf
callq 0x1b100b
movq 0x40(%rsp), %rsi
addq $0x40, %rsp
movslq 0x54(%rsp), %r10
jmp 0x1d1199
leaq (%rax,%rcx,8), %rax
movl (%r8,%rax), %r10d
movslq -0x8(%r13), %r11
cmpq %r11, %r10
jne 0x1d11b2
incq %r12
cmpq 0x28(%rsp), %r12
jne 0x1d10c6
jmp 0x1d120b
movq 0xc3e27(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
shrl %ebp
incl %ebp
andl $0x1, %r14d
leaq 0x61108(%rip), %rax     # 0x2322d3
movsbl (%r14,%rax), %r8d
shrl %r15d
incl %r15d
andl $0x1, %ebx
movsbl (%rbx,%rax), %ebx
subq $0x8, %rsp
leaq 0x6febd(%rip), %rsi     # 0x2410a5
leaq 0x71f67(%rip), %rdx     # 0x243156
movl %ebp, %ecx
movl %r15d, %r9d
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %rbx
callq 0x22b0
movq 0x20(%rsp), %rsi
addq $0x20, %rsp
jmp 0x1d11a2
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq