// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rcx, 0x48(%rsp)
movapd %xmm3, 0x90(%rsp)
movsd %xmm2, 0x50(%rsp)
movapd %xmm1, 0x80(%rsp)
movapd %xmm0, 0x70(%rsp)
movq %rdi, %r15
movq %rsi, 0x20(%rsp)
cmpl $0x0, 0x1c(%rsi)
jle 0x81be4
movl %edx, %ebp
movq 0x20(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x60(%rsp)
movaps 0xcff23(%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), %xmm9
movapd %xmm9, %xmm2
mulpd 0xd3854(%rip), %xmm2    # 0x154fc0
addpd 0xa0(%rsp), %xmm2
movsd 0x10(%rcx,%rax), %xmm10
movapd %xmm10, %xmm4
movsd 0xcb8af(%rip), %xmm7    # 0x14d038
mulsd %xmm7, %xmm4
addsd 0x50(%rsp), %xmm4
movsd 0x8(%r15), %xmm0
movsd 0x10(%r15), %xmm8
movapd %xmm0, %xmm1
divsd %xmm8, %xmm1
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
mulsd %xmm3, %xmm1
movapd %xmm2, %xmm5
subsd %xmm1, %xmm5
movsd 0x20(%r15), %xmm11
movsd 0x18(%r15), %xmm6
mulsd %xmm8, %xmm6
mulsd %xmm11, %xmm0
subsd %xmm6, %xmm0
mulsd %xmm4, %xmm0
movsd 0x28(%r15), %xmm6
mulsd %xmm6, %xmm8
divsd %xmm8, %xmm0
addsd %xmm5, %xmm0
divsd %xmm6, %xmm11
mulsd %xmm4, %xmm11
movapd %xmm3, %xmm1
subsd %xmm11, %xmm1
movapd %xmm9, %xmm5
mulpd %xmm9, %xmm5
unpckhpd %xmm5, %xmm5            # xmm5 = xmm5[1,1]
mulsd %xmm9, %xmm9
addsd %xmm5, %xmm9
mulsd %xmm10, %xmm10
addsd %xmm9, %xmm10
xorps %xmm5, %xmm5
sqrtsd %xmm10, %xmm5
mulsd %xmm7, %xmm5
addsd 0xb0(%rsp), %xmm5
movsd %xmm5, 0x58(%rsp)
leaq 0x4(%r12), %rbx
leaq 0x8(%r12), %r13
leaq 0xc(%r12), %r9
movq %r15, %rdi
movsd %xmm0, 0x10(%rsp)
movapd %xmm1, 0xc0(%rsp)
movapd %xmm2, 0x30(%rsp)
movsd %xmm4, 0x18(%rsp)
leaq 0xc(%rsp), %rsi
leaq 0x2c(%rsp), %rdx
movq %rbx, %rcx
movq %r13, %r8
movq %r9, 0x68(%rsp)
callq 0x80958
testb %al, %al
je 0x818da
movq 0x68(%r15), %rax
movslq 0xc(%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 0x58(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x81b67
leaq 0x3(,%rax,4), %rax
movsd %xmm1, (%rdx,%rax,8)
jmp 0x81b67
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 0x8191c
xorl %esi, %esi
movapd 0x30(%rsp), %xmm2
jmp 0x81969
testl %ebx, %ebx
js 0x81929
movl %ebx, %eax
cltd
idivl %edi
movl %eax, %esi
jmp 0x81933
leal 0x1(%rbx), %eax
cltd
idivl %edi
movl %eax, %esi
decl %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movupd 0x18(%r15), %xmm1
movapd %xmm0, %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
mulpd %xmm1, %xmm2
mulsd 0x28(%r15), %xmm0
movapd 0x30(%rsp), %xmm1
subpd %xmm2, %xmm1
movapd %xmm1, %xmm2
subsd %xmm0, %xmm3
imull %esi, %edi
subl %edi, %ebx
movapd 0xc0(%rsp), %xmm1
mulsd 0x48(%r15), %xmm1
xorl %eax, %eax
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
seta %al
cvttsd2si %xmm1, %edi
subl %eax, %edi
setns %al
movl 0x34(%r15), %r8d
cmpl %r8d, %edi
setl %dl
testb %dl, %al
jne 0x819d5
testl %edi, %edi
js 0x819aa
movl %edi, %eax
cltd
idivl %r8d
movl %eax, %ecx
jmp 0x819b5
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 0x10(%rsp), %xmm1
mulsd 0x40(%r15), %xmm1
xorl %eax, %eax
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
seta %al
cvttsd2si %xmm1, %r8d
subl %eax, %r8d
setns %al
movl 0x30(%r15), %r9d
cmpl %r9d, %r8d
setl %dl
testb %dl, %al
je 0x81a11
xorl %eax, %eax
movsd %xmm2, 0x10(%rsp)
jmp 0x81a4a
testl %r8d, %r8d
js 0x81a1f
movl %r8d, %eax
cltd
idivl %r9d
jmp 0x81a29
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, 0x10(%rsp)
imull %eax, %r9d
subl %r9d, %r8d
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, 0xc(%rsp)
movl 0xa0(%r15), %eax
cmpl 0xa4(%r15), %eax
movapd %xmm2, 0x30(%rsp)
movsd %xmm3, 0x18(%rsp)
jne 0x81a9b
movq %r15, %rdi
callq 0x7f988
movsd 0x18(%rsp), %xmm3
movapd 0x30(%rsp), %xmm2
movq 0x70(%r15), %rax
movq 0x78(%r15), %rcx
movslq %ebx, %r13
movl (%rax,%r13,4), %edx
cmpl (%rcx,%r13,4), %edx
jne 0x81aca
movq %r15, %rdi
movl %ebx, %esi
callq 0x7f876
movsd 0x18(%rsp), %xmm3
movapd 0x30(%rsp), %xmm2
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 0x10(%rsp), %xmm0
movsd %xmm0, (%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 0x58(%rsp), %xmm0
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 0x81b94
movq 0x88(%r15), %rdx
movq (%rdx,%rbx,8), %rdx
xorl %esi, %esi
cmpl %ebp, (%rdx,%rsi,4)
je 0x81bcb
incq %rsi
cmpq %rsi, %rcx
jne 0x81b87
movq 0xb8(%r15), %rdx
cmpl (%rdx,%rbx,4), %ecx
jne 0x81bb4
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 0x8174d
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movaps 0x70(%rsp), %xmm0
movaps 0x80(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
movaps 0x90(%rsp), %xmm3
movq 0x48(%rsp), %rdx
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x82e7c