// File: /workspace/github_cpp_makefile_star2_O2/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 0xc02f7(%rip), %rax     # 0x254318
movq 0x48(%rax), %rax
imulq $0x58, %rsi, %rcx
movq 0x20(%rax,%rcx), %rdx
movq 0x30(%rax,%rcx), %r14
movq %rdx, 0x8(%rsp)
leaq -0x1(%rdx), %r12
testq %r12, %r12
js 0x194190
imulq $0x24, %r12, %rbp
movb 0x20(%r14,%rbp), %bl
movl %ebx, %eax
andb $-0x40, %al
negb %al
setno %al
testb $0x1f, %bl
sete %cl
orb %al, %cl
jne 0x194188
addq %r14, %rbp
movl 0x14(%rbp), %r15d
movl (%rbp), %eax
movl 0xc(%rbp), %edi
movl 0x10(%rbp), %esi
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %r13
imulq $0x28, %rax, %rdx
addq %r13, %rdx
callq 0x193c23
cmpl $-0x1, %r15d
je 0x1940e9
testl %eax, %eax
jne 0x194188
leaq 0x14(%rbp), %r15
movl (%r15), %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rbx
je 0x1940d1
imulq $0x24, %rbx, %rax
leaq (%r14,%rax), %r15
addq $0x14, %r15
movl -0x14(%r15), %eax
movl -0x8(%r15), %edi
movl -0x4(%r15), %esi
imulq $0x28, %rax, %rdx
addq %r13, %rdx
callq 0x193c23
testl %eax, %eax
je 0x19409c
movl 0x1c(%rbp), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x194118
imulq $0x24, %rax, %rcx
movl 0x18(%r14,%rcx), %ecx
jmp 0x19411a
testl %eax, %eax
jne 0x194188
andb $-0x60, %bl
movb %bl, 0x20(%rbp)
movl 0x1c(%rbp), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x194188
imulq $0x24, %rax, %rax
orq $-0x1, 0x14(%r14,%rax)
orl $-0x1, 0x1c(%rbp)
jmp 0x194188
xorl %ecx, %ecx
movl %r12d, %edx
cmpl %ebx, %edx
je 0x194145
movl %edx, %edx
imulq $0x24, %rdx, %rsi
addl 0x18(%r14,%rsi), %ecx
movl 0x14(%r14,%rsi), %edx
orl $-0x1, 0x1c(%r14,%rsi)
orq $-0x1, 0x14(%r14,%rsi)
andb $-0x20, 0x20(%r14,%rsi)
jmp 0x19411d
cmpl $-0x1, %ebx
je 0x194168
cmpl $-0x1, %eax
je 0x194168
imulq $0x24, %rax, %rdx
movl %ecx, 0x18(%r14,%rdx)
movl %ebx, 0x14(%r14,%rdx)
imulq $0x24, %rbx, %rcx
movl %eax, 0x1c(%r14,%rcx)
jmp 0x194188
cmpl $-0x1, %eax
je 0x194179
imulq $0x24, %rax, %rax
orq $-0x1, 0x14(%r14,%rax)
jmp 0x194188
cmpl $-0x1, %ebx
je 0x194188
imulq $0x24, %rbx, %rax
orl $-0x1, 0x1c(%r14,%rax)
decq %r12
jmp 0x19403c
movq 0x8(%rsp), %r10
imulq $0x24, %r10, %rax
leaq (%rax,%r14), %rcx
addq $-0x10, %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r10, %rsi
movq %rsi, %rdi
decq %rsi
js 0x194249
movb 0xc(%rcx), %r8b
movl %r8d, %r9d
andb $-0x40, %r9b
negb %r9b
setno %r9b
testb $0x1f, %r8b
sete %r8b
orb %r9b, %r8b
jne 0x194240
movl (%rcx), %r8d
cmpq %rdx, %r8
je 0x194209
imulq $0x24, %r8, %r8
movl 0x1c(%r14,%r8), %r9d
testl %edi, %edi
je 0x1941f4
cmpl $-0x1, %r9d
jne 0x1941f4
orl $-0x1, (%rcx)
jmp 0x194209
cmpl %r9d, %esi
jne 0x19434d
testb $0x1f, 0x20(%r14,%r8)
je 0x19436c
movl 0x8(%rcx), %r8d
cmpq %rdx, %r8
je 0x194240
imulq $0x24, %r8, %r8
movl 0x14(%r14,%r8), %r9d
testl %edi, %edi
je 0x19422b
cmpl $-0x1, %r9d
jne 0x19422b
orl $-0x1, 0x8(%rcx)
jmp 0x194240
cmpl %r9d, %esi
jne 0x19438b
testb $0x1f, 0x20(%r14,%r8)
je 0x1943aa
addq $-0x24, %rcx
jmp 0x1941a9
addq %r14, %rax
addq $-0x4, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %r10, %rdx
decq %rdx
js 0x1942c2
movb (%rax), %sil
movl %esi, %edi
andb $-0x40, %dil
negb %dil
setno %dil
testb $0x1f, %sil
sete %sil
orb %dil, %sil
jne 0x1942b9
movl -0xc(%rax), %esi
cmpq %rcx, %rsi
je 0x19429a
imulq $0x24, %rsi, %rsi
leal -0x1(%r10), %edi
cmpl 0x1c(%r14,%rsi), %edi
jne 0x1942f0
addq %r14, %rsi
testb $0x1f, 0x20(%rsi)
je 0x1942d1
movl -0x4(%rax), %esi
cmpq %rcx, %rsi
je 0x1942b9
imulq $0x24, %rsi, %rsi
decl %r10d
cmpl 0x14(%r14,%rsi), %r10d
jne 0x19430f
addq %r14, %rsi
testb $0x1f, 0x20(%rsi)
je 0x19432e
addq $-0x24, %rax
movq %rdx, %r10
jmp 0x194258
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x62bd7(%rip), %rdi     # 0x1f6eaf
leaq 0x5d844(%rip), %rsi     # 0x1f1b23
leaq 0x62b97(%rip), %rcx     # 0x1f6e7d
movl $0x4d10, %edx           # imm = 0x4D10
callq 0x2110
leaq 0x62b67(%rip), %rdi     # 0x1f6e5e
leaq 0x5d825(%rip), %rsi     # 0x1f1b23
leaq 0x62b78(%rip), %rcx     # 0x1f6e7d
movl $0x4d0f, %edx           # imm = 0x4D0F
callq 0x2110
leaq 0x62bab(%rip), %rdi     # 0x1f6ec1
leaq 0x5d806(%rip), %rsi     # 0x1f1b23
leaq 0x62b59(%rip), %rcx     # 0x1f6e7d
movl $0x4d17, %edx           # imm = 0x4D17
callq 0x2110
leaq 0x62bab(%rip), %rdi     # 0x1f6ee0
leaq 0x5d7e7(%rip), %rsi     # 0x1f1b23
leaq 0x62b3a(%rip), %rcx     # 0x1f6e7d
movl $0x4d18, %edx           # imm = 0x4D18
callq 0x2110
leaq 0x62b0a(%rip), %rdi     # 0x1f6e5e
leaq 0x5d7c8(%rip), %rsi     # 0x1f1b23
leaq 0x62b1b(%rip), %rcx     # 0x1f6e7d
movl $0x4cf3, %edx           # imm = 0x4CF3
callq 0x2110
leaq 0x62b3c(%rip), %rdi     # 0x1f6eaf
leaq 0x5d7a9(%rip), %rsi     # 0x1f1b23
leaq 0x62afc(%rip), %rcx     # 0x1f6e7d
movl $0x4cf4, %edx           # imm = 0x4CF4
callq 0x2110
leaq 0x62b2f(%rip), %rdi     # 0x1f6ec1
leaq 0x5d78a(%rip), %rsi     # 0x1f1b23
leaq 0x62add(%rip), %rcx     # 0x1f6e7d
movl $0x4cfb, %edx           # imm = 0x4CFB
callq 0x2110
leaq 0x62b2f(%rip), %rdi     # 0x1f6ee0
leaq 0x5d76b(%rip), %rsi     # 0x1f1b23
leaq 0x62abe(%rip), %rcx     # 0x1f6e7d
movl $0x4cfc, %edx           # imm = 0x4CFC
callq 0x2110