// File: /workspace/github_cpp_makefile_star2_O2/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, %r14d
movl %edx, %r13d
movq %rsi, %rbp
movq %rdi, %r15
leaq 0x48(%rsp), %rdi
callq 0x3d98a
leaq 0x60(%r15), %r12
movslq %r13d, %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0xabe2
movsd 0x8(%rax), %xmm0
movsd %xmm0, (%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0xabe2
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0xabe2
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movslq %r14d, %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0xabe2
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0xabe2
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0xabe2
movsd 0x18(%rax), %xmm5
movq %rbp, 0x40(%rsp)
movq %rbp, %rdi
movsd (%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
movsd 0x28(%rsp), %xmm4
callq 0x3f636
movsd %xmm0, (%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0xabe2
movsd 0x38(%rax), %xmm0
mulsd 0xa48b2(%rip), %xmm0    # 0x101140
ucomisd (%rsp), %xmm0
jbe 0x5cb3c
movl 0x138(%r15), %eax
movq 0x140(%r15), %rcx
movl %eax, (%rcx,%r14,4)
movq %r12, %rdi
movq %r14, %rsi
callq 0xabe2
leaq 0x170(%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x158(%r15), %rbp
xorl %ebx, %ebx
movl %r13d, 0x14(%rsp)
movq %r12, 0x18(%rsp)
movq %r14, 0x8(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0xabe2
movq 0x28(%rax), %rcx
subq 0x20(%rax), %rcx
movq %rcx, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cltq
cmpq %rax, %rbx
jge 0x5cb3c
movq %r12, %rdi
movq %r14, %rsi
callq 0xabe2
leaq 0x20(%rax), %rdi
movq %rbx, %rsi
callq 0x29efa
movl 0x4(%rax), %ecx
movslq %ecx, %r12
movq 0x140(%r15), %rax
movl (%rax,%r12,4), %edx
cmpl $-0x1, %edx
je 0x5caef
movl 0x138(%r15), %ecx
cmpl %ecx, %edx
je 0x5cb2f
movl %r14d, 0x48(%rsp)
movl %r12d, 0x4c(%rsp)
movl %ecx, 0x50(%rsp)
movl (%rax,%r12,4), %eax
movl %eax, 0x54(%rsp)
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0xabe2
leaq 0x20(%rax), %rdi
movq %rbx, %rsi
callq 0x29efa
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %r14, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0xabe2
leaq 0x20(%rax), %rdi
movq %rbx, %rsi
callq 0x29efa
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
andl $0x0, 0x68(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %r13
movq %r13, %rsi
callq 0x5f28a
movq 0x158(%r15), %rcx
movq 0x160(%r15), %rax
cmpq %rcx, %rax
je 0x5cb1f
xorl %r14d, %r14d
xorl %r13d, %r13d
subq %rcx, %rax
cqto
pushq $0x30
popq %rcx
idivq %rcx
cltq
cmpq %rax, %r14
jge 0x5cb01
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5f2b8
movl 0x8(%rax), %eax
cmpl 0x138(%r15), %eax
jne 0x5ca25
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5f2b8
movl 0xc(%rax), %eax
movq 0x140(%r15), %rcx
cmpl (%rcx,%r12,4), %eax
je 0x5ca5b
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5f2b8
movl 0x8(%rax), %eax
movq 0x140(%r15), %rcx
cmpl (%rcx,%r12,4), %eax
jne 0x5cad9
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5f2b8
movl 0x4(%rax), %eax
cmpl 0x138(%r15), %eax
jne 0x5cad9
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5f2b8
movsd 0x10(%rax), %xmm0
movsd %xmm0, (%rsp)
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0xabe2
leaq 0x20(%rax), %rdi
movq %rbx, %rsi
callq 0x29efa
movsd 0x10(%rax), %xmm0
ucomisd (%rsp), %xmm0
pushq $0x1
popq %r13
jbe 0x5cad9
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0xabe2
leaq 0x20(%rax), %rdi
movq %rbx, %rsi
callq 0x29efa
movsd 0x10(%rax), %xmm0
movsd %xmm0, (%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5f2b8
movsd (%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
pushq $0x1
popq %r13
incq %r14
movq 0x158(%r15), %rcx
movq 0x160(%r15), %rax
jmp 0x5c9dd
movq %r15, %rdi
movq 0x40(%rsp), %rsi
movl %r13d, %edx
callq 0x5c79c
jmp 0x5cb2f
testl %r13d, %r13d
movl 0x14(%rsp), %r13d
movq 0x8(%rsp), %r14
jne 0x5cb2f
movq %rbp, %rdi
leaq 0x48(%rsp), %rsi
callq 0x5f28a
jmp 0x5cb2f
movq %rbp, %rdi
movq %r13, %rsi
callq 0x5f28a
movl 0x14(%rsp), %r13d
incq %rbx
movq 0x18(%rsp), %r12
jmp 0x5c8da
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop