// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
movq %rcx, 0x38(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdi, 0x30(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x128(%rsp)
movq %r8, 0x78(%rsp)
movq %r9, 0x50(%rsp)
je 0x1cc124
testq %r9, %r9
je 0x1cc360
xorl %eax, %eax
movl $0x0, 0x4(%r12,%rax,8)
incq %rax
cmpq %rax, %r9
jne 0x1cbdcb
leaq (%r12,%r9,8), %rsi
movq %r12, %rdi
callq 0x19dd99
movq 0x50(%rsp), %rdx
leaq 0xc0(%rsp), %rax
movq $0x0, (%rax)
movq 0x30(%rsp), %rax
addq $0x18, %rax
movq %rax, 0xc8(%rsp)
movl $0x1, %ebp
movq $-0x1, %r13
xorl %ebx, %ebx
leaq 0x14(%rsp), %r14
cmpq %rbp, %rdx
jne 0x1cbe2b
movq (%r12,%rbx,8), %rax
jmp 0x1cbe40
movq (%r12,%rbx,8), %rax
movq (%r12,%rbp,8), %rcx
xorq %rax, %rcx
cmpq $0x2, %rcx
jb 0x1cc110
movq %r13, 0x60(%rsp)
movq 0x80(%rsp), %rcx
movq (%rcx), %rdi
movq 0x30(%rsp), %rcx
movq 0x10(%rcx), %rcx
andq $-0x2, %rax
movl (%rcx,%rax,4), %eax
imulq $0xa8, %rax, %r9
leaq (%rdi,%r9), %r13
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rdi,%r9), %ecx
movl 0x10(%rdi,%r9), %edx
leaq (%rdx,%rdx,4), %r15
movl (%rax,%r15,8), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl %ecx, 0x14(%rsp)
movl %edx, 0x20(%rsp)
movl 0x30(%rdi,%r9), %edx
movl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
andl %esi, %edx
movl 0x1c(%rdi,%r9), %r10d
shll $0x1f, %r10d
leal (%rdx,%r10), %esi
addl $0x40000000, %esi       # imm = 0x40000000
movl %esi, 0x2c(%rsp)
movl 0x4(%rdi,%r9), %esi
movl %esi, 0x18(%rsp)
movl 0x8(%rdi,%r9), %edi
incl %edi
movl %edi, 0x1c(%rsp)
testl %r10d, %r10d
je 0x1cbee6
movl 0x18(%r13), %r9d
notl %r9d
addl %r8d, %r9d
movl 0x14(%r13), %r11d
movl %r8d, %r10d
subl %r11d, %r10d
jmp 0x1cbef1
movl 0x14(%r13), %r9d
movl 0x18(%r13), %r10d
incl %r10d
movl %r9d, 0x24(%rsp)
movl %r10d, 0x28(%rsp)
leaq 0x2(%rbx), %r12
cmpq %r12, %rbp
ja 0x1cc3f9
subl %esi, %edi
movq 0x8(%rsp), %rsi
cmpq %rsi, %rdi
jb 0x1cc3da
subl %r9d, %r10d
cmpq %rsi, %r10
jb 0x1cc3bb
testl %edx, %edx
je 0x1cc39c
leaq (%rcx,%rcx,4), %rcx
movl (%rax,%rcx,8), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rcx
subq $0x8, %rsp
movq %r14, %rdi
movq 0xd0(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0x70(%rsp), %r9
leaq 0xc0(%rsp), %rax
pushq %rax
callq 0x1cab51
addq $0x10, %rsp
movq %rax, %rsi
movq 0x68(%rsp), %rdx
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rax,%r15,8), %ecx
movq %rdx, %r15
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rcx
subq $0x10, %rsp
movq %r13, %rdi
movq %rsi, 0x68(%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 0x1cb063
addq $0x30, %rsp
testq %rax, %rax
je 0x1cc37d
movq 0xb0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movq 0x98(%rsp), %r8
movq 0x90(%rsp), %r9
movq 0x88(%rsp), %r11
movq 0x78(%rsp), %rdi
movq (%rdi,%rbx,8), %rax
andl $0x1, %eax
xorl %r10d, %r10d
cmpq %r12, %rbp
movq %rdi, %r12
sete %r10b
subq $0x8, %rsp
movq 0x78(%rsp), %r13
movq %r13, %rdi
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rcx, 0xe8(%rsp)
movq %r8, 0xe0(%rsp)
movq %r9, 0xd8(%rsp)
pushq %r14
movq %r11, %r14
pushq 0x18(%rsp)
pushq %r10
pushq %rax
pushq %r11
callq 0x1cbc14
addq $0x30, %rsp
leaq 0x1(%rbx), %rax
cmpq %rbp, %rax
jae 0x1cc0ca
movq 0x8(%r12,%rbx,8), %rax
andl $0x1, %eax
leaq 0x3(%rbx), %rcx
xorl %r10d, %r10d
cmpq %rcx, %rbp
sete %r10b
subq $0x8, %rsp
movq %r13, %rdi
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0xe8(%rsp), %rcx
movq 0xe0(%rsp), %r8
movq 0xd8(%rsp), %r9
leaq 0x1c(%rsp), %r11
pushq %r11
pushq 0x18(%rsp)
pushq %r10
pushq %rax
pushq %r14
callq 0x1cbc14
addq $0x30, %rsp
movq %rbp, %rsi
subq %rbx, %rsi
movq 0x8(%r13), %rax
shlq $0x5, %rax
addq (%r13), %rax
movq 0x60(%rsp), %r13
addq %r13, %rbx
shlq $0x5, %rbx
addq %rax, %rbx
movq 0xb8(%rsp), %r8
movq %rbx, %rdi
movq 0x58(%rsp), %rdx
movq %r15, %rcx
callq 0x1cba5b
movq %rbp, %rbx
movq 0x50(%rsp), %rdx
leaq 0x14(%rsp), %r14
incq %rbp
decq %r13
cmpq %rdx, %rbp
jbe 0x1cbe20
jmp 0x1cc34e
testq %r9, %r9
je 0x1cc34e
movq 0x30(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x40(%rsp)
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rax
movl %eax, %ecx
movq %rcx, (%r12,%rbx,8)
movq 0x80(%rsp), %rcx
movq (%rcx), %rsi
movq 0x30(%rsp), %rcx
movq 0x10(%rcx), %rcx
shrl %eax
movl (%rcx,%rax,8), %eax
imulq $0xa8, %rax, %rdi
leaq (%rsi,%rdi), %r14
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rsi,%rdi), %ecx
movl 0x10(%rsi,%rdi), %r11d
leaq (%r11,%r11,4), %rdx
movq %rdx, 0x58(%rsp)
movl (%rax,%rdx,8), %r8d
movl %ecx, 0x14(%rsp)
movl %r11d, 0x20(%rsp)
movl 0x30(%rsi,%rdi), %edx
movl $0x3fffffff, %r10d      # imm = 0x3FFFFFFF
andl %r10d, %edx
movl 0x1c(%rsi,%rdi), %r15d
shll $0x1f, %r15d
leal (%rdx,%r15), %r10d
addl $0x40000000, %r10d      # imm = 0x40000000
movl %r10d, 0x2c(%rsp)
movl 0x4(%rsi,%rdi), %r12d
movl %r12d, 0x18(%rsp)
movl 0x8(%rsi,%rdi), %ebp
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
incl %ebp
movl %ebp, 0x1c(%rsp)
testl %r15d, %r15d
movq %r14, 0x60(%rsp)
je 0x1cc1f3
movl 0x18(%r14), %r13d
notl %r13d
addl %r8d, %r13d
movl 0x14(%r14), %esi
movl %r8d, %r14d
subl %esi, %r14d
jmp 0x1cc1fe
movl 0x14(%r14), %r13d
movl 0x18(%r14), %r14d
incl %r14d
movq 0x8(%rsp), %rdi
movl %r13d, 0x24(%rsp)
movl %r14d, 0x28(%rsp)
movl %ebp, %esi
subl %r12d, %esi
cmpq %rdi, %rsi
jb 0x1cc418
movl %r14d, %esi
subl %r13d, %esi
cmpq %rdi, %rsi
jb 0x1cc437
testl %edx, %edx
je 0x1cc2f0
leaq (%rcx,%rcx,4), %rcx
movl (%rax,%rcx,8), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rcx
subq $0x8, %rsp
leaq 0x1c(%rsp), %rdi
movq 0x48(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0x70(%rsp), %r9
leaq 0xc0(%rsp), %rax
pushq %rax
movq %r11, 0x58(%rsp)
callq 0x1cab51
addq $0x10, %rsp
movq 0x68(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x58(%rsp), %rsi
movl (%rcx,%rsi,8), %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andq %rsi, %rcx
subq $0x10, %rsp
movq 0x70(%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 0x1cb063
movq 0x78(%rsp), %r11
movq 0x80(%rsp), %r9
addq $0x30, %rsp
testq %rax, %rax
jne 0x1cc456
movq 0x70(%rsp), %rsi
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
shlq $0x5, %rcx
movl $0x0, 0x1c(%rax,%rcx)
movl %r11d, (%rax,%rcx)
shrl $0x18, %r15d
orb $0x42, %r15b
movb %r15b, 0x1c(%rax,%rcx)
movq $-0x1, 0x4(%rax,%rcx)
movl %r12d, 0xc(%rax,%rcx)
movl %ebp, 0x10(%rax,%rcx)
movl %r13d, 0x14(%rax,%rcx)
movl %r14d, 0x18(%rax,%rcx)
incq %rbx
cmpq %rbx, %r9
movq 0x78(%rsp), %r12
jne 0x1cc13d
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%r12,%r9,8), %rsi
movq %r12, %rdi
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x19dd99
leaq 0x76c99(%rip), %rdi     # 0x24301d
leaq 0x738d0(%rip), %rsi     # 0x23fc5b
leaq 0x75c64(%rip), %rcx     # 0x241ff6
movl $0x2fb1, %edx           # imm = 0x2FB1
callq 0x2110
leaq 0x75cfc(%rip), %rdi     # 0x24209f
leaq 0x738b1(%rip), %rsi     # 0x23fc5b
leaq 0x75c45(%rip), %rcx     # 0x241ff6
movl $0x2fae, %edx           # imm = 0x2FAE
callq 0x2110
leaq 0x75cc8(%rip), %rdi     # 0x24208a
leaq 0x73892(%rip), %rsi     # 0x23fc5b
leaq 0x75c26(%rip), %rcx     # 0x241ff6
movl $0x2fad, %edx           # imm = 0x2FAD
callq 0x2110
leaq 0x75c94(%rip), %rdi     # 0x242075
leaq 0x73873(%rip), %rsi     # 0x23fc5b
leaq 0x75c07(%rip), %rcx     # 0x241ff6
movl $0x2fac, %edx           # imm = 0x2FAC
callq 0x2110
leaq 0x75bef(%rip), %rdi     # 0x241fef
leaq 0x73854(%rip), %rsi     # 0x23fc5b
leaq 0x75be8(%rip), %rcx     # 0x241ff6
movl $0x2fab, %edx           # imm = 0x2FAB
callq 0x2110
leaq 0x75c56(%rip), %rdi     # 0x242075
leaq 0x73835(%rip), %rsi     # 0x23fc5b
leaq 0x75bc9(%rip), %rcx     # 0x241ff6
movl $0x2fc0, %edx           # imm = 0x2FC0
callq 0x2110
leaq 0x75c4c(%rip), %rdi     # 0x24208a
leaq 0x73816(%rip), %rsi     # 0x23fc5b
leaq 0x75baa(%rip), %rcx     # 0x241ff6
movl $0x2fc1, %edx           # imm = 0x2FC1
callq 0x2110
leaq 0x75c4c(%rip), %rdi     # 0x2420a9
leaq 0x737f7(%rip), %rsi     # 0x23fc5b
leaq 0x75b8b(%rip), %rcx     # 0x241ff6
movl $0x2fc5, %edx           # imm = 0x2FC5
callq 0x2110