// File: /workspace/github_cpp_makefile_star2_O1/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, 0x6c(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdi, 0x70(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movq %rax, 0x10(%rsp)
movapd %xmm0, (%rsp)
movq %rax, 0x40(%rsp)
movl %eax, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movl %eax, 0x58(%rsp)
movq %rax, 0x60(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
leaq 0x8c(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x509d8
leaq 0x98(%rsp), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x509d8
movl $0x8, %r12d
leaq 0xa8(%rsp), %rbp
leaq 0xd8(%rsp), %rbx
leaq 0x408(%rsp), %r15
leaq 0x180(%rsp), %r13
movq %r13, %rdi
callq 0x555c0
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 0x70(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %r8
movq %rbx, %r9
callq 0x8057
movq %r15, %rdi
callq 0x50e9e
leaq 0x180(%rsp), %rdi
movq %r15, %rsi
callq 0x50fc8
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 0x31a1a
leaq 0x1f8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x326f8
movsd 0x260(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x88bd
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x88cc
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x139c2
movsd 0x268(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x88fa
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x8907
movq %rsp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x139c2
movzbl 0x1f8(%rsp), %esi
leaq 0x40(%rsp), %rdi
callq 0xe9e6
leaq 0x298(%rsp), %rdi
callq 0xf168
movq 0x280(%rsp), %rdi
testq %rdi, %rdi
je 0x8943
movq 0x290(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x238(%rsp), %rdi
testq %rdi, %rdi
je 0x8960
movq 0x248(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x200(%rsp), %rdi
callq 0xf07c
leaq 0x150(%rsp), %rdi
callq 0xf0ca
leaq 0x138(%rsp), %rdi
callq 0xf0ca
leaq 0x120(%rsp), %rdi
callq 0xf0ca
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x89b1
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %r15, %rdi
callq 0xf07c
movq %rbp, %rdi
callq 0xf118
movq %rbx, %rdi
callq 0xf168
movq 0x1e0(%rsp), %rdi
testq %rdi, %rdi
je 0x89e6
movq 0x1f0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x1c8(%rsp), %rdi
callq 0xf1b8
addq $0xc, %r12
cmpq $0x2c, %r12
jne 0x87ac
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 0x8a8a
movq %rbx, %rdi
callq 0x41e0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x8aa9
movq 0x208(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x228(%rsp,%rax), %esi
orl $0x1, %esi
callq 0x4710
leaq 0x1469dd(%rip), %rsi    # 0x14f48d
movl $0x4, %edx
movq %r12, %rdi
callq 0x44e0
movq 0x70(%rsp), %rdi
callq 0x3501d
addsd %xmm0, %xmm0
movq %r12, %rdi
callq 0x46b0
leaq 0x14e9ac(%rip), %rsi    # 0x157486
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
xorl %r14d, %r14d
subq %rax, %rcx
je 0x8b50
sarq $0x3, %rcx
xorpd %xmm0, %xmm0
movq (%rsp), %rdx
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm1
testl %esi, %esi
je 0x8b36
ucomisd %xmm0, %xmm1
ja 0x8b31
ucomisd %xmm1, %xmm0
jne 0x8b3b
jp 0x8b3b
movslq %r14d, %rdi
movsd (%rdx,%rsi,8), %xmm1
ucomisd (%rdx,%rdi,8), %xmm1
jbe 0x8b3b
movapd %xmm0, %xmm1
movl %esi, %r14d
jmp 0x8b3f
xorl %r14d, %r14d
jmp 0x8b3f
movapd %xmm0, %xmm1
incq %rsi
movl %esi, %edi
movapd %xmm1, %xmm0
cmpq %rdi, %rcx
ja 0x8b07
movslq %r14d, %r14
movsd (%rax,%r14,8), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %rbx
leaq 0x146927(%rip), %rsi    # 0x14f48f
movl $0x2, %edx
movq %rax, %rdi
callq 0x44e0
movq (%rsp), %rax
movsd (%rax,%r14,8), %xmm0
movq %rbx, %rdi
callq 0x46b0
cmpb $0x0, 0x6c(%rsp)
je 0x8c46
leaq 0x1468f6(%rip), %rsi    # 0x14f48f
movl $0x2, %edx
movq %r12, %rdi
callq 0x44e0
movq 0x20(%rsp), %rax
cmpq %rax, 0x28(%rsp)
je 0x8bf7
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x1468cf(%rip), %rbx    # 0x14f48f
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 0x8bc0
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x8c46
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x14687f(%rip), %rbx    # 0x14f48f
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 0x8c10
leaq 0x14c8e1(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %r12, %rdi
callq 0x44e0
leaq 0x1f8(%rsp), %rdi
callq 0x4110
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x8c97
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movl %eax, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movl %eax, 0x58(%rsp)
movq %rax, 0x60(%rsp)
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x8cad
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x8cc4
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 0x8d08
jmp 0x8d08
jmp 0x8ce4
jmp 0x8ce4
jmp 0x8cf6
jmp 0x8cf6
jmp 0x8ce4
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0x4110
jmp 0x8d5f
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0xea34
jmp 0x8d1e
movq %rax, %rbx
jmp 0x8d5f
jmp 0x8d0f
movq %rax, %rbx
jmp 0x8d38
jmp 0x8d16
movq %rax, %rbx
jmp 0x8d2b
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0xea82
leaq 0x408(%rsp), %rdi
callq 0xf07c
leaq 0xa8(%rsp), %rdi
callq 0xf118
leaq 0xd8(%rsp), %rdi
callq 0xf168
leaq 0x180(%rsp), %rdi
callq 0xeab8
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x8d8f
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movl %eax, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movl %eax, 0x58(%rsp)
movq %rax, 0x60(%rsp)
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x8da5
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x8dbc
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780