// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, 0x8(%rdx)
movl (%rdi), %edx
movl 0xc(%rdi), %eax
leal (%rdx,%rdx), %r8d
movl 0x18(%rdi), %ecx
shrdl $0x1f, %eax, %ecx
movl %ecx, 0xc(%rsp)
movq %rsi, 0x10(%rsp)
movq 0x18(%rsi), %rax
movq 0x28(%rax), %rcx
movq %r8, 0x30(%rsp)
movq (%rcx,%r8,8), %rcx
movl %ecx, %esi
movq %rsi, 0x18(%rsp)
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rdx, 0x40(%rsp)
xorl %eax, %eax
cmpq 0x18(%rsp), %rax
je 0x17d3e4
movq %rax, 0x38(%rsp)
imulq $0x18, %rax, %rsi
movq 0x20(%rsp), %rax
cmpl $0x0, 0xc(%rax,%rsi)
js 0x17d21f
addq 0x20(%rsp), %rsi
movl 0x8(%rsi), %r14d
movq 0x10(%rsp), %r15
movq %r15, %rdi
leaq 0x68(%rsp), %rdx
callq 0x17cb1d
cmpl 0xc(%rsp), %r14d
jne 0x17d22c
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x17d200
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 0x68(%rsp), %xmm0
movups 0x74(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
movq 0x38(%rsp), %rax
incq %rax
jmp 0x17d18c
movq 0x18(%r15), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r14
movq (%rcx,%r14,8), %rcx
movl %ecx, %edx
movq %rdx, 0x28(%rsp)
shrq $0x20, %rcx
imulq $0x18, %rcx, %rbp
addq 0x8(%rax), %rbp
xorl %r13d, %r13d
cmpq 0x28(%rsp), %r13
je 0x17d21f
imulq $0x18, %r13, %rsi
cmpl $0x0, 0xc(%rbp,%rsi)
js 0x17d306
addq %rbp, %rsi
movl 0x8(%rsi), %r14d
movl %r14d, %eax
shrl %eax
cmpl 0x40(%rsp), %eax
je 0x17d306
movq 0x10(%rsp), %rdi
leaq 0xbc(%rsp), %r12
movq %r12, %rdx
callq 0x17cb1d
leaq 0x68(%rsp), %rsi
movq %r12, %rdx
leaq 0x4c(%rsp), %rcx
callq 0x17cc5b
testl %eax, %eax
je 0x17d306
movl %r14d, %eax
xorl 0xc(%rsp), %eax
cmpl $0x1, %eax
jne 0x17d30e
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x17d2e7
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)
incq %r13
jmp 0x17d252
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r14
movq (%rcx,%r14,8), %rcx
movl %ecx, %r14d
shrq $0x20, %rcx
imulq $0x18, %rcx, %r12
addq 0x8(%rax), %r12
subq $0x1, %r14
jb 0x17d306
cmpl $0x0, 0xc(%r12)
js 0x17d3db
movl 0xc(%rsp), %eax
cmpl %eax, 0x8(%r12)
jne 0x17d3db
movq 0x10(%rsp), %rdi
movq %r12, %rsi
leaq 0xa0(%rsp), %r15
movq %r15, %rdx
callq 0x17cb1d
leaq 0x4c(%rsp), %rsi
movq %r15, %rdx
leaq 0x84(%rsp), %rcx
callq 0x17cc5b
testl %eax, %eax
je 0x17d3db
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x17d3b6
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 0x84(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
addq $0x18, %r12
jmp 0x17d332
movl 0xc(%rsp), %r13d
xorl $0x1, %r13d
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rcx
movl 0x30(%rsp), %edx
movq 0x8(%rcx,%rdx,8), %rcx
movl %ecx, %edx
movq %rdx, 0x30(%rsp)
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
xorl %eax, %eax
cmpq 0x30(%rsp), %rax
je 0x17d676
movq %rax, 0x20(%rsp)
imulq $0x18, %rax, %rsi
movq 0x18(%rsp), %rax
cmpl $0x0, 0xc(%rax,%rsi)
js 0x17d4ae
addq 0x18(%rsp), %rsi
movl 0x8(%rsi), %r14d
movq 0x10(%rsp), %r12
movq %r12, %rdi
leaq 0x68(%rsp), %rdx
callq 0x17cb1d
cmpl %r13d, %r14d
jne 0x17d4bb
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x17d48f
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 0x68(%rsp), %xmm0
movups 0x74(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
movq 0x20(%rsp), %rax
incq %rax
jmp 0x17d41d
movq 0x18(%r12), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r14
movq (%rcx,%r14,8), %rcx
movl %ecx, %edx
movq %rdx, 0x38(%rsp)
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
xorl %r14d, %r14d
cmpq 0x38(%rsp), %r14
je 0x17d4ae
imulq $0x18, %r14, %rsi
movq 0x28(%rsp), %rax
cmpl $0x0, 0xc(%rax,%rsi)
js 0x17d59d
addq 0x28(%rsp), %rsi
movl 0x8(%rsi), %r12d
movl %r12d, %eax
shrl %eax
cmpl 0x40(%rsp), %eax
je 0x17d59d
movq 0x10(%rsp), %rdi
leaq 0xbc(%rsp), %rbp
movq %rbp, %rdx
callq 0x17cb1d
leaq 0x68(%rsp), %rsi
movq %rbp, %rdx
leaq 0x4c(%rsp), %rcx
callq 0x17cc5b
testl %eax, %eax
je 0x17d59d
cmpl 0xc(%rsp), %r12d
jne 0x17d5a5
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x17d57e
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)
incq %r14
jmp 0x17d4e7
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rcx
xorq $0x1, %r12
movq (%rcx,%r12,8), %rcx
movl %ecx, %ebp
shrq $0x20, %rcx
imulq $0x18, %rcx, %r12
addq 0x8(%rax), %r12
subq $0x1, %rbp
jb 0x17d59d
cmpl $0x0, 0xc(%r12)
js 0x17d66d
cmpl %r13d, 0x8(%r12)
jne 0x17d66d
movq 0x10(%rsp), %rdi
movq %r12, %rsi
leaq 0xa0(%rsp), %r15
movq %r15, %rdx
callq 0x17cb1d
leaq 0x4c(%rsp), %rsi
movq %r15, %rdx
leaq 0x84(%rsp), %rcx
callq 0x17cc5b
testl %eax, %eax
je 0x17d66d
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x17d648
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 0x84(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
addq $0x18, %r12
jmp 0x17d5c8
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq