// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/segment.cc
// Function: segmentChannels_saveSegments(ATOM_NETWORK*, VORONOI_NETWORK*, std::vector<int, std::allocator<int>>*, std::vector<double, std::allocator<double>>*, int, char*, char const*)
void segmentChannels_saveSegments(ATOM_NETWORK *uc, VORONOI_NETWORK *vornet,vector<int> *accessInfo, vector<double> *segment_radii_vector, 
				  int num_segments, char *name,const char *feattype) {
  int i,j,no;
  
  char filename_out[256];
  fstream file_out;
  //double x,y,z;
  Point xyzpt,abcpt;

  for(i=0;i<num_segments;i++){
    //   sprintf(filename_out,"%s-segment_%d.active",name,(i+1));
    sprintf(filename_out,"%s-%s_%d.active",name,feattype,(i+1));
    
    file_out.open(filename_out, fstream::out);
    no=0;
    for(j=0;j<(int)(accessInfo->size());j++){
      if(accessInfo->at(j)==(i+1)) no++;
    };

    file_out << no << "\n";
    
    for(j=0;j<(int)(accessInfo->size());j++){
      if(accessInfo->at(j)==(i+1)){ 
	xyzpt[0] = vornet->nodes.at(j).x; xyzpt[1]=vornet->nodes.at(j).y; xyzpt[2]=vornet->nodes.at(j).z;
	abcpt=uc->xyz_to_abc(xyzpt);
	file_out << abcpt[0] << "   " << abcpt[1] << "   " << abcpt[2]<< "    ";
	file_out << vornet->nodes.at(j).rad_stat_sphere*SCALE_SPHERE << "\n";	
      }
    }
    file_out.flush();
    file_out.close();
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
movq %r9, 0x28(%rsp)
movl %r8d, %ebx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, 0x30(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x4540
leaq 0x38(%rsp), %rdi
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x63c46
leaq 0x50(%rsp), %rdi
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x63c46
addq $0x48, %r15
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
movl %ebx, 0x24(%rsp)
leaq 0x50(%rsp), %rbx
xorl %r12d, %r12d
cmpl 0x24(%rsp), %r12d
je 0x38066
incl %r12d
leaq 0x290(%rsp), %r13
movq %r13, %rdi
leaq 0xc9320(%rip), %rsi     # 0x101148
movq 0x28(%rsp), %rdx
movq 0x3d0(%rsp), %rcx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x40d0
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
pushq $0x10
popq %rdx
callq 0x4410
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x2, %rax
cltq
cmpq %rax, %rbp
jge 0x37e84
movq %r14, %rdi
movq %rbp, %rsi
callq 0xac00
xorl %ecx, %ecx
cmpl %r12d, (%rax)
sete %cl
addl %ecx, %r13d
incq %rbp
jmp 0x37e57
leaq 0x90(%rsp), %rdi
movl %r13d, %esi
callq 0x4760
movq %rax, %rdi
leaq 0xca6e0(%rip), %rsi     # 0x10257e
callq 0x4480
xorl %r13d, %r13d
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x2, %rax
cltq
cmpq %rax, %r13
jge 0x38047
movq %r14, %rdi
movq %r13, %rsi
callq 0xac00
cmpl %r12d, (%rax)
jne 0x3803f
movq %r15, %rdi
movq %r13, %rsi
callq 0xa848
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x63c78
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %r15, %rdi
movq %r13, %rsi
callq 0xa848
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x38(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %r15, %rdi
movq %r13, %rsi
callq 0xa848
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x38(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x63c78
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x38(%rsp), %xmm0
movupd %xmm0, (%rsp)
leaq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3e4c8
movq 0x78(%rsp), %rax
movq %rax, 0x60(%rsp)
movupd 0x68(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
leaq 0x90(%rsp), %rdi
callq 0x46c0
movq %rax, %rdi
leaq 0xc451a(%rip), %rsi     # 0xfc4ce
callq 0x4480
movq %rax, %rbp
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movq %rbp, %rdi
callq 0x46c0
movq %rax, %rdi
leaq 0xc44f1(%rip), %rsi     # 0xfc4ce
callq 0x4480
movq %rax, %rbp
movq %rbx, %rdi
pushq $0x2
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movq %rbp, %rdi
callq 0x46c0
movq %rax, %rdi
leaq 0xc44c7(%rip), %rsi     # 0xfc4cd
callq 0x4480
movq %r15, %rdi
movq %r13, %rsi
callq 0xa848
movsd 0x18(%rax), %xmm0
mulsd 0xc911d(%rip), %xmm0    # 0x101140
leaq 0x90(%rsp), %rdi
callq 0x46c0
movq %rax, %rdi
leaq 0xca544(%rip), %rsi     # 0x10257e
callq 0x4480
incq %r13
jmp 0x37ea6
leaq 0x90(%rsp), %rdi
callq 0x42f0
leaq 0x80(%rsp), %rdi
callq 0x4080
jmp 0x37e08
leaq 0x80(%rsp), %rdi
callq 0x4120
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3808f
jmp 0x3808f
jmp 0x3808f
jmp 0x3808f
jmp 0x3808f
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4780
nop