// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/network.cc
// Function: calculateFreeSphereParameters(VORONOI_NETWORK*, char*, bool)
void calculateFreeSphereParameters(VORONOI_NETWORK *vornet, char *filename, bool extendedPrintout){
  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(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);
  }

  fstream output;
  output.setf(ios::fixed,ios::floatfield);  
  output.precision(5);
  output.width(12);
  output.open(filename, fstream::out);
  output << filename << "    " << 2 * findMaxIncludedSphere(vornet) << " ";

  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;
         };
       };
     };

  output << freeRadResults[maxdir] << "  " << incRadResults[maxdir];

  if(extendedPrintout==true){
    output << "  ";
    for(unsigned int i = 0; i < freeRadResults.size(); i++)
       output << freeRadResults[i] << "  ";

    for(unsigned int i = 0; i < incRadResults.size(); i++)
       output << incRadResults[i] << "  ";
    };

 /* 
  for(unsigned int i = 0; i < NtoN.size(); i++)
    output << (NtoN[i] ? "t" : "f") << "  ";
 */
  output << "\n";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movl %edx, 0x44(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdi, 0x48(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movq %rax, 0x10(%rsp)
movapd %xmm0, (%rsp)
movq %rax, 0x50(%rsp)
movl %eax, 0x58(%rsp)
movq %rax, 0x60(%rsp)
movl %eax, 0x68(%rsp)
movq %rax, 0x70(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x506b0
leaq 0x8c(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x506b0
leaq 0x98(%rsp), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x506b0
movl $0x8, %r12d
leaq 0xa8(%rsp), %rbp
leaq 0xd8(%rsp), %rbx
leaq 0x408(%rsp), %r15
leaq 0x180(%rsp), %r13
movq %r13, %rdi
callq 0x55288
movl %r14d, 0xe0(%rsp)
movq %r14, 0xe8(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq %rax, 0xf8(%rsp)
movq %r14, 0x100(%rsp)
movl %r14d, 0xb0(%rsp)
movq %r14, 0xb8(%rsp)
leaq 0xb0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
movq %r14, 0xd0(%rsp)
movq 0x78(%rsp,%r12), %rdx
movl 0x80(%rsp,%r12), %ecx
movq 0x48(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %r8
movq %rbx, %r9
callq 0x81d9
movq %r15, %rdi
callq 0x50b12
leaq 0x180(%rsp), %rdi
movq %r15, %rsi
callq 0x50c10
movl 0x78(%rsp,%r12), %esi
movl 0x7c(%rsp,%r12), %edx
movl 0x80(%rsp,%r12), %ecx
leaq 0x108(%rsp), %r13
movq %r13, %rdi
movq %r15, %r8
callq 0x3171e
leaq 0x1f8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x32330
movsd 0x260(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x8a06
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x8a15
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x1391c
movsd 0x268(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8a43
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x8a50
movq %rsp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x1391c
movzbl 0x1f8(%rsp), %esi
leaq 0x50(%rsp), %rdi
callq 0xea58
leaq 0x298(%rsp), %rdi
callq 0xf206
movq 0x280(%rsp), %rdi
testq %rdi, %rdi
je 0x8a8c
movq 0x290(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x238(%rsp), %rdi
testq %rdi, %rdi
je 0x8aa9
movq 0x248(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x200(%rsp), %rdi
callq 0xf10e
leaq 0x150(%rsp), %rdi
callq 0xf162
leaq 0x138(%rsp), %rdi
callq 0xf162
leaq 0x120(%rsp), %rdi
callq 0xf162
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x8afa
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %r15, %rdi
callq 0xf10e
movq %rbp, %rdi
callq 0xf1b6
movq %rbx, %rdi
callq 0xf206
movq 0x1e0(%rsp), %rdi
testq %rdi, %rdi
je 0x8b2f
movq 0x1f0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x1c8(%rsp), %rdi
callq 0xf256
addq $0xc, %r12
cmpq $0x2c, %r12
jne 0x88f5
leaq 0x1f8(%rsp), %rdi
callq 0x4520
leaq 0x1f8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rcx
movl $0xfffffefb, %edx       # imm = 0xFFFFFEFB
andl 0x210(%rsp,%rcx), %edx
orl $0x4, %edx
movl %edx, 0x210(%rsp,%rcx)
movq -0x18(%rax), %rcx
movq $0x5, 0x200(%rsp,%rcx)
movq -0x18(%rax), %rax
movq $0xc, 0x208(%rsp,%rax)
movq 0x78(%rsp), %rbx
movq %rbx, %rsi
movl $0x10, %edx
callq 0x43d0
leaq 0x208(%rsp), %r12
testq %rbx, %rbx
je 0x8bd3
movq %rbx, %rdi
callq 0x41e0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x8bf2
movq 0x208(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x228(%rsp,%rax), %esi
orl $0x1, %esi
callq 0x4710
leaq 0x1448e4(%rip), %rsi    # 0x14d4dd
movl $0x4, %edx
movq %r12, %rdi
callq 0x44e0
movq 0x48(%rsp), %rdi
callq 0x34bcb
addsd %xmm0, %xmm0
movq %r12, %rdi
callq 0x46b0
leaq 0x14c9b3(%rip), %rsi    # 0x1555d6
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
xorl %r14d, %r14d
subq %rax, %rcx
je 0x8c99
sarq $0x3, %rcx
xorpd %xmm0, %xmm0
movq (%rsp), %rdx
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm1
testl %esi, %esi
je 0x8c7f
ucomisd %xmm0, %xmm1
ja 0x8c7a
ucomisd %xmm1, %xmm0
jne 0x8c84
jp 0x8c84
movslq %r14d, %rdi
movsd (%rdx,%rsi,8), %xmm1
ucomisd (%rdx,%rdi,8), %xmm1
jbe 0x8c84
movapd %xmm0, %xmm1
movl %esi, %r14d
jmp 0x8c88
xorl %r14d, %r14d
jmp 0x8c88
movapd %xmm0, %xmm1
incq %rsi
movl %esi, %edi
movapd %xmm1, %xmm0
cmpq %rdi, %rcx
ja 0x8c50
movslq %r14d, %r14
movsd (%rax,%r14,8), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %rbx
leaq 0x14482e(%rip), %rsi    # 0x14d4df
movl $0x2, %edx
movq %rax, %rdi
callq 0x44e0
movq (%rsp), %rax
movsd (%rax,%r14,8), %xmm0
movq %rbx, %rdi
callq 0x46b0
cmpb $0x0, 0x44(%rsp)
je 0x8d8f
leaq 0x1447fd(%rip), %rsi    # 0x14d4df
movl $0x2, %edx
movq %r12, %rdi
callq 0x44e0
movq 0x20(%rsp), %rax
cmpq %rax, 0x28(%rsp)
je 0x8d40
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x1447d6(%rip), %rbx    # 0x14d4df
movsd (%rax,%rcx,8), %xmm0
movq %r12, %rdi
callq 0x46b0
movl $0x2, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x44e0
movl %ebp, %ecx
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x8d09
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x8d8f
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x144786(%rip), %rbx    # 0x14d4df
movsd (%rax,%rcx,8), %xmm0
movq %r12, %rdi
callq 0x46b0
movl $0x2, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x44e0
movl %ebp, %ecx
movq (%rsp), %rax
movq 0x8(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x8d59
leaq 0x14a888(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %r12, %rdi
callq 0x44e0
leaq 0x1f8(%rsp), %rdi
callq 0x4110
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x8dc7
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x8ddd
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x8df4
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8e38
jmp 0x8e38
jmp 0x8e14
jmp 0x8e14
jmp 0x8e26
jmp 0x8e26
jmp 0x8e14
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0x4110
jmp 0x8e8f
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0xeaa6
jmp 0x8e4e
movq %rax, %rbx
jmp 0x8e8f
jmp 0x8e3f
movq %rax, %rbx
jmp 0x8e68
jmp 0x8e46
movq %rax, %rbx
jmp 0x8e5b
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xeaf4
leaq 0x408(%rsp), %rdi
callq 0xf10e
leaq 0xa8(%rsp), %rdi
callq 0xf1b6
leaq 0xd8(%rsp), %rdi
callq 0xf206
leaq 0x180(%rsp), %rdi
callq 0xeb2a
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x8eba
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x50(%rsp)
movl $0x0, 0x58(%rsp)
movq %rax, 0x60(%rsp)
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x8ed0
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x8ee7
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780