// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/grid.cc
// Function: GaussianCube::calculateDistanceGridWithAccessibilityInfo(ATOM_NETWORK*, ATOM_NETWORK*, bool, double)
void GaussianCube::calculateDistanceGridWithAccessibilityInfo(ATOM_NETWORK *atmnet, ATOM_NETWORK *orgatmnet, bool highAccuracy, double probe_radius){

 AccessibilityClass accessAnalysis;
 if(highAccuracy) accessAnalysis.setupAndFindChannels(atmnet, orgatmnet, highAccuracy, probe_radius, probe_radius);
   else accessAnalysis.setupAndFindChannels(atmnet, atmnet, highAccuracy, probe_radius, probe_radius);

 for(int x=0; x<na; x++)
   for(int y=0; y<nb; y++)
     for(int z=0; z<nc; z++)
       {
       bool overlaps = false;
       bool inside = false;
       Point 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_var;
       pair<bool,bool> answer = (accessAnalysis.isVPointInsideAtomAndNotAccessible(point, dist_var));
       inside = answer.first; overlaps = answer.second;

       if(accessAnalysis.needToResample() == true)
          {
          cout << "Need to resample in grid calc. Abort." << "Contact the author" << endl;
          abort();
          };

       double dist;

//       dist = accessAnalysis.lastMinDist();
//       if(inside == false && overlaps == true) dist = dist * -1.0;
  
       if(inside == true)
         {
         dist = 0.0;
         } else
         {
         dist = accessAnalysis.lastMinDist()-probe_radius;
         if(overlaps == true) dist = dist * -1.0;
         };

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

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa98, %rsp            # imm = 0xA98
movsd %xmm0, 0x20(%rsp)
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x4866a
testl %ebp, %ebp
cmoveq %r15, %r14
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movsd 0x20(%rsp), %xmm0
movapd %xmm0, %xmm1
callq 0x93b2c
movl 0x78(%rbx), %ecx
testl %ecx, %ecx
jle 0x880b7
movl 0x7c(%rbx), %eax
xorl %r13d, %r13d
leaq 0x58(%rsp), %r15
testl %eax, %eax
jle 0x880a8
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x80(%rbx), %ecx
xorl %r14d, %r14d
testl %ecx, %ecx
jle 0x88096
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r12d, %r12d
movsd 0x18(%rbx), %xmm0
movsd 0x28(%rsp), %xmm4
mulsd %xmm4, %xmm0
addsd (%rbx), %xmm0
movsd 0x30(%rbx), %xmm1
movsd 0x30(%rsp), %xmm5
mulsd %xmm5, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %r12d, %xmm2
addsd %xmm0, %xmm1
movsd 0x48(%rbx), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x20(%rbx), %xmm1
mulsd %xmm4, %xmm1
addsd 0x8(%rbx), %xmm1
movsd 0x38(%rbx), %xmm3
mulsd %xmm5, %xmm3
addsd %xmm1, %xmm3
movsd 0x50(%rbx), %xmm1
mulsd %xmm2, %xmm1
addsd %xmm3, %xmm1
movsd 0x28(%rbx), %xmm3
mulsd %xmm4, %xmm3
addsd 0x10(%rbx), %xmm3
movsd 0x40(%rbx), %xmm4
mulsd %xmm5, %xmm4
addsd %xmm3, %xmm4
mulsd 0x58(%rbx), %xmm2
addsd %xmm4, %xmm2
leaq 0x40(%rsp), %rdi
callq 0x83f68
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x40(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x93f76
movl %eax, %ebp
movq %r15, %rdi
callq 0x487fa
testb %al, %al
jne 0x880d3
xorpd %xmm0, %xmm0
testb $0x1, %bpl
jne 0x8806b
btl $0x8, %ebp
movsd 0xa50(%rsp), %xmm0
subsd 0x20(%rsp), %xmm0
jae 0x8806b
xorpd 0xc95d5(%rip), %xmm0    # 0x151640
movq 0x88(%rbx), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
movslq 0x80(%rbx), %rcx
cmpq %rcx, %r12
jl 0x87f7f
movl 0x7c(%rbx), %eax
incq %r14
movslq %eax, %rdx
cmpq %rdx, %r14
jl 0x87f66
movl 0x78(%rbx), %ecx
incq %r13
movslq %ecx, %rdx
cmpq %rdx, %r13
jl 0x87f47
leaq 0x58(%rsp), %rdi
callq 0x48974
addq $0xa98, %rsp            # imm = 0xA98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10cee6(%rip), %rdi    # 0x194fc0
leaq 0xcd8fa(%rip), %rsi     # 0x1559db
movl $0x25, %edx
callq 0x44e0
movq 0x10cece(%rip), %rdi    # 0x194fc0
leaq 0xcd908(%rip), %rsi     # 0x155a01
movl $0x12, %edx
callq 0x44e0
movq 0x10ceb6(%rip), %rdi    # 0x194fc0
callq 0x41f0
callq 0x4260
jmp 0x8811a
jmp 0x8811a
jmp 0x8811a
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x48974
movq %rbx, %rdi
callq 0x4780