// File: /workspace/github_cpp_makefile_star2_O1/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 %r8d, 0x1c(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
cmpq $0x0, 0x10(%rdi)
je 0x3b837
movl %r9d, %ebp
movq %rsi, %r12
movq %rdi, %r13
xorl %r15d, %r15d
movsd 0x1e956f(%rip), %xmm1   # 0x224bd0
xorl %r14d, %r14d
movl 0xc(%r12), %eax
cmpq %rax, %r15
jae 0x3b837
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), %edi
cmpl %edi, %edx
jae 0x3b699
incq %r14
jmp 0x3b821
cmpl %edi, %edx
ja 0x3b81e
leaq (%rax,%rbx), %r9
leaq (%rcx,%rsi,8), %r8
movl 0x1c(%r9), %edi
movl 0x18(%r8), %r10d
shrl $0x1f, %r10d
cmpl %r10d, %edi
jne 0x3b7ad
movl (%r8), %r9d
movl 0x8(%r8), %r10d
subl %r9d, %r10d
incl %r10d
movl 0x14(%r8), %r11d
subl 0x10(%r8), %r11d
incl %r11d
cmpl %r11d, %r10d
cmoval %r10d, %r11d
xorps %xmm0, %xmm0
cvtsi2sd %r11, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %r8
movl 0x4(%rax,%rbx), %r10d
subq %r9, %r10
movq %r10, %r9
negq %r9
cmovsq %r10, %r9
movl %r9d, %r9d
cmpq %r8, %r9
jae 0x3b727
movl 0x8(%rax,%rbx), %r9d
movl 0x8(%rcx,%rsi,8), %r10d
subq %r10, %r9
movq %r9, %r10
negq %r10
cmovsq %r9, %r10
movl %r10d, %r9d
cmpq %r8, %r9
jb 0x3b765
movl 0x14(%rax,%rbx), %r9d
movl 0x10(%rcx,%rsi,8), %r10d
subq %r10, %r9
movq %r9, %r10
negq %r10
cmovsq %r9, %r10
movl %r10d, %r9d
cmpq %r8, %r9
jae 0x3b7b4
movl 0x18(%rax,%rbx), %r9d
movl 0x14(%rcx,%rsi,8), %r10d
subq %r10, %r9
movq %r9, %r10
negq %r10
cmovsq %r9, %r10
movl %r10d, %r9d
cmpq %r8, %r9
jae 0x3b7b4
movl 0x1c(%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, %ebp
jne 0x3b81b
testl %edi, %edi
movl %ebp, 0xc(%rsp)
je 0x3b7bb
movq 0x10(%rsp), %rdi
leaq 0x24fa8a(%rip), %rsi    # 0x28b230
callq 0x33dc3
jmp 0x3b7cc
movb $0x3, 0x2c(%r9)
jmp 0x3b81b
movb $0x3, 0x2c(%rax,%rbx)
jmp 0x3b81b
movq 0x10(%rsp), %rdi
leaq 0x24fa69(%rip), %rsi    # 0x28b230
callq 0x33cf8
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 0x3b807
incq %rdx
movq 0x20(%rsp), %rax
addq (%rax), %rdi
movq 0x10(%rsp), %rax
addq (%rax), %rsi
callq 0x21a0
testl %eax, %eax
je 0x3b82d
movl $0x0, 0x24(%rbp,%rbx)
movl 0xc(%rsp), %ebp
movsd 0x1e93b5(%rip), %xmm1   # 0x224bd0
incq %r14
incq %r15
cmpq 0x10(%r13), %r14
jb 0x3b664
jmp 0x3b837
movl $0x1, 0x24(%rbp,%rbx)
jmp 0x3b80f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq