// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/v_network.cc
// Function: voronoi_network::voronoi_network<voro::container_periodic>(voro::container_periodic&, double)
voronoi_network::voronoi_network(c_class &c,double net_tol_) :
	bx(c.bx), bxy(c.bxy), by(c.by), bxz(c.bxz), byz(c.byz), bz(c.bz),
	nx(c.nx), ny(c.ny), nz(c.nz), nxyz(nx*ny*nz),
	xsp(nx/bx), ysp(ny/by), zsp(nz/bz), net_tol(net_tol_) {
	int l;

	// Allocate memory for vertex structure
	pts=new double*[nxyz];
	idmem=new int*[nxyz];
	ptsc=new int[nxyz];
	ptsmem=new int[nxyz];
	for(l=0;l<nxyz;l++) {
		pts[l]=new double[4*init_network_vertex_memory];
		idmem[l]=new int[init_network_vertex_memory];
		ptsc[l]=0;ptsmem[l]=init_network_vertex_memory;
	}

	// Allocate memory for network edges and related statistics 
	edc=0;edmem=init_network_vertex_memory*nxyz;
	ed=new int*[edmem];
	ne=new int*[edmem];
	pered=new unsigned int*[edmem];
	raded=new block*[edmem];
	nu=new int[edmem];
	nec=new int[edmem];
	numem=new int[edmem];

	// Allocate memory for back pointers
	reg=new int[edmem];
	regp=new int[edmem];

	// Allocate edge memory
	for(l=0;l<edmem;l++) {
		ed[l]=new int[2*init_network_edge_memory];
		ne[l]=ed[l]+init_network_edge_memory;
	}
	for(l=0;l<edmem;l++) raded[l]=new block[init_network_edge_memory];
	for(l=0;l<edmem;l++) pered[l]=new unsigned int[init_network_edge_memory];
	for(l=0;l<edmem;l++) {nu[l]=nec[l]=0;numem[l]=init_network_edge_memory;}

	// vertices
	vmap=new int[4*init_vertices];
	map_mem=init_vertices;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movupd (%rsi), %xmm1
movupd %xmm1, (%rdi)
movupd 0x10(%rsi), %xmm2
movupd %xmm2, 0x10(%rdi)
movupd 0x20(%rsi), %xmm3
movupd %xmm3, 0x20(%rdi)
movl 0x130(%rsi), %eax
movl %eax, 0x38(%rdi)
movq 0x128(%rsi), %r12
movq %r12, %xmm4
movq %r12, 0x30(%rdi)
pshufd $0x55, %xmm4, %xmm5     # xmm5 = xmm4[1,1,1,1]
movd %xmm5, %ecx
imull %eax, %r12d
imull %ecx, %r12d
cvtdq2pd %xmm4, %xmm4
movl %r12d, 0x3c(%rdi)
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
divpd %xmm1, %xmm4
movupd %xmm4, 0x40(%rdi)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
divsd %xmm3, %xmm1
movsd %xmm1, 0x50(%rdi)
movsd %xmm0, 0x58(%rdi)
movslq %r12d, %rbp
leaq (,%rbp,8), %r14
testl %ebp, %ebp
movq $-0x1, %r13
cmovsq %r13, %r14
leaq (,%rbp,4), %r15
cmovsq %r13, %r15
movq %r14, %rdi
callq 0x4030
movq %rax, 0x60(%rbx)
movq %r14, %rdi
callq 0x4030
movq %rax, 0x68(%rbx)
movq %r15, %rdi
callq 0x4030
movq %rax, 0x70(%rbx)
movq %r15, %rdi
callq 0x4030
movq %rax, 0x78(%rbx)
testl %ebp, %ebp
jle 0x811a9
xorl %r14d, %r14d
movl $0x800, %edi            # imm = 0x800
callq 0x4030
movq 0x60(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movl $0x100, %edi            # imm = 0x100
callq 0x4030
movq 0x68(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x70(%rbx), %rax
movl $0x0, (%rax,%r14,4)
movq 0x78(%rbx), %rax
movl $0x40, (%rax,%r14,4)
incq %r14
movslq 0x3c(%rbx), %r12
cmpq %r12, %r14
jl 0x81161
movl $0x0, 0xa0(%rbx)
movl %r12d, %ebp
shll $0x6, %ebp
movl %ebp, 0xa4(%rbx)
movslq %ebp, %r14
leaq (,%r14,8), %r15
shlq $0x2, %r14
testl %r12d, %r12d
cmovsq %r13, %r15
cmovsq %r13, %r14
movq %r15, %rdi
callq 0x4030
movq %rax, 0x80(%rbx)
movq %r15, %rdi
callq 0x4030
movq %rax, 0x88(%rbx)
movq %r15, %rdi
callq 0x4030
movq %rax, 0x98(%rbx)
movq %r15, %rdi
callq 0x4030
movq %rax, 0x90(%rbx)
movq %r14, %rdi
callq 0x4030
movq %rax, 0xa8(%rbx)
movq %r14, %rdi
callq 0x4030
movq %rax, 0xb0(%rbx)
movq %r14, %rdi
callq 0x4030
movq %rax, 0xb8(%rbx)
movq %r14, %rdi
callq 0x4030
movq %rax, 0xc0(%rbx)
movq %r14, %rdi
callq 0x4030
movq %rax, 0xc8(%rbx)
testl %r12d, %r12d
jle 0x81307
cmpl $0x2, %ebp
movl $0x1, %r14d
cmovgel %ebp, %r14d
xorl %r15d, %r15d
movl $0x20, %edi
callq 0x4030
movq 0x80(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x80(%rbx), %rax
movq 0x88(%rbx), %rcx
movq (%rax,%r15,8), %rax
addq $0x10, %rax
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x81279
testl %r12d, %r12d
jle 0x81307
xorl %r15d, %r15d
movl $0x40, %edi
callq 0x4030
movq 0x90(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x812b8
testl %r12d, %r12d
jle 0x81307
cmpl $0x2, %ebp
movl $0x1, %r14d
cmovgel %ebp, %r14d
xorl %r15d, %r15d
movl $0x10, %edi
callq 0x4030
movq 0x98(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x812ea
testl %ebp, %ebp
jle 0x81340
movq 0xa8(%rbx), %rax
movq 0xb0(%rbx), %rcx
movq 0xb8(%rbx), %rdx
xorl %esi, %esi
xorl %edi, %edi
movl %esi, (%rcx,%rdi,4)
movl %esi, (%rax,%rdi,4)
movl $0x4, (%rdx,%rdi,4)
incq %rdi
movslq 0xa4(%rbx), %r8
cmpq %r8, %rdi
jl 0x81324
movl $0x1000, %edi           # imm = 0x1000
callq 0x4030
movq %rax, 0xd0(%rbx)
movl $0x100, 0xd8(%rbx)      # imm = 0x100
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq