// File: chhylp123[P]hifiasm/inter.cpp
// Function: debug_ul_vec_t_chain(void*, asg_t const*, ul_vec_t*, st_mt_t*, vec_sp_node_t*)
void debug_ul_vec_t_chain(void *km, const asg_t *g, ul_vec_t *rch, st_mt_t *dst_done, vec_sp_node_t *out)
{
	if(rch->dd == 0) return;
	uint64_t k, i, v, w, nv; int64_t dd; asg_arc_t *av; 
	mg_path_dst_t dst; uint64_t dst_group; uc_block_t *a = rch->bb.a;
	for (k = 0; k < rch->bb.n; k++) {
		if(a[k].pidx != (uint32_t)-1) assert(a[a[k].pidx].aidx == k);
		if(a[k].aidx != (uint32_t)-1) assert(a[a[k].aidx].pidx == k);
		if(a[k].pidx == (uint32_t)-1) continue;

		v = (a[k].hid<<1)|a[k].rev; v ^= 1;
		w = (a[a[k].pidx].hid<<1)|a[a[k].pidx].rev; w ^= 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].pdis;
            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].pdis != 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].pdis, 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 -0x20(%rbp), %rax
movzbl 0x50(%rax), %eax
cmpl $0x0, %eax
jne 0x29baa2
jmp 0x29be62
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0xa8(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x29be62
movq -0xa8(%rbp), %rax
imulq $0x24, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpl $-0x1, 0x14(%rax)
je 0x29bb2c
movq -0xa8(%rbp), %rax
movq -0xa8(%rbp), %rcx
imulq $0x24, -0x38(%rbp), %rdx
addq %rdx, %rcx
movl 0x14(%rcx), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
cmpq -0x38(%rbp), %rax
jne 0x29bb0b
jmp 0x29bb2a
leaq 0xf60e0(%rip), %rdi     # 0x391bf2
leaq 0xf4d16(%rip), %rsi     # 0x39082f
movl $0x13e2, %edx           # imm = 0x13E2
leaq 0xf60e4(%rip), %rcx     # 0x391c09
callq 0x2130
jmp 0x29bb2c
movq -0xa8(%rbp), %rax
imulq $0x24, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpl $-0x1, 0x1c(%rax)
je 0x29bb8d
movq -0xa8(%rbp), %rax
movq -0xa8(%rbp), %rcx
imulq $0x24, -0x38(%rbp), %rdx
addq %rdx, %rcx
movl 0x1c(%rcx), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
cmpq -0x38(%rbp), %rax
jne 0x29bb6c
jmp 0x29bb8b
leaq 0xf60ef(%rip), %rdi     # 0x391c62
leaq 0xf4cb5(%rip), %rsi     # 0x39082f
movl $0x13e3, %edx           # imm = 0x13E3
leaq 0xf6083(%rip), %rcx     # 0x391c09
callq 0x2130
jmp 0x29bb8d
movq -0xa8(%rbp), %rax
imulq $0x24, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpl $-0x1, 0x14(%rax)
jne 0x29bba7
jmp 0x29be51
movq -0xa8(%rbp), %rax
imulq $0x24, -0x38(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
shll %eax
movq -0xa8(%rbp), %rcx
imulq $0x24, -0x38(%rbp), %rdx
addq %rdx, %rcx
movb 0x20(%rcx), %cl
shrb $0x5, %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
xorq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0xa8(%rbp), %rax
movq -0xa8(%rbp), %rcx
imulq $0x24, -0x38(%rbp), %rdx
addq %rdx, %rcx
movl 0x14(%rcx), %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
shll %eax
movq -0xa8(%rbp), %rcx
movq -0xa8(%rbp), %rdx
imulq $0x24, -0x38(%rbp), %rsi
addq %rsi, %rdx
movl 0x14(%rdx), %edx
imulq $0x24, %rdx, %rdx
addq %rdx, %rcx
movb 0x20(%rcx), %cl
shrb $0x5, %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
xorq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x48(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x29bcc3
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpq -0x50(%rbp), %rax
jne 0x29bcb3
jmp 0x29bcc3
jmp 0x29bcb5
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x29bc92
movq -0x40(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x29bce7
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %eax
movq %rax, -0x60(%rbp)
jmp 0x29bdad
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2100
movq -0x50(%rbp), %rax
movl %eax, -0x98(%rbp)
movq -0xa8(%rbp), %rax
imulq $0x24, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x94(%rbp)
movl $0x0, -0x90(%rbp)
movl -0x8c(%rbp), %eax
andl $0xbfffffff, %eax       # imm = 0xBFFFFFFF
orl $0x0, %eax
movl %eax, -0x8c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x48(%rbp), %rax
movl %eax, %edx
movl -0x94(%rbp), %r9d
movq -0x28(%rbp), %r11
movq -0x30(%rbp), %rax
movl $0x1, %ecx
leaq -0x98(%rbp), %r8
leaq -0xa0(%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 -0x7c(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0xa8(%rbp), %rax
imulq $0x24, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
cmpq -0x60(%rbp), %rax
je 0x29be4f
movq 0x128210(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x48(%rbp), %rax
shrq %rax
movl %eax, %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rdx
andq $0x1, %rdx
leaq 0xe70ad(%rip), %rax     # 0x382e9b
movsbl (%rax,%rdx), %r8d
movq -0x50(%rbp), %rax
shrq %rax
movl %eax, %r9d
addl $0x1, %r9d
movq -0x50(%rbp), %rdx
andq $0x1, %rdx
leaq 0xe708b(%rip), %rax     # 0x382e9b
movsbl (%rax,%rdx), %r11d
movq -0xa8(%rbp), %rax
imulq $0x24, -0x38(%rbp), %rdx
addq %rdx, %rax
movl 0x18(%rax), %r10d
movq -0x60(%rbp), %rax
leaq 0xf5e46(%rip), %rsi     # 0x391c79
leaq 0xf5e79(%rip), %rdx     # 0x391cb3
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x22a0
jmp 0x29be51
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x29bab9
addq $0xd8, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)