// File: chhylp123[P]hifiasm/Correct.cpp
// Function: check_connect_rg(ul_idx_t const*, ug_opt_t const*, unsigned int, unsigned int, long, double, long)
uint64_t check_connect_rg(const ul_idx_t *uref, const ug_opt_t *uopt, uint32_t uv, uint32_t uw, int64_t bw, double diff_ec_ul, int64_t dq)
{
	int64_t dt = -1;
	if(uref->ug->u.a[uv>>1].circ || uref->ug->u.a[uw>>1].circ) return 0;
	uint32_t rv = (uref->ug->u.a[uv>>1].a[(uv&1)?(0):(uref->ug->u.a[uv>>1].n-1)]>>32)^(uv&1);
	uint32_t rw = (uref->ug->u.a[uw>>1].a[(uw&1)?(uref->ug->u.a[uw>>1].n-1):(0)]>>32)^(uw&1);
	ma_hit_t_alloc* src = uopt->sources;
	int64_t min_ovlp = uopt->min_ovlp;
	int64_t max_hang = uopt->max_hang;
	uint64_t z, qn, tn, x = rv>>1; int32_t r = 1; asg_arc_t e;
	for (z = 0; z < src[x].length; z++) {
		qn = Get_qn(src[x].buffer[z]); tn = Get_tn(src[x].buffer[z]);
		if(tn != (rw>>1)) continue;
		r = ma_hit2arc(&(src[x].buffer[z]), 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) != rv || e.v != rw) continue;
		dt = e.ol; 
		break;
	}
	if(dt < 0) return 0;
	int64_t diff = (dq>dt? dq-dt:dt-dq), mm = MAX(dq, dt);
	mm *= diff_ec_ul; if(mm < bw) mm = bw;
	if(diff <= mm) return 1;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movsd %xmm0, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $-0x1, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %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 0x72424
movq -0x10(%rbp), %rax
movq (%rax), %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 0x72431
movq $0x0, -0x8(%rbp)
jmp 0x7277f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0xb8(%rbp)
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7246a
xorl %eax, %eax
movl %eax, -0xbc(%rbp)
jmp 0x7248f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
subl $0x1, %eax
movl %eax, -0xbc(%rbp)
movq -0xb8(%rbp), %rax
movl -0xbc(%rbp), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl -0x1c(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
xorq %rcx, %rax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0xc8(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7250a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
subl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x72514
xorl %eax, %eax
movl %eax, -0xcc(%rbp)
jmp 0x72514
movq -0xc8(%rbp), %rax
movl -0xcc(%rbp), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl -0x20(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
xorq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movslq 0x44(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movslq 0x40(%rax), %rax
movq %rax, -0x60(%rbp)
movl -0x44(%rbp), %eax
shrl %eax
movl %eax, %eax
movq %rax, -0x80(%rbp)
movl $0x1, -0x84(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x50(%rbp), %rcx
imulq $0x18, -0x80(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x726ab
movq -0x50(%rbp), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x68(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, %eax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x68(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl -0x48(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x725ed
jmp 0x7269a
movq -0x50(%rbp), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rdi
imulq $0x28, -0x68(%rbp), %rax
addq %rax, %rdi
leaq 0x352cc5(%rip), %rax    # 0x3c52d0
movq 0x18(%rax), %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %esi
leaq 0x352cb0(%rip), %rax    # 0x3c52d0
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %edx
movq -0x60(%rbp), %rax
movl %eax, %ecx
leaq 0x3521bd(%rip), %rax    # 0x3c47f8
movss 0x158(%rax), %xmm0
movq -0x58(%rbp), %rax
movl %eax, %r8d
leaq -0xa0(%rbp), %r9
callq 0x72790
movl %eax, -0x84(%rbp)
cmpl $0x0, -0x84(%rbp)
jge 0x72667
jmp 0x7269a
movq -0xa0(%rbp), %rax
shrq $0x20, %rax
movl -0x44(%rbp), %ecx
cmpq %rcx, %rax
jne 0x72685
movl -0x98(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0x72687
jmp 0x7269a
movl -0x94(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x726ab
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x7257a
cmpq $0x0, -0x40(%rbp)
jge 0x726bf
movq $0x0, -0x8(%rbp)
jmp 0x7277f
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jle 0x726da
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0x726e9
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0x7270e
movq -0x38(%rbp), %rax
movq %rax, -0xe0(%rbp)
jmp 0x72719
movq -0x40(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movsd -0x30(%rbp), %xmm1
cvtsi2sdq -0xb0(%rbp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0x7275d
movq -0x28(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
cmpq -0xb0(%rbp), %rax
jg 0x72777
movq $0x1, -0x8(%rbp)
jmp 0x7277f
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax)