// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x94d10
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
addq $0x60, %rdi
movslq -0x14(%rbp), %rsi
callq 0x10130
movq -0x70(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
addq $0x60, %rdi
movslq -0x14(%rbp), %rsi
callq 0x10130
movq -0x70(%rbp), %rdi
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
addq $0x60, %rdi
movslq -0x14(%rbp), %rsi
callq 0x10130
movq -0x70(%rbp), %rdi
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq -0x70(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq -0x70(%rbp), %rdi
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq -0xa0(%rbp), %rdi
movsd -0x98(%rbp), %xmm0
movsd -0x90(%rbp), %xmm1
movsd -0x88(%rbp), %xmm2
movsd -0x80(%rbp), %xmm3
movsd -0x78(%rbp), %xmm4
movsd 0x18(%rax), %xmm5
callq 0x97a10
movq -0x70(%rbp), %rdi
movsd %xmm0, -0x68(%rbp)
addq $0x60, %rdi
movslq -0x14(%rbp), %rsi
callq 0x10130
movsd -0x68(%rbp), %xmm1
movsd 0x11ae44(%rip), %xmm0   # 0x1f72f0
mulsd 0x38(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xdc896
movq -0x70(%rbp), %rdi
movl 0x138(%rdi), %eax
movl %eax, -0xa4(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x18(%rbp), %rsi
callq 0xed60
movl -0xa4(%rbp), %ecx
movq -0x70(%rbp), %rdi
movl %ecx, (%rax)
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movsd 0x38(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x70(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, -0xa8(%rbp)
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq %rax, %rdi
addq $0x20, %rdi
callq 0x2a9e0
movq %rax, %rcx
movl -0xa8(%rbp), %eax
cmpl %ecx, %eax
jge 0xdc894
movq -0x70(%rbp), %rdi
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq %rax, %rdi
addq $0x20, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x64470
movq -0x70(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x24(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x24(%rbp), %rsi
callq 0xed60
cmpl $-0x1, (%rax)
jne 0xdc594
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x24(%rbp), %ecx
callq 0xdc380
jmp 0xdc884
movq -0x70(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
movslq -0x24(%rbp), %rsi
callq 0xed60
cmpl $-0x1, (%rax)
je 0xdc882
movq -0x70(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
movslq -0x24(%rbp), %rsi
callq 0xed60
movq -0x70(%rbp), %rcx
movl (%rax), %eax
cmpl 0x138(%rcx), %eax
je 0xdc882
movq -0x70(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl 0x138(%rdi), %eax
movl %eax, -0x58(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x24(%rbp), %rsi
callq 0xed60
movq -0x70(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x54(%rbp)
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq %rax, %rdi
addq $0x20, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x64470
movq -0x70(%rbp), %rdi
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq %rax, %rdi
addq $0x20, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x64470
movq -0x70(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x40(%rbp)
addq $0x170, %rdi            # imm = 0x170
leaq -0x60(%rbp), %rsi
callq 0xe08b0
movq -0x70(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
callq 0xe0920
cmpq $0x0, %rax
jne 0xdc6a5
movq -0x70(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
leaq -0x60(%rbp), %rsi
callq 0xe08b0
jmp 0xdc880
movl $0x0, -0x28(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x70(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, -0xac(%rbp)
addq $0x158, %rdi            # imm = 0x158
callq 0xe0920
movq %rax, %rcx
movl -0xac(%rbp), %eax
cmpl %ecx, %eax
jge 0xdc864
movq -0x70(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
movslq -0x20(%rbp), %rsi
callq 0xe0950
movq -0x70(%rbp), %rcx
movl 0x8(%rax), %eax
cmpl 0x138(%rcx), %eax
jne 0xdc73e
movq -0x70(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
movslq -0x20(%rbp), %rsi
callq 0xe0950
movq -0x70(%rbp), %rdi
movl 0xc(%rax), %eax
movl %eax, -0xb0(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x24(%rbp), %rsi
callq 0xed60
movq %rax, %rcx
movl -0xb0(%rbp), %eax
cmpl (%rcx), %eax
je 0xdc7a7
movq -0x70(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
movslq -0x20(%rbp), %rsi
callq 0xe0950
movq -0x70(%rbp), %rdi
movl 0x8(%rax), %eax
movl %eax, -0xb4(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x24(%rbp), %rsi
callq 0xed60
movq %rax, %rcx
movl -0xb4(%rbp), %eax
cmpl (%rcx), %eax
jne 0xdc854
movq -0x70(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
movslq -0x20(%rbp), %rsi
callq 0xe0950
movq -0x70(%rbp), %rcx
movl 0x4(%rax), %eax
cmpl 0x138(%rcx), %eax
jne 0xdc854
movq -0x70(%rbp), %rdi
movl $0x1, -0x28(%rbp)
addq $0x158, %rdi            # imm = 0x158
movslq -0x20(%rbp), %rsi
callq 0xe0950
movq -0x70(%rbp), %rdi
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq %rax, %rdi
addq $0x20, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x64470
movsd -0xc0(%rbp), %xmm1
movsd 0x10(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xdc852
movq -0x70(%rbp), %rdi
addq $0x60, %rdi
movslq -0x18(%rbp), %rsi
callq 0x10130
movq %rax, %rdi
addq $0x20, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x64470
movq -0x70(%rbp), %rdi
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
addq $0x158, %rdi            # imm = 0x158
movslq -0x20(%rbp), %rsi
callq 0xe0950
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0xdc854
jmp 0xdc856
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xdc6b3
cmpl $0x0, -0x28(%rbp)
jne 0xdc87e
movq -0x70(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
leaq -0x60(%rbp), %rsi
callq 0xe08b0
jmp 0xdc880
jmp 0xdc882
jmp 0xdc884
jmp 0xdc886
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xdc505
jmp 0xdc896
addq $0xd0, %rsp
popq %rbp
retq
nop