// File: /workspace/github_cpp_makefile_star2_O1/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 $0x0, 0x8(%rdx)
movl (%rdi), %ecx
movl 0xc(%rdi), %eax
movq %rcx, 0x18(%rsp)
leal (%rcx,%rcx), %edx
movl 0x18(%rdi), %ecx
shrdl $0x1f, %eax, %ecx
movl %ecx, 0x4(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x18(%rsi), %rcx
movq 0x28(%rcx), %rax
movq %rdx, 0x78(%rsp)
movq (%rax,%rdx,8), %rax
testl %eax, %eax
je 0x1befa2
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x3, %rdx
addq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rsp), %rcx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, 0x38(%rsp)
movl %eax, %eax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
js 0x1bef8f
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 0x1be59e
cmpl 0x4(%rsp), %r14d
jne 0x1bed8d
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x1bed5b
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %rax
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 0x1bef8f
movq 0x18(%r15), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r14
movq (%rcx,%r14,8), %rcx
testl %ecx, %ecx
je 0x1bef8f
movq %rcx, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rbp
shlq $0x3, %rbp
addq 0x8(%rax), %rbp
movl %ecx, %eax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
leaq (%r14,%r14,2), %rax
cmpl $0x0, 0xc(%rbp,%rax,8)
js 0x1bef81
leaq (,%rax,8), %rsi
addq %rbp, %rsi
movl 0x8(%rsi), %r15d
movl %r15d, %eax
shrl %eax
cmpl 0x38(%rsp), %eax
je 0x1bef81
movq 0x8(%rsp), %rdi
leaq 0xbc(%rsp), %r12
movq %r12, %rdx
callq 0x1be59e
leaq 0x5c(%rsp), %rsi
movq %r12, %rdx
leaq 0x40(%rsp), %rcx
callq 0x1be6f7
testl %eax, %eax
je 0x1bef81
movl %r15d, %eax
xorl 0x4(%rsp), %eax
cmpl $0x1, %eax
jne 0x1bee90
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x1bee5e
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %rax
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 0x1bef81
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r15
movq (%rcx,%r15,8), %rcx
testl %ecx, %ecx
je 0x1bef81
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 0x1bef74
movl 0x4(%rsp), %eax
cmpl %eax, 0x8(%r15)
jne 0x1bef74
movq 0x8(%rsp), %rdi
movq %r15, %rsi
leaq 0xa0(%rsp), %r13
movq %r13, %rdx
callq 0x1be59e
leaq 0x40(%rsp), %rsi
movq %r13, %rdx
leaq 0x84(%rsp), %rcx
callq 0x1be6f7
testl %eax, %eax
je 0x1bef74
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x1bef41
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %rax
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 0x1beec3
incq %r14
cmpq 0x20(%rsp), %r14
jne 0x1bedc2
movq 0x30(%rsp), %rax
incq %rax
cmpq 0x28(%rsp), %rax
jne 0x1bece8
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x28(%rcx), %rax
movl 0x78(%rsp), %edx
movq 0x8(%rax,%rdx,8), %rax
testl %eax, %eax
je 0x1bf2b8
movl 0x4(%rsp), %edx
xorl $0x1, %edx
movl %edx, 0x20(%rsp)
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x3, %rdx
addq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rsp), %rcx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq %rcx, 0x18(%rsp)
movl %eax, %eax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
js 0x1bf2a5
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 0x1be59e
cmpl 0x20(%rsp), %r14d
jne 0x1bf0a1
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x1bf06f
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %rax
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 0x1bf2a5
movq 0x18(%r15), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r14
movq (%rcx,%r14,8), %rcx
testl %ecx, %ecx
je 0x1bf2a5
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 0x1bf297
leaq (,%rax,8), %rsi
addq %r13, %rsi
movl 0x8(%rsi), %r15d
movl %r15d, %eax
shrl %eax
cmpl 0x18(%rsp), %eax
je 0x1bf297
movq 0x8(%rsp), %rdi
leaq 0xbc(%rsp), %r12
movq %r12, %rdx
callq 0x1be59e
leaq 0x5c(%rsp), %rsi
movq %r12, %rdx
leaq 0x40(%rsp), %rcx
callq 0x1be6f7
testl %eax, %eax
je 0x1bf297
cmpl 0x4(%rsp), %r15d
jne 0x1bf1a6
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x1bf174
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %rax
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 0x1bf297
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r15
movq (%rcx,%r15,8), %rcx
testl %ecx, %ecx
je 0x1bf297
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 0x1bf28a
movl 0x20(%rsp), %eax
cmpl %eax, 0x8(%r15)
jne 0x1bf28a
movq 0x8(%rsp), %rdi
movq %r15, %rsi
leaq 0xa0(%rsp), %r14
movq %r14, %rdx
callq 0x1be59e
leaq 0x40(%rsp), %rsi
movq %r14, %rdx
leaq 0x84(%rsp), %rcx
callq 0x1be6f7
testl %eax, %eax
je 0x1bf28a
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x1bf257
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %rax
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 0x1bf1d9
incq %rbp
cmpq 0x38(%rsp), %rbp
jne 0x1bf0d5
movq 0x30(%rsp), %rax
incq %rax
cmpq 0x28(%rsp), %rax
jne 0x1beffc
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq