// File: chhylp123[P]hifiasm/inter.cpp
// Function: get_ug_edge_src(ma_ug_t*, ma_hit_t_alloc*, long, long, unsigned int, unsigned int)
ma_hit_t *get_ug_edge_src(ma_ug_t *ug, ma_hit_t_alloc *src, int64_t max_hang, int64_t min_ovlp, uint32_t uv, uint32_t uw)
{
	if(ug->u.a[uv>>1].circ || ug->u.a[uw>>1].circ) return NULL;
	uint32_t v, w, k, qn, tn; int32_t r; asg_arc_t t;
    v = ((uv&1)?(ug->u.a[uv>>1].start^1):(ug->u.a[uv>>1].end^1));
    w = ((uw&1)?(ug->u.a[uw>>1].end):(ug->u.a[uw>>1].start));
    ma_hit_t_alloc *x = &(src[v>>1]);

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

	return NULL;
}

// 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)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x291e10
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x291e1d
movq $0x0, -0x8(%rbp)
jmp 0x291ff2
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x291e49
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x291e68
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x291e97
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x70(%rbp)
jmp 0x291eb3
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x291fea
movq -0x68(%rbp), %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, -0x40(%rbp)
movq -0x68(%rbp), %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
movl -0x34(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x291fda
movl -0x44(%rbp), %eax
movl -0x38(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x291fda
movq -0x68(%rbp), %rax
movq (%rax), %rdi
movl -0x3c(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
leaq 0x133380(%rip), %rax    # 0x3c52d0
movq 0x18(%rax), %rax
movl -0x34(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %esi
leaq 0x133368(%rip), %rax    # 0x3c52d0
movq 0x18(%rax), %rax
movl -0x38(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movl %eax, %ecx
leaq 0x132872(%rip), %rax    # 0x3c47f8
movss 0x158(%rax), %xmm0
movq -0x28(%rbp), %rax
movl %eax, %r8d
leaq -0x60(%rbp), %r9
callq 0x287f40
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jge 0x291fa9
jmp 0x291fdc
movq -0x60(%rbp), %rax
shrq $0x20, %rax
movl -0x34(%rbp), %ecx
cmpq %rcx, %rax
jne 0x291fc1
movl -0x58(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0x291fc3
jmp 0x291fdc
movq -0x68(%rbp), %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x291ff2
jmp 0x291fdc
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x291ed6
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)