// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: bi_direction_hap_alignment_extention(ma_utg_t*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, float, int, unsigned long*, ma_hit_t_alloc*, asg_t*, R_to_U*, unsigned int, long long*, long long*)
void bi_direction_hap_alignment_extention(ma_utg_t* xReads, uint32_t xLeftBeg, uint32_t xLeftLen,
uint32_t xRightBeg, uint32_t xRightLen, uint32_t targetUid, uint32_t target_beg, uint32_t target_end,
float Hap_rate, int is_local, uint64_t* position_index, ma_hit_t_alloc* reverse_sources, asg_t *read_g, R_to_U* ruIndex,
uint32_t rev, long long* x_interval_beg, long long* x_interval_end)
{
    if(rev)
    {
        uint32_t k;
        k = xLeftBeg; xLeftBeg = xRightBeg; xRightBeg = k;
        k = xLeftLen; xLeftLen = xRightLen; xRightLen = k;
    }
    uint32_t n_matchLenLeft, x_max_countLeft, x_min_countLeft;
    uint32_t n_matchLenRight, x_max_countRight, x_min_countRight;
    n_matchLenLeft = x_max_countLeft = x_min_countLeft = 0;
    determin_hap_alignment_boundary_single_side(xReads->a+xLeftBeg, xLeftLen,
    target_beg, target_end, targetUid, x_max_countLeft, x_min_countLeft, 1, Hap_rate, is_local,
    position_index, reverse_sources, read_g, ruIndex, &n_matchLenLeft, &x_max_countLeft, 
    &x_min_countLeft);

    n_matchLenRight = x_max_countRight = x_min_countRight = 0;
    determin_hap_alignment_boundary_single_side(xReads->a+xRightBeg, xRightLen,
    target_beg, target_end, targetUid, x_max_countRight, x_min_countRight, 0, Hap_rate, is_local,
    position_index, reverse_sources, read_g, ruIndex, &n_matchLenRight, &x_max_countRight,
    &x_min_countRight);

    if(x_max_countLeft >= x_max_countRight)
    {
        determin_hap_alignment_boundary_single_side(xReads->a+xRightBeg, xRightLen,
        target_beg, target_end, targetUid, x_max_countLeft, x_min_countLeft, 0, Hap_rate, is_local,
        position_index, reverse_sources, read_g, ruIndex, &n_matchLenRight, &x_max_countRight,
        &x_min_countRight);
    }
    else
    {
        determin_hap_alignment_boundary_single_side(xReads->a+xLeftBeg, xLeftLen,
        target_beg, target_end, targetUid, x_max_countRight, x_min_countRight, 1, Hap_rate, is_local,
        position_index, reverse_sources, read_g, ruIndex, &n_matchLenLeft, &x_max_countLeft, 
        &x_min_countLeft);
    }

    (*x_interval_beg) = xLeftBeg + xLeftLen; (*x_interval_beg) -= n_matchLenLeft;
    (*x_interval_end) = xRightBeg + n_matchLenRight; (*x_interval_end) -= 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movl 0x48(%rbp), %eax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x30(%rbp)
movl %esi, -0x34(%rbp)
movl %edx, -0x38(%rbp)
movl %ecx, -0x3c(%rbp)
movl %r8d, -0x40(%rbp)
movl %r9d, -0x44(%rbp)
movss %xmm0, -0x48(%rbp)
cmpl $0x0, 0x48(%rbp)
je 0x17198c
movl -0x34(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x34(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x38(%rbp), %eax
movl %eax, %esi
movl 0x10(%rbp), %eax
movl %eax, %edx
movl 0x18(%rbp), %eax
movl %eax, %ecx
movl -0x44(%rbp), %eax
movl %eax, %r8d
movl -0x54(%rbp), %eax
movl %eax, %r9d
movl -0x58(%rbp), %eax
movq %rax, -0x88(%rbp)
movss -0x48(%rbp), %xmm0
movl 0x20(%rbp), %r13d
movq 0x28(%rbp), %r12
movq 0x30(%rbp), %r15
movq 0x38(%rbp), %r14
movq 0x40(%rbp), %rbx
leaq -0x50(%rbp), %r11
leaq -0x54(%rbp), %r10
leaq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x88(%rbp), %rax
movq %rax, (%rsp)
movq -0x80(%rbp), %rax
movq $0x1, 0x8(%rsp)
movl %r13d, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
callq 0x1713e0
movl $0x0, -0x64(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x3c(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x40(%rbp), %eax
movl %eax, %esi
movl 0x10(%rbp), %eax
movl %eax, %edx
movl 0x18(%rbp), %eax
movl %eax, %ecx
movl -0x44(%rbp), %eax
movl %eax, %r8d
movl -0x60(%rbp), %eax
movl %eax, %r9d
movl -0x64(%rbp), %eax
movq %rax, -0x78(%rbp)
movss -0x48(%rbp), %xmm0
movl 0x20(%rbp), %r13d
movq 0x28(%rbp), %r12
movq 0x30(%rbp), %r15
movq 0x38(%rbp), %r14
movq 0x40(%rbp), %rbx
xorl %eax, %eax
leaq -0x5c(%rbp), %r11
leaq -0x60(%rbp), %r10
leaq -0x64(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x78(%rbp), %rax
movq %rax, (%rsp)
movq -0x70(%rbp), %rax
movq $0x0, 0x8(%rsp)
movl %r13d, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
callq 0x1713e0
movl -0x54(%rbp), %eax
cmpl -0x60(%rbp), %eax
jb 0x171bba
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x3c(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x40(%rbp), %eax
movl %eax, %esi
movl 0x10(%rbp), %eax
movl %eax, %edx
movl 0x18(%rbp), %eax
movl %eax, %ecx
movl -0x44(%rbp), %eax
movl %eax, %r8d
movl -0x54(%rbp), %eax
movl %eax, %r9d
movl -0x58(%rbp), %eax
movq %rax, -0x98(%rbp)
movss -0x48(%rbp), %xmm0
movl 0x20(%rbp), %r13d
movq 0x28(%rbp), %r12
movq 0x30(%rbp), %r15
movq 0x38(%rbp), %r14
movq 0x40(%rbp), %rbx
xorl %eax, %eax
leaq -0x5c(%rbp), %r11
leaq -0x60(%rbp), %r10
leaq -0x64(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x98(%rbp), %rax
movq %rax, (%rsp)
movq -0x90(%rbp), %rax
movq $0x0, 0x8(%rsp)
movl %r13d, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
callq 0x1713e0
jmp 0x171c65
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x34(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x38(%rbp), %eax
movl %eax, %esi
movl 0x10(%rbp), %eax
movl %eax, %edx
movl 0x18(%rbp), %eax
movl %eax, %ecx
movl -0x44(%rbp), %eax
movl %eax, %r8d
movl -0x60(%rbp), %eax
movl %eax, %r9d
movl -0x64(%rbp), %eax
movq %rax, -0xa8(%rbp)
movss -0x48(%rbp), %xmm0
movl 0x20(%rbp), %r13d
movq 0x28(%rbp), %r12
movq 0x30(%rbp), %r15
movq 0x38(%rbp), %r14
movq 0x40(%rbp), %rbx
leaq -0x50(%rbp), %r11
leaq -0x54(%rbp), %r10
leaq -0x58(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, (%rsp)
movq -0xa0(%rbp), %rax
movq $0x1, 0x8(%rsp)
movl %r13d, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
callq 0x1713e0
movl -0x34(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x50(%rbp), %rax
movq %rcx, (%rax)
movl -0x50(%rbp), %eax
movl %eax, %edx
movq 0x50(%rbp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movl -0x3c(%rbp), %eax
addl -0x5c(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x58(%rbp), %rax
movq %rcx, (%rax)
movq 0x58(%rbp), %rax
movq (%rax), %rcx
subq $0x1, %rcx
movq %rcx, (%rax)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)