// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %r15
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x4520
movq %rbx, %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x43d0
leaq 0x98(%rsp), %rdi
callq 0x4120
movl %eax, %ebp
testb %al, %al
je 0x2c774
movq 0x168881(%rip), %rbx    # 0x194fc0
leaq 0x121f5c(%rip), %rsi    # 0x14e6a2
movl $0x27, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2c7b7
movq %r15, %rdi
callq 0x41e0
movq 0x168859(%rip), %rdi    # 0x194fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2c7ce
movq 0x168875(%rip), %rbx    # 0x194ff0
leaq 0x121ef7(%rip), %rsi    # 0x14e679
movl $0x28, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2cae4
movq %r15, %rdi
callq 0x41e0
movq 0x168849(%rip), %rdi    # 0x194ff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2cafb
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x1687eb(%rip), %rdi    # 0x194fc0
leaq 0x126e42(%rip), %rsi    # 0x15361e
movl $0x1, %edx
callq 0x44e0
leaq 0x28(%rsp), %r15
leaq 0x121ed8(%rip), %rsi    # 0x14e6ca
movl $0xd, %edx
movq %r15, %rdi
callq 0x44e0
leaq 0x126e18(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
movb %bpl, 0x7(%rsp)
movq 0x48(%r14), %rbp
movq 0x50(%r14), %rax
cmpq %rax, %rbp
je 0x2c970
xorl %r12d, %r12d
leaq 0x128da3(%rip), %r13    # 0x1555d6
movq %r14, 0x10(%rsp)
movsd 0x18(%rbp), %xmm0
ucomisd 0x8(%rsp), %xmm0
jbe 0x2c960
movq %r15, %rdi
movl %r12d, %esi
callq 0x4750
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd (%rbp), %xmm0
movq %rbx, %rdi
callq 0x46b0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0x8(%rbp), %xmm0
movq %rbx, %rdi
callq 0x46b0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0x10(%rbp), %xmm0
movq %rbx, %rdi
callq 0x46b0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0x18(%rbp), %xmm0
movq %rbx, %rdi
callq 0x46b0
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x44e0
movq 0x20(%rbp), %rax
cmpq %rax, 0x28(%rbp)
je 0x2c943
movl $0x1, %ebx
xorl %r14d, %r14d
movl (%rax,%r14,4), %esi
movq %r15, %rdi
callq 0x4750
movq 0x20(%rbp), %rax
movq 0x28(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
leaq -0x1(%rcx), %rdx
cmpq %r14, %rdx
jbe 0x2c939
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x44e0
movq 0x20(%rbp), %rax
movq 0x28(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movl %ebx, %r14d
incl %ebx
cmpq %r14, %rcx
ja 0x2c8f6
movl $0x1, %edx
movq %r15, %rdi
leaq 0x126ccc(%rip), %rsi    # 0x15361e
callq 0x44e0
movq 0x10(%rsp), %r14
movq 0x50(%r14), %rax
incl %r12d
addq $0x40, %rbp
cmpq %rax, %rbp
jne 0x2c838
leaq 0x126ca7(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
leaq 0x121d4d(%rip), %rsi    # 0x14e6d8
movl $0xb, %edx
movq %r15, %rdi
callq 0x44e0
leaq 0x126c7f(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
movq 0x60(%r14), %r12
movq 0x68(%r14), %rax
cmpq %rax, %r12
je 0x2cad3
leaq 0x128c12(%rip), %r13    # 0x1555d6
leaq 0x126c53(%rip), %rbp    # 0x15361e
movsd 0x8(%r12), %xmm0
ucomisd 0x8(%rsp), %xmm0
jbe 0x2cac6
movl (%r12), %esi
movq %r15, %rdi
callq 0x4750
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x121ce8(%rip), %rsi    # 0x14e6e4
callq 0x44e0
movl 0x4(%r12), %esi
movq %rbx, %rdi
callq 0x4750
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0x8(%r12), %xmm0
movq %rbx, %rdi
callq 0x46b0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movl 0x10(%r12), %esi
movq %rbx, %rdi
callq 0x4750
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movl 0x14(%r12), %esi
movq %rbx, %rdi
callq 0x4750
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movl 0x18(%r12), %esi
movq %rbx, %rdi
callq 0x4750
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0x20(%r12), %xmm0
movq %rbx, %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x44e0
movq 0x68(%r14), %rax
addq $0x28, %r12
cmpq %rax, %r12
jne 0x2c9cb
leaq 0x18(%rsp), %rdi
callq 0x4090
movb 0x7(%rsp), %bpl
jmp 0x2cb13
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x1684ee(%rip), %rdi    # 0x194ff0
leaq 0x126b15(%rip), %rsi    # 0x15361e
movl $0x1, %edx
callq 0x44e0
leaq 0x18(%rsp), %rdi
callq 0x4110
movl %ebp, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2cb39
jmp 0x2cb39
jmp 0x2cb39
jmp 0x2cb39
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780