// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/voro++/src/unitcell.cc
// Function: voro::unitcell::unitcell(double, double, double, double, double, double)
unitcell::unitcell(double bx_,double bxy_,double by_,double bxz_,double byz_,double bz_)
	: bx(bx_), bxy(bxy_), by(by_), bxz(bxz_), byz(byz_), bz(bz_),
	unit_voro(max_unit_voro_shells*max_unit_voro_shells*4*(bx*bx+by*by+bz*bz)) {
	int i,j,l=1;

	// Initialize the Voronoi cell to be a very large rectangular box
	const double ucx=max_unit_voro_shells*bx,ucy=max_unit_voro_shells*by,ucz=max_unit_voro_shells*bz;
	unit_voro.init(-ucx,ucx,-ucy,ucy,-ucz,ucz);

	// Repeatedly cut the cell by shells of periodic image particles
	while(l<2*max_unit_voro_shells) {

		// Check to see if any of the planes from the current shell
		// will cut the cell
		if(unit_voro_intersect(l)) {

			// If they do, apply the plane cuts from the current
			// shell
			unit_voro_apply(l,0,0);
			for(i=1;i<l;i++) {
				unit_voro_apply(l,i,0);
				unit_voro_apply(-l,i,0);
			}
			for(i=-l;i<=l;i++) unit_voro_apply(i,l,0);
			for(i=1;i<l;i++) for(j=-l+1;j<=l;j++) {
				unit_voro_apply(l,j,i);
				unit_voro_apply(-j,l,i);
				unit_voro_apply(-l,-j,i);
				unit_voro_apply(j,-l,i);
			}
			for(i=-l;i<=l;i++) for(j=-l;j<=l;j++) unit_voro_apply(i,j,l);
		} else {

			// Calculate a bound on the maximum y and z coordinates
			// that could possibly cut the cell. This is based upon
			// a geometric result that particles with z>l can't cut
			// a cell lying within the paraboloid
			// z<=(l*l-x*x-y*y)/(2*l). It is always a tighter bound
			// than the one based on computing the maximum radius
			// of a Voronoi cell vertex.
			max_uv_y=max_uv_z=0;
			double y,z,q,*pts=unit_voro.pts,*pp=pts;
			while(pp<pts+4*unit_voro.p) {
				q=*(pp++);y=*(pp++);z=*pp;pp+=2;q=sqrt(q*q+y*y+z*z);
				if(y+q>max_uv_y) max_uv_y=y+q;
				if(z+q>max_uv_z) max_uv_z=z+q;
			}
			max_uv_z*=0.5;
			max_uv_y*=0.5;
			return;
		}
		l++;
	}

	// If the routine makes it here, then the unit cell still hasn't been
	// completely bounded by the plane cuts. Give the memory error code,
	// because this is mainly a case of hitting a safe limit, than any
	// inherent problem.
	voro_fatal_error("Periodic cell computation failed",VOROPP_MEMORY_ERROR);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movsd %xmm0, (%rdi)
movsd %xmm1, 0x8(%rdi)
movsd %xmm2, 0x10(%rdi)
movsd %xmm3, 0x18(%rdi)
movsd %xmm4, 0x20(%rdi)
movsd %xmm5, 0x28(%rdi)
leaq 0x30(%rdi), %r14
mulsd %xmm2, %xmm2
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm5, %xmm5
addsd %xmm5, %xmm0
mulsd 0x8966(%rip), %xmm0     # 0x355f0
movq %r14, %rdi
callq 0x2da4c
movsd 0x895e(%rip), %xmm5     # 0x355f8
movsd (%rbx), %xmm1
mulsd %xmm5, %xmm1
movsd 0x10(%rbx), %xmm3
mulsd %xmm5, %xmm3
mulsd 0x28(%rbx), %xmm5
movapd 0x2388(%rip), %xmm4     # 0x2f040
movapd %xmm1, %xmm0
xorpd %xmm4, %xmm0
movapd %xmm3, %xmm2
xorpd %xmm4, %xmm2
xorpd %xmm5, %xmm4
movq %r14, 0x20(%rsp)
movq %r14, %rdi
callq 0x5bdc
pushq $0x1
popq %r12
pushq $-0x3
popq %rax
movq %rax, 0x10(%rsp)
pushq $0x2
popq %rax
movl $0x0, 0x4(%rsp)
xorl %r13d, %r13d
movl %eax, 0xc(%rsp)
movl %eax, %r14d
movl %r12d, (%rsp)
cmpl $0x15, %r14d
je 0x2ce6b
movq %rbx, %rdi
movl (%rsp), %esi
callq 0x2cf62
testb %al, %al
je 0x2ce7f
movq %rbx, %rdi
movl (%rsp), %ebp
movl %ebp, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2da62
movl %r14d, 0x8(%rsp)
movl %ebp, %r15d
negl %r15d
movl %r12d, %r14d
leal (%r14,%r13), %eax
cmpl $0x1, %eax
je 0x2cd67
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x2da62
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x2da62
incl %r14d
jmp 0x2cd3a
pushq $-0x1
popq %rax
movl %eax, %r14d
movq 0x10(%rsp), %rax
addl %r14d, %eax
cmpl $-0x1, %eax
je 0x2cd8f
leal (%r14,%r13), %esi
movq %rbx, %rdi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x2da62
incl %r14d
jmp 0x2cd6d
movq %r13, 0x18(%rsp)
cmpl %ebp, %r12d
je 0x2ce02
xorl %ebp, %ebp
movl 0x4(%rsp), %r13d
cmpl %ebp, 0xc(%rsp)
je 0x2cdfa
movq 0x18(%rsp), %rax
leal (%rax,%rbp), %r14d
movq %rbx, %rdi
movl (%rsp), %esi
movl %r14d, %edx
movl %r12d, %ecx
callq 0x2da62
movq %rbx, %rdi
movl %r13d, %esi
movl (%rsp), %edx
movl %r12d, %ecx
callq 0x2da62
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
movl %r12d, %ecx
callq 0x2da62
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
movl %r12d, %ecx
callq 0x2da62
incl %ebp
decl %r13d
jmp 0x2cda0
incl %r12d
movl (%rsp), %ebp
jmp 0x2cd94
pushq $0x1
popq %r12
movq 0x18(%rsp), %r13
cmpl 0x8(%rsp), %r15d
je 0x2ce40
pushq $-0x1
popq %rax
movl %eax, %r14d
movq 0x10(%rsp), %rax
addl %r14d, %eax
cmpl $-0x1, %eax
je 0x2ce3b
leal (%r14,%r13), %edx
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %ecx
callq 0x2da62
incl %r14d
jmp 0x2ce18
incl %r15d
jmp 0x2ce0b
incl %ebp
movl %ebp, (%rsp)
movl 0x8(%rsp), %r14d
incl %r14d
decl %r13d
movq 0x10(%rsp), %rax
addl $-0x2, %eax
movq %rax, 0x10(%rsp)
addl $0x2, 0xc(%rsp)
incl 0x4(%rsp)
jmp 0x2ccfe
leaq 0x8796(%rip), %rdi      # 0x35608
pushq $0x2
popq %rsi
callq 0xfdaf
jmp 0x2cf34
leaq 0x118(%rbx), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, 0x118(%rbx)
movq 0x70(%rbx), %rsi
movslq 0x4c(%rbx), %rcx
shlq $0x5, %rcx
addq %rsi, %rcx
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
cmpq %rcx, %rsi
jae 0x2cf14
movq %rsi, %rdx
movsd (%rsi), %xmm4
movsd 0x8(%rsi), %xmm3
movsd 0x10(%rsi), %xmm2
movapd %xmm3, %xmm5
mulsd %xmm3, %xmm5
mulsd %xmm4, %xmm4
addsd %xmm5, %xmm4
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm4, %xmm5
sqrtsd %xmm5, %xmm4
addsd %xmm4, %xmm3
ucomisd %xmm0, %xmm3
jbe 0x2cef1
movsd %xmm3, (%rax)
movapd %xmm3, %xmm0
addsd %xmm4, %xmm2
leaq 0x20(%rdx), %rsi
ucomisd %xmm1, %xmm2
jbe 0x2cea9
addq $0x20, %rdx
movsd %xmm2, 0x120(%rbx)
movapd %xmm2, %xmm1
movq %rdx, %rsi
jmp 0x2cea9
movsd 0x2114(%rip), %xmm2     # 0x2f030
mulsd %xmm2, %xmm1
movsd %xmm1, 0x120(%rbx)
mulsd %xmm2, %xmm0
movsd %xmm0, 0x118(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2cf4d
jmp 0x2cf4d
jmp 0x2cf4d
jmp 0x2cf4d
jmp 0x2cf4d
movq %rax, %rbx
movq 0x20(%rsp), %rdi
callq 0x5744
movq %rbx, %rdi
callq 0x2220