// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: rescue_adject_ovlp(asg_t*, unsigned int, kv_u_trans_t*, kv_ul_ov_t*, st_mt_t*)
uint32_t rescue_adject_ovlp(asg_t *g, uint32_t id, kv_u_trans_t *ta, kv_ul_ov_t *out, st_mt_t *buf)
{
	u_trans_t *a, *b; ul_ov_t rr; uint64_t a_n, b_n, k, l, i, z, m; 
	a = u_trans_a((*ta), id); a_n = u_trans_n((*ta), id);
	for (i = out->n = buf->n = 0; i < a_n; i++) {
		b = u_trans_a((*ta), a[i].tn); b_n = u_trans_n((*ta), a[i].tn);
		z = a[i].tn; z <<= 32; kv_push(uint64_t, *buf, z);
		for (k = 0; k < b_n; k++) {
			if(b[k].tn == id) continue;
			if(!tranfor_ovlp(&(a[i]), &(b[k]), g, &rr, 1)) continue;
			z = rr.tn; z <<= 32; z |= out->n; z |= ((uint64_t)0x80000000);
			rr.tn <<= 1; rr.tn |= rr.rev; kv_push(ul_ov_t, *out, rr); 
		}
	}
	if(out->n == 0) return 1;

	radix_sort_gfa64(buf->a, buf->a + buf->n); 
	for (k = 1, l = m = 0; k <= buf->n; k++) {
		if(k == buf->n || (buf->a[l]>>32)!=(buf->a[k]>>32)) {
			if((k - l > 1) && (!(buf->a[l]&((uint64_t)0x80000000)))) {///overlap within bck
				for (z = l; z < k; z++) {
					if(buf->a[z]&((uint64_t)0x80000000)) {
						out->a[(uint32_t)(buf->a[z]-((uint64_t)0x80000000))].tn = (uint32_t)-1;
						m++;
					}
				}
			}
			l = k;
		}
	}

	if(m) {
		for (k = m = 0; k < out->n; k++) {
			if(out->a[k].tn == (uint32_t)-1) continue;
			out->a[m++] = out->a[k];
		}
		out->n = m;
	}
	if(out->n == 0) return 1;

	radix_sort_ul_ov_srt_tn(out->a, out->a+out->n);
	for (k = 0; k < out->n; k++) out->a[k].tn >>= 1;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %rbx
movl %esi, %r12d
movq 0x28(%rdx), %rax
movl %esi, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, %rcx
shrq $0x20, %rcx
imulq $0x30, %rcx, %rcx
movq %rdx, 0x30(%rsp)
addq 0x10(%rdx), %rcx
movq %rcx, 0x18(%rsp)
movq %r8, 0x10(%rsp)
andq $0x0, (%r8)
movl %eax, %eax
movq %rax, 0x38(%rsp)
andq $0x0, 0x8(%rbx)
xorl %edx, %edx
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
movq %rdi, 0x28(%rsp)
cmpq 0x38(%rsp), %rdx
je 0x17bbef
movq 0x30(%rsp), %rcx
movq 0x28(%rcx), %rax
movq %rdx, 0x40(%rsp)
imulq $0x30, %rdx, %r14
movq 0x18(%rsp), %rdx
movl 0x14(%rdx,%r14), %esi
movq (%rax,%rsi,8), %r15
movq %r15, %rax
shrq $0x20, %rax
imulq $0x30, %rax, %rbp
addq 0x10(%rcx), %rbp
movq 0x10(%rsp), %r13
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0x17bb36
movq %rsi, 0x20(%rsp)
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r13)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x20(%rsp), %rsi
movq %rax, 0x10(%r13)
movq (%r13), %rcx
addq 0x18(%rsp), %r14
movl %r15d, %r15d
shlq $0x20, %rsi
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
movq %rsi, (%rax,%rcx,8)
movq 0x28(%rsp), %r13
subq $0x1, %r15
jb 0x17bbe2
cmpl %r12d, 0x14(%rbp)
je 0x17bbd9
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
leaq 0x4c(%rsp), %rcx
pushq $0x1
popq %r8
callq 0x17b8cf
testl %eax, %eax
je 0x17bbd9
movl 0x64(%rsp), %eax
shldl $0x1, %eax, 0x58(%rsp)
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x17bbba
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rbx)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbx)
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
imulq $0x1c, %rcx, %rcx
movups 0x4c(%rsp), %xmm0
movups 0x58(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
addq $0x30, %rbp
jmp 0x17bb53
movq 0x40(%rsp), %rdx
incq %rdx
jmp 0x17bab9
cmpq $0x0, 0x8(%rbx)
je 0x17bcfb
movq 0x10(%rsp), %r14
movq (%r14), %rax
movq 0x10(%r14), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x156b0d
movq (%r14), %rax
pushq $0x1
popq %rcx
xorl %esi, %esi
xorl %edx, %edx
cmpq %rax, %rcx
ja 0x17bc7b
je 0x17bc32
movq 0x10(%r14), %rdi
movq (%rdi,%rcx,8), %r8
xorq (%rdi,%rsi,8), %r8
shrq $0x20, %r8
je 0x17bc76
movq %rcx, %rdi
subq %rsi, %rdi
cmpq $0x2, %rdi
jb 0x17bc73
movq 0x10(%r14), %rdi
testb $-0x80, 0x3(%rdi,%rsi,8)
jne 0x17bc73
cmpq %rcx, %rsi
jae 0x17bc73
movq (%rdi,%rsi,8), %r8
testl %r8d, %r8d
jns 0x17bc6e
movq (%rbx), %r9
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
imulq $0x1c, %r8, %r8
orl $-0x1, 0xc(%r9,%r8)
incq %rdx
incq %rsi
jmp 0x17bc49
movq %rcx, %rsi
incq %rcx
jmp 0x17bc19
testq %rdx, %rdx
je 0x17bcc2
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
cmpq 0x8(%rbx), %rdx
jae 0x17bcbc
movq (%rbx), %rsi
cmpl $-0x1, 0xc(%rsi,%rcx)
je 0x17bcb3
leaq (%rsi,%rcx), %rdi
imulq $0x1c, %rax, %r8
incq %rax
movups (%rdi), %xmm0
movups 0xc(%rdi), %xmm1
movups %xmm1, 0xc(%rsi,%r8)
movups %xmm0, (%rsi,%r8)
incq %rdx
addq $0x1c, %rcx
jmp 0x17bc86
movq %rax, 0x8(%rbx)
jmp 0x17bcc6
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x17bcfb
movq (%rbx), %rdi
imulq $0x1c, %rax, %rsi
addq %rdi, %rsi
callq 0x1574e1
movq 0x8(%rbx), %rax
pushq $0xc
popq %rcx
subq $0x1, %rax
jb 0x17bcf3
movq (%rbx), %rdx
shrl (%rdx,%rcx)
addq $0x1c, %rcx
jmp 0x17bce1
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq