// File: 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
movq %rsp, %rbp
subq $0x620, %rsp            # imm = 0x620
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xf650
leaq -0x48(%rbp), %rdi
callq 0xf650
leaq -0x70(%rbp), %rdi
callq 0xf670
leaq -0xa0(%rbp), %rdi
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x94010
jmp 0x83cc
leaq -0x94(%rbp), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq 0x94010
jmp 0x83e3
leaq -0x88(%rbp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
movl %edx, %esi
callq 0x94010
jmp 0x83fa
movl $0x0, -0xb0(%rbp)
cmpl $0x3, -0xb0(%rbp)
jae 0x869b
leaq -0x128(%rbp), %rdi
callq 0x99ba0
jmp 0x841f
leaq -0x158(%rbp), %rdi
movq %rdi, -0x590(%rbp)
callq 0xf690
leaq -0x188(%rbp), %rdi
movq %rdi, -0x598(%rbp)
callq 0xf6b0
movq -0x598(%rbp), %r8
movq -0x590(%rbp), %r9
movq -0x8(%rbp), %rdi
movl -0xb0(%rbp), %eax
leaq (%rax,%rax,2), %rax
movl -0x98(%rbp,%rax,4), %ecx
movl %ecx, -0x190(%rbp)
movq -0xa0(%rbp,%rax,4), %rax
movq %rax, -0x198(%rbp)
movl -0x190(%rbp), %eax
movl %eax, -0x1a0(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rdx
movl -0x1a0(%rbp), %ecx
leaq -0x128(%rbp), %rsi
callq 0x7a80
jmp 0x84b2
leaq -0x208(%rbp), %rdi
callq 0x94790
jmp 0x84c0
leaq -0x128(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0x948c0
jmp 0x84d5
movl -0xb0(%rbp), %eax
leaq (%rax,%rax,2), %rax
movl -0xa0(%rbp,%rax,4), %esi
movl -0x9c(%rbp,%rax,4), %edx
movl -0x98(%rbp,%rax,4), %ecx
leaq -0x280(%rbp), %rdi
leaq -0x208(%rbp), %r8
callq 0x5d5d0
jmp 0x8509
leaq -0x350(%rbp), %rdi
leaq -0x280(%rbp), %rsi
leaq -0x188(%rbp), %rdx
leaq -0x158(%rbp), %rcx
callq 0x5e3a0
jmp 0x852c
movsd -0x2e8(%rbp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, -0x358(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0xf6d0
jmp 0x8552
movsd -0x2e0(%rbp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, -0x360(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0xf6d0
jmp 0x8578
movzbl -0x350(%rbp), %esi
andl $0x1, %esi
leaq -0x70(%rbp), %rdi
callq 0xf700
jmp 0x858d
leaq -0x350(%rbp), %rdi
callq 0xf7d0
leaq -0x280(%rbp), %rdi
callq 0xf7f0
leaq -0x208(%rbp), %rdi
callq 0xf840
leaq -0x188(%rbp), %rdi
callq 0xf860
leaq -0x158(%rbp), %rdi
callq 0xf880
leaq -0x128(%rbp), %rdi
callq 0xf8a0
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x8404
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x8b41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x8672
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x8666
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x865a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x350(%rbp), %rdi
callq 0xf7d0
leaq -0x280(%rbp), %rdi
callq 0xf7f0
leaq -0x208(%rbp), %rdi
callq 0xf840
leaq -0x188(%rbp), %rdi
callq 0xf860
leaq -0x158(%rbp), %rdi
callq 0xf880
leaq -0x128(%rbp), %rdi
callq 0xf8a0
jmp 0x8b41
leaq -0x570(%rbp), %rdi
callq 0x5660
jmp 0x86a9
movq -0x570(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x570(%rbp,%rax), %rdi
movl $0x4, %esi
movl $0x104, %edx            # imm = 0x104
callq 0xf8d0
jmp 0x86cd
movq -0x570(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x570(%rbp,%rax), %rdi
movl $0x5, %esi
callq 0xf930
jmp 0x86ec
movq -0x570(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x570(%rbp,%rax), %rdi
movl $0xc, %esi
callq 0xf960
jmp 0x870b
movq -0x10(%rbp), %rsi
leaq -0x570(%rbp), %rdi
movl $0x10, %edx
callq 0x54b0
jmp 0x8722
leaq -0x560(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5540
movq %rax, -0x5a0(%rbp)
jmp 0x873b
movq -0x5a0(%rbp), %rdi
leaq 0x1e9d3d(%rip), %rsi    # 0x1f2486
callq 0x5540
movq %rax, -0x5a8(%rbp)
jmp 0x8757
movq -0x8(%rbp), %rdi
callq 0x5fdc0
movsd %xmm0, -0x5b0(%rbp)
jmp 0x876a
movq -0x5a8(%rbp), %rdi
movsd -0x5b0(%rbp), %xmm0
addsd %xmm0, %xmm0
callq 0x5980
movq %rax, -0x5b8(%rbp)
jmp 0x878b
movq -0x5b8(%rbp), %rdi
leaq 0x1f3b15(%rip), %rsi    # 0x1fc2ae
callq 0x5540
jmp 0x87a0
xorps %xmm0, %xmm0
movsd %xmm0, -0x578(%rbp)
movl $0x0, -0x57c(%rbp)
movl $0x0, -0x580(%rbp)
movl -0x580(%rbp), %eax
movq %rax, -0x5c0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xf990
movq %rax, %rcx
movq -0x5c0(%rbp), %rax
cmpq %rcx, %rax
jae 0x893b
cmpl $0x0, -0x580(%rbp)
jne 0x8842
movl -0x580(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xedb0
movsd (%rax), %xmm0
movsd %xmm0, -0x578(%rbp)
movl -0x580(%rbp), %eax
movl %eax, -0x57c(%rbp)
jmp 0x8925
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x570(%rbp), %rdi
callq 0x5150
jmp 0x8b41
movsd -0x578(%rbp), %xmm0
movsd %xmm0, -0x5c8(%rbp)
movl -0x580(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xedb0
movsd -0x5c8(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x88a3
movl -0x580(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xedb0
movsd (%rax), %xmm0
movsd %xmm0, -0x578(%rbp)
movl -0x580(%rbp), %eax
movl %eax, -0x57c(%rbp)
jmp 0x8923
movsd -0x578(%rbp), %xmm0
movsd %xmm0, -0x5d0(%rbp)
movl -0x580(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xedb0
movsd -0x5d0(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x8921
jp 0x8921
movslq -0x57c(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xedb0
movsd (%rax), %xmm0
movsd %xmm0, -0x5d8(%rbp)
movl -0x580(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0xedb0
movsd -0x5d8(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x891f
movl -0x580(%rbp), %eax
movl %eax, -0x57c(%rbp)
jmp 0x8921
jmp 0x8923
jmp 0x8925
jmp 0x8927
movl -0x580(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x580(%rbp)
jmp 0x87bf
leaq -0x560(%rbp), %rax
movq %rax, -0x5e8(%rbp)
movslq -0x57c(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xedb0
movq -0x5e8(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x5980
movq %rax, -0x5e0(%rbp)
jmp 0x8972
movq -0x5e0(%rbp), %rdi
leaq 0x1e9b08(%rip), %rsi    # 0x1f2488
callq 0x5540
movq %rax, -0x5f0(%rbp)
jmp 0x898e
movslq -0x57c(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xedb0
movq -0x5f0(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x5980
jmp 0x89b0
movb -0x11(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x8afc
leaq -0x560(%rbp), %rdi
leaq 0x1e9ab9(%rip), %rsi    # 0x1f2488
callq 0x5540
jmp 0x89d6
movl $0x0, -0x584(%rbp)
movl -0x584(%rbp), %eax
movq %rax, -0x5f8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xf990
movq %rax, %rcx
movq -0x5f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x8a68
leaq -0x560(%rbp), %rax
movq %rax, -0x608(%rbp)
movl -0x584(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xedb0
movq -0x608(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x5980
movq %rax, -0x600(%rbp)
jmp 0x8a3d
movq -0x600(%rbp), %rdi
leaq 0x1e9a3d(%rip), %rsi    # 0x1f2488
callq 0x5540
jmp 0x8a52
jmp 0x8a54
movl -0x584(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x584(%rbp)
jmp 0x89e0
movl $0x0, -0x588(%rbp)
movl -0x588(%rbp), %eax
movq %rax, -0x610(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xf990
movq %rax, %rcx
movq -0x610(%rbp), %rax
cmpq %rcx, %rax
jae 0x8afa
leaq -0x560(%rbp), %rax
movq %rax, -0x620(%rbp)
movl -0x588(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0xedb0
movq -0x620(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x5980
movq %rax, -0x618(%rbp)
jmp 0x8acf
movq -0x618(%rbp), %rdi
leaq 0x1e99ab(%rip), %rsi    # 0x1f2488
callq 0x5540
jmp 0x8ae4
jmp 0x8ae6
movl -0x588(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x588(%rbp)
jmp 0x8a72
jmp 0x8afc
leaq -0x560(%rbp), %rdi
leaq 0x1f0b1b(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x8b11
leaq -0x570(%rbp), %rdi
callq 0x5150
leaq -0x70(%rbp), %rdi
callq 0xf9b0
leaq -0x48(%rbp), %rdi
callq 0xf9d0
leaq -0x30(%rbp), %rdi
callq 0xf9d0
addq $0x620, %rsp            # imm = 0x620
popq %rbp
retq
leaq -0x70(%rbp), %rdi
callq 0xf9b0
leaq -0x48(%rbp), %rdi
callq 0xf9d0
leaq -0x30(%rbp), %rdi
callq 0xf9d0
movq -0xa8(%rbp), %rdi
callq 0x58f0
nopl (%rax,%rax)