// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/v_network.cc
// Function: void voronoi_network::add_to_network_rectangular_internal<voro::voronoicell>(voro::voronoicell&, int, double, double, double, double, int*)
void voronoi_network::add_to_network_rectangular_internal(v_cell &c,int idn,double x,double y,double z,double rad,int *cmap) {
	int i,j,k,ijk,l,q,ai,aj,ak,*vmp(cmap);
	double vx,vy,vz,crad,*cp(c.pts);
	
	for(l=0;l<c.p;l++,vmp+=4) {
		vx=x+cp[4*l]*0.5;vy=y+cp[4*l+1]*0.5;vz=z+cp[4*l+2]*0.5;
		crad=0.5*sqrt(cp[4*l]*cp[4*l]+cp[4*l+1]*cp[4*l+1]+cp[4*l+2]*cp[4*l+2])-rad;
		if(safe_search_previous_rect(vx,vy,vz,ijk,q,vmp[1],vmp[2],vmp[3])) {
			*vmp=idmem[ijk][q];

			// Store this radius if it smaller than the current
			// value
			if(pts[ijk][4*q+3]>crad) pts[ijk][4*q+3]=crad;			
		} else {
			k=step_int(vz*zsp);
			if(k<0||k>=nz) {
				ak=step_div(k,nz);
				vz-=ak*bz;vy-=ak*byz;vx-=ak*bxz;k-=ak*nz;
			} else ak=0;
			j=step_int(vy*ysp);
			if(j<0||j>=ny) {
				aj=step_div(j,ny);
				vy-=aj*by;vx-=aj*bxy;j-=aj*ny;
			} else aj=0;
			i=step_int(vx*xsp);
			if(i<0||i>=nx) {
				ai=step_div(i,nx);
				vx-=ai*bx;i-=ai*nx;
			} else ai=0;
			vmp[1]=ai;
			vmp[2]=aj;
			vmp[3]=ak;
			ijk=i+nx*(j+ny*k);
			if(edc==edmem) add_edge_network_memory();
			if(ptsc[ijk]==ptsmem[ijk]) add_network_memory(ijk);
			reg[edc]=ijk;regp[edc]=ptsc[ijk];
			pts[ijk][4*ptsc[ijk]]=vx;
			pts[ijk][4*ptsc[ijk]+1]=vy;
			pts[ijk][4*ptsc[ijk]+2]=vz;
			pts[ijk][4*ptsc[ijk]+3]=crad;
			idmem[ijk][ptsc[ijk]++]=edc;
			*vmp=edc++;
		}

		add_neighbor(*vmp,idn);
	}

	add_edges_to_network(c,x,y,z,rad,cmap);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, 0x48(%rsp)
movapd %xmm3, 0x90(%rsp)
movsd %xmm2, 0x58(%rsp)
movapd %xmm1, 0x80(%rsp)
movapd %xmm0, 0x70(%rsp)
movq %rdi, %r15
movq %rsi, 0x20(%rsp)
cmpl $0x0, 0x1c(%rsi)
jle 0x8270e
movl %edx, %ebp
movq 0x20(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x60(%rsp)
movaps 0xcf37f(%rip), %xmm0    # 0x151640
xorps 0x90(%rsp), %xmm0
movaps %xmm0, 0xb0(%rsp)
movapd 0x70(%rsp), %xmm0
unpcklpd 0x80(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd %xmm0, 0xa0(%rsp)
xorl %r14d, %r14d
movq 0x48(%rsp), %r12
movq %r14, %rax
shlq $0x5, %rax
movq 0x60(%rsp), %rcx
movupd (%rcx,%rax), %xmm4
movapd %xmm4, %xmm0
mulpd 0xd2cb2(%rip), %xmm0    # 0x154fc0
addpd 0xa0(%rsp), %xmm0
movsd 0x10(%rcx,%rax), %xmm1
movapd %xmm1, %xmm5
movsd 0xcad0f(%rip), %xmm3    # 0x14d038
mulsd %xmm3, %xmm5
addsd 0x58(%rsp), %xmm5
movapd %xmm4, %xmm2
mulpd %xmm4, %xmm2
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
mulsd %xmm4, %xmm4
addsd %xmm2, %xmm4
mulsd %xmm1, %xmm1
addsd %xmm4, %xmm1
sqrtsd %xmm1, %xmm1
mulsd %xmm3, %xmm1
addsd 0xb0(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
leaq 0x4(%r12), %rbx
leaq 0x8(%r12), %r13
leaq 0xc(%r12), %r9
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movq %r15, %rdi
movapd %xmm0, 0x30(%rsp)
movsd %xmm5, 0x18(%rsp)
movapd %xmm5, %xmm2
leaq 0x14(%rsp), %rsi
leaq 0x2c(%rsp), %rdx
movq %rbx, %rcx
movq %r13, %r8
movq %r9, 0x68(%rsp)
callq 0x80c76
testb %al, %al
je 0x823ff
movq 0x68(%r15), %rax
movslq 0x14(%rsp), %rdx
movq (%rax,%rdx,8), %rcx
movslq 0x2c(%rsp), %rax
movl (%rcx,%rax,4), %ecx
movl %ecx, (%r12)
movq 0x60(%r15), %rsi
movq (%rsi,%rdx,8), %rdx
leaq (,%rax,4), %rsi
movsd 0x18(%rdx,%rsi,8), %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x82691
leaq 0x3(,%rax,4), %rax
movsd %xmm1, (%rdx,%rax,8)
jmp 0x82691
movq %rbx, %r10
movsd 0x50(%r15), %xmm0
movsd 0x18(%rsp), %xmm3
mulsd %xmm3, %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
cvttsd2si %xmm0, %ebx
subl %eax, %ebx
setns %al
movl 0x38(%r15), %edi
cmpl %edi, %ebx
setl %dl
xorl %ecx, %ecx
testb %dl, %al
je 0x82441
xorl %esi, %esi
movapd 0x30(%rsp), %xmm2
jmp 0x8248a
testl %ebx, %ebx
movapd 0x30(%rsp), %xmm2
js 0x82454
movl %ebx, %eax
cltd
idivl %edi
movl %eax, %esi
jmp 0x8245e
leal 0x1(%rbx), %eax
cltd
idivl %edi
movl %eax, %esi
decl %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0x28(%r15), %xmm1
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm3
movupd 0x18(%r15), %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm1, %xmm0
subpd %xmm0, %xmm2
imull %esi, %edi
subl %edi, %ebx
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
mulsd 0x48(%r15), %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
cvttsd2si %xmm0, %edi
subl %eax, %edi
setns %al
movl 0x34(%r15), %r8d
cmpl %r8d, %edi
setl %dl
testb %dl, %al
jne 0x824f5
testl %edi, %edi
js 0x824ca
movl %edi, %eax
cltd
idivl %r8d
movl %eax, %ecx
jmp 0x824d5
leal 0x1(%rdi), %eax
cltd
idivl %r8d
movl %eax, %ecx
decl %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movupd 0x8(%r15), %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm1, %xmm0
subpd %xmm0, %xmm2
imull %ecx, %r8d
subl %r8d, %edi
movsd 0x40(%r15), %xmm0
mulsd %xmm2, %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
cvttsd2si %xmm0, %r8d
subl %eax, %r8d
setns %al
movl 0x30(%r15), %r9d
cmpl %r9d, %r8d
setl %dl
testb %dl, %al
je 0x8252f
xorl %eax, %eax
movsd %xmm2, 0x50(%rsp)
jmp 0x82568
testl %r8d, %r8d
js 0x8253d
movl %r8d, %eax
cltd
idivl %r9d
jmp 0x82547
leal 0x1(%r8), %eax
cltd
idivl %r9d
decl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd (%r15), %xmm0
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp)
imull %eax, %r9d
subl %r9d, %r8d
movsd 0x8(%rsp), %xmm0
movl %eax, (%r10)
movl %ecx, (%r13)
movq 0x68(%rsp), %rax
movl %esi, (%rax)
imull 0x34(%r15), %ebx
addl %edi, %ebx
imull 0x30(%r15), %ebx
addl %r8d, %ebx
movl %ebx, 0x14(%rsp)
movl 0xa0(%r15), %eax
cmpl 0xa4(%r15), %eax
movapd %xmm2, 0x30(%rsp)
movsd %xmm3, 0x18(%rsp)
jne 0x825c5
movq %r15, %rdi
callq 0x7f988
movsd 0x18(%rsp), %xmm3
movapd 0x30(%rsp), %xmm2
movsd 0x8(%rsp), %xmm0
movq 0x70(%r15), %rax
movq 0x78(%r15), %rcx
movslq %ebx, %r13
movl (%rax,%r13,4), %edx
cmpl (%rcx,%r13,4), %edx
jne 0x825fa
movq %r15, %rdi
movl %ebx, %esi
callq 0x7f876
movsd 0x18(%rsp), %xmm3
movapd 0x30(%rsp), %xmm2
movsd 0x8(%rsp), %xmm0
movq 0x70(%r15), %rax
movq 0xc0(%r15), %rcx
movslq 0xa0(%r15), %rdx
movl %ebx, (%rcx,%rdx,4)
movslq (%rax,%r13,4), %rcx
movq 0xc8(%r15), %rdx
movslq 0xa0(%r15), %rsi
movl %ecx, (%rdx,%rsi,4)
movq 0x60(%r15), %rdx
movq (%rdx,%r13,8), %rdx
leaq (,%rcx,4), %rsi
movq %rcx, %rdi
shlq $0x5, %rdi
movsd 0x50(%rsp), %xmm1
movsd %xmm1, (%rdx,%rdi)
leal 0x1(%rsi), %edi
movslq %edi, %rdi
movhpd %xmm2, (%rdx,%rdi,8)
leal 0x2(%rsi), %edi
movslq %edi, %rdi
movsd %xmm3, (%rdx,%rdi,8)
orl $0x3, %esi
movslq %esi, %rsi
movsd %xmm0, (%rdx,%rsi,8)
movl 0xa0(%r15), %edx
movq 0x68(%r15), %rsi
movq (%rsi,%r13,8), %rsi
leal 0x1(%rcx), %edi
movl %edi, (%rax,%r13,4)
movl %edx, (%rsi,%rcx,4)
movl 0xa0(%r15), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0xa0(%r15)
movl %ecx, (%r12)
movq 0xb0(%r15), %rax
movslq %ecx, %rbx
movslq (%rax,%rbx,4), %rcx
testq %rcx, %rcx
jle 0x826be
movq 0x88(%r15), %rdx
movq (%rdx,%rbx,8), %rdx
xorl %esi, %esi
cmpl %ebp, (%rdx,%rsi,4)
je 0x826f5
incq %rsi
cmpq %rsi, %rcx
jne 0x826b1
movq 0xb8(%r15), %rdx
cmpl (%rdx,%rbx,4), %ecx
jne 0x826de
movq %r15, %rdi
movl %ebx, %esi
callq 0x7fd54
movq 0xb0(%r15), %rax
movl (%rax,%rbx,4), %ecx
movq 0x88(%r15), %rdx
movq (%rdx,%rbx,8), %rdx
leal 0x1(%rcx), %esi
movl %esi, (%rax,%rbx,4)
movslq %ecx, %rax
movl %ebp, (%rdx,%rax,4)
incq %r14
addq $0x10, %r12
movq 0x20(%rsp), %rax
movslq 0x1c(%rax), %rax
cmpq %rax, %r14
jl 0x822f1
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movaps 0x70(%rsp), %xmm0
movaps 0x80(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movaps 0x90(%rsp), %xmm3
movq 0x48(%rsp), %rdx
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x82e7c