// File: /workspace/github_cpp_makefile_star2_O2/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
movl %r9d, 0xc(%rsp)
movl %r8d, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, %r12
movq %rdi, %r13
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x10(%r13), %rax
imulq $0x28, %rbp, %r14
imulq $0xa8, %rbx, %r15
cmpq %rax, %rbx
jae 0xe871
movl 0xc(%r12), %ecx
cmpq %rcx, %rbp
jae 0xe871
movq (%r13), %rdx
leaq (%rdx,%r15), %rcx
movq (%r12), %rsi
movl 0xc(%rsi,%r14), %esi
cmpl %esi, 0x10(%rdx,%r15)
jb 0xe804
jbe 0xe6b2
incq %rbp
addq $0x28, %r14
jmp 0xe674
leaq 0x38(%rcx), %rdi
movl 0x4(%rcx), %esi
movl 0x8(%rcx), %edx
movss %xmm0, 0x4(%rsp)
callq 0xe52e
movsd 0x1d4521(%rip), %xmm1   # 0x1e2bf0
testl %eax, %eax
je 0xe7fb
movq (%r13), %rdx
leaq (%rdx,%r15), %rax
movl 0x1c(%rdx,%r15), %ecx
movq (%r12), %rsi
movl 0x18(%rsi,%r14), %edi
shrl $0x1f, %edi
cmpl %edi, %ecx
jne 0xe7ef
movq %rax, 0x18(%rsp)
movl (%rsi,%r14), %r11d
movl 0x8(%rsi,%r14), %r10d
movl %r10d, %r8d
subl %r11d, %r8d
incl %r8d
movl 0x14(%rsi,%r14), %edi
movl 0x10(%rsi,%r14), %r9d
movl %edi, %eax
subl %r9d, %eax
incl %eax
cmpl %eax, %r8d
cmoval %r8d, %eax
cvtsi2sd %rax, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %r8
movl 0x4(%rdx,%r15), %eax
subq %r11, %rax
movq %rax, %r11
negq %r11
cmovsq %rax, %r11
movl %r11d, %eax
cmpq %r8, %rax
jae 0xe76c
movl 0x8(%rdx,%r15), %eax
movl %r10d, %r10d
subq %r10, %rax
movq %rax, %r10
negq %r10
cmovsq %rax, %r10
movl %r10d, %eax
cmpq %r8, %rax
jb 0xe7a4
movl 0x14(%rdx,%r15), %eax
movl %r9d, %r9d
subq %r9, %rax
movq %rax, %r9
negq %r9
cmovsq %rax, %r9
movl %r9d, %eax
cmpq %r8, %rax
jae 0xe7f5
movl 0x18(%rdx,%r15), %eax
movl %edi, %edi
subq %rdi, %rax
movq %rax, %rdi
negq %rdi
cmovsq %rax, %rdi
movl %edi, %eax
cmpq %r8, %rax
jae 0xe7f5
movl 0x8(%rsp), %eax
movb %al, 0x2c(%rdx,%r15)
movl 0x18(%rsi,%r14), %eax
shrl $0x1e, %eax
andb $0x1, %al
movb %al, 0x2e(%rdx,%r15)
movb 0x21(%rsi,%r14), %al
movb %al, 0x2d(%rdx,%r15)
cmpl $0x1, 0xc(%rsp)
jne 0xe7fb
movq 0x18(%rsp), %rax
movl 0x10(%rax), %edx
testl %ecx, %ecx
je 0xe80c
movq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x245a48(%rip), %rsi    # 0x254230
callq 0x7215
jmp 0xe820
movb $0x3, 0x2c(%rax)
jmp 0xe7fb
movb $0x3, 0x2c(%rdx,%r15)
incq %rbp
movss 0x4(%rsp), %xmm0
incq %rbx
jmp 0xe665
movq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x245a15(%rip), %rsi    # 0x254230
callq 0x715e
movq 0x20(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
movq (%r14), %rdx
movq 0x8(%r14), %rcx
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
popq %rcx
popq %rdx
movq (%r13), %rcx
addq %r15, %rcx
addq $0x24, %rcx
testl %eax, %eax
je 0xe86c
movl $0x1, (%rcx)
jmp 0xe7fb
andl $0x0, (%rcx)
jmp 0xe7fb
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq