// File: chhylp123[P]hifiasm/inter.cpp
// Function: specific_ovlp(ma_ug_t const*, ug_opt_t const*, unsigned int, unsigned int)
int64_t specific_ovlp(const ma_ug_t *ug, const ug_opt_t *uopt, const uint32_t v, const uint32_t w)
{
	if(ug->u.a[v>>1].circ || ug->u.a[w>>1].circ) return 0;
	uint32_t rv, rw, i; int32_t r;
	const ma_hit_t_alloc *x = NULL;
	asg_arc_t t; memset(&t, 0, sizeof(t));
	if(v&1) rv = ug->u.a[v>>1].start^1;
	else rv = ug->u.a[v>>1].end^1;
	if(w&1) rw = ug->u.a[v>>1].end;
	else rw = ug->u.a[v>>1].start;
	x = &(uopt->sources[rv>>1]);
	for (i = 0; i < x->length; i++) {
		if(Get_tn(x->buffer[i]) == (rw>>1)) {
			r = ma_hit2arc(&(x->buffer[i]), uopt->coverage_cut[rv>>1].e - uopt->coverage_cut[rv>>1].s, 
			uopt->coverage_cut[rw>>1].e - uopt->coverage_cut[rw>>1].s, uopt->max_hang, asm_opt.max_hang_rate, uopt->min_ovlp, &t);
			if(r < 0) return 0;
			if((t.ul>>32)!=rv || t.v!=rw) return 0;
			return t.ol;
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x2882a6
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x2882b3
movq $0x0, -0x8(%rbp)
jmp 0x2884ae
movq $0x0, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2882f7
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x288316
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x28833f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x28(%rbp)
jmp 0x28835b
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x24(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x2884a6
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl -0x28(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x288496
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movl -0x2c(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %esi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl %eax, %esi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x28(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x28(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl %eax, %edx
movq -0x18(%rbp), %rax
movl 0x40(%rax), %ecx
leaq 0x13c3c0(%rip), %rax    # 0x3c47f8
movss 0x158(%rax), %xmm0
movq -0x18(%rbp), %rax
movl 0x44(%rax), %r8d
leaq -0x50(%rbp), %r9
callq 0x287f40
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x288464
movq $0x0, -0x8(%rbp)
jmp 0x2884ae
movq -0x50(%rbp), %rax
shrq $0x20, %rax
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
jne 0x28847c
movl -0x48(%rbp), %eax
cmpl -0x28(%rbp), %eax
je 0x288486
movq $0x0, -0x8(%rbp)
jmp 0x2884ae
movl -0x44(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2884ae
jmp 0x288498
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x28837c
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)