// File: /workspace/github_cpp_makefile_star2_O2/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), %rbp
movq 0xb8(%rsp), %r11
movq 0xb0(%rsp), %r10
movq 0xa8(%rsp), %rax
movl 0x90(%rsp), %ebx
cmpl $0x0, 0xc8(%rsp)
je 0xc8b56
movl %edx, 0x20(%rsp)
movl %esi, %r14d
jmp 0xc8b63
movl %r8d, 0x20(%rsp)
movl %ecx, %r14d
movl %edx, %r8d
movl %esi, %ecx
leaq 0x18(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x2c(%rsp), %r15
andl $0x0, (%r15)
leaq 0x1c(%rsp), %r12
andl $0x0, (%r12)
movl %ecx, %ecx
movq %rcx, 0x38(%rsp)
leaq (,%rcx,8), %rdi
addq 0x18(%r13), %rdi
movl %r8d, %esi
movl %ebx, %r8d
movq %r8, 0x48(%rsp)
movl 0x98(%rsp), %ecx
movq %r13, 0x50(%rsp)
movl %r9d, %ebx
subq $0x50, %rsp
movq %rdx, 0x48(%rsp)
movq %r15, 0x40(%rsp)
movq %r12, 0x38(%rsp)
movq %rbp, 0x30(%rsp)
movq %r11, %r13
movq %r11, 0x28(%rsp)
movq %r10, %r12
movq %r10, 0x20(%rsp)
movq %rax, %r15
movq %rax, 0x18(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, 0x10(%rsp)
andq $0x0, (%rsp)
movq $0x1, 0x8(%rsp)
movq %rsi, 0x90(%rsp)
movq %r8, %rdx
movq %rbx, %r8
xorl %r9d, %r9d
movss %xmm0, 0x5c(%rsp)
callq 0xc870c
addq $0x50, %rsp
leaq 0x10(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x28(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x14(%rsp), %r8
andl $0x0, (%r8)
movl %r14d, %eax
movq %rax, 0x30(%rsp)
leaq (,%rax,8), %rdi
movq 0x50(%rsp), %r14
addq 0x18(%r14), %rdi
movl 0x20(%rsp), %esi
subq $0x50, %rsp
movq %rcx, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %r8, 0x38(%rsp)
movq %rbp, 0x30(%rsp)
movq %rdx, %rbp
movq %r13, 0x28(%rsp)
movl 0xe8(%rsp), %r13d
movq %r12, 0x20(%rsp)
movq 0x98(%rsp), %r12
movq %r15, 0x18(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq %rsi, 0x70(%rsp)
movq %r12, %rdx
movq %r13, %rcx
movq %rbx, %r15
movq %rbx, %r8
xorl %r9d, %r9d
movss 0x5c(%rsp), %xmm0
callq 0xc870c
leaq 0x7c(%rsp), %r11
addq $0x50, %rsp
movl (%r11), %r9d
movl (%rbp), %eax
movq 0x18(%r14), %rcx
cmpl %eax, %r9d
jae 0xc8d3e
movq 0x38(%rsp), %rbx
leaq (%rcx,%rbx,8), %rdi
movl 0x10(%rsp), %r10d
movq 0x40(%rsp), %rbp
movq %rbp, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %r15, %r8
movq %rax, %r9
movss 0xc(%rsp), %xmm0
leaq 0x18(%rsp), %rax
pushq %rax
pushq %r11
leaq 0x2c(%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 0xc870c
addq $0x50, %rsp
movq %rbx, %rcx
movq 0x30(%rsp), %rdx
jmp 0xc8db3
movq 0x30(%rsp), %rbx
leaq (%rcx,%rbx,8), %rdi
movl 0x18(%rsp), %eax
movq 0x20(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %r15, %r8
movss 0xc(%rsp), %xmm0
leaq 0x10(%rsp), %r10
pushq %r10
leaq 0x30(%rsp), %r10
pushq %r10
leaq 0x24(%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 0xc870c
addq $0x50, %rsp
movq 0x40(%rsp), %rbp
movq 0x38(%rsp), %rcx
movq %rbx, %rdx
addl %ebp, %ecx
movl 0x1c(%rsp), %eax
subq %rax, %rcx
movq 0xd0(%rsp), %rax
movq %rcx, (%rax)
addl 0x14(%rsp), %edx
decq %rdx
movq 0xd8(%rsp), %rax
movq %rdx, (%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq