// File: /workspace/github_cpp_makefile_star2_O1/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 0x2c975
movq 0x16a680(%rip), %rbx    # 0x196fc0
leaq 0x123ceb(%rip), %rsi    # 0x150632
movl $0x27, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2c9b8
movq %r15, %rdi
callq 0x41e0
movq 0x16a658(%rip), %rdi    # 0x196fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2c9cf
movq 0x16a674(%rip), %rbx    # 0x196ff0
leaq 0x123c86(%rip), %rsi    # 0x150609
movl $0x28, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2ccd5
movq %r15, %rdi
callq 0x41e0
movq 0x16a648(%rip), %rdi    # 0x196ff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2ccec
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16a5ea(%rip), %rdi    # 0x196fc0
leaq 0x128b51(%rip), %rsi    # 0x15552e
movl $0x1, %edx
callq 0x44e0
leaq 0x28(%rsp), %r15
leaq 0x123c67(%rip), %rsi    # 0x15065a
movl $0xd, %edx
movq %r15, %rdi
callq 0x44e0
leaq 0x128b27(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
movb %bpl, 0x7(%rsp)
movq 0x48(%r14), %rbp
cmpq 0x50(%r14), %rbp
je 0x2cb67
xorl %r12d, %r12d
leaq 0x12aa55(%rip), %r13    # 0x157486
movq %r14, 0x10(%rsp)
movsd 0x18(%rbp), %xmm0
ucomisd 0x8(%rsp), %xmm0
jbe 0x2cb56
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 0x2cb3d
movl $0x1, %ebx
xorl %r14d, %r14d
movl (%rax,%r14,4), %esi
movq %r15, %rdi
callq 0x4750
movq 0x28(%rbp), %rax
subq 0x20(%rbp), %rax
sarq $0x2, %rax
decq %rax
cmpq %r14, %rax
jbe 0x2cb24
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x44e0
movl %ebx, %r14d
movq 0x20(%rbp), %rax
movq 0x28(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
incl %ebx
cmpq %r14, %rcx
ja 0x2caf4
movl $0x1, %edx
movq %r15, %rdi
leaq 0x1289e2(%rip), %rsi    # 0x15552e
callq 0x44e0
movq 0x10(%rsp), %r14
incl %r12d
addq $0x40, %rbp
cmpq 0x50(%r14), %rbp
jne 0x2ca36
leaq 0x1289c0(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
leaq 0x123ae6(%rip), %rsi    # 0x150668
movl $0xb, %edx
movq %r15, %rdi
callq 0x44e0
leaq 0x128998(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
movq 0x60(%r14), %r12
cmpq 0x68(%r14), %r12
je 0x2ccc4
leaq 0x12a8ce(%rip), %r13    # 0x157486
leaq 0x12896f(%rip), %rbp    # 0x15552e
movsd 0x8(%r12), %xmm0
ucomisd 0x8(%rsp), %xmm0
jbe 0x2ccb6
movl (%r12), %esi
movq %r15, %rdi
callq 0x4750
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x123a84(%rip), %rsi    # 0x150674
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
addq $0x28, %r12
cmpq 0x68(%r14), %r12
jne 0x2cbbf
leaq 0x18(%rsp), %rdi
callq 0x4090
movb 0x7(%rsp), %bpl
jmp 0x2cd04
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16a2fd(%rip), %rdi    # 0x196ff0
leaq 0x128834(%rip), %rsi    # 0x15552e
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 0x2cd2a
jmp 0x2cd2a
jmp 0x2cd2a
jmp 0x2cd2a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780