// File: /workspace/github_cpp_makefile_star2_O2/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 $0xa8, %rsp
movsd %xmm2, 0x38(%rsp)
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movq 0x40(%rsi), %rbx
movapd 0x9e2a5(%rip), %xmm2    # 0x1005d0
movapd %xmm3, 0x70(%rsp)
xorpd %xmm3, %xmm2
movapd %xmm2, 0x90(%rsp)
movapd %xmm0, 0x50(%rsp)
movapd %xmm1, 0x60(%rsp)
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd %xmm0, 0x80(%rsp)
addq $0x10, %rbx
movq %rcx, 0x40(%rsp)
leaq 0x8(%rcx), %r12
xorl %r13d, %r13d
movl %edx, 0x18(%rsp)
movslq 0x1c(%r14), %rax
cmpq %rax, %r13
jge 0x62727
movupd -0x10(%rbx), %xmm4
movapd %xmm4, %xmm0
mulpd 0xa1b87(%rip), %xmm0    # 0x103f10
addpd 0x80(%rsp), %xmm0
movsd (%rbx), %xmm1
movapd %xmm1, %xmm5
movsd 0x99c96(%rip), %xmm3    # 0xfc038
mulsd %xmm3, %xmm5
addsd 0x38(%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 0x90(%rsp), %xmm1
movsd %xmm1, (%rsp)
leaq -0x4(%r12), %rcx
leaq 0x4(%r12), %r9
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movq %r15, %rdi
movapd %xmm0, 0x20(%rsp)
movsd %xmm5, 0x10(%rsp)
movapd %xmm5, %xmm2
leaq 0xc(%rsp), %rsi
leaq 0x1c(%rsp), %rdx
movq %r12, %r8
callq 0x60e5c
testb %al, %al
je 0x6246a
movq 0x68(%r15), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movslq 0x1c(%rsp), %rax
movl (%rdx,%rax,4), %esi
movl %esi, -0x8(%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 0x6270d
leaq 0x3(,%rax,4), %rax
movsd %xmm1, (%rcx,%rax,8)
jmp 0x6270d
movq %r13, 0x48(%rsp)
movsd 0x50(%r15), %xmm0
movsd 0x10(%rsp), %xmm3
mulsd %xmm3, %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
cvttsd2si %xmm0, %r13d
subl %eax, %r13d
setns %al
movl 0x38(%r15), %edi
cmpl %edi, %r13d
setl %dl
xorl %ecx, %ecx
testb %dl, %al
je 0x624b1
xorl %esi, %esi
movapd 0x20(%rsp), %xmm2
jmp 0x624fb
testl %r13d, %r13d
movapd 0x20(%rsp), %xmm2
js 0x624c6
movl %r13d, %eax
cltd
idivl %edi
movl %eax, %esi
jmp 0x624d1
leal 0x1(%r13), %eax
cltd
idivl %edi
movl %eax, %esi
decl %esi
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, %r13d
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 0x62563
testl %edi, %edi
js 0x6253b
movl %edi, %eax
cltd
idivl %r8d
movl %eax, %ecx
jmp 0x62546
leal 0x1(%rdi), %eax
cltd
idivl %r8d
movl %eax, %ecx
decl %ecx
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 0x6259d
xorl %eax, %eax
movsd %xmm2, 0x30(%rsp)
jmp 0x625d3
testl %r8d, %r8d
js 0x625ab
movl %r8d, %eax
cltd
idivl %r9d
jmp 0x625b5
leal 0x1(%r8), %eax
cltd
idivl %r9d
decl %eax
cvtsi2sd %eax, %xmm0
mulsd (%r15), %xmm0
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
imull %eax, %r9d
subl %r9d, %r8d
movsd (%rsp), %xmm0
movq %r14, %rbp
movl %eax, -0x4(%r12)
movl %ecx, (%r12)
movl %esi, 0x4(%r12)
imull 0x34(%r15), %r13d
addl %edi, %r13d
imull 0x30(%r15), %r13d
addl %r8d, %r13d
movl %r13d, 0xc(%rsp)
movl 0xa0(%r15), %eax
cmpl 0xa4(%r15), %eax
movapd %xmm2, 0x20(%rsp)
movsd %xmm3, 0x10(%rsp)
jne 0x62633
movq %r15, %rdi
callq 0x5fdd2
movsd 0x10(%rsp), %xmm3
movapd 0x20(%rsp), %xmm2
movsd (%rsp), %xmm0
movq 0x70(%r15), %rax
movq 0x78(%r15), %rcx
movslq %r13d, %r14
movl (%rax,%r14,4), %edx
cmpl (%rcx,%r14,4), %edx
jne 0x62668
movq %r15, %rdi
movl %r13d, %esi
callq 0x5fcd4
movsd 0x10(%rsp), %xmm3
movapd 0x20(%rsp), %xmm2
movsd (%rsp), %xmm0
movq 0x70(%r15), %rax
movq 0xc0(%r15), %rcx
movslq 0xa0(%r15), %rdx
movl %r13d, (%rcx,%rdx,4)
movslq (%rax,%r14,4), %rcx
movq 0xc8(%r15), %rdx
movslq 0xa0(%r15), %rsi
movl %ecx, (%rdx,%rsi,4)
movq 0x60(%r15), %rdx
movq (%rdx,%r14,8), %rdx
leaq (,%rcx,4), %rsi
movq %rcx, %rdi
shlq $0x5, %rdi
movsd 0x30(%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,%r14,8), %rsi
leal 0x1(%rcx), %edi
movl %edi, (%rax,%r14,4)
movl %edx, (%rsi,%rcx,4)
movl 0xa0(%r15), %esi
leal 0x1(%rsi), %eax
movl %eax, 0xa0(%r15)
movl %esi, -0x8(%r12)
movq %rbp, %r14
movl 0x18(%rsp), %ebp
movq 0x48(%rsp), %r13
movq %r15, %rdi
movl %ebp, %edx
callq 0x62d22
incq %r13
addq $0x20, %rbx
addq $0x10, %r12
jmp 0x6236b
movq %r15, %rdi
movq %r14, %rsi
movaps 0x50(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movaps 0x70(%rsp), %xmm3
movq 0x40(%rsp), %rdx
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x62da6
nop