// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Assembly.cpp
// Function: update_overlaps(overlap_region_alloc*, ma_hit_t_alloc*, UC_Read*, UC_Read*, int, int)
void update_overlaps(overlap_region_alloc* overlap_list, ma_hit_t_alloc* paf, 
UC_Read* g_read, UC_Read* overlap_read, int is_match, int is_exact)
{

    uint64_t inner_j = 0;
    uint64_t j = 0;
    long long x_overlapLen, y_overlapLen;
    while (j < overlap_list->length && inner_j < paf->length)
    {
        if(overlap_list->list[j].y_id < paf->buffer[inner_j].tn)
        {
            j++;
        }
        else if(overlap_list->list[j].y_id > paf->buffer[inner_j].tn)
        {
            inner_j++;
        }
        else
        {
            if(overlap_list->list[j].y_pos_strand == paf->buffer[inner_j].rev)
            {
                x_overlapLen = Get_qe(paf->buffer[inner_j]) - Get_qs(paf->buffer[inner_j]) + 1;
                y_overlapLen = Get_te(paf->buffer[inner_j]) - Get_ts(paf->buffer[inner_j]) + 1;
                if(x_overlapLen < y_overlapLen) x_overlapLen = y_overlapLen;
                x_overlapLen = x_overlapLen * 0.1;

                // if(
                // ((DIFF(overlap_list->list[j].x_pos_s, Get_qs(paf->buffer[inner_j])) < x_overlapLen)
                // && (DIFF(overlap_list->list[j].x_pos_e, Get_qe(paf->buffer[inner_j])) < x_overlapLen))
                // ||
                // ((DIFF(overlap_list->list[j].y_pos_s, Get_ts(paf->buffer[inner_j])) < x_overlapLen)
                // && (DIFF(overlap_list->list[j].y_pos_e, Get_te(paf->buffer[inner_j])) < x_overlapLen)))
                if(
                ((DIFF(overlap_list->list[j].x_pos_s, Get_qs(paf->buffer[inner_j])) < (uint64_t)x_overlapLen)
                && (DIFF(overlap_list->list[j].x_pos_e, Get_qe(paf->buffer[inner_j])) < (uint64_t)x_overlapLen))
                || 
                ((DIFF(overlap_list->list[j].y_pos_s, Get_ts(paf->buffer[inner_j])) < (uint64_t)x_overlapLen)
                && (DIFF(overlap_list->list[j].y_pos_e, Get_te(paf->buffer[inner_j])) < (uint64_t)x_overlapLen))
                )
                {
                    overlap_list->list[j].is_match = is_match;
                    overlap_list->list[j].strong = paf->buffer[inner_j].ml;
                    overlap_list->list[j].without_large_indel = paf->buffer[inner_j].no_l_indel;
                    if(is_exact == 1)
                    {
                        if(overlap_list->list[j].y_pos_strand == 0)
                        {
                            recover_UC_Read(overlap_read, &R_INF, overlap_list->list[j].y_id);
                        }
                        else
                        {
                            recover_UC_Read_RC(overlap_read, &R_INF, overlap_list->list[j].y_id);
                        }
                        if(if_exact_match(g_read->seq, g_read->length, overlap_read->seq, overlap_read->length, 
                        overlap_list->list[j].x_pos_s, overlap_list->list[j].x_pos_e, 
                        overlap_list->list[j].y_pos_s, overlap_list->list[j].y_pos_e))
                        {
                            overlap_list->list[j].shared_seed = 1;
                        }
                        else
                        {
                            overlap_list->list[j].shared_seed = 0;
                        }
                    }
                }
                else
                {
                    overlap_list->list[j].is_match = 3;
                }
            }
            else
            {
                overlap_list->list[j].is_match = 3;
            }

            j++;
            inner_j++;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, 0x18(%rsp)
movl %r8d, 0x14(%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, 0x20(%rsp)
movq %rdi, %r13
movq 0x10(%rdi), %rdi
testq %rdi, %rdi
je 0x3ae06
movq %rsi, %r12
xorl %r15d, %r15d
movsd 0x1f5ff4(%rip), %xmm1   # 0x230c10
xorl %r14d, %r14d
movl 0xc(%r12), %eax
cmpq %rax, %r15
jae 0x3ae06
movq (%r13), %rax
imulq $0xa8, %r14, %rbx
movl 0x10(%rax,%rbx), %edx
movq (%r12), %rcx
leaq (%r15,%r15,4), %rsi
movl 0xc(%rcx,%rsi,8), %r8d
cmpl %r8d, %edx
jae 0x3ac56
incq %r14
jmp 0x3adf1
cmpl %r8d, %edx
jbe 0x3ac63
incq %r15
jmp 0x3adf1
leaq (%rax,%rbx), %r8
leaq (%rcx,%rsi,8), %r9
movl 0x1c(%r8), %edi
movl 0x18(%r9), %r10d
shrl $0x1f, %r10d
cmpl %r10d, %edi
jne 0x3ad7d
movl %edi, 0x10(%rsp)
movl (%r9), %ebp
movl 0x8(%r9), %r8d
movl %r8d, %r11d
subl %ebp, %r11d
incl %r11d
movl 0x14(%r9), %edi
movl 0x10(%r9), %r10d
movl %edi, 0x1c(%rsp)
movl %edi, %r9d
subl %r10d, %r9d
incl %r9d
cmpl %r9d, %r11d
cmoval %r11d, %r9d
xorps %xmm0, %xmm0
cvtsi2sd %r9, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %r9
movl 0x4(%rax,%rbx), %r11d
subq %rbp, %r11
movq %r11, %rbp
negq %rbp
cmovsq %r11, %rbp
movl %ebp, %r11d
cmpq %r9, %r11
jae 0x3acf8
movl 0x8(%rax,%rbx), %r11d
movl %r8d, %r8d
subq %r8, %r11
movq %r11, %r8
negq %r8
cmovsq %r11, %r8
movl %r8d, %r8d
cmpq %r9, %r8
jb 0x3ad34
movl 0x14(%rax,%rbx), %r8d
movl %r10d, %r10d
subq %r10, %r8
movq %r8, %r10
negq %r10
cmovsq %r8, %r10
movl %r10d, %r8d
cmpq %r9, %r8
jae 0x3ad84
movl 0x18(%rax,%rbx), %r8d
movl 0x1c(%rsp), %r10d
subq %r10, %r8
movq %r8, %r10
negq %r10
cmovsq %r8, %r10
movl %r10d, %r8d
cmpq %r9, %r8
jae 0x3ad84
movl 0x14(%rsp), %r8d
movb %r8b, 0x2c(%rax,%rbx)
movl 0x18(%rcx,%rsi,8), %r8d
shrl $0x1e, %r8d
andb $0x1, %r8b
movb %r8b, 0x2e(%rax,%rbx)
movb 0x21(%rcx,%rsi,8), %cl
movb %cl, 0x2d(%rax,%rbx)
cmpl $0x1, 0x18(%rsp)
jne 0x3ade7
cmpl $0x0, 0x10(%rsp)
je 0x3ad8b
movq 0x8(%rsp), %rdi
leaq 0x25b4ba(%rip), %rsi    # 0x296230
callq 0x334a6
jmp 0x3ad9c
movb $0x3, 0x2c(%r8)
jmp 0x3ade7
movb $0x3, 0x2c(%rax,%rbx)
jmp 0x3ade7
movq 0x8(%rsp), %rdi
leaq 0x25b499(%rip), %rsi    # 0x296230
callq 0x333e0
movq (%r13), %rbp
movl 0x4(%rbp,%rbx), %edi
movl 0x8(%rbp,%rbx), %edx
movl 0x14(%rbp,%rbx), %esi
movl 0x18(%rbp,%rbx), %eax
subq %rdi, %rdx
subq %rsi, %rax
cmpq %rdx, %rax
jne 0x3add7
incq %rdx
movq 0x20(%rsp), %rax
addq (%rax), %rdi
movq 0x8(%rsp), %rax
addq (%rax), %rsi
callq 0x21a0
testl %eax, %eax
je 0x3adfc
movl $0x0, 0x24(%rbp,%rbx)
movsd 0x1f5e29(%rip), %xmm1   # 0x230c10
incq %r14
incq %r15
movq 0x10(%r13), %rdi
cmpq %rdi, %r14
jb 0x3ac1f
jmp 0x3ae06
movl $0x1, 0x24(%rbp,%rbx)
jmp 0x3addf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq