// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, -0x28(%rsp)
testq %rdi, %rdi
je 0x1d4c5a
movq 0x28(%rdi), %rax
movl %r8d, %edx
movq (%rax,%rdx,8), %r10
testl %r10d, %r10d
je 0x1d4c5a
movq 0x8(%rdi), %rax
movq %r10, %rdx
shrq $0x20, %rdx
movl %r10d, %edi
leaq (%rdx,%rdx,2), %r11
leaq (%rax,%r11,8), %rdx
addq $0xc, %rdx
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %r10
xorl %edi, %edi
cmpl $0x0, (%rdx,%rdi)
js 0x1d4c51
cmpl %r9d, -0x4(%rdx,%rdi)
je 0x1d4e3b
addq $0x18, %rdi
cmpq %rdi, %r10
jne 0x1d4c40
movq $-0x1, %rax
testq %rsi, %rsi
je 0x1d4e42
movl %r8d, %edx
shrl %edx
movq %rdx, -0x8(%rsp)
leaq (%rdx,%rdx,2), %rdx
movl 0xc(%rsi,%rdx,8), %edi
testq %rdi, %rdi
je 0x1d4e42
movq %rcx, -0x30(%rsp)
leaq (%rsi,%rdx,8), %rcx
movq (%rcx), %rsi
movl %r9d, %r10d
shrl %r10d
leaq 0xc1592(%rip), %rcx     # 0x296230
movq 0x18(%rcx), %rax
movq %rax, -0x20(%rsp)
leaq 0xc0aaa(%rip), %rcx     # 0x295758
movss 0x158(%rcx), %xmm0
movl %r8d, %eax
movq %rax, -0x18(%rsp)
movl %r9d, -0x34(%rsp)
andl $-0x2, %r9d
movl %r9d, -0x38(%rsp)
shlq $0x3, %rdi
leaq (%rdi,%rdi,4), %rax
movq %rax, -0x10(%rsp)
xorl %r15d, %r15d
movq (%rsi,%r15), %r12
movq %r12, %rcx
shrq $0x20, %rcx
cmpl %ecx, -0x8(%rsp)
jne 0x1d4da7
cmpl %r10d, 0xc(%rsi,%r15)
jne 0x1d4da7
movq -0x20(%rsp), %rax
movl (%rax,%r10,8), %ebp
movq 0x18(%rsi,%r15), %r13
testl %r13d, %r13d
js 0x1d4d23
movl 0x10(%rsi,%r15), %r9d
movl 0x14(%rsi,%r15), %eax
subl %eax, %ebp
movl %ebp, %r8d
movl %r9d, %ebp
jmp 0x1d4d32
movl 0x10(%rsi,%r15), %r9d
movl 0x14(%rsi,%r15), %eax
subl %eax, %ebp
movl %r9d, %r8d
movq -0x20(%rsp), %rdx
movl (%rdx,%rcx,8), %r14d
cmpl %r12d, %ebp
movl %r12d, %edi
cmovll %ebp, %edi
movl 0x8(%rsi,%r15), %r11d
movl %r14d, %ebx
subl %r11d, %ebx
cmpl %r8d, %ebx
movl %r8d, %ecx
cmovll %ebx, %ecx
cmpl -0x28(%rsp), %edi
jg 0x1d4da7
cmpl -0x28(%rsp), %ecx
jg 0x1d4da7
movl %r11d, %edx
subl %r12d, %edx
xorps %xmm1, %xmm1
cvtsi2ss %rdx, %xmm1
addl %edi, %edx
addl %ecx, %edx
xorps %xmm2, %xmm2
cvtsi2ss %rdx, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0x1d4da7
subl %r9d, %eax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
addl %edi, %ecx
addl %eax, %ecx
xorps %xmm2, %xmm2
cvtsi2ss %rcx, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
jbe 0x1d4db8
addq $0x28, %r15
cmpq %r15, -0x10(%rsp)
jne 0x1d4cdc
jmp 0x1d4e32
cmpl %r8d, %ebx
setl %al
setg %r9b
cmpl %ebp, %r12d
setg %bl
setl %dil
orb %r9b, %bl
cmpb $0x1, %bl
jne 0x1d4da7
orb %al, %dil
je 0x1d4da7
cmpl -0x30(%rsp), %edx
jl 0x1d4da7
cmpl -0x30(%rsp), %ecx
jl 0x1d4da7
addl %r11d, %r8d
subl %r8d, %r14d
movl %r12d, %eax
subl %ebp, %eax
cmovlel %r14d, %eax
testl %eax, %eax
js 0x1d4da7
xorl %edi, %edi
cmpl %ebp, %r12d
setle %dil
setg %cl
testl %r13d, %r13d
setns %dl
shrq $0x1f, %r12
andl $-0x2, %r12d
orl %r12d, %edi
cmpl -0x18(%rsp), %edi
jne 0x1d4da7
xorb %cl, %dl
movzbl %dl, %ecx
orl -0x38(%rsp), %ecx
cmpl -0x34(%rsp), %ecx
jne 0x1d4da7
movl %eax, %eax
jmp 0x1d4e42
movq $-0x1, %rax
jmp 0x1d4e42
leaq (%rax,%r11,8), %rax
movl (%rdi,%rax), %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq