// File: 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
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x5660
leaq -0x368(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xe9c70
jmp 0x894ea
leaq -0x390(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xe9c70
jmp 0x89501
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x8998e
movq -0x30(%rbp), %rdx
movq 0x10(%rbp), %rcx
movl -0x34(%rbp), %r8d
incl %r8d
leaq 0x16ddce(%rip), %rsi    # 0x1f72f8
xorl %eax, %eax
leaq -0x140(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x5100
movq -0x3c8(%rbp), %rsi
leaq -0x350(%rbp), %rdi
movl $0x10, %edx
callq 0x54b0
jmp 0x89559
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x3cc(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10090
movq %rax, %rcx
movl -0x3cc(%rbp), %eax
cmpl %ecx, %eax
jge 0x895ed
movq -0x18(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0x101d0
movq %rax, -0x3d8(%rbp)
jmp 0x8959c
movq -0x3d8(%rbp), %rax
movl (%rax), %eax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x895dd
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x895dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x370(%rbp)
movl %eax, -0x374(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x5150
jmp 0x899a3
jmp 0x895df
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x89567
leaq -0x340(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x58d0
movq %rax, -0x3e0(%rbp)
jmp 0x89605
movq -0x3e0(%rbp), %rdi
leaq 0x170012(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x8961a
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x3e4(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10090
movq %rax, %rcx
movl -0x3e4(%rbp), %eax
cmpl %ecx, %eax
jge 0x89962
movq -0x18(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0x101d0
movq %rax, -0x3f0(%rbp)
jmp 0x8965a
movq -0x3f0(%rbp), %rax
movl (%rax), %eax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x89952
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movslq -0x38(%rbp), %rsi
callq 0xf390
movq %rax, -0x3f8(%rbp)
jmp 0x8968b
movq -0x3f8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x408(%rbp)
leaq -0x368(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x400(%rbp)
jmp 0x896b5
movq -0x400(%rbp), %rax
movsd -0x408(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movslq -0x38(%rbp), %rsi
callq 0xf390
movq %rax, -0x410(%rbp)
jmp 0x896e2
movq -0x410(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x420(%rbp)
leaq -0x368(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x418(%rbp)
jmp 0x89710
movq -0x418(%rbp), %rax
movsd -0x420(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movslq -0x38(%rbp), %rsi
callq 0xf390
movq %rax, -0x428(%rbp)
jmp 0x8973d
movq -0x428(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x438(%rbp)
leaq -0x368(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x430(%rbp)
jmp 0x8976b
movq -0x430(%rbp), %rax
movsd -0x438(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x8(%rbp), %rsi
movq -0x358(%rbp), %rax
movq %rax, -0x3b0(%rbp)
movups -0x368(%rbp), %xmm0
movaps %xmm0, -0x3c0(%rbp)
movq -0x3b0(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movaps -0x3c0(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x3a8(%rbp), %rdi
callq 0x96150
jmp 0x897c4
movq -0x398(%rbp), %rax
movq %rax, -0x380(%rbp)
movups -0x3a8(%rbp), %xmm0
movaps %xmm0, -0x390(%rbp)
leaq -0x340(%rbp), %rax
movq %rax, -0x448(%rbp)
leaq -0x390(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x440(%rbp)
jmp 0x89805
movq -0x448(%rbp), %rdi
movq -0x440(%rbp), %rax
movsd (%rax), %xmm0
callq 0x5980
movq %rax, -0x450(%rbp)
jmp 0x89825
movq -0x450(%rbp), %rdi
leaq 0x168c54(%rip), %rsi    # 0x1f2487
callq 0x5540
movq %rax, -0x458(%rbp)
jmp 0x89841
leaq -0x390(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x460(%rbp)
jmp 0x8985b
movq -0x458(%rbp), %rdi
movq -0x460(%rbp), %rax
movsd (%rax), %xmm0
callq 0x5980
movq %rax, -0x468(%rbp)
jmp 0x8987b
movq -0x468(%rbp), %rdi
leaq 0x168bfe(%rip), %rsi    # 0x1f2487
callq 0x5540
movq %rax, -0x470(%rbp)
jmp 0x89897
leaq -0x390(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x478(%rbp)
jmp 0x898b1
movq -0x470(%rbp), %rdi
movq -0x478(%rbp), %rax
movsd (%rax), %xmm0
callq 0x5980
movq %rax, -0x480(%rbp)
jmp 0x898d1
movq -0x480(%rbp), %rdi
leaq 0x168ba7(%rip), %rsi    # 0x1f2486
callq 0x5540
jmp 0x898e6
leaq -0x340(%rbp), %rax
movq %rax, -0x490(%rbp)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movslq -0x38(%rbp), %rsi
callq 0xf390
movq %rax, -0x488(%rbp)
jmp 0x8990e
movq -0x490(%rbp), %rdi
movq -0x488(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd 0x16d9c7(%rip), %xmm1   # 0x1f72f0
mulsd %xmm1, %xmm0
callq 0x5980
movq %rax, -0x498(%rbp)
jmp 0x8993b
movq -0x498(%rbp), %rdi
leaq 0x16fcdc(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x89950
jmp 0x89952
jmp 0x89954
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x89621
leaq -0x340(%rbp), %rdi
callq 0x5330
jmp 0x89970
leaq -0x350(%rbp), %rdi
callq 0x50a0
jmp 0x8997e
jmp 0x89980
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x89508
leaq -0x350(%rbp), %rdi
callq 0x5150
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
movq -0x370(%rbp), %rdi
callq 0x58f0
nop