// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/gchain1.c
// Function: bridge_shortk
static int32_t bridge_shortk(bridge_aux_t *aux, const mg_lchain_t *l0, const mg_lchain_t *l1)
{
	int32_t s, n_pathv;
	mg_path_dst_t dst;
	mg_pathv_t *p;
	memset(&dst, 0, sizeof(mg_path_dst_t));
	dst.v = l0->v ^ 1;
	assert(l1->dist_pre >= 0);
	dst.target_dist = l1->dist_pre;
	dst.target_hash = l1->hash_pre;
	dst.check_hash = 1;
	p = mg_shortest_k(aux->km, aux->g, l1->v^1, 1, &dst, dst.target_dist, MG_MAX_SHORT_K, &n_pathv);
	if (n_pathv == 0 || dst.target_hash != dst.hash) {
		fprintf(stderr, "[W::%s] %c%s[%d] -> %c%s[%d], dist=%d, target_dist=%d; chain skiped.\n", __func__, "><"[(l1->v^1)&1], aux->g->seg[l1->v>>1].name, l1->v^1, "><"[(l0->v^1)&1],
				aux->g->seg[l0->v>>1].name, l0->v^1, dst.dist, dst.target_dist);
		kfree(aux->km, p);
		return -1;
	}
	for (s = n_pathv - 2; s >= 1; --s) { // path found in a backward way, so we need to reverse it
		mg_llchain_t *q;
		if (aux->n_llc == aux->m_llc) KEXPAND(aux->km, aux->llc, aux->m_llc);
		q = &aux->llc[aux->n_llc++];
		q->off = q->cnt = q->score = 0;
		q->v = p[s].v^1; // when reversing a path, we also need to flip the orientation
		q->ed = -1;
	}
	kfree(aux->km, p);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
leaq -0x5c(%rbp), %rdi
xorl %esi, %esi
movl $0x24, %edx
callq 0x2190
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jl 0x29273
jmp 0x29292
leaq 0x14501(%rip), %rdi     # 0x3d77b
leaq 0x14133(%rip), %rsi     # 0x3d3b4
movl $0x146, %edx            # imm = 0x146
leaq 0x14500(%rip), %rcx     # 0x3d78d
callq 0x2170
movq -0x30(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
andl $0xbfffffff, %eax       # imm = 0xBFFFFFFF
orl $0x40000000, %eax       # imm = 0x40000000
movl %eax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
xorl $0x1, %edx
movl -0x58(%rbp), %r9d
movl $0x1, %ecx
leaq -0x5c(%rbp), %r8
leaq -0x38(%rbp), %rax
movl $0xf, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x19720
movq %rax, -0x68(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x29307
movl -0x54(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x293f5
movq 0x1bcea(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x13363(%rip), %rax     # 0x3c68c
movsbl (%rax,%rcx), %ecx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rdx
movl 0x8(%rdx), %edx
shrl %edx
movl %edx, %edx
shlq $0x6, %rdx
addq %rdx, %rax
movq 0x18(%rax), %r8
movq -0x30(%rbp), %rax
movl 0x8(%rax), %r9d
xorl $0x1, %r9d
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x13319(%rip), %rax     # 0x3c68c
movsbl (%rax,%rdx), %r14d
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rdx
movl 0x8(%rdx), %edx
shrl %edx
movl %edx, %edx
shlq $0x6, %rdx
addq %rdx, %rax
movq 0x18(%rax), %rbx
movq -0x28(%rbp), %rax
movl 0x8(%rax), %r11d
xorl $0x1, %r11d
movl -0x40(%rbp), %r10d
movl -0x58(%rbp), %eax
leaq 0x14429(%rip), %rsi     # 0x3d7dd
leaq 0x14468(%rip), %rdx     # 0x3d823
movl %r14d, (%rsp)
movq %rbx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movb $0x0, %al
callq 0x2210
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x68(%rbp), %rsi
callq 0x2670
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
jmp 0x2950c
movl -0x38(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x34(%rbp)
jl 0x294f5
movq -0x20(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x2947c
jmp 0x2941a
movq -0x20(%rbp), %rax
cmpl $0x4, 0x28(%rax)
jl 0x2943b
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x20(%rbp), %rcx
movl 0x28(%rcx), %ecx
sarl %ecx
addl %ecx, %eax
movl %eax, -0x74(%rbp)
jmp 0x29445
movl $0x10, %eax
movl %eax, -0x74(%rbp)
jmp 0x29445
movl -0x74(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x20(%rbp), %rax
movslq 0x28(%rax), %rax
imulq $0x14, %rax, %rdx
callq 0x2ae0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x2947c
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rdx
movl 0x24(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x24(%rdx)
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x70(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x70(%rbp), %rax
movl $0x0, (%rax)
movq -0x68(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
xorl $0x1, %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x70(%rbp), %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x293fe
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x68(%rbp), %rsi
callq 0x2670
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax,%rax)