// File: /workspace/github_cpp_makefile_star2_O3/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, 0x14(%rsp)
movl %r9d, 0x10(%rsp)
movl %r8d, 0xc(%rsp)
movq %rcx, (%rsp)
movq %rdx, 0x20(%rsp)
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x3b173
movq %rsi, %r12
movq %rdi, %r13
xorl %r15d, %r15d
xorl %r14d, %r14d
movl 0xc(%r12), %ecx
cmpq %rcx, %r15
jae 0x3b173
movq (%r13), %rdx
imulq $0xa8, %r14, %rbx
leaq (%rdx,%rbx), %rcx
movq (%r12), %rsi
leaq (%r15,%r15,4), %rbp
movl 0xc(%rsi,%rbp,8), %esi
cmpl %esi, 0x10(%rdx,%rbx)
jae 0x3afbc
incq %r14
jmp 0x3b15e
jbe 0x3afc6
incq %r15
jmp 0x3b15e
leaq 0x38(%rcx), %rdi
movl 0x4(%rcx), %esi
movl 0x8(%rcx), %edx
movss 0x14(%rsp), %xmm0
callq 0x3ae15
testl %eax, %eax
je 0x3b154
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 0x3b0f5
movq %rax, 0x18(%rsp)
leaq (%rsi,%rbp,8), %r8
movl (%r8), %r11d
movl 0x8(%r8), %eax
movl %eax, %r10d
subl %r11d, %r10d
incl %r10d
movl 0x14(%r8), %edi
movl 0x10(%r8), %r9d
movl %edi, %r8d
subl %r9d, %r8d
incl %r8d
cmpl %r8d, %r10d
cmoval %r10d, %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8, %xmm0
mulsd 0x1f5bcd(%rip), %xmm0   # 0x230c10
cvttsd2si %xmm0, %r8
movl 0x4(%rdx,%rbx), %r10d
subq %r11, %r10
movq %r10, %r11
negq %r11
cmovsq %r10, %r11
movl %r11d, %r10d
cmpq %r8, %r10
jae 0x3b07d
movl 0x8(%rdx,%rbx), %r10d
movl %eax, %eax
subq %rax, %r10
movq %r10, %rax
negq %rax
cmovsq %r10, %rax
movl %eax, %eax
cmpq %r8, %rax
jb 0x3b0b3
movl 0x14(%rdx,%rbx), %eax
movl %r9d, %r9d
subq %r9, %rax
movq %rax, %r9
negq %r9
cmovsq %rax, %r9
movl %r9d, %eax
cmpq %r8, %rax
jae 0x3b0fb
movl 0x18(%rdx,%rbx), %eax
movl %edi, %edi
subq %rdi, %rax
movq %rax, %rdi
negq %rdi
cmovsq %rax, %rdi
movl %edi, %eax
cmpq %r8, %rax
jae 0x3b0fb
movl 0xc(%rsp), %eax
movb %al, 0x2c(%rdx,%rbx)
movl 0x18(%rsi,%rbp,8), %eax
shrl $0x1e, %eax
andb $0x1, %al
movb %al, 0x2e(%rdx,%rbx)
movb 0x21(%rsi,%rbp,8), %al
movb %al, 0x2d(%rdx,%rbx)
cmpl $0x1, 0x10(%rsp)
jne 0x3b154
movq 0x18(%rsp), %rax
movl 0x10(%rax), %edx
testl %ecx, %ecx
je 0x3b102
movq (%rsp), %rdi
leaq 0x25b142(%rip), %rsi    # 0x296230
callq 0x334a6
jmp 0x3b112
movb $0x3, 0x2c(%rax)
jmp 0x3b154
movb $0x3, 0x2c(%rdx,%rbx)
jmp 0x3b154
movq (%rsp), %rdi
leaq 0x25b123(%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 0x3b14c
incq %rdx
movq 0x20(%rsp), %rax
addq (%rax), %rdi
movq (%rsp), %rax
addq (%rax), %rsi
callq 0x21a0
testl %eax, %eax
je 0x3b169
movl $0x0, 0x24(%rbp,%rbx)
incq %r14
incq %r15
movq 0x10(%r13), %rax
cmpq %rax, %r14
jb 0x3af85
jmp 0x3b173
movl $0x1, 0x24(%rbp,%rbx)
jmp 0x3b154
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq