// File: 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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movss %xmm0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpq 0x10(%rdx), %rcx
movb %al, -0x51(%rbp)
jae 0x1867f
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
setb %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x1868b
jmp 0x18d46
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x186c5
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x18d41
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jbe 0x186ff
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x18d3f
movq -0x8(%rbp), %rax
movq (%rax), %rdi
imulq $0xa8, -0x40(%rbp), %rax
addq %rax, %rdi
addq $0x38, %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, %esi
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %edx
movss -0x2c(%rbp), %xmm0
callq 0x184a0
cmpl $0x1, %eax
jne 0x18d27
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x1f, %rcx
andq $0x1, %rcx
cmpl %ecx, %eax
jne 0x18d0f
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
subl %ecx, %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
subl 0x10(%rcx), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jge 0x187fc
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
cvtsi2sdq -0x48(%rbp), %xmm0
movsd 0x36680e(%rip), %xmm1   # 0x37f018
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
cmpl %ecx, %eax
jb 0x1885c
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x58(%rbp)
jmp 0x18871
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
cmpl %ecx, %eax
ja 0x188bc
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x60(%rbp)
jmp 0x188d1
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
movl -0x60(%rbp), %ecx
subl %ecx, %eax
movl %eax, %eax
cmpq -0x48(%rbp), %rax
jae 0x189af
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jb 0x18928
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
jmp 0x1893d
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
ja 0x18986
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0x1899b
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x68(%rbp), %eax
movl -0x6c(%rbp), %ecx
subl %ecx, %eax
movl %eax, %eax
cmpq -0x48(%rbp), %rax
jb 0x18b4c
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
jb 0x189f2
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x70(%rbp)
jmp 0x18a07
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
ja 0x18a50
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x78(%rbp)
jmp 0x18a65
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %eax
movl -0x78(%rbp), %ecx
subl %ecx, %eax
movl %eax, %eax
cmpq -0x48(%rbp), %rax
jae 0x18cf7
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jb 0x18abc
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x7c(%rbp)
jmp 0x18ad1
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
ja 0x18b1d
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x84(%rbp)
jmp 0x18b35
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x84(%rbp)
movl -0x80(%rbp), %eax
movl -0x84(%rbp), %ecx
subl %ecx, %eax
movl %eax, %eax
cmpq -0x48(%rbp), %rax
jae 0x18cf7
movl -0x24(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rdx
addq %rdx, %rax
movb %cl, 0x2c(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x1e, %rax
andq $0x1, %rax
movb %al, %cl
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rdx
addq %rdx, %rax
movb %cl, 0x2e(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movb 0x21(%rax), %cl
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rdx
addq %rdx, %rax
movb %cl, 0x2d(%rax)
cmpl $0x1, -0x28(%rbp)
jne 0x18cf5
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jne 0x18c0a
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, %edx
leaq 0x3ac6cd(%rip), %rsi    # 0x3c52d0
callq 0xa380
jmp 0x18c31
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, %edx
leaq 0x3ac6a4(%rip), %rsi    # 0x3c52d0
callq 0xa500
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %r8
addq %r8, %rax
movl 0x4(%rax), %eax
movl %eax, %r8d
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %r9
addq %r9, %rax
movl 0x8(%rax), %eax
movl %eax, %r9d
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %r10
addq %r10, %rax
movl 0x14(%rax), %eax
movl %eax, %r10d
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %r11
addq %r11, %rax
movl 0x18(%rax), %eax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1c610
cmpl $0x0, %eax
je 0x18cda
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl $0x1, 0x24(%rax)
jmp 0x18cf3
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl $0x0, 0x24(%rax)
jmp 0x18cf5
jmp 0x18d0d
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movb $0x3, 0x2c(%rax)
jmp 0x18d25
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movb $0x3, 0x2c(%rax)
jmp 0x18d27
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x18d41
jmp 0x18658
addq $0xa0, %rsp
popq %rbp
retq
nop