// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: push_emask_lst(mask_ul_ov_t*, overlap_region_alloc*, unsigned long, ma_ug_t*, unsigned long*, unsigned long, kv_emask_t*, unsigned long)
void push_emask_lst(mask_ul_ov_t *mk, overlap_region_alloc* ol, uint64_t minov, ma_ug_t *ug, uint64_t *a, uint64_t an, kv_emask_t *res, uint64_t is_pe)
{
	uint64_t i, l, sn, si, re, cn, skip_n; overlap_region *z; ul_ov_t p, *sa; 	
	uint64_t q0l, t0l, e0l, q1l, t1l, e1l; emask_t *m;
	if(is_pe) {
		for (i = 0; i < an; i++) {
			a[i] <<= 32; a[i] >>= 32;
		}
		radix_sort_gfa64(a, a+an);
		for (i = 1, l = si = 0; i <= an; i++) {
			if(i == an || (a[i]>>1) != (a[l]>>1)) {
				// k = (uint32_t)mk->idx.a[a[l]>>1];
				z = &(ol->list[(uint32_t)mk->idx.a[a[l]>>1]]);
				overlap_region2ul_ov_t(z, &p, ug->u.a[z->y_id].len);
				assert(i<=l+2); 
				assert((p.qe-p.qs) >= minov); 
				assert((p.te-p.ts) >= minov);
				assert(p.sec > 0);	
				sa = get_mask_interval(&p, &(mk->srt), &si, ug->u.a[p.qn].len, ug->u.a[p.tn].len, &sn, &skip_n);
				re = cal_exact_batch(z, sa, sn, ug->u.a[p.tn].len, &q0l, &t0l, &e0l, &q1l, &t1l, &e1l, ug);
				assert(re);
				cn = i - l;

				push_emask0(res, q0l, t0l, e0l, q1l, t1l, e1l, a[l]&1, ((i==(l+2))?1:0), minov, &p); l++;
				if(l < i) push_emask0(res, q0l, t0l, e0l, q1l, t1l, e1l, a[l]&1, ((i==(l+2))?1:0), minov, &p);
				// fprintf(stderr, "[M::%s]\tres->n::%u\tcn::%lu\n", __func__, (uint32_t)res->n, cn);
				full_lst_set(res->a+res->n-cn, cn, sa, sn, skip_n);	
				l = i;
			}
		}
	} else {
		for (i = 0; i < an; i++) {
			a[i] <<= 32; a[i] >>= 32;
			z = &(ol->list[(uint32_t)mk->idx.a[a[i]>>1]]);
			overlap_region2ul_ov_t(z, &p, ug->u.a[z->y_id].len);
			assert((p.qe-p.qs) >= minov); 
			assert((p.te-p.ts) >= minov);
			if(p.sec > 0) {
				sa = get_mask_interval(&p, &(mk->srt), &si, ug->u.a[p.qn].len, ug->u.a[p.tn].len, &sn, &skip_n);
				re = cal_exact_batch(z, sa, sn, ug->u.a[p.tn].len, &q0l, &t0l, &e0l, &q1l, &t1l, &e1l, ug);
				assert(re == 0);
			}

			m = &(res->a[res->n++]); memset(m, 0, sizeof((*m))); 
			m->dir = 2; m->pe = 0; m->tn = p.tn; m->rev = p.rev; m->full = 1; m->el = (uint32_t)-1; m->rn = (uint32_t)-1;
			m->qs = p.qs; m->qe = p.qe; m->ts = p.ts; m->te = p.te;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r9, %rbx
movq %r8, (%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, %r13
movq %rsi, 0x50(%rsp)
movq %rdi, %r14
cmpq $0x0, 0x108(%rsp)
movq %r9, 0x48(%rsp)
movq %rdx, 0x28(%rsp)
je 0x180671
xorl %eax, %eax
movq (%rsp), %rcx
cmpq %rax, %rbx
je 0x180384
andl $0x0, 0x4(%rcx,%rax,8)
incq %rax
jmp 0x180375
movq (%rsp), %rdi
leaq (%rdi,%rbx,8), %rsi
callq 0x156b0d
leaq 0x90(%rsp), %rax
andq $0x0, (%rax)
movq %r14, 0xa0(%rsp)
leaq 0x18(%r14), %rax
movq %rax, 0x98(%rsp)
pushq $0x1
popq %r14
xorl %r12d, %r12d
leaq 0xc(%rsp), %rbp
cmpq %rbx, %r14
ja 0x180833
jne 0x1803d2
movq (%rsp), %rax
movq (%rax,%r12,8), %rax
jmp 0x1803eb
movq (%rsp), %rcx
movq (%rcx,%r12,8), %rax
movq (%rcx,%r14,8), %rcx
xorq %rax, %rcx
cmpq $0x2, %rcx
jb 0x180669
movq 0x50(%rsp), %rcx
movq (%rcx), %rcx
movq 0xa0(%rsp), %rdx
movq 0x10(%rdx), %rdx
andq $-0x2, %rax
movl (%rdx,%rax,4), %eax
imulq $0xa8, %rax, %rax
leaq (%rcx,%rax), %rbx
movq 0x30(%rsp), %rdx
movq 0x10(%rdx), %rdx
movl 0x10(%rcx,%rax), %eax
imulq $0x28, %rax, %rax
movl (%rdx,%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1a334e
leaq 0x2(%r12), %r15
cmpq %r15, %r14
ja 0x1808c1
movl 0x14(%rsp), %eax
subl 0x10(%rsp), %eax
cmpq %r13, %rax
jb 0x1808a2
movl 0x20(%rsp), %eax
subl 0x1c(%rsp), %eax
cmpq %r13, %rax
jb 0x180883
testl $0x3fffffff, 0x24(%rsp) # imm = 0x3FFFFFFF
je 0x180864
movq %r12, %r13
movq 0x30(%rsp), %r12
movq 0x10(%r12), %rax
movl 0xc(%rsp), %ecx
movl 0x18(%rsp), %edx
imulq $0x28, %rcx, %rcx
movl (%rax,%rcx), %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andq %rsi, %rcx
imulq $0x28, %rdx, %rdx
movl (%rax,%rdx), %r8d
andq %rsi, %r8
subq $0x8, %rsp
movq %rbp, %rdi
movq 0xa0(%rsp), %rsi
leaq 0x98(%rsp), %rdx
leaq 0x48(%rsp), %r9
leaq 0x90(%rsp), %rax
pushq %rax
callq 0x17ecb8
popq %rcx
popq %rdx
movq %rax, %rsi
movq 0x40(%rsp), %rdx
movq 0x10(%r12), %rax
movl 0x18(%rsp), %ecx
imulq $0x28, %rcx, %rcx
movl (%rax,%rcx), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rcx
subq $0x10, %rsp
movq %rbx, %rdi
movq %rsi, 0xd0(%rsp)
movq %rdx, 0x48(%rsp)
leaq 0x90(%rsp), %r8
leaq 0x88(%rsp), %r9
leaq 0x68(%rsp), %rax
pushq %rax
leaq 0x78(%rsp), %rax
pushq %rax
leaq 0x88(%rsp), %rax
pushq %rax
leaq 0x98(%rsp), %rax
pushq %rax
callq 0x17f0fe
addq $0x30, %rsp
testq %rax, %rax
je 0x180845
movq 0x80(%rsp), %rbx
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %r12
movq 0x68(%rsp), %r8
movq 0x60(%rsp), %r9
movq 0x58(%rsp), %r11
movq (%rsp), %rax
movq (%rax,%r13,8), %rax
andl $0x1, %eax
xorl %r10d, %r10d
cmpq %r15, %r14
sete %r10b
subq $0x8, %rsp
movq 0x108(%rsp), %rdi
movq %rbx, %rsi
movq %rdx, 0xc0(%rsp)
movq %r12, %rcx
movq %r8, 0xb8(%rsp)
movq %r9, 0xb0(%rsp)
movq %rbp, %r15
pushq %rbp
movq %r11, %rbp
pushq 0x38(%rsp)
pushq %r10
pushq %rax
pushq %r11
callq 0x1801e3
addq $0x30, %rsp
leaq 0x1(%r13), %rax
cmpq %r14, %rax
jae 0x18061c
movq (%rsp), %rax
movq 0x8(%rax,%r13,8), %rax
andl $0x1, %eax
leaq 0x3(%r13), %rcx
xorl %r10d, %r10d
cmpq %rcx, %r14
sete %r10b
subq $0x8, %rsp
movq 0x108(%rsp), %rdi
movq %rbx, %rsi
movq 0xc0(%rsp), %rdx
movq %r12, %rcx
movq 0xb8(%rsp), %r8
movq 0xb0(%rsp), %r9
pushq %r15
pushq 0x38(%rsp)
pushq %r10
pushq %rax
pushq %rbp
callq 0x1801e3
addq $0x30, %rsp
movq %r14, %rsi
subq %r13, %rsi
movq 0x100(%rsp), %rax
movq 0x8(%rax), %rdi
shlq $0x5, %rdi
addq (%rax), %rdi
movq %rsi, %rax
shlq $0x5, %rax
subq %rax, %rdi
movq 0x88(%rsp), %r8
movq 0xc0(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x180075
movq %r14, %r12
movq 0x48(%rsp), %rbx
movq 0x28(%rsp), %r13
movq %r15, %rbp
incq %r14
jmp 0x1803bd
movq %r14, %r12
leaq 0x18(%r14), %rax
movq %rax, 0x38(%rsp)
xorl %r14d, %r14d
leaq 0xc(%rsp), %rbp
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
cmpq %r14, %rbx
je 0x180833
movq (%rsp), %rdx
movq (%rdx,%r14,8), %rax
movl %eax, %ecx
movq %rcx, (%rdx,%r14,8)
movq 0x50(%rsp), %rcx
movq (%rcx), %rcx
movq 0x10(%r12), %rdx
shrl %eax
movl (%rdx,%rax,8), %eax
imulq $0xa8, %rax, %rax
leaq (%rcx,%rax), %rbx
movq 0x30(%rsp), %rdx
movq 0x10(%rdx), %rdx
movl 0x10(%rcx,%rax), %eax
imulq $0x28, %rax, %rax
movl (%rdx,%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1a334e
movl 0x14(%rsp), %eax
subl 0x10(%rsp), %eax
cmpq %r13, %rax
jb 0x1808e0
movl 0x20(%rsp), %eax
subl 0x1c(%rsp), %eax
cmpq %r13, %rax
jb 0x1808ff
testl $0x3fffffff, 0x24(%rsp) # imm = 0x3FFFFFFF
je 0x1807cb
movq 0x30(%rsp), %r13
movq 0x10(%r13), %rax
movl 0xc(%rsp), %ecx
movl 0x18(%rsp), %edx
imulq $0x28, %rcx, %rcx
movl (%rax,%rcx), %ecx
andq %r15, %rcx
imulq $0x28, %rdx, %rdx
movl (%rax,%rdx), %r8d
andq %r15, %r8
subq $0x8, %rsp
movq %rbp, %rdi
movq 0x40(%rsp), %rsi
leaq 0x98(%rsp), %rdx
leaq 0x48(%rsp), %r9
leaq 0x90(%rsp), %rax
pushq %rax
callq 0x17ecb8
addq $0x10, %rsp
movq 0x40(%rsp), %rdx
movq 0x10(%r13), %rcx
movq 0x28(%rsp), %r13
movl 0x18(%rsp), %esi
imulq $0x28, %rsi, %rsi
movl (%rcx,%rsi), %ecx
andq %r15, %rcx
subq $0x10, %rsp
movq %rbx, %rdi
movq %rax, %rsi
leaq 0x90(%rsp), %r8
leaq 0x88(%rsp), %r9
leaq 0x68(%rsp), %rax
pushq %rax
leaq 0x78(%rsp), %rax
pushq %rax
leaq 0x88(%rsp), %rax
pushq %rax
leaq 0x98(%rsp), %rax
pushq %rax
callq 0x17f0fe
addq $0x30, %rsp
testq %rax, %rax
jne 0x18091e
movq 0x100(%rsp), %rsi
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
shlq $0x5, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax,%rcx)
movups %xmm0, 0x4(%rax,%rcx)
movb $0x2, 0x1c(%rax,%rcx)
movl 0x18(%rsp), %edx
movl %edx, (%rax,%rcx)
movb 0x27(%rsp), %dl
andb $-0x80, %dl
orb $0x42, %dl
movb %dl, 0x1c(%rax,%rcx)
orq $-0x1, 0x4(%rax,%rcx)
movups 0x10(%rsp), %xmm0
movsd 0x1c(%rsp), %xmm1
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movups %xmm0, 0xc(%rax,%rcx)
incq %r14
movq 0x48(%rsp), %rbx
jmp 0x18068b
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x74699(%rip), %rdi     # 0x1f4ee5
leaq 0x712d0(%rip), %rsi     # 0x1f1b23
leaq 0x73664(%rip), %rcx     # 0x1f3ebe
movl $0x2fb1, %edx           # imm = 0x2FB1
callq 0x2110
leaq 0x736fc(%rip), %rdi     # 0x1f3f67
leaq 0x712b1(%rip), %rsi     # 0x1f1b23
leaq 0x73645(%rip), %rcx     # 0x1f3ebe
movl $0x2fae, %edx           # imm = 0x2FAE
callq 0x2110
leaq 0x736c8(%rip), %rdi     # 0x1f3f52
leaq 0x71292(%rip), %rsi     # 0x1f1b23
leaq 0x73626(%rip), %rcx     # 0x1f3ebe
movl $0x2fad, %edx           # imm = 0x2FAD
callq 0x2110
leaq 0x73694(%rip), %rdi     # 0x1f3f3d
leaq 0x71273(%rip), %rsi     # 0x1f1b23
leaq 0x73607(%rip), %rcx     # 0x1f3ebe
movl $0x2fac, %edx           # imm = 0x2FAC
callq 0x2110
leaq 0x735ef(%rip), %rdi     # 0x1f3eb7
leaq 0x71254(%rip), %rsi     # 0x1f1b23
leaq 0x735e8(%rip), %rcx     # 0x1f3ebe
movl $0x2fab, %edx           # imm = 0x2FAB
callq 0x2110
leaq 0x73656(%rip), %rdi     # 0x1f3f3d
leaq 0x71235(%rip), %rsi     # 0x1f1b23
leaq 0x735c9(%rip), %rcx     # 0x1f3ebe
movl $0x2fc0, %edx           # imm = 0x2FC0
callq 0x2110
leaq 0x7364c(%rip), %rdi     # 0x1f3f52
leaq 0x71216(%rip), %rsi     # 0x1f1b23
leaq 0x735aa(%rip), %rcx     # 0x1f3ebe
movl $0x2fc1, %edx           # imm = 0x2FC1
callq 0x2110
leaq 0x7364c(%rip), %rdi     # 0x1f3f71
leaq 0x711f7(%rip), %rsi     # 0x1f1b23
leaq 0x7358b(%rip), %rcx     # 0x1f3ebe
movl $0x2fc5, %edx           # imm = 0x2FC5
callq 0x2110