// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r13
movq 0xc0(%rsp), %r14
movq 0xb8(%rsp), %r10
movl 0xa0(%rsp), %ebx
movl 0x90(%rsp), %ebp
cmpl $0x0, 0xc8(%rsp)
je 0x106e92
movl %edx, 0x18(%rsp)
movl %esi, 0x4(%rsp)
jmp 0x106ea0
movl %r8d, 0x18(%rsp)
movl %ecx, 0x4(%rsp)
movl %edx, %r8d
movl %esi, %ecx
xorl %r15d, %r15d
leaq 0x10(%rsp), %r12
movl %r15d, (%r12)
leaq 0x24(%rsp), %rax
movl %r15d, (%rax)
leaq 0x14(%rsp), %r11
movl %r15d, (%r11)
movl %ecx, %ecx
movq %rcx, 0x28(%rsp)
leaq (,%rcx,8), %rdi
addq 0x18(%r13), %rdi
movl %r8d, %esi
movl %ebp, %edx
movq %rdx, 0x48(%rsp)
movl 0x98(%rsp), %ecx
movq %rcx, 0x40(%rsp)
movq %r13, 0x38(%rsp)
movl %r9d, %ebp
movq %rsi, 0x30(%rsp)
movq %rbp, %r8
xorl %r9d, %r9d
movss %xmm0, (%rsp)
pushq %r12
pushq %rax
pushq %r11
pushq %r14
movq %r10, %r13
pushq %r10
movq 0xd8(%rsp), %r12
pushq %r12
movq 0xd8(%rsp), %rax
pushq %rax
pushq %rbx
pushq $0x1
pushq $0x0
callq 0x1066b9
addq $0x50, %rsp
leaq 0x8(%rsp), %rax
movl %r15d, (%rax)
leaq 0x54(%rsp), %r9
movl %r15d, (%r9)
leaq 0xc(%rsp), %rcx
movl %r15d, (%rcx)
movl 0x4(%rsp), %r15d
leaq (,%r15,8), %rdi
movq 0x38(%rsp), %rbx
addq 0x18(%rbx), %rdi
movl 0x18(%rsp), %esi
subq $0x50, %rsp
movq %rax, 0x48(%rsp)
movq %r9, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %r14, 0x30(%rsp)
movq %r13, 0x28(%rsp)
movq 0x90(%rsp), %r13
movq %r12, 0x20(%rsp)
movq 0x98(%rsp), %r12
movq 0xf8(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq %rsi, 0x68(%rsp)
movq %r12, %rdx
movq %r13, %rcx
movq %rbp, %r14
movq %rbp, %r8
movq %r9, %rbp
xorl %r9d, %r9d
movss 0x50(%rsp), %xmm0
callq 0x1066b9
leaq 0x74(%rsp), %r11
addq $0x50, %rsp
movl (%r11), %r9d
movl (%rbp), %eax
movq 0x18(%rbx), %rcx
cmpl %eax, %r9d
jae 0x107052
movq 0x28(%rsp), %rbx
leaq (%rcx,%rbx,8), %rdi
movl 0x8(%rsp), %r10d
movq 0x30(%rsp), %rbp
movq %rbp, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %r14, %r8
movq %rax, %r9
movss (%rsp), %xmm0
leaq 0x10(%rsp), %rax
pushq %rax
pushq %r11
leaq 0x24(%rsp), %rax
pushq %rax
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
movl 0xd8(%rsp), %eax
pushq %rax
pushq $0x1
pushq %r10
callq 0x1066b9
addq $0x50, %rsp
movq %rbx, %rdx
jmp 0x1070b8
leaq (%rcx,%r15,8), %rdi
movl 0x10(%rsp), %eax
movq 0x18(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %r14, %r8
movss (%rsp), %xmm0
leaq 0x8(%rsp), %r10
pushq %r10
pushq %rbp
leaq 0x1c(%rsp), %r10
pushq %r10
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
pushq 0xd8(%rsp)
movl 0xd8(%rsp), %r10d
pushq %r10
pushq $0x0
pushq %rax
callq 0x1066b9
addq $0x50, %rsp
movq 0x30(%rsp), %rbp
movq 0x28(%rsp), %rdx
addl %ebp, %edx
movq 0xd0(%rsp), %rcx
movq %rdx, (%rcx)
movl 0x14(%rsp), %eax
subq %rax, %rdx
movq %rdx, (%rcx)
addl 0xc(%rsp), %r15d
decq %r15
movq 0xd8(%rsp), %rax
movq %r15, (%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq