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

    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(check_chain_indels(&(overlap_list->list[j].f_cigar), overlap_list->list[j].x_pos_s, 
            overlap_list->list[j].x_pos_e, indel_rate) == 1)
            {
                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
movss %xmm0, 0x1c(%rsp)
movl %r9d, 0x18(%rsp)
movl %r8d, 0x14(%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, 0x20(%rsp)
cmpq $0x0, 0x10(%rdi)
je 0x3bb9e
movq %rsi, %r12
movq %rdi, %r13
xorl %r15d, %r15d
xorl %r14d, %r14d
movl 0xc(%r12), %eax
cmpq %rax, %r15
jae 0x3bb9e
movq (%r13), %rcx
imulq $0xa8, %r14, %rbx
leaq (%rcx,%rbx), %rax
movq (%r12), %rdx
leaq (%r15,%r15,4), %rbp
movl 0xc(%rdx,%rbp,8), %edx
cmpl %edx, 0x10(%rcx,%rbx)
jae 0x3b9ec
incq %r14
jmp 0x3bb88
ja 0x3bb85
leaq 0x38(%rax), %rdi
movl 0x4(%rax), %esi
movl 0x8(%rax), %edx
movss 0x1c(%rsp), %xmm0
callq 0x3b846
testl %eax, %eax
je 0x3bb82
movq (%r13), %rdx
leaq (%rdx,%rbx), %rax
movl 0x1c(%rdx,%rbx), %ecx
movq (%r12), %rsi
movl 0x18(%rsi,%rbp,8), %edi
shrl $0x1f, %edi
cmpl %edi, %ecx
jne 0x3bb21
leaq (%rsi,%rbp,8), %rdi
movl (%rdi), %r8d
movl 0x8(%rdi), %r9d
subl %r8d, %r9d
incl %r9d
movl 0x14(%rdi), %r10d
subl 0x10(%rdi), %r10d
incl %r10d
cmpl %r10d, %r9d
cmoval %r9d, %r10d
xorps %xmm0, %xmm0
cvtsi2sd %r10, %xmm0
mulsd 0x1e916f(%rip), %xmm0   # 0x224bd0
cvttsd2si %xmm0, %rdi
movl 0x4(%rdx,%rbx), %r9d
subq %r8, %r9
movq %r9, %r8
negq %r8
cmovsq %r9, %r8
movl %r8d, %r8d
cmpq %rdi, %r8
jae 0x3ba9f
movl 0x8(%rdx,%rbx), %r8d
movl 0x8(%rsi,%rbp,8), %r9d
subq %r9, %r8
movq %r8, %r9
negq %r9
cmovsq %r8, %r9
movl %r9d, %r8d
cmpq %rdi, %r8
jb 0x3badd
movl 0x14(%rdx,%rbx), %r8d
movl 0x10(%rsi,%rbp,8), %r9d
subq %r9, %r8
movq %r8, %r9
negq %r9
cmovsq %r8, %r9
movl %r9d, %r8d
cmpq %rdi, %r8
jae 0x3bb27
movl 0x18(%rdx,%rbx), %r8d
movl 0x14(%rsi,%rbp,8), %r9d
subq %r9, %r8
movq %r8, %r9
negq %r9
cmovsq %r8, %r9
movl %r9d, %r8d
cmpq %rdi, %r8
jae 0x3bb27
movl 0x14(%rsp), %edi
movb %dil, 0x2c(%rdx,%rbx)
movl 0x18(%rsi,%rbp,8), %edi
shrl $0x1e, %edi
andb $0x1, %dil
movb %dil, 0x2e(%rdx,%rbx)
movb 0x21(%rsi,%rbp,8), %sil
movb %sil, 0x2d(%rdx,%rbx)
cmpl $0x1, 0x18(%rsp)
jne 0x3bb82
movl 0x10(%rax), %edx
testl %ecx, %ecx
je 0x3bb2e
movq 0x8(%rsp), %rdi
leaq 0x24f716(%rip), %rsi    # 0x28b230
callq 0x33dc3
jmp 0x3bb3f
movb $0x3, 0x2c(%rax)
jmp 0x3bb82
movb $0x3, 0x2c(%rdx,%rbx)
jmp 0x3bb82
movq 0x8(%rsp), %rdi
leaq 0x24f6f6(%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 0x3bb7a
incq %rdx
movq 0x20(%rsp), %rax
addq (%rax), %rdi
movq 0x8(%rsp), %rax
addq (%rax), %rsi
callq 0x21a0
testl %eax, %eax
je 0x3bb94
movl $0x0, 0x24(%rbp,%rbx)
incq %r14
incq %r15
cmpq 0x10(%r13), %r14
jb 0x3b9b5
jmp 0x3bb9e
movl $0x1, 0x24(%rbp,%rbx)
jmp 0x3bb82
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq