// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: push_ne_ovlp(ma_hit_t_alloc*, overlap_region_alloc*, unsigned int, All_reads*, asg16_v*)
void push_ne_ovlp(ma_hit_t_alloc* paf, overlap_region_alloc* ov, uint32_t flag, All_reads* R_INF, asg16_v *ec/**, uint64_t qid, UC_Read *qu, UC_Read *tu**/)
{
    // if(qu && tu) {
    //     debug_extract_max_exact_sub(qid, qu, tu);
    // }
    uint64_t k, n; ma_hit_t *z; uint32_t rxs, rxe, rys, rye;
    for (k = n = 0; k < ov->length; k++) {
        if(ov->list[k].is_match == flag) n++;
    }

    if(n > paf->size) {
        paf->size = n;
        REALLOC(paf->buffer, paf->size);
    }

    for (k = paf->length = 0; k < ov->length; k++) {
        if(ov->list[k].is_match == flag) {
            // fprintf(stderr, "@%s\tSN:%.*s(id::%u)\terr::%u\n", flag==1?"SQ":"RQ", (int32_t)Get_NAME_LENGTH((*R_INF), ov->list[k].y_id), Get_NAME((*R_INF), ov->list[k].y_id), ov->list[k].y_id, ov->list[k].non_homopolymer_errors);

            z = &(paf->buffer[paf->length++]);

            z->qns = ov->list[k].x_id;
            z->qns = z->qns << 32;
            z->tn = ov->list[k].y_id;

            z->qns = z->qns | (uint64_t)(ov->list[k].x_pos_s);
            z->qe = ov->list[k].x_pos_e + 1;
            z->ts = ov->list[k].y_pos_s;
            z->te = ov->list[k].y_pos_e + 1;

            ///for overlap_list, the x_strand of all overlaps are 0, so the tmp.rev is the same as the y_strand
            z->rev = ov->list[k].y_pos_strand;

            z->bl = Get_READ_LENGTH((*R_INF), ov->list[k].y_id);
            z->ml = ov->list[k].strong;
            z->no_l_indel = ov->list[k].without_large_indel;

            if(ec) {
                extract_max_exact(&ov->list[k], ec, /**qu, tu,**/ &rxs, &rxe, &rys, &rye);
                z->el = 0;
                // fprintf(stderr, "[M::%s]\tq::[%u,\t%u)\tt::[%u,\t%u)\teq::[%u,\t%u)\tet::[%u,\t%u)\n", __func__, ov->list[k].x_pos_s, ov->list[k].x_pos_e + 1, ov->list[k].y_pos_s, ov->list[k].y_pos_e + 1, rxs, rxe, rys, rye);
                if(rxe > rxs) {
                    z->qns = ov->list[k].x_id;
                    z->qns = z->qns << 32;
                    z->qns = z->qns | (uint64_t)(rxs);
                    z->qe = rxe;
                    z->ts = rys;
                    z->te = rye;

                    z->el = 1;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x256530
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x256520
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x256522
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x2564eb
movq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
cmpq %rcx, %rax
jbe 0x25656e
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
imulq $0x28, %rax, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xc(%rax)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x256845
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x256832
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rdx
movl 0xc(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0xc(%rdx)
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rdx
addq %rdx, %rax
movl 0x4(%rax), %eax
orq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x1c(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x1, %rdx
shlq $0x1f, %rdx
movabsq $-0x80000001, %rsi      # imm = 0xFFFFFFFF7FFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x10(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x7fffffff, %rdx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movabsq $-0x7fffffff00000001, %rsi # imm = 0x80000000FFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movsbl 0x2e(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x1, %rdx
shlq $0x1e, %rdx
andq $-0x40000001, %rcx      # imm = 0xBFFFFFFF
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movb 0x2d(%rax), %cl
movq -0x40(%rbp), %rax
movb %cl, 0x21(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x256830
movq -0x10(%rbp), %rax
movq (%rax), %rdi
imulq $0xa8, -0x30(%rbp), %rax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
leaq -0x44(%rbp), %rdx
leaq -0x48(%rbp), %rcx
leaq -0x4c(%rbp), %r8
leaq -0x50(%rbp), %r9
callq 0x256130
movq -0x40(%rbp), %rax
movb $0x0, 0x20(%rax)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jbe 0x25682e
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movl -0x44(%rbp), %eax
orq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movl -0x48(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x4c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x50(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x40(%rbp), %rax
movb $0x1, 0x20(%rax)
jmp 0x256830
jmp 0x256832
jmp 0x256834
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x256581
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)