// File: /workspace/github_cpp_makefile_star2_O3/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 0x83f68
leaq 0x30(%rsp), %rdi
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x83f68
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 0x4a154
incl %r12d
leaq 0x2a0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x108355(%rip), %rsi    # 0x1521d8
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 0x49ee9
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edi, %edi
xorl %esi, %esi
cmpq %rdi, %rdx
je 0x4a173
xorl %r8d, %r8d
cmpl %r12d, (%rax,%rdi,4)
sete %r8b
addl %r8d, %esi
incq %rdi
cmpq %rdi, %rcx
jne 0x49ec8
jmp 0x49eeb
xorl %esi, %esi
leaq 0xa0(%rsp), %rdi
callq 0x4750
movl $0x1, %edx
movq %rax, %rdi
leaq 0x109717(%rip), %rsi    # 0x15361e
callq 0x44e0
movq (%r14), %rax
movq 0x8(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
testl %edx, %edx
jle 0x4a132
xorl %ebx, %ebx
xorl %r13d, %r13d
cmpq %r13, %rdx
jbe 0x4a17e
cmpl %r12d, (%rax,%r13,4)
jne 0x4a10e
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r13, %rdx
jbe 0x4a17e
movsd (%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x83f9a
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 0x4a17e
movsd 0x8(%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x60(%rsp), %rdi
movl $0x1, %esi
callq 0x83f9a
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 0x4a17e
movsd 0x10(%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x60(%rsp), %rdi
movl $0x2, %esi
callq 0x83f9a
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 0x51c42
movq 0x88(%rsp), %rax
movq %rax, 0x40(%rsp)
movupd 0x78(%rsp), %xmm0
movapd %xmm0, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
leaq 0xa0(%rsp), %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
leaq 0x103484(%rip), %rsi    # 0x14d4de
callq 0x44e0
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movq %rbp, %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
leaq 0x103452(%rip), %rsi    # 0x14d4de
callq 0x44e0
leaq 0x30(%rsp), %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movq %rbp, %rdi
callq 0x46b0
movl $0x4, %edx
movq %rax, %rdi
leaq 0x103422(%rip), %rsi    # 0x14d4dd
callq 0x44e0
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r13, %rdx
jbe 0x4a17e
movsd 0x18(%rax,%rbx), %xmm0
mulsd 0x1080ea(%rip), %xmm0   # 0x1521d0
leaq 0xa0(%rsp), %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x10951c(%rip), %rsi    # 0x15361e
callq 0x44e0
movq (%r14), %rax
movq 0x8(%r14), %rcx
incq %r13
movq %rcx, %rsi
subq %rax, %rsi
movq %rsi, %rdx
sarq $0x2, %rdx
shrq $0x2, %rsi
movslq %esi, %rsi
addq $0x40, %rbx
cmpq %rsi, %r13
jl 0x49f2a
leaq 0xa0(%rsp), %rdi
callq 0x42c0
leaq 0x90(%rsp), %r13
movq %r13, %rdi
callq 0x4090
jmp 0x49e63
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 0x103570(%rip), %rdi    # 0x14d6f5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x4a197
jmp 0x4a197
jmp 0x4a197
jmp 0x4a197
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780
nop