// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/feature.cc
// Function: FEATURE::segmentChannel(ATOM_NETWORK*)
void FEATURE::segmentChannel(ATOM_NETWORK *uc){
int i;

cout << "Current channel has " << nodes.size() << " nodes" << "\n";

for(i=0;i<(int)nodes.size();i++)
   {
   segments.push_back(-1);
   };
nsegments=0;

while(segment_findMaxNode()>-1)
   {
//   segment_growSegment_start(uc,segment_findMaxNode());
   segment_distBasedSegmentation(uc);
   };

cout << "Initial number of segments (minima) " << nsegments << "\n";

/*
fstream output1;
output1.open("segments.zvis",fstream::out);
segment_saveVis(output1);
output1.close();
*/

//segment_identify_connections(); // analyzes connectivity of each segment to find segment's 'faces' - connection between segments 



//merge_segments(); // analyze segments and merge if neccesary

//merge_nothing(); // this function copies segments into features

merge_singlenode_segments();


//calculateVolumeForAllFeatures(); // calculate volume of each segment


/* Print results */
cout << "\n" << "Segment info (ID - r):"<<"\n";
for(i=0;i<(int)segment_max_r.size();i++)
   {
   cout << i<< "   " << segment_max_r[i]  << "\n";
   };
cout << "\n" << "Segment connection info (from to radii merge_stat):"<<"\n";

/*
for(i=0;i<(int)segment_conn.size();i++)
   {
   cout << segment_conn.at(i).from_seg << "   " << segment_conn.at(i).to_seg << "   " <<segment_conn.at(i).max_radius << "   " << segment_conn.at(i).merged << "\n";
   };

cout << "\n" << "Total number of segment connecting edges :  "<< segment_conn_fulllist.size()  <<"\n";

cout << "\n" << "Segment info vs features (segment ID - feature ID):"<<"\n";
for(i=0;i<nsegments;i++)
   {
   cout << i<< "   " << segment_merge_list[i]  << "\n";
   };
*/
cout << "\n" << "Features info (ID - r - volume):"<<"\n";
for(i=0;i<(int)feature_max_r.size();i++)
   {
//   cout << i<< "   " << feature_max_r[i]  << "   " << feature_volume[i] << "\n";
   cout << i<< "   " << feature_max_r[i]   << "\n";
   };
/*
cout << "\n" << "Features connection info (from to radii ):"<<"\n";
for(i=0;i<(int)feature_conn.size();i++)
   {
   cout << feature_conn.at(i).from_seg << "   " << feature_conn.at(i).to_seg << "   " <<feature_conn.at(i).max_radius << "\n";
   };
*/

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x11d796(%rip), %r15    # 0x196fc0
leaq 0xdd400(%rip), %rsi     # 0x156c31
movl $0x14, %edx
movq %r15, %rdi
callq 0x44e0
movq 0x68(%rbx), %rax
subq 0x60(%rbx), %rax
sarq $0x3, %rax
movabsq $-0x71c71c71c71c71c7, %rsi # imm = 0x8E38E38E38E38E39
imulq %rax, %rsi
movq %r15, %rdi
callq 0x42b0
movq %rax, %r15
leaq 0xda266(%rip), %rsi     # 0x153ad0
movl $0x6, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0xdbcb0(%rip), %rsi     # 0x15552e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
movq 0x68(%rbx), %rax
subq 0x60(%rbx), %rax
shrq $0x3, %rax
imull $0x38e38e39, %eax, %eax # imm = 0x38E38E39
testl %eax, %eax
jle 0x798fd
leaq 0x140(%rbx), %r15
xorl %ebp, %ebp
leaq 0x4(%rsp), %r12
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq 0x148(%rbx), %rsi
cmpq 0x150(%rbx), %rsi
je 0x798da
movl $0xffffffff, (%rsi)     # imm = 0xFFFFFFFF
addq $0x4, %rsi
movq %rsi, 0x148(%rbx)
jmp 0x798e5
movq %r15, %rdi
movq %r12, %rdx
callq 0x1422c
movq 0x68(%rbx), %rax
subq 0x60(%rbx), %rax
incl %ebp
shrq $0x3, %rax
imull $0x38e38e39, %eax, %eax # imm = 0x38E38E39
cmpl %eax, %ebp
jl 0x798af
movl $0x0, 0x138(%rbx)
movq %rbx, %rdi
callq 0x7ba10
testl %eax, %eax
js 0x79920
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7ba90
jmp 0x79907
movq 0x11d699(%rip), %r14    # 0x196fc0
leaq 0xdd318(%rip), %rsi     # 0x156c46
movl $0x24, %edx
movq %r14, %rdi
callq 0x44e0
movl 0x138(%rbx), %esi
movq %r14, %rdi
callq 0x4750
leaq 0xdbbde(%rip), %r15     # 0x15552e
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
movq %rbx, %rdi
callq 0x7bdbc
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0xdd2ec(%rip), %rsi     # 0x156c6b
movl $0x16, %edx
movq %r14, %rdi
callq 0x44e0
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x44e0
movq 0x240(%rbx), %rax
subq 0x238(%rbx), %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0x79a29
xorl %r14d, %r14d
movq 0x11d604(%rip), %r15    # 0x196fc0
leaq 0xd5acb(%rip), %r12     # 0x14f48e
leaq 0xdbb64(%rip), %r13     # 0x15552e
movq %r15, %rdi
movl %r14d, %esi
callq 0x4750
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
movq 0x238(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
movq %rbp, %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movq 0x240(%rbx), %rax
subq 0x238(%rbx), %rax
incq %r14
shrq $0x3, %rax
cltq
cmpq %rax, %r14
jl 0x799ca
movq 0x11d590(%rip), %r14    # 0x196fc0
leaq 0xdbaf7(%rip), %r15     # 0x15552e
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0xdd234(%rip), %rsi     # 0x156c82
movl $0x33, %edx
movq %r14, %rdi
callq 0x44e0
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x44e0
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0xdd234(%rip), %rsi     # 0x156cb6
movl $0x20, %edx
movq %r14, %rdi
callq 0x44e0
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x44e0
movq 0x258(%rbx), %rax
subq 0x250(%rbx), %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0x79b2c
xorl %r14d, %r14d
movq 0x11d501(%rip), %r15    # 0x196fc0
leaq 0xd59c8(%rip), %r12     # 0x14f48e
leaq 0xdba61(%rip), %r13     # 0x15552e
movq %r15, %rdi
movl %r14d, %esi
callq 0x4750
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
movq 0x250(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
movq %rbp, %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movq 0x258(%rbx), %rax
subq 0x250(%rbx), %rax
incq %r14
shrq $0x3, %rax
cltq
cmpq %rax, %r14
jl 0x79acd
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop