// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/feature.cc
// Function: FEATURE::createFeatures(ATOM_NETWORK*, VORONOI_NETWORK*, DIJKSTRA_NETWORK*, std::basic_fstream<char, std::char_traits<char>>&, int, char*)
int FEATURE::createFeatures(ATOM_NETWORK *uc,VORONOI_NETWORK *origVNet, DIJKSTRA_NETWORK *origDNet, std::fstream &output, int initIndex,char *name){
    nfeatures = 0;
    features = std::vector<int> ();
    feature_node_mapping = std::vector<int> ();
    segmentChannel(uc);
    if(nfeatures == 0){
        std::cerr << "Error occurred during channel segmentation. No features were found." << "\n"
        << "Exiting..." << "\n";
        exit(1);
    }
    
    std::vector< std::vector<int> > nodesForFeatures = std::vector < std::vector<int> > (nfeatures, std::vector<int> ());
    std::vector<FEATURE> featChannels = std::vector<FEATURE> ();
    for(unsigned int i = 0; i < feature_node_mapping.size(); i++){
        nodesForFeatures[feature_node_mapping[i]].push_back(reverseIDMappings.find(i)->second);
    }
    
    
    int zeroVecs [3][3] = {{0, 0, 0},{ 0, 0, 0}, {0, 0, 0}};
    
    for(int i = 0; i < nfeatures; i++){
        DIJKSTRA_NETWORK featNet;
        DIJKSTRA_NETWORK::filterDnetEdges(nodesForFeatures[i], origVNet, &featNet);
        std::vector<bool> infoStorage; std::vector<CHANNEL> channels;
        findChannels(&featNet, &infoStorage, &channels);
        int dim;
        if(channels.size() != 0){
            dim = channels[0].dimensionality;
            featChannels.push_back(FEATURE(nodesForFeatures[i], origDNet, dim, channels[0].basis));
        }
        else{
            dim = 0;
            featChannels.push_back(FEATURE(nodesForFeatures[i], origDNet, 0, zeroVecs));
        }
        featChannels[i].writeToVMD("feature", initIndex + i, output);
        std::cout << "@@ " << name << " Feature " << initIndex + i << " volume = " << featChannels[i].calculateVolume() << "\n";
        featChannels[i].calculateSurfaceArea(uc,&nodes,&feature_node_mapping,i,name,initIndex + i);
    }
    return nfeatures;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movl %r9d, %ebp
movq %r8, 0xc0(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0xc8(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r15
movl $0x0, 0x1b8(%rdi)
movq 0x1c0(%rdi), %rdi
movq 0x1d0(%r15), %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x1c0(%r15)
movq $0x0, 0x1d0(%r15)
testq %rdi, %rdi
je 0x78193
subq %rdi, %rsi
callq 0x4470
xorps %xmm0, %xmm0
movq 0x1d8(%r15), %rdi
movq 0x1e8(%r15), %rsi
movups %xmm0, 0x1d8(%r15)
movq $0x0, 0x1e8(%r15)
testq %rdi, %rdi
je 0x781c1
subq %rdi, %rsi
callq 0x4470
movq %r15, %rdi
movq 0x20(%rsp), %rsi
callq 0x78840
movslq 0x1b8(%r15), %rsi
testq %rsi, %rsi
je 0x786bb
xorps %xmm0, %xmm0
leaq 0x1d0(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq 0x90(%rsp), %rdi
leaq 0x170(%rsp), %rcx
callq 0x6757e
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x78226
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x1d8(%r15), %rax
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x1d8(%r15), %rax
cmpq %rax, 0x1e0(%r15)
je 0x782ee
leaq 0x38(%r15), %rbx
xorl %r14d, %r14d
movq 0x40(%r15), %rsi
movq %rbx, %rdx
testq %rsi, %rsi
je 0x78297
movq %rbx, %rcx
xorl %edx, %edx
cmpl %r14d, 0x20(%rsi)
setl %dl
cmovgeq %rsi, %rcx
movq 0x10(%rsi,%rdx,8), %rsi
testq %rsi, %rsi
jne 0x7826d
movq %rbx, %rdx
cmpq %rbx, %rcx
je 0x78297
cmpl 0x20(%rcx), %r14d
cmovlq %rbx, %rcx
movq %rcx, %rdx
movslq (%rax,%r14,4), %rcx
leaq (%rcx,%rcx,2), %rdi
shlq $0x3, %rdi
addq 0x90(%rsp), %rdi
addq $0x24, %rdx
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x782c7
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x782d4
callq 0xf864
movq 0x28(%rsp), %rax
movq (%rax), %rax
incl %r14d
movq 0x1e0(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x7825e
xorps %xmm0, %xmm0
movaps %xmm0, 0x150(%rsp)
movaps %xmm0, 0x140(%rsp)
movl $0x0, 0x160(%rsp)
movl 0x1b8(%r15), %ebx
testl %ebx, %ebx
jle 0x78690
movq 0x470(%rsp), %r14
movq %r15, 0xa8(%rsp)
leaq 0x60(%r15), %rax
movq %rax, 0xb0(%rsp)
movl %ebp, %eax
movq %rax, 0xb8(%rsp)
leaq 0x170(%rsp), %r15
leaq 0xf8(%rsp), %r12
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movq %r15, %rdi
callq 0x50b12
movq 0x90(%rsp), %rsi
addq %r13, %rsi
movq %r12, %rdi
callq 0xe8f8
movq %r12, %rdi
movq 0xc8(%rsp), %rsi
movq %r15, %rdx
callq 0x50ddc
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x783aa
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0xd0(%rsp)
movl %eax, 0xd8(%rsp)
movq %rax, 0xe0(%rsp)
movl %eax, 0xe8(%rsp)
movq %rax, 0xf0(%rsp)
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq %r15, %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x739cc
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
leaq 0x110(%rsp), %rbx
leaq 0x1d0(%rsp), %r15
je 0x7847c
movl 0x108(%rax), %ebx
movq 0x90(%rsp), %rsi
addq %r13, %rsi
leaq 0x128(%rsp), %r12
movq %r12, %rdi
callq 0xe8f8
movq 0x30(%rsp), %r8
movl $0x10c, %eax            # imm = 0x10C
addq %rax, %r8
movq %r15, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl %ebx, %ecx
callq 0x7eb52
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x7eed4
movq %r15, %rdi
callq 0x7ec22
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x784db
movq 0x138(%rsp), %rsi
jmp 0x784d3
movq 0x90(%rsp), %rsi
addq %r13, %rsi
movq %rbx, %rdi
callq 0xe8f8
movq %r15, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
leaq 0x140(%rsp), %r8
callq 0x7eb52
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x7eed4
movq %r15, %rdi
callq 0x7ec22
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x784db
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x70(%rsp), %r15
movq %r14, %r12
movq 0x50(%rsp), %rbx
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
movq %r15, %rdi
leaq 0xdc7dd(%rip), %rsi     # 0x154cdc
leaq 0xdc7dd(%rip), %rdx     # 0x154ce3
callq 0x22538
addq 0x10(%rsp), %rbx
movq 0xb8(%rsp), %rax
leaq (%rax,%rbp), %r14
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
movq 0xc0(%rsp), %rcx
callq 0x72f6e
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
movq 0x11ca77(%rip), %r15    # 0x194fc0
je 0x7855b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
movl $0x3, %edx
movq %r15, %rdi
leaq 0xdc77a(%rip), %rsi     # 0x154ce4
callq 0x44e0
testq %r12, %r12
je 0x7858c
movq %r12, %rdi
callq 0x41e0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x785a4
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x4710
movl $0x9, %edx
movq %r15, %rdi
leaq 0xdc735(%rip), %rsi     # 0x154ce8
callq 0x44e0
movq %r15, %rdi
movl %r14d, %esi
callq 0x4750
movq %rax, %rbx
movl $0xa, %edx
movq %rax, %rdi
leaq 0xdc71d(%rip), %rsi     # 0x154cf2
callq 0x44e0
movq 0x50(%rsp), %rdi
addq 0x10(%rsp), %rdi
callq 0x78b76
movq %rbx, %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0xdb01e(%rip), %rsi     # 0x15361e
callq 0x44e0
movl %r14d, (%rsp)
movq 0x20(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl %ebp, %r8d
movq %r12, %r9
callq 0x792ee
leaq 0x30(%rsp), %rdi
callq 0x48bbc
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x7864d
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x170(%rsp), %r15
movq %r15, %rdi
callq 0xf10e
incq %rbp
movq 0xa8(%rsp), %rax
movslq 0x1b8(%rax), %rbx
addq $0x18, %r13
addq $0x268, 0x10(%rsp)      # imm = 0x268
cmpq %rbx, %rbp
movq %r12, %r14
leaq 0xf8(%rsp), %r12
jl 0x7835f
leaq 0x50(%rsp), %rdi
callq 0x7eda6
leaq 0x90(%rsp), %rdi
callq 0xf066
movl %ebx, %eax
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11c92e(%rip), %rdi    # 0x194ff0
leaq 0xdc5cf(%rip), %rsi     # 0x154c98
callq 0x4440
leaq 0xdaf49(%rip), %rbx     # 0x15361e
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
leaq 0xdbfe3(%rip), %rsi     # 0x1546ca
movq %rax, %rdi
callq 0x4440
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
movl $0x1, %edi
callq 0x72bc
movq %rax, %rbx
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x78838
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
jmp 0x78838
jmp 0x787ea
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x7ec22
jmp 0x78747
movq %rax, %rbx
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x787ed
movq 0x120(%rsp), %rsi
jmp 0x78793
jmp 0x78798
jmp 0x787ea
movq %rax, %rbx
jmp 0x7877e
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x7ec22
movq 0x128(%rsp), %rdi
testq %rdi, %rdi
je 0x787ed
movq 0x138(%rsp), %rsi
subq %rdi, %rsi
jmp 0x787e3
movq %rax, %rbx
jmp 0x78821
movq %rax, %rbx
jmp 0x78814
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x78814
movq 0x108(%rsp), %rsi
jmp 0x7880c
jmp 0x787ea
jmp 0x787ea
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x787ed
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x787ed
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x48bbc
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x78814
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x170(%rsp), %rdi
callq 0xf10e
leaq 0x50(%rsp), %rdi
callq 0x7eda6
leaq 0x90(%rsp), %rdi
callq 0xf066
movq %rbx, %rdi
callq 0x4780