// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: determine_hap_overlap_type(hap_candidates*, ma_utg_t*, ma_utg_t*, R_to_U*, ma_hit_t_alloc*, ma_sub_t*, asg_t*, unsigned long*, int, int, unsigned int, unsigned int, long long*, long long*, long long*, long long*)
uint32_t determine_hap_overlap_type(hap_candidates* hap_can, ma_utg_t *xReads, ma_utg_t *yReads,
R_to_U* ruIndex, ma_hit_t_alloc* reverse_sources, ma_sub_t *coverage_cut, asg_t *read_g, 
uint64_t* position_index, int max_hang, int min_ovlp, uint32_t xUid, uint32_t yUid,
long long* r_x_pos_beg, long long* r_x_pos_end, long long* r_y_pos_beg, long long* r_y_pos_end)
{
    uint32_t x_pos_beg, y_pos_beg, x_pos_end, y_pos_end;
    /*************************x***************************/
    get_base_boundary(ruIndex, reverse_sources, coverage_cut, read_g, position_index, max_hang, 
    min_ovlp, xReads, yReads, xUid, yUid, Get_x_beg(*hap_can), Get_x_end(*hap_can), 
    Get_y_beg(*hap_can), Get_y_end(*hap_can), 0, Get_rev(*hap_can), &x_pos_beg, &y_pos_beg);

    get_base_boundary(ruIndex, reverse_sources, coverage_cut, read_g, position_index, max_hang, 
    min_ovlp, xReads, yReads, xUid, yUid, Get_x_beg(*hap_can), Get_x_end(*hap_can), 
    Get_y_beg(*hap_can), Get_y_end(*hap_can), 1, Get_rev(*hap_can), &x_pos_end, &y_pos_end);
    /*************************x***************************/

    if(x_pos_beg == (uint32_t)-1 || y_pos_beg == (uint32_t)-1 
                    || x_pos_end == (uint32_t)-1 || y_pos_end == (uint32_t)-1)
    {
        return (uint32_t)-1;
    }
    if(x_pos_beg > x_pos_end || y_pos_beg > y_pos_end) return (uint32_t)-1;
    
    /**
    #define X2Y 0
    #define Y2X 1
    #define XCY 2
    #define YCX 3
    **/
    return classify_hap_overlap(x_pos_beg, x_pos_end, xReads->len, y_pos_beg, y_pos_end, yReads->len, 
    r_x_pos_beg, r_x_pos_end, r_y_pos_beg, r_y_pos_end);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movl 0x38(%rbp), %eax
movl 0x30(%rbp), %eax
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdx, -0x48(%rbp)
movq %rcx, -0x50(%rbp)
movq %r8, -0x58(%rbp)
movq %r9, -0x60(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x18(%rbp), %r8
movl 0x20(%rbp), %r9d
movl 0x28(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl 0x30(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl 0x38(%rbp), %r13d
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %r12d
movq -0x38(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, %r15d
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r14d
movq -0x38(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, %ebx
movq -0x38(%rbp), %rax
movzbl 0x28(%rax), %r11d
xorl %eax, %eax
leaq -0x64(%rbp), %r10
leaq -0x68(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, (%rsp)
movq -0xb8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xb0(%rbp), %rax
movq %rax, 0x10(%rsp)
movl -0xa4(%rbp), %eax
movl %eax, 0x18(%rsp)
movq -0xa0(%rbp), %rax
movl %r13d, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq %r14, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
movl %r11d, 0x50(%rsp)
movq %r10, 0x58(%rsp)
movq %rax, 0x60(%rsp)
callq 0x172610
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x18(%rbp), %r8
movl 0x20(%rbp), %r9d
movl 0x28(%rbp), %eax
movl %eax, -0x94(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x88(%rbp)
movl 0x30(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl 0x38(%rbp), %r13d
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %r12d
movq -0x38(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, %r15d
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r14d
movq -0x38(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, %ebx
movq -0x38(%rbp), %rax
movzbl 0x28(%rax), %r11d
leaq -0x6c(%rbp), %r10
leaq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x94(%rbp), %eax
movl %eax, (%rsp)
movq -0x90(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x88(%rbp), %rax
movq %rax, 0x10(%rsp)
movl -0x7c(%rbp), %eax
movl %eax, 0x18(%rsp)
movq -0x78(%rbp), %rax
movl %r13d, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq %r14, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movl $0x1, 0x48(%rsp)
movl %r11d, 0x50(%rsp)
movq %r10, 0x58(%rsp)
movq %rax, 0x60(%rsp)
callq 0x172610
cmpl $-0x1, -0x64(%rbp)
je 0x177c22
cmpl $-0x1, -0x68(%rbp)
je 0x177c22
cmpl $-0x1, -0x6c(%rbp)
je 0x177c22
cmpl $-0x1, -0x70(%rbp)
jne 0x177c2b
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x177ca3
movl -0x64(%rbp), %eax
cmpl -0x6c(%rbp), %eax
ja 0x177c3b
movl -0x68(%rbp), %eax
cmpl -0x70(%rbp), %eax
jbe 0x177c44
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x177ca3
movl -0x64(%rbp), %eax
movl %eax, %edi
movl -0x6c(%rbp), %eax
movl %eax, %esi
movq -0x40(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
movl -0x68(%rbp), %eax
movl %eax, %ecx
movl -0x70(%rbp), %eax
movl %eax, %r8d
movq -0x48(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r9d
movq 0x40(%rbp), %rbx
movq 0x48(%rbp), %r11
movq 0x50(%rbp), %r10
movq 0x58(%rbp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x170800
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)