// File: 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
movq %rsp, %rbp
subq $0x90, %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)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpq 0x10(%rdx), %rcx
movb %al, -0x49(%rbp)
jae 0x17e2a
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
setb %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x17e36
jmp 0x1848f
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x17e70
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1848a
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jbe 0x17eaa
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x18488
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x1f, %rcx
andq $0x1, %rcx
cmpl %ecx, %eax
jne 0x1845a
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
subl %ecx, %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
subl 0x10(%rcx), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jge 0x17f50
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
cvtsi2sdq -0x40(%rbp), %xmm0
movsd 0x3670ba(%rip), %xmm1   # 0x37f018
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
cmpl %ecx, %eax
jb 0x17fb0
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x50(%rbp)
jmp 0x17fc5
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
cmpl %ecx, %eax
ja 0x18010
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x58(%rbp)
jmp 0x18025
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
movl -0x58(%rbp), %ecx
subl %ecx, %eax
movl %eax, %eax
cmpq -0x40(%rbp), %rax
jae 0x18103
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jb 0x1807c
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x5c(%rbp)
jmp 0x18091
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
ja 0x180da
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
jmp 0x180ef
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %eax
movl -0x64(%rbp), %ecx
subl %ecx, %eax
movl %eax, %eax
cmpq -0x40(%rbp), %rax
jb 0x18297
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
jb 0x18146
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x68(%rbp)
jmp 0x1815b
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
ja 0x181a4
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x70(%rbp)
jmp 0x181b9
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %eax
movl -0x70(%rbp), %ecx
subl %ecx, %eax
movl %eax, %eax
cmpq -0x40(%rbp), %rax
jae 0x18442
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jb 0x18210
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x74(%rbp)
jmp 0x18225
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
ja 0x1826e
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x7c(%rbp)
jmp 0x18283
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x7c(%rbp)
movl -0x78(%rbp), %eax
movl -0x7c(%rbp), %ecx
subl %ecx, %eax
movl %eax, %eax
cmpq -0x40(%rbp), %rax
jae 0x18442
movl -0x24(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rdx
addq %rdx, %rax
movb %cl, 0x2c(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%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, -0x38(%rbp), %rdx
addq %rdx, %rax
movb %cl, 0x2e(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movb 0x21(%rax), %cl
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rdx
addq %rdx, %rax
movb %cl, 0x2d(%rax)
cmpl $0x1, -0x28(%rbp)
jne 0x18440
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jne 0x18355
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, %edx
leaq 0x3acf82(%rip), %rsi    # 0x3c52d0
callq 0xa380
jmp 0x1837c
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, %edx
leaq 0x3acf59(%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, -0x38(%rbp), %r8
addq %r8, %rax
movl 0x4(%rax), %eax
movl %eax, %r8d
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %r9
addq %r9, %rax
movl 0x8(%rax), %eax
movl %eax, %r9d
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %r10
addq %r10, %rax
movl 0x14(%rax), %eax
movl %eax, %r10d
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %r11
addq %r11, %rax
movl 0x18(%rax), %eax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1c610
cmpl $0x0, %eax
je 0x18425
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl $0x1, 0x24(%rax)
jmp 0x1843e
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl $0x0, 0x24(%rax)
jmp 0x18440
jmp 0x18458
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movb $0x3, 0x2c(%rax)
jmp 0x18470
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movb $0x3, 0x2c(%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1848a
jmp 0x17e03
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)