// File: /workspace/github_cpp_makefile_star2_O2/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, %r14d
movq %rdx, %r11
movq %rsi, %r12
xorl %ebx, %ebx
movsd 0x1d4909(%rip), %xmm1   # 0x1e2bf0
xorl %ebp, %ebp
movq 0x10(%rdi), %r10
imulq $0x28, %rbp, %rax
addq $0x21, %rax
imulq $0xa8, %rbx, %r15
cmpq %r10, %rbx
jae 0xe51f
movl 0xc(%r12), %edx
cmpq %rdx, %rbp
jae 0xe51f
movq (%rdi), %r13
movl 0x10(%r13,%r15), %edx
movq (%r12), %rsi
movl -0x15(%rsi,%rax), %r9d
cmpl %r9d, %edx
jb 0xe49c
cmpl %r9d, %edx
jbe 0xe33b
incq %rbp
addq $0x28, %rax
jmp 0xe2fc
movq %rdi, 0x20(%rsp)
leaq (%r15,%r13), %r10
movl 0x1c(%r10), %edi
movl -0x9(%rsi,%rax), %r9d
shrl $0x1f, %r9d
cmpl %r9d, %edi
jne 0xe473
movq %r11, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
movl %r8d, 0x4(%rsp)
movl %r14d, 0x14(%rsp)
movl -0x21(%rsi,%rax), %r14d
movl -0x19(%rsi,%rax), %r11d
movl %r11d, %r9d
subl %r14d, %r9d
incl %r9d
movl -0xd(%rsi,%rax), %ecx
movl -0x11(%rsi,%rax), %r10d
movl %ecx, %r8d
subl %r10d, %r8d
incl %r8d
cmpl %r8d, %r9d
cmoval %r9d, %r8d
cvtsi2sd %r8, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %r9
movl 0x4(%r13,%r15), %r8d
subq %r14, %r8
movq %r8, %r14
negq %r14
cmovsq %r8, %r14
movl %r14d, %r8d
cmpq %r9, %r8
jae 0xe3df
movl 0x8(%r13,%r15), %r8d
movl %r11d, %r11d
subq %r11, %r8
movq %r8, %r11
negq %r11
cmovsq %r8, %r11
movl %r11d, %r8d
cmpq %r9, %r8
jb 0xe419
movl 0x14(%r13,%r15), %r8d
movl %r10d, %r10d
subq %r10, %r8
movq %r8, %r10
negq %r10
cmovsq %r8, %r10
movl %r10d, %r8d
cmpq %r9, %r8
jae 0xe47a
movl 0x18(%r13,%r15), %r8d
movl %ecx, %r10d
subq %r10, %r8
movq %r8, %r10
negq %r10
cmovsq %r8, %r10
movl %r10d, %r8d
cmpq %r9, %r8
jae 0xe47a
movl %edi, %r10d
movl 0x4(%rsp), %r8d
movb %r8b, 0x2c(%r13,%r15)
movl -0x9(%rsi,%rax), %r9d
shrl $0x1e, %r9d
andb $0x1, %r9b
movb %r9b, 0x2e(%r13,%r15)
movb (%rsi,%rax), %al
movb %al, 0x2d(%r13,%r15)
movl 0x14(%rsp), %r14d
cmpl $0x1, %r14d
movq 0x18(%rsp), %rcx
movq 0x8(%rsp), %r11
movq 0x20(%rsp), %rdi
jne 0xe499
movq %rcx, %rdi
leaq 0x245dcc(%rip), %rsi    # 0x254230
movq %rcx, %r13
testl %r10d, %r10d
je 0xe4a4
callq 0x7215
jmp 0xe4a9
movb $0x3, 0x2c(%r10)
jmp 0xe494
movb $0x3, 0x2c(%r13,%r15)
movl 0x14(%rsp), %r14d
movl 0x4(%rsp), %r8d
movq 0x18(%rsp), %rcx
movq 0x8(%rsp), %r11
movq 0x20(%rsp), %rdi
incq %rbp
incq %rbx
jmp 0xe2e9
callq 0x715e
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
movq (%r13), %rdx
movq 0x8(%r13), %rcx
movq 0x20(%rsp), %r13
movq (%r13), %rax
movl 0x4(%rax,%r15), %r8d
movl 0x8(%rax,%r15), %r9d
movl 0x14(%rax,%r15), %r10d
movl 0x18(%rax,%r15), %eax
pushq %rax
pushq %r10
callq 0x1097d
movq %r13, %rdi
addq $0x10, %rsp
movq (%r13), %rcx
addq %r15, %rcx
addq $0x24, %rcx
testl %eax, %eax
je 0xe500
movl $0x1, (%rcx)
jmp 0xe503
andl $0x0, (%rcx)
movl 0x4(%rsp), %r8d
movq 0x18(%rsp), %rcx
movq 0x8(%rsp), %r11
movsd 0x1d46d6(%rip), %xmm1   # 0x1e2bf0
jmp 0xe499
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq