// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: get_base_boundary_advance(R_to_U*, ma_hit_t_alloc*, ma_sub_t*, asg_t*, unsigned long*, int, int, ma_utg_t*, ma_utg_t*, unsigned int, unsigned int, long long, long long, long long, long long, unsigned int, kvec_asg_arc_t_offset*, kvec_t_i32_warp*, kvec_t_i32_warp*, unsigned int*, unsigned int*, unsigned int*, unsigned int*)
void get_base_boundary_advance(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, ma_utg_t *xReads, ma_utg_t *yReads,
uint32_t xUid, uint32_t yUid, long long xBegIndex, long long xEndIndex, long long yBegIndex, long long yEndIndex, 
uint32_t rev, kvec_asg_arc_t_offset* u_buffer, kvec_t_i32_warp* tailIndex, kvec_t_i32_warp* prevIndex,
uint32_t* xBeg, uint32_t* xEnd, uint32_t* yBeg, uint32_t* yEnd)
{
    long long offset;
    long long new_xBeg, new_yBeg, new_xEnd, new_yEnd;
    long long new_xIdxBeg, new_yIdxBeg, new_xIdxEnd, new_yIdxEnd;

    (*xBeg) = (*xEnd) = (*yBeg) = (*yEnd) = (uint32_t)-1;
    if(!get_base_boundary_chain(ruIndex, reverse_sources, coverage_cut, read_g, position_index, 
    max_hang, min_ovlp, xReads, yReads, xUid, yUid, xBegIndex, xEndIndex, yBegIndex, yEndIndex, 
    rev, u_buffer, tailIndex, prevIndex))
    {
        return;
    }
    ///base
    new_xBeg = Get_xOff(u_buffer->a.a[tailIndex->a.a[0]].Off);
    new_yBeg = Get_yOff(u_buffer->a.a[tailIndex->a.a[0]].Off);
    new_xEnd = Get_xOff(u_buffer->a.a[tailIndex->a.a[tailIndex->a.n-1]].Off);
    new_yEnd = Get_yOff(u_buffer->a.a[tailIndex->a.a[tailIndex->a.n-1]].Off);

    if(new_xBeg > new_xEnd || new_yBeg > new_yEnd) return;
    
    classify_hap_overlap(new_xBeg, new_xEnd, xReads->len, new_yBeg, new_yEnd, yReads->len, 
                                                        &new_xBeg, &new_xEnd, &new_yBeg, &new_yEnd);

    if(rev) 
    {
        new_yBeg = yReads->len - new_yBeg - 1;
        new_yEnd = yReads->len - new_yEnd - 1;
        offset = new_yBeg; new_yBeg = new_yEnd; new_yEnd = offset;
    }
    ///idx
    get_idx_by_base(xReads, read_g, new_xBeg, new_xEnd, &new_xIdxBeg, &new_xIdxEnd);
    get_idx_by_base(yReads, read_g, new_yBeg, new_yEnd, &new_yIdxBeg, &new_yIdxEnd);
    if(new_xIdxBeg == -1 || new_xIdxEnd == -1 || new_yIdxBeg == -1 || new_yIdxEnd == -1) return;
    
    if(!get_base_boundary_chain(ruIndex, reverse_sources, coverage_cut, read_g, position_index, 
    max_hang, min_ovlp, xReads, yReads, xUid, yUid, new_xIdxBeg, new_xIdxEnd, new_yIdxBeg, 
    new_yIdxEnd, rev, u_buffer, tailIndex, prevIndex))
    {
        return;
    }

    (*xBeg) = Get_xOff(u_buffer->a.a[tailIndex->a.a[0]].Off);
    (*yBeg) = Get_yOff(u_buffer->a.a[tailIndex->a.a[0]].Off);
    (*xEnd) = Get_xOff(u_buffer->a.a[tailIndex->a.a[tailIndex->a.n-1]].Off);
    (*yEnd) = Get_yOff(u_buffer->a.a[tailIndex->a.a[tailIndex->a.n-1]].Off);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq 0x90(%rbp), %rax
movq 0x88(%rbp), %rax
movq 0x80(%rbp), %rax
movq 0x78(%rbp), %rax
movq 0x70(%rbp), %rax
movq 0x68(%rbp), %rax
movq 0x60(%rbp), %rax
movl 0x58(%rbp), %eax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movl 0x30(%rbp), %eax
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movl %r9d, -0x54(%rbp)
movq 0x90(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x88(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x80(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x78(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movl -0x54(%rbp), %r9d
movl 0x10(%rbp), %eax
movl %eax, -0xc4(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl 0x30(%rbp), %eax
movl %eax, -0xac(%rbp)
movq 0x38(%rbp), %r13
movq 0x40(%rbp), %r12
movq 0x48(%rbp), %r15
movq 0x50(%rbp), %r14
movl 0x58(%rbp), %ebx
movq 0x60(%rbp), %r11
movq 0x68(%rbp), %r10
movq 0x70(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, (%rsp)
movq -0xc0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xb8(%rbp), %rax
movq %rax, 0x10(%rsp)
movl -0xb0(%rbp), %eax
movl %eax, 0x18(%rsp)
movl -0xac(%rbp), %eax
movl %eax, 0x20(%rsp)
movq -0xa8(%rbp), %rax
movq %r13, 0x28(%rsp)
movq %r12, 0x30(%rsp)
movq %r15, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movl %ebx, 0x48(%rsp)
movq %r11, 0x50(%rsp)
movq %r10, 0x58(%rsp)
movq %rax, 0x60(%rsp)
callq 0x175740
cmpl $0x0, %eax
jne 0x175fb7
jmp 0x176350
movq 0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, %eax
movq %rax, -0x68(%rbp)
movq 0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, %eax
movq %rax, -0x70(%rbp)
movq 0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq 0x68(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, %eax
movq %rax, -0x78(%rbp)
movq 0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq 0x68(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, %eax
movq %rax, -0x80(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x78(%rbp), %rax
jg 0x17607b
movq -0x70(%rbp), %rax
cmpq -0x80(%rbp), %rax
jle 0x176080
jmp 0x176350
movq -0x68(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq 0x18(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
movq -0x70(%rbp), %rcx
movq -0x80(%rbp), %r8
movq 0x20(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r9d
leaq -0x68(%rbp), %rbx
leaq -0x78(%rbp), %r11
leaq -0x70(%rbp), %r10
leaq -0x80(%rbp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x170800
cmpl $0x0, 0x58(%rbp)
je 0x176127
movq 0x20(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
subq -0x70(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x70(%rbp)
movq 0x20(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
subq -0x80(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
movq 0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x78(%rbp), %rcx
leaq -0x88(%rbp), %r8
leaq -0x98(%rbp), %r9
callq 0x175620
movq 0x20(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x80(%rbp), %rcx
leaq -0x90(%rbp), %r8
leaq -0xa0(%rbp), %r9
callq 0x175620
cmpq $-0x1, -0x88(%rbp)
je 0x176195
cmpq $-0x1, -0x98(%rbp)
je 0x176195
cmpq $-0x1, -0x90(%rbp)
je 0x176195
cmpq $-0x1, -0xa0(%rbp)
jne 0x17619a
jmp 0x176350
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movl -0x54(%rbp), %r9d
movl 0x10(%rbp), %eax
movl %eax, -0xec(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0xd8(%rbp)
movl 0x30(%rbp), %eax
movl %eax, -0xd4(%rbp)
movq -0x88(%rbp), %r13
movq -0x98(%rbp), %r12
movq -0x90(%rbp), %r15
movq -0xa0(%rbp), %r14
movl 0x58(%rbp), %ebx
movq 0x60(%rbp), %r11
movq 0x68(%rbp), %r10
movq 0x70(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0xec(%rbp), %eax
movl %eax, (%rsp)
movq -0xe8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xe0(%rbp), %rax
movq %rax, 0x10(%rsp)
movl -0xd8(%rbp), %eax
movl %eax, 0x18(%rsp)
movl -0xd4(%rbp), %eax
movl %eax, 0x20(%rsp)
movq -0xd0(%rbp), %rax
movq %r13, 0x28(%rsp)
movq %r12, 0x30(%rsp)
movq %r15, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movl %ebx, 0x48(%rsp)
movq %r11, 0x50(%rsp)
movq %r10, 0x58(%rsp)
movq %rax, 0x60(%rsp)
callq 0x175740
cmpl $0x0, %eax
jne 0x176287
jmp 0x176350
movq 0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, %eax
movl %eax, %ecx
movq 0x78(%rbp), %rax
movl %ecx, (%rax)
movq 0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, %eax
movl %eax, %ecx
movq 0x88(%rbp), %rax
movl %ecx, (%rax)
movq 0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq 0x68(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, %eax
movl %eax, %ecx
movq 0x80(%rbp), %rax
movl %ecx, (%rax)
movq 0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq 0x68(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, %eax
movl %eax, %ecx
movq 0x90(%rbp), %rax
movl %ecx, (%rax)
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)