// File: /workspace/github_cpp_makefile_star2_O3/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 0x84364
leaq 0x18(%rbx), %r12
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r12, %rdi
callq 0x84364
leaq 0x30(%rbx), %r15
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r15, %rdi
callq 0x84364
leaq 0x48(%rbx), %r14
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rdi
callq 0x84364
leaq 0x60(%rbx), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x84364
movupd 0x8(%r13), %xmm0
divpd 0xccbe7(%rip), %xmm0    # 0x155800
movapd %xmm0, 0x30(%rsp)
callq 0x40d0
movapd %xmm0, (%rsp)
movapd 0x30(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x40d0
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 0xccb6b(%rip), %xmm0    # 0x1557d0
callq 0x40d0
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 0x10c325(%rip), %rbp    # 0x194fc0
cmpl $0x1, %ecx
jg 0x88cc8
leaq 0xccc0e(%rip), %rsi     # 0x1558b5
movl $0x23, %edx
movq %rbp, %rdi
callq 0x44e0
leaq 0xca963(%rip), %rsi     # 0x15361e
movl $0x1, %edx
movq %rbp, %rdi
jmp 0x88d62
leaq 0xccc0a(%rip), %rsi     # 0x1558d9
movl $0x15, %edx
movq %rbp, %rdi
callq 0x44e0
movl 0x78(%rbx), %esi
movq %rbp, %rdi
callq 0x4750
movq %rax, %rbp
leaq 0xccbfe(%rip), %rsi     # 0x1558ef
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movl 0x7c(%rbx), %esi
movq %rbp, %rdi
callq 0x4750
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
leaq 0xccbd4(%rip), %rsi     # 0x1558ef
callq 0x44e0
movl 0x80(%rbx), %esi
movq %rbp, %rdi
callq 0x4750
movq %rax, %rbp
leaq 0xd4b28(%rip), %rsi     # 0x15d860
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movl 0x84(%rbx), %esi
movq %rbp, %rdi
callq 0x4750
leaq 0xccb99(%rip), %rsi     # 0x1558f3
movl $0x9, %edx
movq %rax, %rdi
callq 0x44e0
movl 0x78(%rbx), %esi
movl 0x7c(%rbx), %edx
movl 0x80(%rbx), %ecx
movq %rbx, %rdi
callq 0x88ea2
leaq 0x18(%rsp), %rbp
pxor %xmm0, %xmm0
pxor %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %rbp, %rdi
callq 0x84364
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)
xorps %xmm1, %xmm1
cvtsi2sdl 0x78(%rbx), %xmm1
addsd 0xc8579(%rip), %xmm1    # 0x151360
movsd 0xc4269(%rip), %xmm0    # 0x14d058
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x84416
movq 0x10(%r13), %rax
movq %rax, 0x10(%r12)
movups (%r13), %xmm0
movups %xmm0, (%r12)
xorps %xmm1, %xmm1
cvtsi2sdl 0x7c(%rbx), %xmm1
addsd 0xc853a(%rip), %xmm1    # 0x151360
movsd 0xc422a(%rip), %xmm0    # 0x14d058
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x84416
movq 0x10(%r12), %rax
movq %rax, 0x10(%r15)
movups (%r12), %xmm0
movups %xmm0, (%r15)
xorps %xmm1, %xmm1
cvtsi2sdl 0x80(%rbx), %xmm1
addsd 0xc84f9(%rip), %xmm1    # 0x151360
movsd 0xc41e9(%rip), %xmm0    # 0x14d058
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x84416
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