// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: gen_shared_interval_adv(ul_ov_t*, ma_ug_t*, kv_ul_ov_t*)
void gen_shared_interval_adv(ul_ov_t *p, ma_ug_t *ug, kv_ul_ov_t *res)
{
	uint32_t st, et, v, w, i, k, z, nv, nw, nz; asg_arc_t *av, *aw, *az;
	ul_ov_t s1, s2, s3, s4, rr; res->n = 0;

	st = p->qn<<1; et = (p->tn<<1) + (!!(p->rev));
	v = st; av = asg_arc_a(ug->g, v); nv = asg_arc_n(ug->g, v);
	for (i = 0; i < nv; i++) {
        if(av[i].del) continue;
		w = av[i].v;
		cal_s_interval(ug, &(av[i]), &s1);
		if(w == et) {
			kv_push(ul_ov_t, *res, s1);
		} else {
			aw = asg_arc_a(ug->g, (w^1)); nw = asg_arc_n(ug->g, (w^1));
			for (k = 0; k < nw; k++) {
				if(aw[k].del) continue;
				if((aw[k].v>>1) == (st>>1)) continue;

				cal_s_interval(ug, &(aw[k]), &s2);
				if(!cal_x_interval(ug, &s1, &s2, &s3)) continue;
				if(aw[k].v == (et^1)) {
					kv_push(ul_ov_t, *res, s3);
				} else {
					az = asg_arc_a(ug->g, (aw[k].v^1)); nz = asg_arc_n(ug->g, (aw[k].v^1));
					for (z = 0; z < nz; z++) {
						if(az[z].del) continue;
						if(az[z].v == et) {
							cal_s_interval(ug, &(az[z]), &s4);
							if(cal_x_interval(ug, &s3, &s4, &rr)) {
								kv_push(ul_ov_t, *res, rr);
							}
						}
					}
				}
			}
		}
    }

	st ^= 1; et ^= 1;
	v = st; av = asg_arc_a(ug->g, v); nv = asg_arc_n(ug->g, v);
	for (i = 0; i < nv; i++) {
        if(av[i].del) continue;
		w = av[i].v;
		cal_s_interval(ug, &(av[i]), &s1);
		if(w == et) {
			kv_push(ul_ov_t, *res, s1);
		} else {
			aw = asg_arc_a(ug->g, (w^1)); nw = asg_arc_n(ug->g, (w^1));
			for (k = 0; k < nw; k++) {
				if(aw[k].del) continue;
				if((aw[k].v>>1) == (st>>1)) continue;

				cal_s_interval(ug, &(aw[k]), &s2);
				if(!cal_x_interval(ug, &s1, &s2, &s3)) continue;
				if(aw[k].v == (et^1)) {
					kv_push(ul_ov_t, *res, s3);
				} else {
					az = asg_arc_a(ug->g, (aw[k].v^1)); nz = asg_arc_n(ug->g, (aw[k].v^1));
					for (z = 0; z < nz; z++) {
						if(az[z].del) continue;
						if(az[z].v == et) {
							cal_s_interval(ug, &(az[z]), &s4);
							if(cal_x_interval(ug, &s3, &s4, &rr)) {
								kv_push(ul_ov_t, *res, rr);
							}
						}
					}
				}
			}
		}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %rbx
movq %rsi, 0x8(%rsp)
movq $0x0, 0x8(%rdx)
movl (%rdi), %r8d
movl 0xc(%rdi), %eax
leal (%r8,%r8), %r9d
movl 0x18(%rdi), %ecx
shrdl $0x1f, %eax, %ecx
movl %ecx, 0x4(%rsp)
movq 0x18(%rsi), %rcx
movq 0x8(%rcx), %rax
movq 0x28(%rcx), %rcx
movq (%rcx,%r9,8), %rdx
testl %edx, %edx
movq %r8, 0x30(%rsp)
je 0x1c8dc3
movq %r9, 0x78(%rsp)
movq %rdx, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movl %r8d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x38(%rsp)
movl %edx, %eax
movq %rax, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x28(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
js 0x1c8d9a
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %rsi
movl 0x8(%rsi), %r14d
movq 0x8(%rsp), %r15
movq %r15, %rdi
leaq 0x5c(%rsp), %rdx
callq 0x1c83c0
cmpl 0x4(%rsp), %r14d
jne 0x1c8b98
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1c8b6d
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 0x5c(%rsp), %xmm0
movups 0x68(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
jmp 0x1c8d9a
movq 0x18(%r15), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r14
movq (%rcx,%r14,8), %rcx
testl %ecx, %ecx
je 0x1c8d9a
movq %rcx, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rbp
shlq $0x3, %rbp
addq 0x8(%rax), %rbp
movl %ecx, %eax
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
leaq (%r14,%r14,2), %rax
cmpl $0x0, 0xc(%rbp,%rax,8)
js 0x1c8d8c
leaq (,%rax,8), %rsi
addq %rbp, %rsi
movl 0x8(%rsi), %r15d
movl %r15d, %eax
shrl %eax
cmpl 0x38(%rsp), %eax
je 0x1c8d8c
movq 0x8(%rsp), %rdi
leaq 0xbc(%rsp), %r12
movq %r12, %rdx
callq 0x1c83c0
leaq 0x5c(%rsp), %rsi
movq %r12, %rdx
leaq 0x40(%rsp), %rcx
callq 0x1c850b
testl %eax, %eax
je 0x1c8d8c
movl %r15d, %eax
xorl 0x4(%rsp), %eax
cmpl $0x1, %eax
jne 0x1c8c9b
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1c8c70
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 0x40(%rsp), %xmm0
movups 0x4c(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
jmp 0x1c8d8c
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r15
movq (%rcx,%r15,8), %rcx
testl %ecx, %ecx
je 0x1c8d8c
movq %rcx, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %r15
shlq $0x3, %r15
addq 0x8(%rax), %r15
movl %ecx, %r12d
cmpl $0x0, 0xc(%r15)
js 0x1c8d7f
movl 0x4(%rsp), %eax
cmpl %eax, 0x8(%r15)
jne 0x1c8d7f
movq 0x8(%rsp), %rdi
movq %r15, %rsi
leaq 0xa0(%rsp), %r13
movq %r13, %rdx
callq 0x1c83c0
leaq 0x40(%rsp), %rsi
movq %r13, %rdx
leaq 0x84(%rsp), %rcx
callq 0x1c850b
testl %eax, %eax
je 0x1c8d7f
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1c8d53
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 0x84(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
addq $0x18, %r15
decq %r12
jne 0x1c8cce
incq %r14
cmpq 0x18(%rsp), %r14
jne 0x1c8bcd
movq 0x28(%rsp), %rax
incq %rax
cmpq 0x20(%rsp), %rax
jne 0x1c8af3
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x8(%rcx), %rax
movq 0x28(%rcx), %rcx
movq 0x78(%rsp), %r9
movl %r9d, %edx
movq 0x8(%rcx,%rdx,8), %rcx
testl %ecx, %ecx
je 0x1c90c6
movl 0x4(%rsp), %edx
xorl $0x1, %edx
movl %edx, 0x18(%rsp)
movq %rcx, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x30(%rsp)
movl %ecx, %eax
movq %rax, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x28(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
js 0x1c90b3
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %rsi
movl 0x8(%rsi), %r14d
movq 0x8(%rsp), %r15
movq %r15, %rdi
leaq 0x5c(%rsp), %rdx
callq 0x1c83c0
cmpl 0x18(%rsp), %r14d
jne 0x1c8eaf
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1c8e84
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 0x5c(%rsp), %xmm0
movups 0x68(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
jmp 0x1c90b3
movq 0x18(%r15), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r14
movq (%rcx,%r14,8), %rcx
testl %ecx, %ecx
je 0x1c90b3
movq %rcx, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %r13
shlq $0x3, %r13
addq 0x8(%rax), %r13
movl %ecx, %eax
movq %rax, 0x38(%rsp)
xorl %ebp, %ebp
leaq (,%rbp,2), %rax
addq %rbp, %rax
cmpl $0x0, 0xc(%r13,%rax,8)
js 0x1c90a5
leaq (,%rax,8), %rsi
addq %r13, %rsi
movl 0x8(%rsi), %r15d
movl %r15d, %eax
shrl %eax
cmpl 0x30(%rsp), %eax
je 0x1c90a5
movq 0x8(%rsp), %rdi
leaq 0xbc(%rsp), %r12
movq %r12, %rdx
callq 0x1c83c0
leaq 0x5c(%rsp), %rsi
movq %r12, %rdx
leaq 0x40(%rsp), %rcx
callq 0x1c850b
testl %eax, %eax
je 0x1c90a5
cmpl 0x4(%rsp), %r15d
jne 0x1c8fb4
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1c8f89
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 0x40(%rsp), %xmm0
movups 0x4c(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
jmp 0x1c90a5
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r15
movq (%rcx,%r15,8), %rcx
testl %ecx, %ecx
je 0x1c90a5
movq %rcx, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %r15
shlq $0x3, %r15
addq 0x8(%rax), %r15
movl %ecx, %r12d
cmpl $0x0, 0xc(%r15)
js 0x1c9098
movl 0x18(%rsp), %eax
cmpl %eax, 0x8(%r15)
jne 0x1c9098
movq 0x8(%rsp), %rdi
movq %r15, %rsi
leaq 0xa0(%rsp), %r14
movq %r14, %rdx
callq 0x1c83c0
leaq 0x40(%rsp), %rsi
movq %r14, %rdx
leaq 0x84(%rsp), %rcx
callq 0x1c850b
testl %eax, %eax
je 0x1c9098
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1c906c
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 0x84(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
addq $0x18, %r15
decq %r12
jne 0x1c8fe7
incq %rbp
cmpq 0x38(%rsp), %rbp
jne 0x1c8ee3
movq 0x28(%rsp), %rax
incq %rax
cmpq 0x20(%rsp), %rax
jne 0x1c8e0a
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq