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

 for(int x=0; x<na; x++)
   for(int y=0; y<nb; y++)
     for(int z=0; z<nc; z++)
       {
       XYZ point(o.x+x*va.x+y*vb.x+z*vc.x,
                 o.y+x*va.y+y*vb.y+z*vc.y,
                 o.z+x*va.z+y*vb.z+z*vc.z);
       double dist=10000;

       for(int i=0;i<atmnet->numAtoms; i++){
           double atmDist = atmnet->calcDistanceXYZ(point.x, point.y, point.z, atmnet->atoms[i].x, atmnet->atoms[i].y, atmnet->atoms[i].z);
           double radius = atmnet->atoms[i].radius;
           atmDist -= radius;
           if(atmDist<dist) dist=atmDist;
           };


       cube[x][y][z]=dist;
       };

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x60(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x78(%rcx), %eax
jge 0xf1126
movl $0x0, -0x18(%rbp)
movq -0x60(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x7c(%rcx), %eax
jge 0xf1116
movl $0x0, -0x1c(%rbp)
movq -0x60(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x80(%rcx), %eax
jge 0xf1106
movq -0x60(%rbp), %rax
movsd (%rax), %xmm1
cvtsi2sdl -0x14(%rbp), %xmm0
movsd 0x18(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
movsd 0x30(%rax), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvtsi2sdl -0x1c(%rbp), %xmm0
movsd 0x48(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x8(%rax), %xmm2
cvtsi2sdl -0x14(%rbp), %xmm1
movsd 0x20(%rax), %xmm3
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
cvtsi2sdl -0x18(%rbp), %xmm2
movsd 0x38(%rax), %xmm3
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
cvtsi2sdl -0x1c(%rbp), %xmm1
movsd 0x50(%rax), %xmm3
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd 0x10(%rax), %xmm3
cvtsi2sdl -0x14(%rbp), %xmm2
movsd 0x28(%rax), %xmm4
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
cvtsi2sdl -0x18(%rbp), %xmm3
movsd 0x40(%rax), %xmm4
mulsd %xmm4, %xmm3
addsd %xmm2, %xmm3
cvtsi2sdl -0x1c(%rbp), %xmm2
movsd 0x58(%rax), %xmm4
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
leaq -0x38(%rbp), %rdi
callq 0xea8e0
movsd 0x10b480(%rip), %xmm0   # 0x1fc428
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x110(%rcx), %eax
jge 0xf10cf
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x44(%rbp), %rsi
callq 0xfcc0
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x44(%rbp), %rsi
callq 0xfcc0
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x44(%rbp), %rsi
callq 0xfcc0
movq -0x90(%rbp), %rdi
movsd -0x88(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
movsd -0x78(%rbp), %xmm2
movsd -0x70(%rbp), %xmm3
movsd -0x68(%rbp), %xmm4
movsd 0x10(%rax), %xmm5
callq 0x97a10
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x44(%rbp), %rsi
callq 0xfcc0
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xf10bf
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0xf10c1
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xf0fb4
movq -0x60(%rbp), %rax
movsd -0x40(%rbp), %xmm0
movq 0x88(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xf0ed0
jmp 0xf1108
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xf0eb9
jmp 0xf1118
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xf0ea2
addq $0x90, %rsp
popq %rbp
retq
nop