// File: /workspace/github_cpp_makefile_star2_O1/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 $0x428, %rsp            # imm = 0x428
movl %r9d, %ebp
movq %r8, 0xd8(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, 0xe0(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, %r15
movl $0x0, 0x1b8(%rdi)
addq $0x1c0, %rdi            # imm = 0x1C0
xorps %xmm0, %xmm0
leaq 0x1c0(%rsp), %rbx
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq %rbx, %rsi
callq 0x12d52
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x79128
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x1d8(%r15), %rdi
leaq 0x1c0(%rsp), %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq %rdi, 0xd0(%rsp)
movq %rbx, %rsi
callq 0x12d52
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x7916d
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %r15, %rdi
movq 0x40(%rsp), %rsi
callq 0x79812
movslq 0x1b8(%r15), %rsi
testq %rsi, %rsi
je 0x7966c
xorps %xmm0, %xmm0
leaq 0x1c0(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq 0xa8(%rsp), %rdi
leaq 0x160(%rsp), %rcx
callq 0x67eb0
movq 0x1c0(%rsp), %rdi
testq %rdi, %rdi
je 0x791d2
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
movq 0x1d8(%r15), %rax
cmpq %rax, 0x1e0(%r15)
je 0x79291
leaq 0x38(%r15), %rbx
xorl %r14d, %r14d
movq 0x40(%r15), %rdx
movq %rbx, %rcx
testq %rdx, %rdx
je 0x79228
movq %rbx, %rcx
xorl %esi, %esi
cmpl %r14d, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x79210
movq %rbx, %rdx
cmpq %rbx, %rcx
je 0x7923b
cmpl 0x20(%rcx), %r14d
cmovlq %rbx, %rcx
movq %rcx, %rdx
movslq (%rax,%r14,4), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x3, %rdi
addq 0xa8(%rsp), %rdi
addq $0x24, %rdx
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x7926b
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x79270
callq 0xf7b4
incl %r14d
movq 0x1d8(%r15), %rax
movq 0x1e0(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x79201
xorps %xmm0, %xmm0
movaps %xmm0, 0x140(%rsp)
movaps %xmm0, 0x130(%rsp)
movl $0x0, 0x150(%rsp)
movl 0x1b8(%r15), %ebx
testl %ebx, %ebx
jle 0x79641
movq 0x460(%rsp), %r12
movq %r15, 0xc0(%rsp)
leaq 0x60(%r15), %rax
movq %rax, 0xc8(%rsp)
movl %ebp, %eax
movq %rax, 0x48(%rsp)
leaq 0x160(%rsp), %r15
leaq 0xe8(%rsp), %rbp
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x50e9e
movq 0xa8(%rsp), %rsi
addq %r13, %rsi
movq %rbp, %rdi
callq 0xe886
movq %rbp, %rdi
movq 0xe0(%rsp), %rsi
movq %r15, %rdx
callq 0x51180
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x7934b
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movq %rax, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x746d0
movq 0x50(%rsp), %rax
cmpq %rax, 0x58(%rsp)
leaq 0x100(%rsp), %rbx
leaq 0x1c0(%rsp), %r15
je 0x7940b
movl 0x108(%rax), %ebx
movq 0xa8(%rsp), %rsi
addq %r13, %rsi
leaq 0x118(%rsp), %rbp
movq %rbp, %rdi
callq 0xe886
movq 0x50(%rsp), %r8
movl $0x10c, %eax            # imm = 0x10C
addq %rax, %r8
movq %r15, %rdi
movq %rbp, %rsi
movq 0x38(%rsp), %rdx
movl %ebx, %ecx
callq 0x7fcf6
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x80070
movq %r15, %rdi
callq 0x7fdc6
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0x7946a
movq 0x128(%rsp), %rsi
jmp 0x79462
movq 0xa8(%rsp), %rsi
addq %r13, %rsi
movq %rbx, %rdi
callq 0xe886
movq %r15, %rdi
movq %rbx, %rsi
movq 0x38(%rsp), %rdx
xorl %ecx, %ecx
leaq 0x130(%rsp), %r8
callq 0x7fcf6
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x80070
movq %r15, %rdi
callq 0x7fdc6
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x7946a
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x88(%rsp), %r15
movq %r12, %rbp
movq 0x70(%rsp), %rbx
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %r15, %rdi
leaq 0xdd730(%rip), %rsi     # 0x156bc4
leaq 0xdd730(%rip), %rdx     # 0x156bcb
callq 0x2263c
addq 0x8(%rsp), %rbx
movq 0x48(%rsp), %rax
leaq (%rax,%r14), %r12
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movq 0xd8(%rsp), %rcx
callq 0x73c72
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
movq 0x11dae2(%rip), %r15    # 0x196fc0
je 0x794f0
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x4470
movl $0x3, %edx
movq %r15, %rdi
leaq 0xdd6cd(%rip), %rsi     # 0x156bcc
callq 0x44e0
testq %rbp, %rbp
je 0x79521
movq %rbp, %rdi
callq 0x41e0
movq %r15, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x79539
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 0xdd688(%rip), %rsi     # 0x156bd0
callq 0x44e0
movq 0x48(%rsp), %rax
leal (%rax,%r14), %esi
movq %r15, %rdi
callq 0x4750
movq %rax, %rbx
movl $0xa, %edx
movq %rax, %rdi
leaq 0xdd66a(%rip), %rsi     # 0x156bda
callq 0x44e0
movq 0x70(%rsp), %rdi
addq 0x8(%rsp), %rdi
callq 0x79b3c
movq %rbx, %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0xdbf93(%rip), %rsi     # 0x15552e
callq 0x44e0
movl %r12d, (%rsp)
movq 0x40(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movl %r14d, %r8d
movq %rbp, %r9
callq 0x7a310
leaq 0x50(%rsp), %rdi
callq 0x494b0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x795fe
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movq %rax, 0x30(%rsp)
leaq 0x160(%rsp), %r15
movq %r15, %rdi
callq 0xf07c
incq %r14
movq 0xc0(%rsp), %rax
movslq 0x1b8(%rax), %rbx
addq $0x18, %r13
addq $0x268, 0x8(%rsp)       # imm = 0x268
cmpq %rbx, %r14
movq %rbp, %r12
leaq 0xe8(%rsp), %rbp
jl 0x79300
leaq 0x70(%rsp), %rdi
callq 0x7ff4a
leaq 0xa8(%rsp), %rdi
callq 0xefda
movl %ebx, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11d97d(%rip), %rdi    # 0x196ff0
leaq 0xdd506(%rip), %rsi     # 0x156b80
callq 0x4440
leaq 0xdbea8(%rip), %rbx     # 0x15552e
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
leaq 0xdcf1a(%rip), %rsi     # 0x1565b2
movq %rax, %rdi
callq 0x4440
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
movl $0x1, %edi
callq 0x710c
movq %rax, %rbx
movq 0x1c0(%rsp), %rdi
testq %rdi, %rdi
je 0x7980a
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
jmp 0x7980a
jmp 0x797a9
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x7fdc6
jmp 0x796f8
movq %rax, %rbx
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x797ac
movq 0x110(%rsp), %rsi
jmp 0x79744
jmp 0x79749
jmp 0x797a9
movq %rax, %rbx
jmp 0x7972f
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x7fdc6
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0x797ac
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
jmp 0x797a2
movq %rax, %rbx
jmp 0x797f3
movq %rax, %rbx
jmp 0x797e6
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x797e6
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
jmp 0x797e6
jmp 0x797a9
jmp 0x797a9
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x797ac
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x797ac
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x494b0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x797e6
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movq %rax, 0x30(%rsp)
leaq 0x160(%rsp), %rdi
callq 0xf07c
leaq 0x70(%rsp), %rdi
callq 0x7ff4a
leaq 0xa8(%rsp), %rdi
callq 0xefda
movq %rbx, %rdi
callq 0x4780