// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/network.cc
// Function: NEWcalculateFreeSphereParameters(MATERIAL*)
void NEWcalculateFreeSphereParameters(MATERIAL *Mat){

  if(Mat->doneFlatVoroFlag == false)
    {
    Mat->runVoroFlat();
    };

  vector<double> freeRadResults;
  vector<double> incRadResults;
  vector<bool> NtoN;

  DELTA_POS directions [3] = {DELTA_POS(1,0,0), DELTA_POS(0,1,0), DELTA_POS(0,0,1)};
  for(unsigned int i = 0; i < 3; i++){
    VORONOI_NETWORK newNet;
    set<int> sourceNodes;
    map<int,int> idAliases;
    extendVorNet(&(Mat->vornet), &newNet, directions[i], &idAliases, &sourceNodes);
   
    DIJKSTRA_NETWORK dnet;
    DIJKSTRA_NETWORK::buildDijkstraNetwork(&newNet,&dnet);

    TRAVERSAL_NETWORK analyzeNet = TRAVERSAL_NETWORK(directions[i].x,directions[i].y,directions[i].z, &dnet);    
    pair<bool,PATH> results = analyzeNet.findMaxFreeSphere(&idAliases, &sourceNodes);
    
    freeRadResults.push_back(2*results.second.max_radius);
    incRadResults.push_back(2*results.second.max_inc_radius);
    NtoN.push_back(results.first);
  }

  double maxd=0.0; int maxdir=0;
  for(unsigned int i = 0; i < freeRadResults.size(); i++)
     {
     if(i==0) {maxd=freeRadResults[i]; maxdir=i;}
       else
       {
       if(maxd<freeRadResults[i])
         {
         maxd=freeRadResults[i]; 
         maxdir=i;
         }
       else if(maxd==freeRadResults[i])
         {
         if(incRadResults[maxdir]<incRadResults[i]) maxdir=i;
         };
       };
     };

 Mat->directionDf = freeRadResults; Mat->directionDif = incRadResults;
 Mat->Di = 2 * findMaxIncludedSphere(&(Mat->vornet));
 Mat->Df = freeRadResults[maxdir];
 Mat->Dif = incRadResults[maxdir];

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x338, %rsp            # imm = 0x338
movq %rdi, 0x8(%rsp)
cmpb $0x0, 0xc20(%rdi)
jne 0x6861
movq 0x8(%rsp), %rdi
callq 0xc2eec
andq $0x0, 0x30(%rsp)
andq $0x0, 0x50(%rsp)
andq $0x0, 0xc0(%rsp)
andl $0x0, 0xc8(%rsp)
xorpd %xmm0, %xmm0
andq $0x0, 0xd0(%rsp)
movapd %xmm0, 0x20(%rsp)
andl $0x0, 0xd8(%rsp)
movapd %xmm0, 0x40(%rsp)
andq $0x0, 0xe0(%rsp)
leaq 0x60(%rsp), %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3d328
leaq 0x6c(%rsp), %rdi
pushq $0x1
popq %rdx
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x3d328
leaq 0x78(%rsp), %rdi
pushq $0x1
popq %rcx
xorl %esi, %esi
xorl %edx, %edx
callq 0x3d328
movq 0x8(%rsp), %rax
addq $0x8c0, %rax            # imm = 0x8C0
movq %rax, 0x10(%rsp)
pushq $0x8
popq %r14
leaq 0x2c0(%rsp), %r12
leaq 0xe8(%rsp), %r13
leaq 0x1e8(%rsp), %rbx
leaq 0x248(%rsp), %r15
cmpq $0x2c, %r14
je 0x6a92
movq %r12, %rdi
callq 0x4090e
andl $0x0, 0x98(%rsp)
andq $0x0, 0xa0(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
andq $0x0, 0xb8(%rsp)
andl $0x0, 0xf0(%rsp)
andq $0x0, 0xf8(%rsp)
leaq 0xf0(%rsp), %rax
movq %rax, 0x100(%rsp)
movq %rax, 0x108(%rsp)
andq $0x0, 0x110(%rsp)
movq 0x58(%rsp,%r14), %rdx
movl 0x60(%rsp,%r14), %ecx
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r13, %r8
leaq 0x90(%rsp), %r9
callq 0x5db0
movq %rbx, %rdi
callq 0x3d70e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3d7e6
movl 0x58(%rsp,%r14), %esi
movl 0x5c(%rsp,%r14), %edx
movl 0x60(%rsp,%r14), %ecx
movq %r15, %rdi
movq %rbx, %r8
callq 0x26030
leaq 0x118(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rbp
movq %r13, %rdx
leaq 0x90(%rsp), %rcx
callq 0x268be
movsd 0x180(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %r13
movq %r13, %rsi
callq 0xf9fe
movsd 0x188(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0xf9fe
movzbl 0x118(%rsp), %esi
leaq 0xc0(%rsp), %rdi
callq 0xa8f6
movq %rbp, %r13
leaq 0x120(%rsp), %rdi
callq 0xadf4
movq %r15, %rdi
callq 0xa934
movq %rbx, %rdi
callq 0xae22
movq %rbp, %rdi
callq 0xaf66
leaq 0x90(%rsp), %rdi
callq 0xafbe
movq %r12, %rdi
callq 0xa95c
addq $0xc, %r14
jmp 0x690f
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
xorl %edi, %edi
xorpd %xmm0, %xmm0
movq 0x40(%rsp), %rdx
xorl %esi, %esi
movl %esi, %r8d
movslq %edi, %r15
cmpq %r8, %rcx
jbe 0x6af9
movsd (%rax,%r8,8), %xmm1
testl %esi, %esi
je 0x6ae9
ucomisd %xmm0, %xmm1
ja 0x6ae5
ucomisd %xmm1, %xmm0
jne 0x6aed
jp 0x6aed
movsd (%rdx,%r8,8), %xmm1
ucomisd (%rdx,%r15,8), %xmm1
jbe 0x6aed
movapd %xmm0, %xmm1
movl %esi, %edi
jmp 0x6af1
xorl %edi, %edi
jmp 0x6af1
movapd %xmm0, %xmm1
incl %esi
movapd %xmm1, %xmm0
jmp 0x6ab0
movq 0x8(%rsp), %rax
leaq 0xc40(%rax), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa986
movq 0x8(%rsp), %rax
leaq 0xc58(%rax), %rdi
leaq 0x40(%rsp), %rsi
callq 0xa986
movq 0x10(%rsp), %rdi
callq 0x278fe
addsd %xmm0, %xmm0
movq 0x8(%rsp), %rcx
movsd %xmm0, 0xc28(%rcx)
leaq 0x20(%rsp), %rbx
movq (%rbx), %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0xc30(%rcx)
leaq 0x40(%rsp), %r14
movq (%r14), %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0xc38(%rcx)
leaq 0xc0(%rsp), %rdi
callq 0xa976
movq %r14, %rdi
callq 0xb25c
movq %rbx, %rdi
callq 0xb25c
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6bc7
jmp 0x6bc7
movq %rax, %rbx
jmp 0x6bb8
jmp 0x6ba8
jmp 0x6ba8
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0xadf4
leaq 0x248(%rsp), %rdi
callq 0xa934
jmp 0x6bd8
movq %rax, %rbx
jmp 0x6c0c
jmp 0x6bce
movq %rax, %rbx
jmp 0x6be5
jmp 0x6bd5
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0xae22
leaq 0xe8(%rsp), %rdi
callq 0xaf66
leaq 0x90(%rsp), %rdi
callq 0xafbe
leaq 0x2c0(%rsp), %rdi
callq 0xa95c
leaq 0xc0(%rsp), %rdi
callq 0xa976
leaq 0x40(%rsp), %rdi
callq 0xb25c
leaq 0x20(%rsp), %rdi
callq 0xb25c
movq %rbx, %rdi
callq 0x4780