// File: /workspace/github_cpp_makefile_star2_O1/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 $0xe8, %rsp
movq %r8, %r13
movq %rcx, 0x48(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdi, 0x40(%rsp)
cmpq $0x0, 0x128(%rsp)
movq %r9, 0x60(%rsp)
movq %r8, 0x78(%rsp)
je 0x1c20eb
testq %r9, %r9
je 0x1c1d4e
xorl %eax, %eax
movl $0x0, 0x4(%r13,%rax,8)
incq %rax
cmpq %rax, %r9
jne 0x1c1d3d
leaq (,%r9,8), %rsi
addq %r13, %rsi
movq %r13, %rdi
callq 0x194fef
movq 0x60(%rsp), %rcx
movq $0x0, 0xc0(%rsp)
testq %rcx, %rcx
je 0x1c2353
movq 0x40(%rsp), %rax
addq $0x18, %rax
movq %rax, 0xc8(%rsp)
movl $0x1, %ebp
movq $-0x1, %rbx
leaq 0xc(%rsp), %r15
movl 0x18(%r15), %r12d
xorl %r14d, %r14d
cmpq %rbp, %rcx
je 0x1c1dbd
movq (%r13,%r14,8), %rax
xorq (%r13,%rbp,8), %rax
cmpq $0x2, %rax
jb 0x1c20d7
movq 0x80(%rsp), %rax
movq (%rax), %rsi
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq (%r13,%r14,8), %rcx
andq $-0x2, %rcx
movl (%rax,%rcx,4), %eax
imulq $0xa8, %rax, %r9
leaq (%rsi,%r9), %r11
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rsi,%r9), %ecx
movl 0x10(%rsi,%r9), %edx
leaq (%rdx,%rdx,4), %rdi
movq %rdi, 0x28(%rsp)
movl (%rax,%rdi,8), %r8d
movl %ecx, 0xc(%rsp)
movl %edx, 0x18(%rsp)
movl $0x40000000, %edi       # imm = 0x40000000
orl %edi, %r12d
movl %r12d, 0x24(%rsp)
movl 0x30(%rsi,%r9), %edx
movl $0x3fffffff, %r10d      # imm = 0x3FFFFFFF
andl %r10d, %edx
andl $0xc0000000, %r12d      # imm = 0xC0000000
orl %edx, %r12d
movl %r12d, 0x24(%rsp)
movl 0x1c(%rsi,%r9), %r10d
shll $0x1f, %r10d
leal (%rdx,%r10), %r12d
orl %edi, %r12d
movl %r12d, 0x24(%rsp)
movl 0x4(%rsi,%r9), %edi
movl %edi, 0x10(%rsp)
movl 0x8(%rsi,%r9), %esi
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
incl %esi
movl %esi, 0x14(%rsp)
testl %r10d, %r10d
movq %r11, 0x30(%rsp)
je 0x1c1e8e
movl 0x18(%r11), %r9d
notl %r9d
addl %r8d, %r9d
movl %r9d, 0x1c(%rsp)
movl 0x14(%r11), %r11d
movl %r8d, %r10d
subl %r11d, %r10d
jmp 0x1c1e9e
movl 0x14(%r11), %r9d
movl %r9d, 0x1c(%rsp)
movl 0x18(%r11), %r10d
incl %r10d
movl %r10d, 0x20(%rsp)
leaq 0x2(%r14), %r13
cmpq %r13, %rbp
ja 0x1c23e1
subl %edi, %esi
movq 0x38(%rsp), %rdi
cmpq %rdi, %rsi
jb 0x1c23c2
subl %r9d, %r10d
cmpq %rdi, %r10
jb 0x1c23a3
movq %rbx, 0x68(%rsp)
testl %edx, %edx
je 0x1c2384
leaq (%rcx,%rcx,4), %rcx
movl (%rax,%rcx,8), %ecx
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %rcx
subq $0x8, %rsp
movq %r15, %rdi
movq 0xd0(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0x78(%rsp), %r9
leaq 0xc0(%rsp), %rax
pushq %rax
callq 0x1c0b65
addq $0x10, %rsp
movq %rax, %rsi
movq 0x70(%rsp), %rdx
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rsp), %rcx
movl (%rax,%rcx,8), %ecx
andq %rbx, %rcx
subq $0x10, %rsp
movq 0x40(%rsp), %rdi
movq %rsi, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
leaq 0xc0(%rsp), %r8
leaq 0xb8(%rsp), %r9
leaq 0x98(%rsp), %rax
pushq %rax
leaq 0xa8(%rsp), %rax
pushq %rax
leaq 0xb8(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
callq 0x1c1081
addq $0x30, %rsp
testq %rax, %rax
je 0x1c2365
movq 0xb0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %r9
movq 0x98(%rsp), %r8
movq 0x90(%rsp), %rbx
movq 0x88(%rsp), %r11
movq 0x78(%rsp), %rcx
movq (%rcx,%r14,8), %rax
andl $0x1, %eax
xorl %r10d, %r10d
cmpq %r13, %rbp
movq %rcx, %r13
sete %r10b
subq $0x8, %rsp
movq 0x128(%rsp), %rdi
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %r9, 0xe8(%rsp)
movq %r9, %rcx
movq %r8, 0xe0(%rsp)
movq %rbx, 0xd8(%rsp)
movq %rbx, %r9
pushq %r15
movq %r11, %r15
pushq 0x48(%rsp)
pushq %r10
pushq %rax
pushq %r11
callq 0x1c1b86
addq $0x30, %rsp
leaq 0x1(%r14), %rax
cmpq %rbp, %rax
jae 0x1c2085
movq 0x8(%r13,%r14,8), %rax
andl $0x1, %eax
leaq 0x3(%r14), %rcx
xorl %r10d, %r10d
cmpq %rcx, %rbp
sete %r10b
subq $0x8, %rsp
movq 0x128(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0xe8(%rsp), %rcx
movq 0xe0(%rsp), %r8
movq 0xd8(%rsp), %r9
leaq 0x14(%rsp), %r11
pushq %r11
pushq 0x48(%rsp)
pushq %r10
pushq %rax
pushq %r15
callq 0x1c1b86
addq $0x30, %rsp
movq %rbp, %rsi
subq %r14, %rsi
movq 0x120(%rsp), %rcx
movq 0x8(%rcx), %rax
shlq $0x5, %rax
addq (%rcx), %rax
movq 0x68(%rsp), %rcx
addq %rcx, %r14
shlq $0x5, %r14
addq %rax, %r14
movq 0xb8(%rsp), %r8
movq %r14, %rdi
movq 0x28(%rsp), %rdx
movq %rcx, %rbx
movq 0x30(%rsp), %rcx
callq 0x1c1987
movq %rbp, %r14
movq 0x60(%rsp), %rcx
leaq 0xc(%rsp), %r15
incq %rbp
decq %rbx
cmpq %rcx, %rbp
jbe 0x1c1da4
jmp 0x1c2353
testq %r9, %r9
je 0x1c2353
movq 0x40(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x50(%rsp)
movl $0x40000000, %r15d      # imm = 0x40000000
leaq 0xc(%rsp), %rax
orl 0x18(%rax), %r15d
xorl %r14d, %r14d
movq (%r13,%r14,8), %rax
movl %eax, %ecx
movq %rcx, (%r13,%r14,8)
movq 0x80(%rsp), %rcx
movq (%rcx), %rsi
movq 0x40(%rsp), %rcx
movq 0x10(%rcx), %rcx
shrl %eax
movl (%rcx,%rax,8), %eax
imulq $0xa8, %rax, %rdi
leaq (%rsi,%rdi), %r13
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rsi,%rdi), %ecx
movl 0x10(%rsi,%rdi), %r11d
leaq (%r11,%r11,4), %rdx
movq %rdx, 0x28(%rsp)
movl (%rax,%rdx,8), %r8d
movl %ecx, 0xc(%rsp)
movl %r11d, 0x18(%rsp)
movl %r15d, 0x24(%rsp)
movl 0x30(%rsi,%rdi), %edx
movl $0x3fffffff, %r10d      # imm = 0x3FFFFFFF
andl %r10d, %edx
andl $0xc0000000, %r15d      # imm = 0xC0000000
orl %edx, %r15d
movl %r15d, 0x24(%rsp)
movl 0x1c(%rsi,%rdi), %ebp
shll $0x1f, %ebp
leal (%rdx,%rbp), %r15d
addl $0x40000000, %r15d      # imm = 0x40000000
movl %r15d, 0x24(%rsp)
movl 0x4(%rsi,%rdi), %r10d
movl %r10d, 0x10(%rsp)
movl 0x8(%rsi,%rdi), %r12d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
incl %r12d
movl %r12d, 0x14(%rsp)
testl %ebp, %ebp
movq %r13, 0x30(%rsp)
je 0x1c21e3
movl 0x18(%r13), %ebx
notl %ebx
addl %r8d, %ebx
movl %ebx, 0x1c(%rsp)
movl 0x14(%r13), %esi
movl %r8d, %r13d
subl %esi, %r13d
jmp 0x1c21f2
movl 0x14(%r13), %ebx
movl %ebx, 0x1c(%rsp)
movl 0x18(%r13), %r13d
incl %r13d
movl %r13d, 0x20(%rsp)
movq 0x38(%rsp), %rdi
movl %r12d, %esi
subl %r10d, %esi
cmpq %rdi, %rsi
jb 0x1c2400
movl %r13d, %esi
subl %ebx, %esi
cmpq %rdi, %rsi
jb 0x1c241f
testl %edx, %edx
je 0x1c22ef
leaq (%rcx,%rcx,4), %rcx
movl (%rax,%rcx,8), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rcx
subq $0x8, %rsp
leaq 0x14(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0x78(%rsp), %r9
leaq 0xc0(%rsp), %rax
pushq %rax
movq %r11, 0x78(%rsp)
movl %r10d, 0x68(%rsp)
callq 0x1c0b65
addq $0x10, %rsp
movq 0x70(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x28(%rsp), %rsi
movl (%rcx,%rsi,8), %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andq %rsi, %rcx
subq $0x10, %rsp
movq 0x40(%rsp), %rdi
movq %rax, %rsi
leaq 0xc0(%rsp), %r8
leaq 0xb8(%rsp), %r9
leaq 0x98(%rsp), %rax
pushq %rax
leaq 0xa8(%rsp), %rax
pushq %rax
leaq 0xb8(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
callq 0x1c1081
movl 0x88(%rsp), %r10d
movq 0x98(%rsp), %r11
movq 0x90(%rsp), %r9
addq $0x30, %rsp
testq %rax, %rax
jne 0x1c243e
movq 0x120(%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, (%rax,%rcx)
movups %xmm0, 0x10(%rax,%rcx)
movl %r11d, (%rax,%rcx)
shrl $0x18, %ebp
orb $0x42, %bpl
movb %bpl, 0x1c(%rax,%rcx)
movq $-0x1, 0x4(%rax,%rcx)
movl %r10d, 0xc(%rax,%rcx)
movl %r12d, 0x10(%rax,%rcx)
movl %ebx, 0x14(%rax,%rcx)
movl %r13d, 0x18(%rax,%rcx)
incq %r14
cmpq %r14, %r9
movq 0x78(%rsp), %r13
jne 0x1c2114
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x749e1(%rip), %rdi     # 0x236d4d
leaq 0x71618(%rip), %rsi     # 0x23398b
leaq 0x739ac(%rip), %rcx     # 0x235d26
movl $0x2fb1, %edx           # imm = 0x2FB1
callq 0x2110
leaq 0x73a44(%rip), %rdi     # 0x235dcf
leaq 0x715f9(%rip), %rsi     # 0x23398b
leaq 0x7398d(%rip), %rcx     # 0x235d26
movl $0x2fae, %edx           # imm = 0x2FAE
callq 0x2110
leaq 0x73a10(%rip), %rdi     # 0x235dba
leaq 0x715da(%rip), %rsi     # 0x23398b
leaq 0x7396e(%rip), %rcx     # 0x235d26
movl $0x2fad, %edx           # imm = 0x2FAD
callq 0x2110
leaq 0x739dc(%rip), %rdi     # 0x235da5
leaq 0x715bb(%rip), %rsi     # 0x23398b
leaq 0x7394f(%rip), %rcx     # 0x235d26
movl $0x2fac, %edx           # imm = 0x2FAC
callq 0x2110
leaq 0x73937(%rip), %rdi     # 0x235d1f
leaq 0x7159c(%rip), %rsi     # 0x23398b
leaq 0x73930(%rip), %rcx     # 0x235d26
movl $0x2fab, %edx           # imm = 0x2FAB
callq 0x2110
leaq 0x7399e(%rip), %rdi     # 0x235da5
leaq 0x7157d(%rip), %rsi     # 0x23398b
leaq 0x73911(%rip), %rcx     # 0x235d26
movl $0x2fc0, %edx           # imm = 0x2FC0
callq 0x2110
leaq 0x73994(%rip), %rdi     # 0x235dba
leaq 0x7155e(%rip), %rsi     # 0x23398b
leaq 0x738f2(%rip), %rcx     # 0x235d26
movl $0x2fc1, %edx           # imm = 0x2FC1
callq 0x2110
leaq 0x73994(%rip), %rdi     # 0x235dd9
leaq 0x7153f(%rip), %rsi     # 0x23398b
leaq 0x738d3(%rip), %rcx     # 0x235d26
movl $0x2fc5, %edx           # imm = 0x2FC5
callq 0x2110