// File: /workspace/github_cpp_makefile_star2_O3/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, %r12d
movl %edx, %ebx
movq %rsi, 0x50(%rsp)
movq %rdi, %r14
leaq 0x18(%rsp), %rdi
callq 0x50e90
movslq %ebx, %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 0x7ba78
movq %r14, 0x8(%rsp)
movl %ebx, 0x10(%rsp)
movslq %r12d, %rbx
cmpq %rbx, %rdx
jbe 0x7ba84
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 0x5364c
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 0x7ba78
movsd 0x38(%rax,%r14,8), %xmm1
mulsd 0xd6a6c(%rip), %xmm1    # 0x1521d0
ucomisd %xmm0, %xmm1
movl 0x10(%rsp), %r14d
jbe 0x7ba3f
movl 0x138(%rdi), %ecx
movq 0x140(%rdi), %rsi
movl %ecx, (%rsi,%rbx,4)
cmpq %rbx, %rdx
jbe 0x7ba84
leaq 0x170(%rdi), %rcx
movq %rcx, 0x70(%rsp)
leaq 0x158(%rdi), %rcx
movq %rcx, 0x48(%rsp)
xorl %r13d, %r13d
movl %r12d, 0x14(%rsp)
movq %rbx, 0x60(%rsp)
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 0x7ba3f
cmpq %r13, %rdx
jbe 0x7ba78
leaq (,%r13,4), %rax
addq %r13, %rax
movq %rax, 0x68(%rsp)
movl 0x4(%rsi,%rax,8), %ecx
movslq %ecx, %r15
movq 0x140(%rdi), %rax
movl (%rax,%r15,4), %edx
cmpl $-0x1, %edx
je 0x7b88e
movl 0x138(%rdi), %ecx
cmpl %ecx, %edx
je 0x7ba00
movq 0x68(%rsp), %rdx
leaq (%rsi,%rdx,8), %rdx
movl %r12d, 0x18(%rsp)
movl %r15d, 0x1c(%rsp)
movl %ecx, 0x20(%rsp)
movl (%rax,%r15,4), %eax
movl %eax, 0x24(%rsp)
movupd 0x8(%rdx), %xmm0
shufpd $0x1, %xmm0, %xmm0      # xmm0 = xmm0[1,0]
movupd %xmm0, 0x28(%rsp)
movl $0x0, 0x38(%rsp)
movq 0x178(%rdi), %rsi
cmpq 0x180(%rdi), %rsi
je 0x7b8a5
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 0x7b8b9
movq 0x50(%rsp), %rsi
movl %r14d, %edx
callq 0x7b682
movq 0x8(%rsp), %rdi
jmp 0x7ba00
movq 0x70(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x7f3b8
movq 0x8(%rsp), %rdi
movq 0x158(%rdi), %rbp
movq 0x160(%rdi), %rsi
movq %rsi, %rdx
subq %rbp, %rdx
je 0x7b9d1
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
testl %edx, %edx
jle 0x7b9d1
movl 0x138(%rdi), %r8d
movq 0x140(%rdi), %r9
movq 0x60(%rdi), %rcx
movq 0x68(%rdi), %rax
subq %rcx, %rax
sarq $0x3, %rax
movabsq $-0x71c71c71c71c71c7, %rdi # imm = 0x8E38E38E38E38E39
imulq %rdi, %rax
movq 0x58(%rsp), %rdi
leaq (%rcx,%rdi,8), %r10
addq $0x20, %r10
movl %edx, %r11d
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
addq $0x10, %rbp
xorl %r14d, %r14d
xorl %ecx, %ecx
movabsq $-0x3333333333333333, %rdi # imm = 0xCCCCCCCCCCCCCCCD
cmpq %r14, %rdx
je 0x7ba4e
movl -0x8(%rbp), %ebx
movl (%r9,%r15,4), %r12d
cmpl %r8d, %ebx
jne 0x7b95d
cmpl %r12d, -0x4(%rbp)
je 0x7b968
cmpl %r12d, %ebx
jne 0x7b9ad
cmpl %r8d, -0xc(%rbp)
jne 0x7b9ad
movq 0x60(%rsp), %rcx
cmpq %rcx, %rax
jbe 0x7ba69
movq (%r10), %rbx
movq 0x8(%r10), %rcx
subq %rbx, %rcx
sarq $0x3, %rcx
imulq %rdi, %rcx
cmpq %r13, %rcx
jbe 0x7ba5a
movq 0x68(%rsp), %rcx
movsd 0x10(%rbx,%rcx,8), %xmm0
movl $0x1, %ecx
ucomisd (%rbp), %xmm0
jbe 0x7b9ad
movsd %xmm0, (%rbp)
incq %r14
addq $0x30, %rbp
cmpq %r14, %r11
jne 0x7b942
testl %ecx, %ecx
movq 0x60(%rsp), %rbx
movl 0x14(%rsp), %r12d
movl 0x10(%rsp), %r14d
movq 0x8(%rsp), %rdi
jne 0x7ba00
cmpq 0x168(%rdi), %rsi
je 0x7ba2b
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 0x7b7b1
jmp 0x7ba84
movq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x7f3b8
jmp 0x7b89b
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd1ca0(%rip), %rdi     # 0x14d6f5
movq %rdx, %rsi
jmp 0x7ba8e
leaq 0xd1c94(%rip), %rdi     # 0x14d6f5
movq %r13, %rsi
movq %rcx, %rdx
jmp 0x7ba8e
leaq 0xd1c85(%rip), %rdi     # 0x14d6f5
movq %rcx, %rsi
movq %rax, %rdx
jmp 0x7ba8e
leaq 0xd1c76(%rip), %rdi     # 0x14d6f5
movq %r13, %rsi
jmp 0x7ba8e
leaq 0xd1c6a(%rip), %rdi     # 0x14d6f5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
nop