// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/feature.cc
// Function: FEATURE::segment_growSegment_cont(ATOM_NETWORK*, int, int)
void FEATURE::segment_growSegment_cont(ATOM_NETWORK *uc,int initnodeid,int nodeid){
int i,j;
int conn_to;
int update_conn_flag; // segment connection updated or new
double r;
SEGCONN segcon;

/* this if makes sure that segment is grown only within the sphere marked by the shere located on the seed node */
if(uc->calcDistanceXYZ(nodes.at(initnodeid).x,nodes.at(initnodeid).y,nodes.at(initnodeid).z,nodes.at(nodeid).x,nodes.at(nodeid).y,nodes.at(nodeid).z)<SPHERE_SCALE*nodes.at(initnodeid).max_radius)
{

segments[nodeid]=nsegments;

r=nodes.at(nodeid).max_radius;

for(i=0;i<(int)nodes.at(nodeid).connections.size();i++)
   {
   conn_to=nodes.at(nodeid).connections.at(i).to;

   if(segments[conn_to]==-1) // investigate connection to nodes not yet assigned to any segments
      {

//      if(nodes.at(conn_to).max_radius<r&&(nodes.at(conn_to).max_radius/nodes.at(nodeid).connections.at(i).max_radius)<NODE_R_EDGE_R_RATIO)
         {
         segment_growSegment_cont(uc,initnodeid,conn_to);
         }
         ;
// 
/*
      else if(nodes.at(conn_to).max_radius==r&&
             ((nodes.at(conn_to).max_radius/nodes.at(nodeid).connections.at(i).max_radius)<1.05||
             (r/nodes.at(nodeid).connections.at(i).max_radius)<1.05)
             )
         {
         segment_growSegment_cont(conn_to);
         };
*/


      } // end if(segments[conn_to]==-1)
      else if(segments[conn_to]!=-1&&segments[conn_to]!=nsegments) // do if encounter segment-segment boundary
      {
      segcon.from=nodeid; // assign value to new segment connection
      segcon.to=conn_to;
      segcon.from_seg=nsegments;
      segcon.to_seg=segments[conn_to];
      segcon.max_radius=nodes.at(nodeid).connections.at(i).max_radius;
      segcon.length=nodes.at(nodeid).connections.at(i).length;
      segcon.merged=0;
      
      segment_conn_fulllist.push_back(segcon); // store every intersegment connection
                                               // this will be used to identify features
                                               // connecting different segments

      if(segment_conn.size()==0) {segment_conn.push_back(segcon);}
        else
           {
           update_conn_flag=0;
           for(j=0;j<(int)segment_conn.size();j++)
              {
//              if((segment_conn.at(j).from==nodeid&&segment_conn.at(j).to==conn_to)||(segment_conn.at(j).from==conn_to&&segment_conn.at(j).to==nodeid))
                if((segment_conn.at(j).from_seg==nsegments&&segment_conn.at(j).to_seg==segments[conn_to])
                      ||(segment_conn.at(j).from_seg==segments[conn_to]&&segment_conn.at(j).to==nsegments))
                 {
                 update_conn_flag=1;
                 if(segment_conn.at(j).max_radius<nodes.at(nodeid).connections.at(i).max_radius) 
                            segment_conn.at(j).max_radius=nodes.at(nodeid).connections.at(i).max_radius;
                 };
         /*        else
                 {             
                 segment_conn.push_back(segcon);
                 }; */
              };
           if(update_conn_flag==0) segment_conn.push_back(segcon);
           }; // end else if(segment_conn.size()==0)


      }; // end of else if
   };


}; // closes if(calculatedistance)....



}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %ecx, %ebx
movl %edx, %ebp
movq %rsi, 0x50(%rsp)
movq %rdi, %r14
leaq 0x18(%rsp), %rdi
callq 0x51234
movl %ebp, 0x14(%rsp)
movslq %ebp, %r13
movq 0x60(%r14), %rax
movq 0x68(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %r13, %rdx
jbe 0x7cba7
movq %r14, 0x8(%rsp)
movl %ebx, 0x10(%rsp)
movslq %ebx, %rbx
cmpq %rbx, %rdx
jbe 0x7cbb3
leaq (,%r13,8), %r14
addq %r13, %r14
movsd 0x18(%rax,%r14,8), %xmm2
movsd 0x8(%rax,%r14,8), %xmm0
movsd 0x10(%rax,%r14,8), %xmm1
leaq (%rbx,%rbx,8), %rcx
movsd 0x8(%rax,%rcx,8), %xmm3
movsd 0x10(%rax,%rcx,8), %xmm4
movq %rcx, 0x58(%rsp)
movsd 0x18(%rax,%rcx,8), %xmm5
movq 0x50(%rsp), %rdi
callq 0x5394a
movq 0x8(%rsp), %rdi
movq 0x60(%rdi), %rax
movq 0x68(%rdi), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %r13, %rdx
jbe 0x7cba7
movsd 0x38(%rax,%r14,8), %xmm1
mulsd 0xd78a7(%rip), %xmm1    # 0x154120
ucomisd %xmm0, %xmm1
movl 0x10(%rsp), %r14d
jbe 0x7cb6f
movl 0x138(%rdi), %eax
movq 0x140(%rdi), %rcx
movl %eax, (%rcx,%rbx,4)
cmpq %rbx, %rdx
jbe 0x7cbb3
movq 0x60(%rdi), %rax
movq 0x68(%rdi), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %rbx, %rdx
jbe 0x7cbb3
leaq 0x170(%rdi), %rcx
movq %rcx, 0x68(%rsp)
leaq 0x158(%rdi), %rcx
movq %rcx, 0x48(%rsp)
xorl %r13d, %r13d
movq 0x58(%rsp), %rcx
movq 0x20(%rax,%rcx,8), %rsi
movq 0x28(%rax,%rcx,8), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rdx
movslq %edx, %rax
cmpq %rax, %r13
jge 0x7cb6f
cmpq %r13, %rdx
jbe 0x7cba7
leaq (,%r13,4), %rbp
addq %r13, %rbp
movl 0x4(%rsi,%rbp,8), %ecx
movslq %ecx, %r15
movq 0x140(%rdi), %rax
movl (%rax,%r15,4), %edx
cmpl $-0x1, %edx
je 0x7c9bb
movl 0x138(%rdi), %ecx
cmpl %ecx, %edx
je 0x7cb30
leaq (%rsi,%rbp,8), %rdx
movl %r14d, 0x18(%rsp)
movl %r15d, 0x1c(%rsp)
movl %ecx, 0x20(%rsp)
movl (%rax,%r15,4), %eax
movl %eax, 0x24(%rsp)
movsd 0x10(%rdx), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x8(%rdx), %xmm0
movsd %xmm0, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movq 0x178(%rdi), %rsi
cmpq 0x180(%rdi), %rsi
je 0x7c9d3
movupd 0x18(%rsp), %xmm0
movupd 0x28(%rsp), %xmm1
movups 0x38(%rsp), %xmm2
movups %xmm2, 0x20(%rsi)
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x30, 0x178(%rdi)
jmp 0x7c9e7
movq 0x50(%rsp), %rsi
movl 0x14(%rsp), %edx
callq 0x7c794
movq 0x8(%rsp), %rdi
jmp 0x7cb30
movq 0x68(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x8061a
movq 0x8(%rsp), %rdi
movq 0x158(%rdi), %rax
movq 0x160(%rdi), %rsi
movq %rsi, %rdx
subq %rax, %rdx
je 0x7cb01
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
testl %edx, %edx
jle 0x7cb01
movq %rsi, 0x70(%rsp)
movq %rbx, %rsi
movl 0x138(%rdi), %r8d
movq 0x140(%rdi), %r9
movq 0x60(%rdi), %rcx
movq 0x68(%rdi), %r10
subq %rcx, %r10
sarq $0x3, %r10
movabsq $-0x71c71c71c71c71c7, %rdi # imm = 0x8E38E38E38E38E39
imulq %rdi, %r10
movq %r10, 0x60(%rsp)
movq 0x58(%rsp), %rdi
leaq (%rcx,%rdi,8), %r10
addq $0x20, %r10
movl %edx, %r11d
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
addq $0x10, %rax
xorl %r14d, %r14d
xorl %ecx, %ecx
movabsq $-0x3333333333333333, %rdi # imm = 0xCCCCCCCCCCCCCCCD
cmpq %r14, %rdx
je 0x7cb7e
movl -0x8(%rax), %ebx
cmpl %r8d, %ebx
jne 0x7ca98
movl -0x4(%rax), %r12d
cmpl (%r9,%r15,4), %r12d
je 0x7caa4
cmpl (%r9,%r15,4), %ebx
jne 0x7cadf
cmpl %r8d, -0xc(%rax)
jne 0x7cadf
cmpq %rsi, 0x60(%rsp)
jbe 0x7cb99
movq (%r10), %rbx
movq 0x8(%r10), %rcx
subq %rbx, %rcx
sarq $0x3, %rcx
imulq %rdi, %rcx
cmpq %r13, %rcx
jbe 0x7cb8a
movsd 0x10(%rbx,%rbp,8), %xmm0
movl $0x1, %ecx
ucomisd (%rax), %xmm0
jbe 0x7cadf
movsd %xmm0, (%rax)
incq %r14
addq $0x30, %rax
cmpq %r14, %r11
jne 0x7ca7d
testl %ecx, %ecx
movq %rsi, %rbx
movl 0x10(%rsp), %r14d
movq 0x8(%rsp), %rdi
movq 0x70(%rsp), %rsi
jne 0x7cb30
cmpq 0x168(%rdi), %rsi
je 0x7cb5b
movupd 0x18(%rsp), %xmm0
movupd 0x28(%rsp), %xmm1
movups 0x38(%rsp), %xmm2
movups %xmm2, 0x20(%rsi)
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x30, 0x160(%rdi)
incq %r13
movq 0x60(%rdi), %rax
movq 0x68(%rdi), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %rbx, %rdx
ja 0x7c8e2
jmp 0x7cbb3
movq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x8061a
jmp 0x7c9c9
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd2b20(%rip), %rdi     # 0x14f6a5
movq %rdx, %rsi
jmp 0x7cbbd
leaq 0xd2b14(%rip), %rdi     # 0x14f6a5
movq %r13, %rsi
movq %rcx, %rdx
jmp 0x7cbbd
leaq 0xd2b05(%rip), %rdi     # 0x14f6a5
movq 0x60(%rsp), %rdx
jmp 0x7cbbd
leaq 0xd2af7(%rip), %rdi     # 0x14f6a5
movq %r13, %rsi
jmp 0x7cbbd
leaq 0xd2aeb(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630