// File: /workspace/github_cpp_makefile_star2_O1/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 0x1c720f
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 0x1c7122
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 0x1c7195
addq $0x18, %r8
cmpq %r8, %rdi
jne 0x1c7113
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movl %ebx, 0x30(%rsp)
movl -0x8(%r13), %r9d
movl %r9d, 0x34(%rsp)
movl $0x0, 0x38(%rsp)
andb $-0x41, 0x3f(%rsp)
subq $0x8, %rsp
xorps %xmm0, %xmm0
movq 0x10(%rsp), %rdi
movl %r14d, %edx
movl $0x1, %ecx
leaq 0x38(%rsp), %r8
xorl %eax, %eax
pushq %rax
pushq $0x1
pushq %rax
pushq 0x38(%rsp)
leaq 0x88(%rsp), %rax
pushq %rax
pushq 0x40(%rsp)
pushq $0xf
callq 0x1a7dd4
movq 0x40(%rsp), %rsi
addq $0x40, %rsp
movslq 0x4c(%rsp), %r10
jmp 0x1c719d
leaq (%rax,%rcx,8), %rax
movl (%r8,%rax), %r10d
movslq -0x8(%r13), %r11
cmpq %r11, %r10
jne 0x1c71b6
incq %r12
cmpq 0x28(%rsp), %r12
jne 0x1c70bc
jmp 0x1c720f
movq 0xc2e23(%rip), %rax     # 0x289fe0
movq (%rax), %rdi
shrl %ebp
incl %ebp
andl $0x1, %r14d
leaq 0x5eff4(%rip), %rax     # 0x2261c3
movsbl (%r14,%rax), %r8d
shrl %r15d
incl %r15d
andl $0x1, %ebx
movsbl (%rbx,%rax), %ebx
subq $0x8, %rsp
leaq 0x6dbe9(%rip), %rsi     # 0x234dd5
leaq 0x6fc93(%rip), %rdx     # 0x236e86
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 0x1c71a6
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq