// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/grid.cc
// Function: GaussianCube::GaussianCube(ATOM_NETWORK*)
GaussianCube::GaussianCube(ATOM_NETWORK *atmnet){

 // calculate desired cube size
 na=(int)ceil(atmnet->a/GRIDRES)+1;
 nb=(int)ceil(atmnet->b/GRIDRES)+1;
 nc=(int)ceil(atmnet->c/GRIDRES)+1;

 // define the grid and allocate memory
 gridsize = na*nb*nc;

 if(gridsize<2)
    {
    cout << "Grid size is 1 or less. Aborting..." << "\n";
//    abort();
    } else
    {
    cout << "Gaussian cube grid - " << na << " x " << nb << " x " << nc << " = " << gridsize << " points.\n";
    };

 allocate(na, nb, nc);

 o = XYZ (0.0,0.0,0.0);
 va=atmnet->v_a;
 vb=atmnet->v_b;
 vc=atmnet->v_c;

 va=va.scale(1.0/(na-1.0)); // substracting 1.0 from na in denominator to make sure va reaches 1.0 after na steps (starting from 0)
 vb=vb.scale(1.0/(nb-1.0));
 vc=vc.scale(1.0/(nc-1.0));

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r13
movq %rdi, %rbx
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x6402e
leaq 0x18(%rbx), %r12
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r12, %rdi
callq 0x6402e
leaq 0x30(%rbx), %r15
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r15, %rdi
callq 0x6402e
leaq 0x48(%rbx), %r14
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rdi
callq 0x6402e
leaq 0x60(%rbx), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x6402e
movupd 0x8(%r13), %xmm0
divpd 0x9c869(%rip), %xmm0    # 0x104740
movapd %xmm0, 0x30(%rsp)
callq 0x40c0
movapd %xmm0, (%rsp)
movapd 0x30(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x40c0
movapd (%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvttpd2dq %xmm1, %xmm1
pcmpeqd %xmm0, %xmm0
psubd %xmm0, %xmm1
movdqa %xmm1, (%rsp)
movq %xmm1, 0x78(%rbx)
movsd 0x18(%r13), %xmm0
divsd 0x9c7ed(%rip), %xmm0    # 0x104710
callq 0x40c0
cvttsd2si %xmm0, %eax
incl %eax
movl %eax, 0x80(%rbx)
movdqa (%rsp), %xmm0
movd %xmm0, %ecx
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %edx
imull %eax, %ecx
imull %edx, %ecx
movl %ecx, 0x84(%rbx)
movq 0xe8067(%rip), %rdi     # 0x14ffc0
cmpl $0x1, %ecx
jg 0x67f73
leaq 0x9c890(%rip), %rsi     # 0x1047f5
callq 0x4480
leaq 0x9a60d(%rip), %rsi     # 0x10257e
jmp 0x67fe4
leaq 0x9c89f(%rip), %rsi     # 0x104819
callq 0x4480
movl 0x78(%rbx), %esi
movq %rax, %rdi
callq 0x4760
leaq 0x9c89e(%rip), %rbp     # 0x10482f
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4480
movl 0x7c(%rbx), %esi
movq %rax, %rdi
callq 0x4760
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4480
movl 0x80(%rbx), %esi
movq %rax, %rdi
callq 0x4760
leaq 0xa6759(%rip), %rsi     # 0x10e720
movq %rax, %rdi
callq 0x4480
movl 0x84(%rbx), %esi
movq %rax, %rdi
callq 0x4760
leaq 0x9c84f(%rip), %rsi     # 0x104833
movq %rax, %rdi
callq 0x4480
movl 0x78(%rbx), %esi
movl 0x7c(%rbx), %edx
movl 0x80(%rbx), %ecx
movq %rbx, %rdi
callq 0x68130
leaq 0x18(%rsp), %rbp
pxor %xmm0, %xmm0
pxor %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %rbp, %rdi
callq 0x6402e
movq 0x10(%rbp), %rax
movq %rax, 0x10(%rbx)
movups (%rbp), %xmm0
movups %xmm0, (%rbx)
movq 0x48(%r13), %rax
movq %rax, 0x10(%r12)
movups 0x38(%r13), %xmm0
movups %xmm0, (%r12)
movq 0x60(%r13), %rax
movq %rax, 0x10(%r15)
movups 0x50(%r13), %xmm0
movups %xmm0, (%r15)
movq 0x78(%r13), %rax
movq %rax, 0x10(%r14)
movups 0x68(%r13), %xmm0
movups %xmm0, (%r14)
cvtsi2sdl 0x78(%rbx), %xmm1
addsd 0x9827f(%rip), %xmm1    # 0x1002e8
movsd 0x93fe7(%rip), %xmm0    # 0xfc058
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x640ba
movq 0x10(%r13), %rax
movq %rax, 0x10(%r12)
movups (%r13), %xmm0
movups %xmm0, (%r12)
cvtsi2sdl 0x7c(%rbx), %xmm1
addsd 0x98243(%rip), %xmm1    # 0x1002e8
movsd 0x93fab(%rip), %xmm0    # 0xfc058
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x640ba
movq 0x10(%r12), %rax
movq %rax, 0x10(%r15)
movups (%r12), %xmm0
movups %xmm0, (%r15)
cvtsi2sdl 0x80(%rbx), %xmm1
addsd 0x98205(%rip), %xmm1    # 0x1002e8
movsd 0x93f6d(%rip), %xmm0    # 0xfc058
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x640ba
movq 0x10(%rbx), %rax
movq %rax, 0x10(%r14)
movups (%rbx), %xmm0
movups %xmm0, (%r14)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop