// File: /workspace/github_cpp_makefile_star2_O3/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 0x11c768(%rip), %r15    # 0x194fc0
leaq 0xdc4ea(%rip), %rsi     # 0x154d49
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 0xd92e8(%rip), %rsi     # 0x151b80
movl $0x6, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0xdad72(%rip), %rsi     # 0x15361e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
movq 0x60(%rbx), %rax
movq 0x68(%rbx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
imull $0x38e38e39, %edx, %edx # imm = 0x38E38E39
testl %edx, %edx
jle 0x78937
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 0x7890e
movl $0xffffffff, (%rsi)     # imm = 0xFFFFFFFF
addq $0x4, %rsi
movq %rsi, 0x148(%rbx)
jmp 0x78921
movq %r15, %rdi
movq %r12, %rdx
callq 0x14198
movq 0x60(%rbx), %rax
movq 0x68(%rbx), %rcx
incl %ebp
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
imull $0x38e38e39, %edx, %edx # imm = 0x38E38E39
cmpl %edx, %ebp
jl 0x788e3
movl $0x0, 0x138(%rbx)
movq %rbx, %rdi
callq 0x7a8ee
testl %eax, %eax
js 0x7895a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7a96e
jmp 0x78941
movq 0x11c65f(%rip), %r14    # 0x194fc0
leaq 0xdc3f6(%rip), %rsi     # 0x154d5e
movl $0x24, %edx
movq %r14, %rdi
callq 0x44e0
movl 0x138(%rbx), %esi
movq %r14, %rdi
callq 0x4750
leaq 0xdac94(%rip), %r15     # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
movq %rbx, %rdi
callq 0x7aca6
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0xdc3ca(%rip), %rsi     # 0x154d83
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 0x78a63
xorl %r14d, %r14d
movq 0x11c5ca(%rip), %r15    # 0x194fc0
leaq 0xd4ae1(%rip), %r12     # 0x14d4de
leaq 0xdac1a(%rip), %r13     # 0x15361e
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 0x78a04
movq 0x11c556(%rip), %r14    # 0x194fc0
leaq 0xdabad(%rip), %r15     # 0x15361e
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0xdc312(%rip), %rsi     # 0x154d9a
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 0xdc312(%rip), %rsi     # 0x154dce
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 0x78b66
xorl %r14d, %r14d
movq 0x11c4c7(%rip), %r15    # 0x194fc0
leaq 0xd49de(%rip), %r12     # 0x14d4de
leaq 0xdab17(%rip), %r13     # 0x15361e
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 0x78b07
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop