// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/networkio.cc
// Function: writeToNt2(char*, VORONOI_NETWORK*, double)
bool writeToNt2(char *filename, VORONOI_NETWORK *vornet, double minRad){
  fstream output;
  output.open(filename, fstream::out);
  if(!output.is_open()){
    cerr << "Error: Failed to open .net2 output file " << filename << "\n";
    //cerr << "Exiting ..." << "\n";
    //exit(1);
    return false;
  }
  else{
    cout << "Writing Voronoi network information to " << filename << "\n";

    // Write Voronoi node information
    output << "Vertex table:" << "\n";
    vector<VOR_NODE> ::iterator niter = vornet->nodes.begin();
    int i = 0;
    while(niter != vornet->nodes.end()){
      if(niter->rad_stat_sphere > minRad){
	output << i << " " << niter-> x << " " << niter-> y << " "
	       << niter-> z << " " << niter->rad_stat_sphere;

	//Write Voronoi node/atom pairing information in i j k....z format
	output << " ";
	for(unsigned int j = 0; j < niter->atomIDs.size(); j++){
	  output << niter->atomIDs.at(j);
	  if(j < niter->atomIDs.size()-1)
	    output << " ";
	}
	output <<  "\n";
      }
      i++;
      niter++;
    }

    // Write Voronoi edge information
    output << "\n" << "Edge table:" << "\n";
    vector<VOR_EDGE> ::iterator eiter = vornet->edges.begin();
    while(eiter != vornet->edges.end()){
      if(eiter->rad_moving_sphere > minRad){
	output << eiter->from << " -> " << eiter->to << " " << eiter->rad_moving_sphere
	       << " " << eiter->delta_uc_x << " " << eiter->delta_uc_y << " "
	       << eiter->delta_uc_z << " " << eiter->length << "\n";
      }
      eiter++;
    }
  }
  output.close();
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movsd %xmm0, 0x10(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x4540
pushq $0x10
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4410
leaq 0x98(%rsp), %rdi
callq 0x4130
movl %eax, %ebp
testb %al, %al
je 0x22def
movq 0x12d338(%rip), %rdi    # 0x14ffc0
leaq 0xdaa13(%rip), %rsi     # 0xfd6a2
callq 0x4480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4480
leaq 0xdf8d8(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0x28(%rsp), %r15
leaq 0xdaa10(%rip), %rsi     # 0xfd6ca
movq %r15, %rdi
callq 0x4480
leaq 0xdf8b5(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
movb %bpl, 0x7(%rsp)
movq %r14, 0x8(%rsp)
movq 0x48(%r14), %r14
xorl %ebp, %ebp
leaq 0xe182a(%rip), %r12     # 0x104512
movq 0x8(%rsp), %rax
cmpq 0x50(%rax), %r14
je 0x22e21
movsd 0x18(%r14), %xmm0
ucomisd 0x10(%rsp), %xmm0
jbe 0x22de4
movq %r15, %rdi
movl %ebp, %esi
callq 0x4760
movq %rax, %rdi
movq %r12, %rsi
callq 0x4480
movsd (%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r12, %rsi
callq 0x4480
movsd 0x8(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r12, %rsi
callq 0x4480
movsd 0x10(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r12, %rsi
callq 0x4480
movsd 0x18(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %r15, %rdi
movq %r12, %rsi
callq 0x4480
leaq 0x20(%r14), %rbx
xorl %r13d, %r13d
movl %r13d, %r13d
movq 0x28(%r14), %rax
subq 0x20(%r14), %rax
sarq $0x2, %rax
cmpq %r13, %rax
jbe 0x22dd5
movq %rbx, %rdi
movq %r13, %rsi
callq 0xac00
movl (%rax), %esi
movq %r15, %rdi
callq 0x4760
movq 0x28(%r14), %rax
subq 0x20(%r14), %rax
sarq $0x2, %rax
decq %rax
cmpq %r13, %rax
jbe 0x22dd0
movq %r15, %rdi
movq %r12, %rsi
callq 0x4480
incl %r13d
jmp 0x22d88
movq %r15, %rdi
leaq 0xdf79f(%rip), %rsi     # 0x10257e
callq 0x4480
incl %ebp
addq $0x40, %r14
jmp 0x22ce8
movq 0x12d1fa(%rip), %rdi    # 0x14fff0
leaq 0xda87c(%rip), %rsi     # 0xfd679
callq 0x4480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4480
leaq 0xdf76a(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
jmp 0x22f3c
leaq 0xdf756(%rip), %rsi     # 0x10257e
movq %r15, %rdi
callq 0x4480
leaq 0xda8a1(%rip), %rsi     # 0xfd6d8
movq %rax, %rdi
callq 0x4480
leaq 0xdf738(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
movq 0x8(%rsp), %r14
movq 0x60(%r14), %rbx
leaq 0xda886(%rip), %r12     # 0xfd6e4
leaq 0xe16ad(%rip), %r13     # 0x104512
leaq 0xdf712(%rip), %rbp     # 0x10257e
cmpq 0x68(%r14), %rbx
je 0x22f2d
movsd 0x8(%rbx), %xmm0
ucomisd 0x10(%rsp), %xmm0
jbe 0x22f24
movl (%rbx), %esi
movq %r15, %rdi
callq 0x4760
movq %rax, %rdi
movq %r12, %rsi
callq 0x4480
movl 0x4(%rbx), %esi
movq %rax, %rdi
callq 0x4760
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd 0x8(%rbx), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movl 0x10(%rbx), %esi
movq %rax, %rdi
callq 0x4760
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movl 0x14(%rbx), %esi
movq %rax, %rdi
callq 0x4760
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movl 0x18(%rbx), %esi
movq %rax, %rdi
callq 0x4760
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd 0x20(%rbx), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4480
addq $0x28, %rbx
jmp 0x22e6c
leaq 0x18(%rsp), %rdi
callq 0x4080
movb 0x7(%rsp), %bpl
leaq 0x18(%rsp), %rdi
callq 0x4120
movl %ebp, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x22f62
jmp 0x22f62
jmp 0x22f62
jmp 0x22f62
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4780