// File: Luthaf[P]zeopp/v_network.cc
// Function: void voronoi_network::add_to_network_internal<voro::voronoicell>(voro::voronoicell&, int, double, double, double, double, int*)
void voronoi_network::add_to_network_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 gx,gy,vx,vy,vz,crad,*cp(c.pts);
	
	// Loop over the vertices of the Voronoi cell
	for(l=0;l<c.p;l++,vmp+=4) {

		// Compute the real position of this vertex, and evaluate its
		// position along the non-rectangular axes
		vx=x+cp[4*l]*0.5;vy=y+cp[4*l+1]*0.5;vz=z+cp[4*l+2]*0.5;
		gx=vx-vy*(bxy/by)+vz*(bxy*byz-by*bxz)/(by*bz);
		gy=vy-vz*(byz/bz);

		// Compute the adjusted radius, which will be needed either way
		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;
	
		// Check to see if a vertex very close to this one already
		// exists in the network 
		if(search_previous(gx,gy,vx,vy,vz,ijk,q,vmp[1],vmp[2],vmp[3])) {

			// If it does, then just map the Voronoi cell
			// vertex to it
			*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);vx-=bxz*ak;vy-=byz*ak;vz-=bz*ak;k-=ak*nz;} else ak=0;
			j=step_int(gy*ysp);if(j<0||j>=ny) {aj=step_div(j,ny);vx-=bxy*aj;vy-=by*aj;j-=aj*ny;} else aj=0;
			i=step_int(gx*xsp);if(i<0||i>=nx) {ai=step_div(i,nx);vx-=bx*ai;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 the neighbor information to this vertex
		add_neighbor(*vmp,idn);
	}

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %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, -0xb0(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0xa8(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0xe6756
movq -0xb0(%rbp), %rax
movsd -0x20(%rbp), %xmm1
movq -0xa8(%rbp), %rcx
movl -0x54(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd 0x10c078(%rip), %xmm2   # 0x1f2078
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x28(%rbp), %xmm1
movq -0xa8(%rbp), %rcx
movl -0x54(%rbp), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd 0x10c043(%rip), %xmm2   # 0x1f2078
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x30(%rbp), %xmm1
movq -0xa8(%rbp), %rcx
movl -0x54(%rbp), %edx
shll $0x2, %edx
addl $0x2, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd 0x10c00e(%rip), %xmm2   # 0x1f2078
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x88(%rbp), %xmm1
movsd -0x90(%rbp), %xmm0
movsd 0x8(%rax), %xmm2
divsd 0x10(%rax), %xmm2
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd -0x98(%rbp), %xmm1
movsd 0x8(%rax), %xmm2
movsd 0x20(%rax), %xmm4
movsd 0x10(%rax), %xmm3
mulsd 0x18(%rax), %xmm3
movq %xmm3, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm1
movsd 0x10(%rax), %xmm2
mulsd 0x28(%rax), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x90(%rbp), %xmm1
movsd -0x98(%rbp), %xmm0
movsd 0x20(%rax), %xmm2
divsd 0x28(%rax), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0xa8(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0xa8(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0xa8(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0xa8(%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 -0xa8(%rbp), %rax
movl -0x54(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0xa8(%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 -0xb0(%rbp), %rdi
movsd -0x38(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x10be67(%rip), %xmm2   # 0x1f2078
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x78(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
movsd -0x88(%rbp), %xmm2
movsd -0x90(%rbp), %xmm3
movsd -0x98(%rbp), %xmm4
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 0xe4850
testb $0x1, %al
jne 0xe626e
jmp 0xe62e6
movq -0xb0(%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 -0xa0(%rbp), %xmm0
jbe 0xe62e1
movq -0xb0(%rbp), %rax
movsd -0xa0(%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 0xe6727
movq -0xb0(%rbp), %rdi
movsd -0x98(%rbp), %xmm0
mulsd 0x50(%rdi), %xmm0
callq 0xe5370
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jl 0xe631b
movq -0xb0(%rbp), %rcx
movl -0x4c(%rbp), %eax
cmpl 0x38(%rcx), %eax
jl 0xe63f5
movq -0xb0(%rbp), %rdi
movl -0x4c(%rbp), %esi
movl 0x38(%rdi), %edx
callq 0xe53b0
movl %eax, %ecx
movq -0xb0(%rbp), %rax
movl %ecx, -0x64(%rbp)
movsd 0x18(%rax), %xmm0
cvtsi2sdl -0x64(%rbp), %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)
movsd 0x20(%rax), %xmm0
cvtsi2sdl -0x64(%rbp), %xmm2
movsd -0x90(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd 0x28(%rax), %xmm0
cvtsi2sdl -0x64(%rbp), %xmm2
movsd -0x98(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movl -0x64(%rbp), %ecx
imull 0x38(%rax), %ecx
movl -0x4c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x4c(%rbp)
jmp 0xe63fc
movl $0x0, -0x64(%rbp)
movq -0xb0(%rbp), %rdi
movsd -0x80(%rbp), %xmm0
mulsd 0x48(%rdi), %xmm0
callq 0xe5370
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jl 0xe642e
movq -0xb0(%rbp), %rcx
movl -0x48(%rbp), %eax
cmpl 0x34(%rcx), %eax
jl 0xe64cf
movq -0xb0(%rbp), %rdi
movl -0x48(%rbp), %esi
movl 0x34(%rdi), %edx
callq 0xe53b0
movl %eax, %ecx
movq -0xb0(%rbp), %rax
movl %ecx, -0x60(%rbp)
movsd 0x8(%rax), %xmm0
cvtsi2sdl -0x60(%rbp), %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)
movsd 0x10(%rax), %xmm0
cvtsi2sdl -0x60(%rbp), %xmm2
movsd -0x90(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0x60(%rbp), %ecx
imull 0x34(%rax), %ecx
movl -0x48(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0xe64d6
movl $0x0, -0x60(%rbp)
movq -0xb0(%rbp), %rdi
movsd -0x78(%rbp), %xmm0
mulsd 0x40(%rdi), %xmm0
callq 0xe5370
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jl 0xe6504
movq -0xb0(%rbp), %rcx
movl -0x44(%rbp), %eax
cmpl 0x30(%rcx), %eax
jl 0xe656b
movq -0xb0(%rbp), %rdi
movl -0x44(%rbp), %esi
movl 0x30(%rdi), %edx
callq 0xe53b0
movl %eax, %ecx
movq -0xb0(%rbp), %rax
movl %ecx, -0x5c(%rbp)
movsd (%rax), %xmm0
cvtsi2sdl -0x5c(%rbp), %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)
movl -0x5c(%rbp), %ecx
imull 0x30(%rax), %ecx
movl -0x44(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x44(%rbp)
jmp 0xe6572
movl $0x0, -0x5c(%rbp)
movq -0xb0(%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 0xe65cb
movq -0xb0(%rbp), %rdi
callq 0xe31a0
movq -0xb0(%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 0xe65f9
movq -0xb0(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0xe2fd0
movq -0xb0(%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 -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
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 $0x1, %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
movsd -0x98(%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 -0xa0(%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 -0xb0(%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 0xe5fc7
movq -0xb0(%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 $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)