// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: check_hap_match(unsigned int, unsigned int, unsigned int, unsigned int, unsigned long*, ma_hit_t_alloc*, asg_t*, R_to_U*, unsigned int*, unsigned int*)
inline void check_hap_match(uint32_t qn, uint32_t targetBeg, uint32_t targetEnd, uint32_t targetID, 
uint64_t* position_index, ma_hit_t_alloc* reverse_sources, asg_t *read_g, R_to_U* ruIndex, uint32_t* is_found, uint32_t* is_match)
{
    uint32_t j, tn, uId, is_Unitig, offset;
    (*is_found) = (*is_match) = 0;
    if(reverse_sources[qn].length > 0) (*is_found) = 1;
    for (j = 0; j < reverse_sources[qn].length; j++)
    {
        tn = Get_tn(reverse_sources[qn].buffer[j]);
        if(read_g->seq[tn].del == 1)
        {
            get_R_to_U(ruIndex, tn, &tn, &is_Unitig);
            if(tn == (uint32_t)-1 || is_Unitig == 1 || read_g->seq[tn].del == 1) continue;
        }


        get_R_to_U(ruIndex, tn, &uId, &is_Unitig);
        if(uId!=(uint32_t)-1 && is_Unitig == 1 && uId == targetID)
        {
            offset = (uint32_t)(position_index[tn]);
            if(offset >= targetBeg && offset <= targetEnd)
            {
                (*is_match) = 1;
                break;
            }                    
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movq %r8, -0x18(%rbp)
movq %r9, -0x20(%rbp)
movq 0x28(%rbp), %rax
movl $0x0, (%rax)
movq 0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl -0x4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jbe 0x18587e
movq 0x20(%rbp), %rax
movl $0x1, (%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
movl -0x4(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x185974
movq -0x20(%rbp), %rax
movl -0x4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x28(%rbp)
movq 0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x28(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x185910
movq 0x18(%rbp), %rdi
movl -0x28(%rbp), %esi
leaq -0x28(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x28(%rbp)
je 0x18590c
cmpl $0x1, -0x30(%rbp)
je 0x18590c
movq 0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x28(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x18590e
jmp 0x185966
jmp 0x185910
movq 0x18(%rbp), %rdi
movl -0x28(%rbp), %esi
leaq -0x2c(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x2c(%rbp)
je 0x185964
cmpl $0x1, -0x30(%rbp)
jne 0x185964
movl -0x2c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x185964
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x8(%rbp), %eax
jb 0x185962
movl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
ja 0x185962
movq 0x28(%rbp), %rax
movl $0x1, (%rax)
jmp 0x185974
jmp 0x185964
jmp 0x185966
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x185885
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)