// File: /workspace/github_cpp_makefile_star2_O1/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 $0x3a8, %rsp            # imm = 0x3A8
movq %r9, 0x50(%rsp)
movl %r8d, %ebx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, 0x58(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x4520
leaq 0x60(%rsp), %rdi
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x85436
leaq 0x30(%rsp), %rdi
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x85436
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
movl %ebx, 0x2c(%rsp)
leaq 0x90(%rsp), %r13
xorl %r12d, %r12d
cmpl 0x2c(%rsp), %r12d
je 0x4a422
incl %r12d
leaq 0x2a0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x109fd1(%rip), %rsi    # 0x154128
movq 0x50(%rsp), %rdx
movq 0x3e0(%rsp), %rcx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x40e0
movq %r13, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x43d0
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
testl %edx, %edx
jle 0x4a1bd
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edi, %edi
xorl %esi, %esi
cmpq %rdi, %rdx
je 0x4a441
xorl %r8d, %r8d
cmpl %r12d, (%rax,%rdi,4)
sete %r8b
addl %r8d, %esi
incq %rdi
cmpq %rdi, %rcx
jne 0x4a19c
jmp 0x4a1bf
xorl %esi, %esi
leaq 0xa0(%rsp), %rdi
callq 0x4750
movl $0x1, %edx
movq %rax, %rdi
leaq 0x10b353(%rip), %rsi    # 0x15552e
callq 0x44e0
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
testl %edx, %edx
jle 0x4a400
xorl %ebx, %ebx
xorl %r13d, %r13d
cmpq %r13, %rdx
jbe 0x4a44c
cmpl %r12d, (%rax,%r13,4)
jne 0x4a3d8
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r13, %rdx
jbe 0x4a44c
movsd (%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x85478
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r13, %rdx
jbe 0x4a44c
movsd 0x8(%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x60(%rsp), %rdi
movl $0x1, %esi
callq 0x85478
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r13, %rdx
jbe 0x4a44c
movsd 0x10(%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x60(%rsp), %rdi
movl $0x2, %esi
callq 0x85478
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x78(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x52082
movq 0x88(%rsp), %rax
movq %rax, 0x40(%rsp)
movupd 0x78(%rsp), %xmm0
movapd %xmm0, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
leaq 0xa0(%rsp), %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
leaq 0x105163(%rip), %rsi    # 0x14f48e
callq 0x44e0
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movq %rbp, %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
leaq 0x105131(%rip), %rsi    # 0x14f48e
callq 0x44e0
leaq 0x30(%rsp), %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm0
movq %rbp, %rdi
callq 0x46b0
movl $0x4, %edx
movq %rax, %rdi
leaq 0x105101(%rip), %rsi    # 0x14f48d
callq 0x44e0
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r13, %rdx
jbe 0x4a44c
movsd 0x18(%rax,%rbx), %xmm0
mulsd 0x109d69(%rip), %xmm0   # 0x154120
leaq 0xa0(%rsp), %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x10b15b(%rip), %rsi    # 0x15552e
callq 0x44e0
incq %r13
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x2, %rdx
shrq $0x2, %rcx
movslq %ecx, %rcx
addq $0x40, %rbx
cmpq %rcx, %r13
jl 0x4a1fb
leaq 0xa0(%rsp), %rdi
callq 0x42c0
leaq 0x90(%rsp), %r13
movq %r13, %rdi
callq 0x4090
jmp 0x4a137
leaq 0x90(%rsp), %rdi
callq 0x4110
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal -0x1(%rdx), %r13d
cmpq %r13, %rdx
cmovbq %rdx, %r13
leaq 0x105252(%rip), %rdi    # 0x14f6a5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x4a465
jmp 0x4a465
jmp 0x4a465
jmp 0x4a465
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780
nop