// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movq %rcx, 0x50(%rsp)
movapd %xmm3, 0x80(%rsp)
movsd %xmm2, 0x68(%rsp)
movsd %xmm1, 0x60(%rsp)
movsd %xmm0, 0x58(%rsp)
movq %rdi, %r15
movq %rsi, 0x30(%rsp)
cmpl $0x0, 0x1c(%rsi)
jle 0x82fa0
movl %edx, %ebp
movq 0x30(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x78(%rsp)
movapd 0xd0b67(%rip), %xmm0    # 0x1535b0
xorpd 0x80(%rsp), %xmm0
movapd %xmm0, 0x90(%rsp)
xorl %r14d, %r14d
movq 0x50(%rsp), %r12
movq %r14, %rax
shlq $0x5, %rax
movq 0x78(%rsp), %rcx
movsd (%rcx,%rax), %xmm6
movsd 0x8(%rcx,%rax), %xmm3
movsd 0x10(%rcx,%rax), %xmm4
movsd 0x8(%r15), %xmm7
movsd 0x10(%r15), %xmm9
movsd 0x20(%r15), %xmm8
movsd 0x18(%r15), %xmm11
mulsd %xmm9, %xmm11
movsd 0x28(%r15), %xmm10
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
movapd %xmm6, %xmm1
mulsd %xmm6, %xmm1
addsd %xmm0, %xmm1
movapd %xmm4, %xmm0
mulsd %xmm4, %xmm0
addsd %xmm1, %xmm0
ucomisd 0xd07f5(%rip), %xmm0    # 0x1532c0
jb 0x82ad3
sqrtsd %xmm0, %xmm0
jmp 0x82b3e
movsd %xmm4, 0x18(%rsp)
movsd %xmm3, 0x10(%rsp)
movsd %xmm6, 0x8(%rsp)
movsd %xmm7, 0x28(%rsp)
movsd %xmm8, (%rsp)
movsd %xmm9, 0x40(%rsp)
movsd %xmm10, 0x38(%rsp)
movsd %xmm11, 0x70(%rsp)
callq 0x4350
movsd 0x70(%rsp), %xmm11
movsd 0x38(%rsp), %xmm10
movsd 0x40(%rsp), %xmm9
movsd (%rsp), %xmm8
movsd 0x28(%rsp), %xmm7
movsd 0x8(%rsp), %xmm6
movsd 0x10(%rsp), %xmm3
movsd 0x18(%rsp), %xmm4
movsd 0xcc4f2(%rip), %xmm2    # 0x14f038
mulsd %xmm2, %xmm6
addsd 0x58(%rsp), %xmm6
mulsd %xmm2, %xmm3
addsd 0x60(%rsp), %xmm3
mulsd %xmm2, %xmm4
addsd 0x68(%rsp), %xmm4
movapd %xmm7, %xmm5
divsd %xmm9, %xmm5
mulsd %xmm3, %xmm5
movapd %xmm6, %xmm1
subsd %xmm5, %xmm1
mulsd %xmm8, %xmm7
subsd %xmm11, %xmm7
mulsd %xmm4, %xmm7
mulsd %xmm10, %xmm9
divsd %xmm9, %xmm7
addsd %xmm1, %xmm7
divsd %xmm10, %xmm8
mulsd %xmm4, %xmm8
movapd %xmm3, %xmm1
subsd %xmm8, %xmm1
mulsd %xmm2, %xmm0
addsd 0x90(%rsp), %xmm0
movsd %xmm0, (%rsp)
leaq 0x4(%r12), %rbx
leaq 0x8(%r12), %r13
leaq 0xc(%r12), %r9
movq %r15, %rdi
movsd %xmm7, 0x28(%rsp)
movapd %xmm7, %xmm0
movsd %xmm1, 0x38(%rsp)
movsd %xmm6, 0x8(%rsp)
movapd %xmm6, %xmm2
movsd %xmm3, 0x10(%rsp)
movsd %xmm4, 0x18(%rsp)
leaq 0x24(%rsp), %rsi
leaq 0x4c(%rsp), %rdx
movq %rbx, %rcx
movq %r13, %r8
movq %r9, 0x40(%rsp)
callq 0x81c1e
testb %al, %al
je 0x82c60
movq 0x68(%r15), %rax
movslq 0x24(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movslq 0x4c(%rsp), %rax
movl (%rdx,%rax,4), %edx
movl %edx, (%r12)
movq 0x60(%r15), %rdx
movq (%rdx,%rcx,8), %rcx
leaq (,%rax,4), %rdx
movsd 0x18(%rcx,%rdx,8), %xmm0
movsd (%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x82f12
leaq 0x3(,%rax,4), %rax
movsd %xmm1, (%rcx,%rax,8)
jmp 0x82f12
movq %rbx, %r11
movsd 0x50(%r15), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %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 0x82cb3
xorl %esi, %esi
movsd 0x10(%rsp), %xmm3
movsd (%rsp), %xmm4
movsd 0x8(%rsp), %xmm5
movsd 0x28(%rsp), %xmm6
jmp 0x82d13
testl %ebx, %ebx
movsd 0x10(%rsp), %xmm3
movsd (%rsp), %xmm4
movsd 0x8(%rsp), %xmm5
movsd 0x28(%rsp), %xmm6
js 0x82cd7
movl %ebx, %eax
cltd
idivl %edi
movl %eax, %esi
jmp 0x82ce1
leal 0x1(%rbx), %eax
cltd
idivl %edi
movl %eax, %esi
decl %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0x18(%r15), %xmm1
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm5
movsd 0x20(%r15), %xmm1
mulsd %xmm0, %xmm1
mulsd 0x28(%r15), %xmm0
subsd %xmm1, %xmm3
subsd %xmm0, %xmm2
imull %esi, %edi
subl %edi, %ebx
movsd 0x38(%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 0x82d82
testl %edi, %edi
js 0x82d51
movl %edi, %eax
cltd
idivl %r8d
movl %eax, %ecx
jmp 0x82d5c
leal 0x1(%rdi), %eax
cltd
idivl %r8d
movl %eax, %ecx
decl %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd 0x8(%r15), %xmm1
mulsd %xmm0, %xmm1
mulsd 0x10(%r15), %xmm0
subsd %xmm1, %xmm5
subsd %xmm0, %xmm3
imull %ecx, %r8d
subl %r8d, %edi
mulsd 0x40(%r15), %xmm6
xorl %eax, %eax
xorpd %xmm0, %xmm0
ucomisd %xmm6, %xmm0
seta %al
cvttsd2si %xmm6, %r8d
subl %eax, %r8d
setns %dl
movl 0x30(%r15), %r9d
cmpl %r9d, %r8d
setl %r10b
xorl %eax, %eax
testb %r10b, %dl
jne 0x82de1
testl %r8d, %r8d
js 0x82dc0
movl %r8d, %eax
cltd
idivl %r9d
jmp 0x82dca
leal 0x1(%r8), %eax
cltd
idivl %r9d
decl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd (%r15), %xmm0
subsd %xmm0, %xmm5
imull %eax, %r9d
subl %r9d, %r8d
movl %eax, (%r11)
movl %ecx, (%r13)
movq 0x40(%rsp), %rax
movl %esi, (%rax)
imull 0x34(%r15), %ebx
addl %edi, %ebx
imull 0x30(%r15), %ebx
addl %r8d, %ebx
movl %ebx, 0x24(%rsp)
movl 0xa0(%r15), %eax
cmpl 0xa4(%r15), %eax
movsd %xmm2, 0x18(%rsp)
movsd %xmm3, 0x10(%rsp)
movsd %xmm5, 0x8(%rsp)
jne 0x82e43
movq %r15, %rdi
callq 0x80bea
movsd 0x8(%rsp), %xmm5
movsd (%rsp), %xmm4
movsd 0x10(%rsp), %xmm3
movsd 0x18(%rsp), %xmm2
movslq %ebx, %r13
movq 0x70(%r15), %rax
movq 0x78(%r15), %rcx
movl (%rax,%r13,4), %eax
cmpl (%rcx,%r13,4), %eax
jne 0x82e79
movq %r15, %rdi
movl %ebx, %esi
callq 0x80ada
movsd 0x8(%rsp), %xmm5
movsd (%rsp), %xmm4
movsd 0x10(%rsp), %xmm3
movsd 0x18(%rsp), %xmm2
movq 0xc0(%r15), %rax
movslq 0xa0(%r15), %rcx
movl %ebx, (%rax,%rcx,4)
movq 0x70(%r15), %rax
movq 0xc8(%r15), %rcx
movl (%rax,%r13,4), %edx
movslq 0xa0(%r15), %rsi
movl %edx, (%rcx,%rsi,4)
movq 0x60(%r15), %rcx
movq (%rcx,%r13,8), %rcx
movslq (%rax,%r13,4), %rdx
leaq (,%rdx,4), %rsi
movq %rdx, %rdi
shlq $0x5, %rdi
movsd %xmm5, (%rcx,%rdi)
leal 0x1(%rsi), %edi
movslq %edi, %rdi
movsd %xmm3, (%rcx,%rdi,8)
leal 0x2(%rsi), %edi
movslq %edi, %rdi
movsd %xmm2, (%rcx,%rdi,8)
orl $0x3, %esi
movslq %esi, %rsi
movsd %xmm4, (%rcx,%rsi,8)
movl 0xa0(%r15), %ecx
movq 0x68(%r15), %rsi
movq (%rsi,%r13,8), %rsi
leal 0x1(%rdx), %edi
movl %edi, (%rax,%r13,4)
movl %ecx, (%rsi,%rdx,4)
movl 0xa0(%r15), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0xa0(%r15)
movl %eax, (%r12)
movslq (%r12), %rbx
movq 0xb0(%r15), %rax
movslq (%rax,%rbx,4), %rax
testq %rax, %rax
jle 0x82f52
movq 0x88(%r15), %rcx
movq (%rcx,%rbx,8), %rcx
cmpl %ebp, (%rcx)
je 0x82f87
leaq -0x1(%rax), %rdx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x82f52
leaq 0x1(%rsi), %rdi
cmpl %ebp, 0x4(%rcx,%rsi,4)
movq %rdi, %rsi
jne 0x82f3b
cmpq %rax, %rdi
jb 0x82f87
movq 0xb8(%r15), %rcx
cmpl (%rcx,%rbx,4), %eax
jne 0x82f68
movq %r15, %rdi
movl %ebx, %esi
callq 0x80fa6
movq 0x88(%r15), %rax
movq 0xb0(%r15), %rcx
movq (%rax,%rbx,8), %rax
movslq (%rcx,%rbx,4), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%rcx,%rbx,4)
movl %ebp, (%rax,%rdx,4)
incq %r14
addq $0x10, %r12
movq 0x30(%rsp), %rax
movslq 0x1c(%rax), %rax
cmpq %rax, %r14
jl 0x82a63
movq %r15, %rdi
movq 0x30(%rsp), %rsi
movsd 0x58(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
movaps 0x80(%rsp), %xmm3
movq 0x50(%rsp), %rdx
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84374
nop