// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: filter_short_ulalignments(void*, long, int)
static void filter_short_ulalignments(void *data, long i, int tid) // callback for kt_for()
{
	const ma_ug_t *ug = (ma_ug_t *)data;
	uc_block_t *a = NULL; uc_block_t *p; int64_t k, a_n; uint32_t z, fz, lz, l, bz;
	a = UL_INF.a[i].bb.a; a_n = UL_INF.a[i].bb.n; 

	for (k = a_n - 1; k >= 0; k--) {
		p = &(a[k]);
		// if(i == 338344) {
		// 	fprintf(stderr, "+[M::%s::id->%ld::rlen->%u::glen->%u] (%ld) utg%.6dl, q::[%u, %u), t::[%u, %u), pidx::%u, aidx::%u, pdis::%u, a[k].base::%u, a[k].el::%u, a[k].pchain::%u\n", 
		// 	__func__, i, UL_INF.a[i].rlen, ug->u.a[p->hid].len, k, (int32_t)a[k].hid+1, a[k].qs, a[k].qe, a[k].ts, a[k].te, a[k].pidx, a[k].aidx, a[k].pdis, 
		// 	a[k].base, a[k].el, a[k].pchain);
		// }
		if(p->base || (!p->el) || (!p->pchain)) continue;
		if(p->pidx == (uint32_t)-1) {
			if(!ugl_cover_check(p->ts, p->te, &(ug->u.a[p->hid]))) {
				p->pchain = 0;
				if(p->aidx != (uint32_t)-1) {
					a[p->aidx].pidx = a[p->aidx].pdis = (uint32_t)-1; p->aidx = (uint32_t)-1;
				}
			}
			continue;
		}
		if(ugl_cover_check(p->ts, p->te, &(ug->u.a[p->hid]))) continue;
		for (z = p->pidx; z != (uint32_t)-1; z = a[z].pidx) {
			if(ugl_cover_check(a[z].ts, a[z].te, &(ug->u.a[a[z].hid]))) break;
		}
		lz = z; fz = p->aidx; l = 0; if(fz != (uint32_t)-1) l = a[fz].pdis;
		for (z = k; z != lz; z = bz) {
			bz = a[z].pidx; l += a[z].pdis;
			a[z].pidx = a[z].pdis = a[z].aidx = (uint32_t)-1; a[z].pchain = 0;
		}

		if(fz != (uint32_t)-1 && lz != (uint32_t)-1) {
			a[fz].pdis = l; a[fz].pidx = lz; a[lz].aidx = fz;
		} else if(fz != (uint32_t)-1) {
			a[fz].pdis = a[fz].pidx = (uint32_t)-1;
		} else if(lz != (uint32_t)-1) {
			a[lz].aidx = (uint32_t)-1;
		}
	}

	for (k = a_n - 1; k >= 0; k--) {
		p = &(a[k]);
		if(p->base || (!p->el) || (!p->pchain)) continue;
		if(p->pidx != (uint32_t)-1) {		
			if((a[p->pidx].aidx != ((uint32_t)k)) && (a[p->pidx].aidx == ((uint32_t)-1))) {
				p->pidx = (uint32_t)-1;
			} else {
				assert(a[p->pidx].aidx == (uint32_t)k);
				assert(a[p->pidx].pchain);
			}
		}
		if(p->aidx != (uint32_t)-1) {
			if((a[p->aidx].pidx != (uint32_t)k) && (a[p->aidx].pidx == ((uint32_t)-1))) {
				p->aidx = (uint32_t)-1;
			} else {
				assert(a[p->aidx].pidx == (uint32_t)k);
				assert(a[p->aidx].pchain);
			}
			
		}
	}

	for (k = a_n - 1; k >= 0; k--) {
		p = &(a[k]);
		if(p->base || (!p->el) || (!p->pchain)) continue;
		// if(i == 338344) {
		// 	fprintf(stderr, "-[M::%s::id->%ld::rlen->%u::glen->%u] (%ld) utg%.6dl, q::[%u, %u), t::[%u, %u), pidx::%u, aidx::%u, pdis::%u, a[k].base::%u, a[k].el::%u, a[k].pchain::%u\n", 
		// 	__func__, i, UL_INF.a[i].rlen, ug->u.a[p->hid].len, k, (int32_t)a[k].hid+1, a[k].qs, a[k].qe, a[k].ts, a[k].te, a[k].pidx, a[k].aidx, a[k].pdis, 
		// 	a[k].base, a[k].el, a[k].pchain);
		// }
		if(p->pidx != (uint32_t)-1) {
			// if(!(a[p->pidx].aidx == (uint32_t)k)) {
			// 	fprintf(stderr, "[M::%s::id->%ld] name::%.*s, a_n::%ld\n", __func__, 
			// 		i, (int32_t)UL_INF.nid.a[i].n, UL_INF.nid.a[i].a, a_n);
			// }			
			assert(a[p->pidx].aidx == (uint32_t)k);
			assert(a[p->pidx].pchain);
		}
		if(p->aidx != (uint32_t)-1) {
			// if(a[p->aidx].pidx != (uint32_t)k) {
			// 	fprintf(stderr, "[M::%s::id->%ld] name::%.*s, a_n::%ld, p->aidx::%u, p->pidx::%u, a[p->aidx].pidx::%u\n", __func__, i, (int32_t)UL_INF.nid.a[i].n, UL_INF.nid.a[i].a, a_n, 
			// 	p->aidx, p->pidx, a[p->aidx].pidx);
			// }
			assert(a[p->aidx].pidx == (uint32_t)k);
			assert(a[p->aidx].pchain);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
leaq 0xb53d7(%rip), %rax     # 0x296318
movq 0x48(%rax), %rax
imulq $0x58, %rsi, %rcx
movq 0x20(%rax,%rcx), %rdx
testq %rdx, %rdx
jle 0x1e122e
movq 0x30(%rax,%rcx), %r15
movq %rdx, 0x8(%rsp)
leaq -0x1(%rdx), %r13
leaq (,%r13,8), %rax
addq %r13, %rax
movb 0x20(%r15,%rax,4), %r14b
movl %r14d, %ecx
andb $-0x40, %cl
negb %cl
setno %cl
testb $0x1f, %r14b
sete %dl
orb %cl, %dl
jne 0x1e10d9
leaq (%r15,%rax,4), %r12
movl 0x14(%r12), %ebp
movl (%r12), %eax
movl 0xc(%r12), %edi
movl 0x10(%r12), %esi
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rbx
leaq (%rax,%rax,4), %rax
leaq (%rbx,%rax,8), %rdx
callq 0x1e0c58
cmpl $-0x1, %ebp
je 0x1e1019
testl %eax, %eax
jne 0x1e10d9
movl %ebp, %eax
leaq (%rax,%rax,8), %r14
movl (%r15,%r14,4), %eax
movl 0xc(%r15,%r14,4), %edi
movl 0x10(%r15,%r14,4), %esi
leaq (%rax,%rax,4), %rax
leaq (%rbx,%rax,8), %rdx
callq 0x1e0c58
testl %eax, %eax
jne 0x1e0fff
leaq (%r15,%r14,4), %rcx
movl 0x14(%rcx), %ebp
cmpl $-0x1, %ebp
jne 0x1e0fc9
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl 0x1c(%r12), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
je 0x1e1058
leaq (%rcx,%rcx,8), %rdx
movl 0x18(%r15,%rdx,4), %edx
jmp 0x1e105a
testl %eax, %eax
jne 0x1e10d9
andb $-0x60, %r14b
movb %r14b, 0x20(%r12)
movl 0x1c(%r12), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x1e10d9
leaq (%rax,%rax,8), %rax
movq $-0x1, 0x14(%r15,%rax,4)
movl $0xffffffff, 0x1c(%r12) # imm = 0xFFFFFFFF
jmp 0x1e10d9
xorl %edx, %edx
cmpl %r13d, %ebp
je 0x1e108e
movl %r13d, %esi
movl %esi, %esi
leaq (%rsi,%rsi,8), %rdi
movl 0x14(%r15,%rdi,4), %esi
addl 0x18(%r15,%rdi,4), %edx
movl $0xffffffff, 0x1c(%r15,%rdi,4) # imm = 0xFFFFFFFF
movq $-0x1, 0x14(%r15,%rdi,4)
andb $-0x20, 0x20(%r15,%rdi,4)
cmpl %ebp, %esi
jne 0x1e1062
testl %eax, %eax
je 0x1e10b2
cmpl $-0x1, %ecx
je 0x1e10b2
leaq (%rcx,%rcx,8), %rax
movl %edx, 0x18(%r15,%rax,4)
movl %ebp, 0x14(%r15,%rax,4)
movl %ebp, %eax
leaq (%rax,%rax,8), %rax
movl %ecx, 0x1c(%r15,%rax,4)
jmp 0x1e10d9
cmpl $-0x1, %ecx
je 0x1e10c6
leaq (%rcx,%rcx,8), %rax
movq $-0x1, 0x14(%r15,%rax,4)
jmp 0x1e10d9
testl %eax, %eax
je 0x1e10d9
movl %ebp, %eax
leaq (%rax,%rax,8), %rax
movl $0xffffffff, 0x1c(%r15,%rax,4) # imm = 0xFFFFFFFF
leaq -0x1(%r13), %rax
testq %r13, %r13
movq %rax, %r13
jg 0x1e0f65
movq 0x8(%rsp), %r10
testq %r10, %r10
jle 0x1e122e
leaq (%r10,%r10,8), %rax
leaq (%r15,%rax,4), %rcx
addq $-0x10, %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r10, %rsi
movb 0xc(%rcx), %dil
movl %edi, %r8d
andb $-0x40, %r8b
negb %r8b
setno %r8b
testb $0x1f, %dil
sete %dil
orb %r8b, %dil
jne 0x1e11a2
movl (%rcx), %edi
cmpq %rdx, %rdi
je 0x1e1165
leaq (%rdi,%rdi,8), %rdi
movl 0x1c(%r15,%rdi,4), %r8d
testl %esi, %esi
je 0x1e114c
cmpl $-0x1, %r8d
jne 0x1e114c
movl $0xffffffff, (%rcx)     # imm = 0xFFFFFFFF
jmp 0x1e1165
leaq -0x1(%rsi), %r9
cmpl %r8d, %r9d
jne 0x1e12b9
testb $0x1f, 0x20(%r15,%rdi,4)
je 0x1e12d8
movl 0x8(%rcx), %edi
cmpq %rdx, %rdi
je 0x1e11a2
leaq (%rdi,%rdi,8), %rdi
movl 0x14(%r15,%rdi,4), %r8d
testl %esi, %esi
je 0x1e1189
cmpl $-0x1, %r8d
jne 0x1e1189
movl $0xffffffff, 0x8(%rcx)  # imm = 0xFFFFFFFF
jmp 0x1e11a2
leaq -0x1(%rsi), %r9
cmpl %r8d, %r9d
jne 0x1e12f7
testb $0x1f, 0x20(%r15,%rdi,4)
je 0x1e1316
addq $-0x24, %rcx
decq %rsi
jg 0x1e110b
testq %r10, %r10
jle 0x1e122e
leaq (%r15,%rax,4), %rax
addq $-0x4, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movb (%rax), %dl
movl %edx, %esi
andb $-0x40, %sil
negb %sil
setno %sil
testb $0x1f, %dl
sete %dl
orb %sil, %dl
jne 0x1e1225
movl -0xc(%rax), %edx
cmpq %rcx, %rdx
je 0x1e1204
leaq (%rdx,%rdx,8), %rdx
leal -0x1(%r10), %esi
cmpl 0x1c(%r15,%rdx,4), %esi
jne 0x1e127b
leaq (%r15,%rdx,4), %rdx
testb $0x1f, 0x20(%rdx)
je 0x1e129a
movl -0x4(%rax), %edx
cmpq %rcx, %rdx
je 0x1e1225
leaq (%rdx,%rdx,8), %rdx
leal -0x1(%r10), %esi
cmpl 0x14(%r15,%rdx,4), %esi
jne 0x1e123d
leaq (%r15,%rdx,4), %rdx
testb $0x1f, 0x20(%rdx)
je 0x1e125c
addq $-0x24, %rax
decq %r10
jg 0x1e11c1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x63db5(%rip), %rdi     # 0x244ff9
leaq 0x5ea10(%rip), %rsi     # 0x23fc5b
leaq 0x63d63(%rip), %rcx     # 0x244fb5
movl $0x4d17, %edx           # imm = 0x4D17
callq 0x2110
leaq 0x63db5(%rip), %rdi     # 0x245018
leaq 0x5e9f1(%rip), %rsi     # 0x23fc5b
leaq 0x63d44(%rip), %rcx     # 0x244fb5
movl $0x4d18, %edx           # imm = 0x4D18
callq 0x2110
leaq 0x63d14(%rip), %rdi     # 0x244f96
leaq 0x5e9d2(%rip), %rsi     # 0x23fc5b
leaq 0x63d25(%rip), %rcx     # 0x244fb5
movl $0x4d0f, %edx           # imm = 0x4D0F
callq 0x2110
leaq 0x63d46(%rip), %rdi     # 0x244fe7
leaq 0x5e9b3(%rip), %rsi     # 0x23fc5b
leaq 0x63d06(%rip), %rcx     # 0x244fb5
movl $0x4d10, %edx           # imm = 0x4D10
callq 0x2110
leaq 0x63cd6(%rip), %rdi     # 0x244f96
leaq 0x5e994(%rip), %rsi     # 0x23fc5b
leaq 0x63ce7(%rip), %rcx     # 0x244fb5
movl $0x4cf3, %edx           # imm = 0x4CF3
callq 0x2110
leaq 0x63d08(%rip), %rdi     # 0x244fe7
leaq 0x5e975(%rip), %rsi     # 0x23fc5b
leaq 0x63cc8(%rip), %rcx     # 0x244fb5
movl $0x4cf4, %edx           # imm = 0x4CF4
callq 0x2110
leaq 0x63cfb(%rip), %rdi     # 0x244ff9
leaq 0x5e956(%rip), %rsi     # 0x23fc5b
leaq 0x63ca9(%rip), %rcx     # 0x244fb5
movl $0x4cfb, %edx           # imm = 0x4CFB
callq 0x2110
leaq 0x63cfb(%rip), %rdi     # 0x245018
leaq 0x5e937(%rip), %rsi     # 0x23fc5b
leaq 0x63c8a(%rip), %rcx     # 0x244fb5
movl $0x4cfc, %edx           # imm = 0x4CFC
callq 0x2110