// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
leaq 0xb42ec(%rip), %rax     # 0x28b318
movq 0x48(%rax), %rax
imulq $0x58, %rsi, %rcx
movq 0x20(%rax,%rcx), %r14
movq 0x30(%rax,%rcx), %r15
testq %r14, %r14
jle 0x1d720e
leaq -0x1(%r14), %r13
leaq (,%r13,8), %rax
addq %r13, %rax
movb 0x20(%r15,%rax,4), %bl
movl %ebx, %ecx
andb $-0x40, %cl
negb %cl
setno %cl
testb $0x1f, %bl
sete %dl
orb %cl, %dl
jne 0x1d71fe
leaq (%r15,%rax,4), %r12
cmpl $-0x1, 0x14(%r12)
movl (%r12), %eax
movl 0xc(%r12), %edi
movl 0x10(%r12), %esi
je 0x1d7107
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rbx
leaq (%rax,%rax,4), %rax
leaq (%rbx,%rax,8), %rdx
callq 0x1d6d45
testl %eax, %eax
jne 0x1d71fe
movq %rbx, 0x10(%rsp)
movl 0x14(%r12), %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rbp
setne %bl
je 0x1d715b
leaq (,%rbp,8), %rax
addq %rbp, %rax
movl (%r15,%rax,4), %ecx
movl 0xc(%r15,%rax,4), %edi
movl 0x10(%r15,%rax,4), %esi
leaq (%rcx,%rcx,4), %rax
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %rdx
callq 0x1d6d45
testl %eax, %eax
jne 0x1d715b
leaq (,%rbp,8), %rax
addq %rbp, %rax
movl 0x14(%r15,%rax,4), %ebp
jmp 0x1d70b5
leaq (%rax,%rax,4), %rdx
shlq $0x3, %rdx
movq 0x8(%rsp), %rax
addq 0x10(%rax), %rdx
callq 0x1d6d45
testl %eax, %eax
jne 0x1d71fe
andb $-0x60, %bl
movb %bl, 0x20(%r12)
movl 0x1c(%r12), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x1d71fe
leaq (%rax,%rax,8), %rax
movq $-0x1, 0x14(%r15,%rax,4)
movl $0xffffffff, 0x1c(%r12) # imm = 0xFFFFFFFF
jmp 0x1d71fe
movl 0x1c(%r12), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x1d7175
leaq (%rax,%rax,8), %rcx
movl 0x18(%r15,%rcx,4), %ecx
jmp 0x1d7177
xorl %ecx, %ecx
cmpl %r13d, %ebp
je 0x1d71ab
movl %r13d, %edx
movl %edx, %edx
leaq (%rdx,%rdx,8), %rsi
movl 0x14(%r15,%rsi,4), %edx
addl 0x18(%r15,%rsi,4), %ecx
movl $0xffffffff, 0x1c(%r15,%rsi,4) # imm = 0xFFFFFFFF
movq $-0x1, 0x14(%r15,%rsi,4)
andb $-0x20, 0x20(%r15,%rsi,4)
cmpl %ebp, %edx
jne 0x1d717f
cmpl $-0x1, %eax
sete %dl
movl %ebx, %esi
xorb $0x1, %sil
orb %dl, %sil
jne 0x1d71d7
leaq (%rax,%rax,8), %rdx
movl %ecx, 0x18(%r15,%rdx,4)
movl %ebp, 0x14(%r15,%rdx,4)
movl %ebp, %ecx
leaq (%rcx,%rcx,8), %rcx
movl %eax, 0x1c(%r15,%rcx,4)
jmp 0x1d71fe
cmpl $-0x1, %eax
je 0x1d71eb
leaq (%rax,%rax,8), %rax
movq $-0x1, 0x14(%r15,%rax,4)
jmp 0x1d71fe
testb %bl, %bl
je 0x1d71fe
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 0x1d704b
leaq (%r14,%r14,8), %rax
testq %r14, %r14
jle 0x1d72d1
leaq (%r15,%rax,4), %rcx
addq $-0x10, %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r14, %rsi
movb 0xc(%rcx), %dil
movl %edi, %r8d
andb $-0x40, %r8b
negb %r8b
setno %r8b
testb $0x1f, %dil
sete %dil
orb %r8b, %dil
jne 0x1d72c4
movl (%rcx), %edi
cmpq %rdx, %rdi
je 0x1d7286
leaq (%rdi,%rdi,8), %rdi
testl %esi, %esi
je 0x1d7269
cmpl $-0x1, 0x1c(%r15,%rdi,4)
jne 0x1d7269
movl $0xffffffff, (%rcx)     # imm = 0xFFFFFFFF
jmp 0x1d7286
leaq -0x1(%rsi), %r8
cmpl 0x1c(%r15,%rdi,4), %r8d
jne 0x1d73db
leaq (%r15,%rdi,4), %rdi
testb $0x1f, 0x20(%rdi)
je 0x1d73fa
movl 0x8(%rcx), %edi
cmpq %rdx, %rdi
je 0x1d72c4
leaq (%rdi,%rdi,8), %rdi
testl %esi, %esi
je 0x1d72a7
cmpl $-0x1, 0x14(%r15,%rdi,4)
jne 0x1d72a7
movl $0xffffffff, 0x8(%rcx)  # imm = 0xFFFFFFFF
jmp 0x1d72c4
leaq -0x1(%rsi), %r8
cmpl 0x14(%r15,%rdi,4), %r8d
jne 0x1d7419
leaq (%r15,%rdi,4), %rdi
testb $0x1f, 0x20(%rdi)
je 0x1d7438
addq $-0x24, %rcx
decq %rsi
jg 0x1d722b
testq %r14, %r14
jle 0x1d7350
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 0x1d7347
movl -0xc(%rax), %edx
cmpq %rcx, %rdx
je 0x1d7326
leaq (%rdx,%rdx,8), %rdx
leal -0x1(%r14), %esi
cmpl 0x1c(%r15,%rdx,4), %esi
jne 0x1d739d
leaq (%r15,%rdx,4), %rdx
testb $0x1f, 0x20(%rdx)
je 0x1d73bc
movl -0x4(%rax), %edx
cmpq %rcx, %rdx
je 0x1d7347
leaq (%rdx,%rdx,8), %rdx
leal -0x1(%r14), %esi
cmpl 0x14(%r15,%rdx,4), %esi
jne 0x1d735f
leaq (%r15,%rdx,4), %rdx
testb $0x1f, 0x20(%rdx)
je 0x1d737e
addq $-0x24, %rax
decq %r14
jg 0x1d72e3
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x619c3(%rip), %rdi     # 0x238d29
leaq 0x5c61e(%rip), %rsi     # 0x23398b
leaq 0x61971(%rip), %rcx     # 0x238ce5
movl $0x4d17, %edx           # imm = 0x4D17
callq 0x2110
leaq 0x619c3(%rip), %rdi     # 0x238d48
leaq 0x5c5ff(%rip), %rsi     # 0x23398b
leaq 0x61952(%rip), %rcx     # 0x238ce5
movl $0x4d18, %edx           # imm = 0x4D18
callq 0x2110
leaq 0x61922(%rip), %rdi     # 0x238cc6
leaq 0x5c5e0(%rip), %rsi     # 0x23398b
leaq 0x61933(%rip), %rcx     # 0x238ce5
movl $0x4d0f, %edx           # imm = 0x4D0F
callq 0x2110
leaq 0x61954(%rip), %rdi     # 0x238d17
leaq 0x5c5c1(%rip), %rsi     # 0x23398b
leaq 0x61914(%rip), %rcx     # 0x238ce5
movl $0x4d10, %edx           # imm = 0x4D10
callq 0x2110
leaq 0x618e4(%rip), %rdi     # 0x238cc6
leaq 0x5c5a2(%rip), %rsi     # 0x23398b
leaq 0x618f5(%rip), %rcx     # 0x238ce5
movl $0x4cf3, %edx           # imm = 0x4CF3
callq 0x2110
leaq 0x61916(%rip), %rdi     # 0x238d17
leaq 0x5c583(%rip), %rsi     # 0x23398b
leaq 0x618d6(%rip), %rcx     # 0x238ce5
movl $0x4cf4, %edx           # imm = 0x4CF4
callq 0x2110
leaq 0x61909(%rip), %rdi     # 0x238d29
leaq 0x5c564(%rip), %rsi     # 0x23398b
leaq 0x618b7(%rip), %rcx     # 0x238ce5
movl $0x4cfb, %edx           # imm = 0x4CFB
callq 0x2110
leaq 0x61909(%rip), %rdi     # 0x238d48
leaq 0x5c545(%rip), %rsi     # 0x23398b
leaq 0x61898(%rip), %rcx     # 0x238ce5
movl $0x4cfc, %edx           # imm = 0x4CFC
callq 0x2110