// File: chhylp123[P]hifiasm/inter.cpp
// Function: g_adjacent_dis_mul(asg_t const*, ma_hit_t_alloc*, long, long, unsigned int, unsigned int)
int64_t g_adjacent_dis_mul(const asg_t *g, ma_hit_t_alloc *src, int64_t max_hang, int64_t min_ovlp, uint32_t v, uint32_t w)
{
	uint32_t i;
	if(g) {
		uint32_t nv; asg_arc_t *av = NULL;
		nv = asg_arc_n(g, v); av = asg_arc_a(g, v);
		for (i = 0; i < nv; i++) {
			if(av[i].del || av[i].v != w) continue;
			return (uint32_t)av[i].ul;
		}
	}

	if(src) {
		ma_hit_t_alloc *x = &(src[v>>1]); uint32_t qn, tn; 
		int32_t r; asg_arc_t e;
		for (i = 0; i < x->length; i++) {
			qn = Get_qn(x->buffer[i]);
			tn = Get_tn(x->buffer[i]);
			if(qn == (v>>1) && tn == (w>>1)) {
				r = ma_hit2arc(&(x->buffer[i]), Get_READ_LENGTH(R_INF, qn), Get_READ_LENGTH(R_INF, tn),
					max_hang, asm_opt.max_hang_rate, min_ovlp, &e);
				if(r < 0) continue;
				if((e.ul>>32) != v || e.v != w) continue;
				return (uint32_t)e.ul;
			}
		}
	}
	
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x2db004
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x2c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x2db002
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x2dafd9
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x30(%rbp), %eax
je 0x2dafdb
jmp 0x2daff7
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2db137
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2dafa2
jmp 0x2db004
cmpq $0x0, -0x18(%rbp)
je 0x2db12f
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x2db12d
movq -0x48(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
movl -0x2c(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x2db11d
movl -0x50(%rbp), %eax
movl -0x30(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x2db11d
movq -0x48(%rbp), %rax
movq (%rax), %rdi
movl -0x34(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
leaq 0xea22a(%rip), %rax     # 0x3c52d0
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %esi
leaq 0xea216(%rip), %rax     # 0x3c52d0
movq 0x18(%rax), %rax
movl -0x50(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movl %eax, %ecx
leaq 0xe9724(%rip), %rax     # 0x3c47f8
movss 0x158(%rax), %xmm0
movq -0x28(%rbp), %rax
movl %eax, %r8d
leaq -0x70(%rbp), %r9
callq 0x287f40
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jge 0x2db0f7
jmp 0x2db11f
movq -0x70(%rbp), %rax
shrq $0x20, %rax
movl -0x2c(%rbp), %ecx
cmpq %rcx, %rax
jne 0x2db10f
movl -0x68(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x2db111
jmp 0x2db11f
movq -0x70(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2db137
jmp 0x2db11f
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2db02c
jmp 0x2db12f
movq $-0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)