// File: 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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movsd %xmm2, -0x30(%rbp)
movsd %xmm3, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0xe7788
movsd -0x20(%rbp), %xmm1
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x10af3f(%rip), %xmm2   # 0x1f2078
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x28(%rbp), %xmm1
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x10af0d(%rip), %xmm2   # 0x1f2078
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x30(%rbp), %xmm1
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x10aedb(%rip), %xmm2   # 0x1f2078
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x98(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x53f0
movq -0xa0(%rbp), %rdi
movsd -0x38(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x10ae01(%rip), %xmm2   # 0x1f2078
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x78(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
movsd -0x88(%rbp), %xmm2
movq -0x70(%rbp), %rcx
addq $0x4, %rcx
movq -0x70(%rbp), %r8
addq $0x8, %r8
movq -0x70(%rbp), %r9
addq $0xc, %r9
leaq -0x50(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0xe4c50
testb $0x1, %al
jne 0xe72c4
jmp 0xe733c
movq -0xa0(%rbp), %rax
movq 0x68(%rax), %rcx
movslq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x58(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movq -0x70(%rbp), %rcx
movl %edx, (%rcx)
movq 0x60(%rax), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x58(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd -0x90(%rbp), %xmm0
jbe 0xe7337
movq -0xa0(%rbp), %rax
movsd -0x90(%rbp), %xmm0
movq 0x60(%rax), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x58(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0xe7759
movq -0xa0(%rbp), %rdi
movsd -0x88(%rbp), %xmm0
mulsd 0x50(%rdi), %xmm0
callq 0xe5370
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jl 0xe7371
movq -0xa0(%rbp), %rcx
movl -0x4c(%rbp), %eax
cmpl 0x38(%rcx), %eax
jl 0xe743f
movq -0xa0(%rbp), %rdi
movl -0x4c(%rbp), %esi
movl 0x38(%rdi), %edx
callq 0xe53b0
movl %eax, %ecx
movq -0xa0(%rbp), %rax
movl %ecx, -0x64(%rbp)
cvtsi2sdl -0x64(%rbp), %xmm0
movsd 0x28(%rax), %xmm2
movsd -0x88(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
cvtsi2sdl -0x64(%rbp), %xmm0
movsd 0x20(%rax), %xmm2
movsd -0x80(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
cvtsi2sdl -0x64(%rbp), %xmm0
movsd 0x18(%rax), %xmm2
movsd -0x78(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0x64(%rbp), %ecx
imull 0x38(%rax), %ecx
movl -0x4c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x4c(%rbp)
jmp 0xe7446
movl $0x0, -0x64(%rbp)
movq -0xa0(%rbp), %rdi
movsd -0x80(%rbp), %xmm0
mulsd 0x48(%rdi), %xmm0
callq 0xe5370
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jl 0xe7478
movq -0xa0(%rbp), %rcx
movl -0x48(%rbp), %eax
cmpl 0x34(%rcx), %eax
jl 0xe750d
movq -0xa0(%rbp), %rdi
movl -0x48(%rbp), %esi
movl 0x34(%rdi), %edx
callq 0xe53b0
movl %eax, %ecx
movq -0xa0(%rbp), %rax
movl %ecx, -0x60(%rbp)
cvtsi2sdl -0x60(%rbp), %xmm0
movsd 0x10(%rax), %xmm2
movsd -0x80(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
cvtsi2sdl -0x60(%rbp), %xmm0
movsd 0x8(%rax), %xmm2
movsd -0x78(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0x60(%rbp), %ecx
imull 0x34(%rax), %ecx
movl -0x48(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0xe7514
movl $0x0, -0x60(%rbp)
movq -0xa0(%rbp), %rdi
movsd -0x78(%rbp), %xmm0
mulsd 0x40(%rdi), %xmm0
callq 0xe5370
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jl 0xe7542
movq -0xa0(%rbp), %rcx
movl -0x44(%rbp), %eax
cmpl 0x30(%rcx), %eax
jl 0xe75a3
movq -0xa0(%rbp), %rdi
movl -0x44(%rbp), %esi
movl 0x30(%rdi), %edx
callq 0xe53b0
movl %eax, %ecx
movq -0xa0(%rbp), %rax
movl %ecx, -0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp), %xmm0
movsd (%rax), %xmm2
movsd -0x78(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0x5c(%rbp), %ecx
imull 0x30(%rax), %ecx
movl -0x44(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x44(%rbp)
jmp 0xe75aa
movl $0x0, -0x5c(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x5c(%rbp), %edx
movq -0x70(%rbp), %rax
movl %edx, 0x4(%rax)
movl -0x60(%rbp), %edx
movq -0x70(%rbp), %rax
movl %edx, 0x8(%rax)
movl -0x64(%rbp), %edx
movq -0x70(%rbp), %rax
movl %edx, 0xc(%rax)
movl -0x44(%rbp), %eax
movl 0x30(%rcx), %edx
movl -0x48(%rbp), %esi
movl 0x34(%rcx), %edi
imull -0x4c(%rbp), %edi
addl %edi, %esi
imull %esi, %edx
addl %edx, %eax
movl %eax, -0x50(%rbp)
movl 0xa0(%rcx), %eax
cmpl 0xa4(%rcx), %eax
jne 0xe7603
movq -0xa0(%rbp), %rdi
callq 0xe31a0
movq -0xa0(%rbp), %rcx
movq 0x70(%rcx), %rax
movslq -0x50(%rbp), %rdx
movl (%rax,%rdx,4), %eax
movq 0x78(%rcx), %rcx
movslq -0x50(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0xe7631
movq -0xa0(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0xe2fd0
movq -0xa0(%rbp), %rax
movl -0x50(%rbp), %esi
movq 0xc0(%rax), %rcx
movslq 0xa0(%rax), %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x70(%rax), %rcx
movslq -0x50(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movq 0xc8(%rax), %rcx
movslq 0xa0(%rax), %rdx
movl %esi, (%rcx,%rdx,4)
movsd -0x78(%rbp), %xmm0
movq 0x60(%rax), %rcx
movslq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x70(%rax), %rdx
movslq -0x50(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
shll $0x2, %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
movsd -0x80(%rbp), %xmm0
movq 0x60(%rax), %rcx
movslq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x70(%rax), %rdx
movslq -0x50(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
movsd -0x88(%rbp), %xmm0
movq 0x60(%rax), %rcx
movslq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x70(%rax), %rdx
movslq -0x50(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
shll $0x2, %edx
addl $0x2, %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
movsd -0x90(%rbp), %xmm0
movq 0x60(%rax), %rcx
movslq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x70(%rax), %rdx
movslq -0x50(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
shll $0x2, %edx
addl $0x3, %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
movl 0xa0(%rax), %esi
movq 0x68(%rax), %rcx
movslq -0x50(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x70(%rax), %rdi
movslq -0x50(%rbp), %r8
movl (%rdi,%r8,4), %edx
movl %edx, %r9d
addl $0x1, %r9d
movl %r9d, (%rdi,%r8,4)
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movl 0xa0(%rax), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0xa0(%rax)
movq -0x70(%rbp), %rax
movl %ecx, (%rax)
movq -0xa0(%rbp), %rdi
movq -0x70(%rbp), %rax
movl (%rax), %esi
movl -0x14(%rbp), %edx
callq 0xe81d0
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x70(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x70(%rbp)
jmp 0xe7107
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rsi
movsd -0x20(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movsd -0x38(%rbp), %xmm3
movq -0x40(%rbp), %rdx
callq 0xe82a0
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)