// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movq %rcx, %rbx
movq 0x28(%rdx), %rax
movl %esi, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movq %rdx, 0x28(%rsp)
addq 0x10(%rdx), %rcx
movq %rcx, 0x8(%rsp)
xorl %ecx, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rcx, (%r8)
movq %rcx, 0x8(%rbx)
andq %rax, %rdx
movq %rdx, 0x20(%rsp)
je 0x1c74f3
movl %esi, %ebp
movq %r8, (%rsp)
xorl %edx, %edx
movq %rdi, 0x18(%rsp)
movq 0x28(%rsp), %rcx
movq 0x28(%rcx), %rax
movq %rdx, 0x30(%rsp)
leaq (%rdx,%rdx,2), %r15
shlq $0x4, %r15
movq 0x8(%rsp), %rdx
movl 0x14(%rdx,%r15), %esi
movq (%rax,%rsi,8), %r13
movq %r13, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %r14
shlq $0x4, %r14
addq 0x10(%rcx), %r14
movq (%rsp), %r12
movq (%r12), %rcx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rcx
jne 0x1c72ff
movq %rsi, 0x10(%rsp)
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x10(%rsp), %rsi
movq %rax, 0x10(%r12)
movq (%r12), %rcx
movl %r13d, %r13d
shlq $0x20, %rsi
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
movq %rsi, (%rax,%rcx,8)
testq %r13, %r13
movq 0x18(%rsp), %r12
je 0x1c73c4
addq 0x8(%rsp), %r15
cmpl %ebp, 0x14(%r14)
je 0x1c73b7
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
leaq 0x3c(%rsp), %rcx
movl $0x1, %r8d
callq 0x1c7080
testl %eax, %eax
je 0x1c73b7
movl 0x54(%rsp), %eax
shldl $0x1, %eax, 0x48(%rsp)
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1c7391
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rbx)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbx)
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movups 0x3c(%rsp), %xmm0
movups 0x48(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
addq $0x30, %r14
decq %r13
jne 0x1c7325
movq 0x30(%rsp), %rdx
incq %rdx
cmpq 0x20(%rsp), %rdx
jne 0x1c7280
movl $0x1, %ebp
cmpq $0x0, 0x8(%rbx)
je 0x1c753e
movq (%rsp), %r14
movq (%r14), %rax
movq 0x10(%r14), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x19dd99
movq (%r14), %rax
testq %rax, %rax
je 0x1c74fa
leaq 0x1(%rax), %rdx
cmpq $0x3, %rdx
movl $0x2, %ecx
cmovaeq %rdx, %rcx
movl $0x1, %esi
xorl %edx, %edx
xorl %edi, %edi
cmpq %rax, %rsi
je 0x1c7438
movq 0x10(%r14), %r8
movq (%r8,%rsi,8), %r9
xorq (%r8,%rdi,8), %r9
shrq $0x20, %r9
je 0x1c7497
movq %rsi, %r8
subq %rdi, %r8
cmpq $0x2, %r8
jb 0x1c7494
movq 0x10(%r14), %r8
testb $-0x80, 0x3(%r8,%rdi,8)
sete %r9b
cmpq %rdi, %rsi
seta %r10b
andb %r9b, %r10b
cmpb $0x1, %r10b
jne 0x1c7494
movq (%r8,%rdi,8), %r9
testl %r9d, %r9d
jns 0x1c748c
movq (%rbx), %r10
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
leaq (%r9,%r9,8), %r11
leaq (%r11,%r11,2), %r11
addq %r9, %r11
movl $0xffffffff, 0xc(%r10,%r11) # imm = 0xFFFFFFFF
incq %rdx
incq %rdi
cmpq %rdi, %rsi
jne 0x1c7462
movq %rsi, %rdi
incq %rsi
cmpq %rcx, %rsi
jne 0x1c7421
testq %rdx, %rdx
je 0x1c74fa
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x1c7500
xorl %ecx, %ecx
xorl %eax, %eax
xorl %edx, %edx
movq (%rbx), %rdi
cmpl $-0x1, 0xc(%rdi,%rcx)
je 0x1c74e5
leaq (%rdi,%rcx), %rsi
leaq (%rax,%rax,8), %r8
leaq (%r8,%r8,2), %r8
addq %rax, %r8
incq %rax
movups (%rsi), %xmm0
movups 0xc(%rsi), %xmm1
movups %xmm1, 0xc(%rdi,%r8)
movups %xmm0, (%rdi,%r8)
movq 0x8(%rbx), %rsi
incq %rdx
addq $0x1c, %rcx
cmpq %rsi, %rdx
jb 0x1c74b3
jmp 0x1c7502
movl $0x1, %ebp
jmp 0x1c753e
movq 0x8(%rbx), %rax
jmp 0x1c7506
xorl %eax, %eax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x1c753e
movq (%rbx), %rdi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
addq %rdi, %rsi
callq 0x19e855
movq 0x8(%rbx), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0x1c753e
movq (%rbx), %rcx
addq $0xc, %rcx
shrl (%rcx)
addq $0x1c, %rcx
decq %rax
jne 0x1c7533
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq