// File: chhylp123[P]hifiasm/Assembly.cpp
// Function: push_overlaps(ma_hit_t_alloc*, overlap_region_alloc*, int, All_reads*, int)
void push_overlaps(ma_hit_t_alloc* paf, overlap_region_alloc* overlap_list, int flag, All_reads* R_INF, int if_reverse)
{
    long long i = 0, xLen, yLen;
	int32_t size = 0;
    ma_hit_t tmp;
	for (i = 0; i < (long long)overlap_list->length; ++i)
		if (overlap_list->list[i].is_match == flag)
			++size;
	resize_ma_hit_t_alloc(paf, size);
    clear_ma_hit_t_alloc(paf);
    for (i = 0; i < (long long)overlap_list->length; i++)
    {
        if (overlap_list->list[i].is_match == flag)
        {
            xLen = Get_READ_LENGTH((*R_INF), overlap_list->list[i].x_id);
            yLen = Get_READ_LENGTH((*R_INF), overlap_list->list[i].y_id);

            tmp.qns = overlap_list->list[i].x_id;
            tmp.qns = tmp.qns << 32;
            tmp.tn = overlap_list->list[i].y_id;

            if(if_reverse != 0)
            {
                tmp.qns = tmp.qns | (uint64_t)(xLen - overlap_list->list[i].x_pos_s - 1);
                tmp.qe = xLen - overlap_list->list[i].x_pos_e - 1;
                tmp.ts = yLen - overlap_list->list[i].y_pos_s - 1;
                tmp.te = yLen - overlap_list->list[i].y_pos_e - 1;
            }
            else
            {
                tmp.qns = tmp.qns | (uint64_t)(overlap_list->list[i].x_pos_s);
                tmp.qe = overlap_list->list[i].x_pos_e;
                tmp.ts = overlap_list->list[i].y_pos_s;
                tmp.te = overlap_list->list[i].y_pos_e;
            }

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

            ///tmp.bl = R_INF.read_length[overlap_list->list[i].y_id];
            tmp.bl = Get_READ_LENGTH((*R_INF), overlap_list->list[i].y_id);
            tmp.ml = overlap_list->list[i].strong;
            tmp.no_l_indel = overlap_list->list[i].without_large_indel;

            add_ma_hit_t_alloc(paf, &tmp);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x44(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x14254
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x14244
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x14246
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x14212
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0xce0c0
movq -0x8(%rbp), %rdi
callq 0xce0a0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x14519
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x14506
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
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
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x143c7
movq -0x70(%rbp), %rax
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rdx
movq (%rdx), %rdx
imulq $0xa8, -0x30(%rbp), %rsi
addq %rsi, %rdx
movl 0x4(%rdx), %edx
subq %rdx, %rcx
subq $0x1, %rcx
orq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0x68(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x14(%rcx), %ecx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x18(%rcx), %ecx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0x5c(%rbp)
jmp 0x1442f
movq -0x70(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
orq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movl %eax, %ecx
movq -0x58(%rbp), %rax
andq $0x1, %rcx
shlq $0x1f, %rcx
movabsq $-0x80000001, %rdx      # imm = 0xFFFFFFFF7FFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, -0x58(%rbp)
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, %eax
movl %eax, %ecx
movq -0x58(%rbp), %rax
andq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
shlq $0x20, %rcx
movabsq $-0x7fffffff00000001, %rdx # imm = 0x80000000FFFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movsbl 0x2e(%rax), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x58(%rbp), %rax
andq $0x1, %rcx
shlq $0x1e, %rcx
andq $-0x40000001, %rax      # imm = 0xBFFFFFFF
orq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movb 0x2d(%rax), %al
movb %al, -0x4f(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xcd340
jmp 0x14508
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x14271
addq $0x70, %rsp
popq %rbp
retq
nop