// File: /workspace/github_cpp_makefile_star2_O2/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, %r12d
movq %r8, 0x90(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x98(%rsp)
movq %rdi, %r15
andl $0x0, 0x1b8(%rdi)
movq %rsi, %rbx
addq $0x1c0, %rdi            # imm = 0x1C0
xorps %xmm0, %xmm0
leaq 0x1c0(%rsp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
movq %r14, %rsi
callq 0xed62
movq %r14, %rdi
callq 0xb290
leaq 0x1d8(%r15), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq 0x1c0(%rsp), %r14
movq %rdi, 0x78(%rsp)
movq %r14, %rsi
callq 0xed62
movq %r14, %rdi
callq 0xb290
movq %r15, %rdi
movq %rbx, 0x80(%rsp)
movq %rbx, %rsi
callq 0x5a39c
movq %r15, 0x8(%rsp)
movslq 0x1b8(%r15), %rsi
testq %rsi, %rsi
je 0x5a281
leaq 0x1c0(%rsp), %rdx
xorps %xmm0, %xmm0
movaps %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
leaq 0x58(%rsp), %rdi
leaq 0x160(%rsp), %rcx
callq 0x4b956
leaq 0x1c0(%rsp), %r14
movq %r14, %rdi
callq 0xb290
movq 0x8(%rsp), %rax
leaq 0x30(%rax), %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
xorl %ebp, %ebp
movl %ebp, %eax
movq 0x8(%rsp), %rdx
movq 0x1d8(%rdx), %rcx
movq 0x1e0(%rdx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0x59f6d
movslq (%rcx,%rax,4), %rbx
movq 0x58(%rsp), %r13
movl %ebp, 0x1c0(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x10996
imulq $0x18, %rbx, %rcx
addq %rcx, %r13
addq $0x24, %rax
movq %r13, %rdi
movq %rax, %rsi
callq 0x9434
incl %ebp
jmp 0x59f17
xorps %xmm0, %xmm0
leaq 0x130(%rsp), %rax
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
andl $0x0, 0x20(%rax)
movq 0x8(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x70(%rsp)
movl %r12d, %eax
movq %rax, 0x88(%rsp)
xorl %r15d, %r15d
leaq 0xc8(%rsp), %r14
movq $0x0, 0x10(%rsp)
xorl %ebx, %ebx
movq 0x8(%rsp), %rax
movslq 0x1b8(%rax), %r13
cmpq %r13, %rbx
jge 0x5a258
leaq 0x160(%rsp), %rdi
callq 0x3d70e
movq 0x58(%rsp), %rsi
addq 0x10(%rsp), %rsi
leaq 0xf8(%rsp), %rbp
movq %rbp, %rdi
callq 0xa6ce
movq %rbp, %rdi
movq 0x98(%rsp), %rsi
leaq 0x160(%rsp), %r13
movq %r13, %rdx
callq 0x3d90c
movq %rbp, %rdi
callq 0xb290
andq $0x0, 0xa0(%rsp)
andl $0x0, 0xa8(%rsp)
andq $0x0, 0xb0(%rsp)
andl $0x0, 0xb8(%rsp)
andq $0x0, 0xc0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq %r13, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x55ab0
movq 0x20(%rsp), %rax
cmpq %rax, 0x28(%rsp)
je 0x5a0ce
movl 0x108(%rax), %r13d
movq 0x58(%rsp), %rsi
addq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xa6ce
movq 0x20(%rsp), %r8
movl $0x10c, %eax            # imm = 0x10C
addq %rax, %r8
leaq 0x1c0(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq 0x18(%rsp), %rdx
movl %r13d, %ecx
callq 0x5f0b4
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x5f3c8
movq %r15, %r14
movq %r12, %rdi
callq 0x5f166
leaq 0xc8(%rsp), %rdi
jmp 0x5a12a
movq 0x58(%rsp), %rsi
addq 0x10(%rsp), %rsi
leaq 0xe0(%rsp), %r13
movq %r13, %rdi
callq 0xa6ce
leaq 0x1c0(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
leaq 0x130(%rsp), %r8
callq 0x5f0b4
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x5f3c8
movq %r15, %r14
movq %r12, %rdi
callq 0x5f166
leaq 0xe0(%rsp), %rdi
callq 0xb290
movq 0x40(%rsp), %rbp
leaq 0x110(%rsp), %r15
movq %r15, %rdi
leaq 0xa9aee(%rip), %rsi     # 0x103c34
movq %r12, %rdx
callq 0x1b80e
addq %r14, %rbp
movq 0x88(%rsp), %rax
leaq (%rax,%rbx), %r13
movq %rbp, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq 0x90(%rsp), %rcx
callq 0x552c0
movq %r15, %rdi
callq 0x4210
movq 0xf5e3e(%rip), %rdi     # 0x14ffc0
leaq 0xa9ab3(%rip), %rsi     # 0x103c3c
callq 0x4480
movq %r14, %r15
movq %rax, %rdi
movq 0x460(%rsp), %rsi
callq 0x4480
movq %rax, %rdi
leaq 0xa9a95(%rip), %rsi     # 0x103c40
callq 0x4480
movq %rax, %rdi
movl %r13d, %esi
callq 0x4760
movq %rax, %rdi
leaq 0xa9a85(%rip), %rsi     # 0x103c4a
callq 0x4480
movq %rax, %rbp
movq 0x40(%rsp), %rdi
addq %r15, %rdi
callq 0x5a5d4
movq %rbp, %rdi
callq 0x46c0
movq %rax, %rdi
leaq 0xa8392(%rip), %rsi     # 0x10257e
callq 0x4480
movl %r13d, (%rsp)
movq 0x80(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x78(%rsp), %rcx
movl %ebx, %r8d
movq 0x460(%rsp), %r9
callq 0x5abd6
leaq 0x20(%rsp), %rdi
callq 0x37062
leaq 0xa0(%rsp), %rdi
callq 0xa976
leaq 0x160(%rsp), %rdi
callq 0xae22
incq %rbx
addq $0x18, 0x10(%rsp)
addq $0x268, %r15            # imm = 0x268
leaq 0xc8(%rsp), %r14
jmp 0x59fb2
leaq 0x40(%rsp), %rdi
callq 0x5f204
leaq 0x58(%rsp), %rdi
callq 0xad7e
movl %r13d, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xf5d68(%rip), %rdi     # 0x14fff0
leaq 0xa9961(%rip), %rsi     # 0x103bf0
callq 0x4480
leaq 0xa82e3(%rip), %rbx     # 0x10257e
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4480
leaq 0xa9375(%rip), %rsi     # 0x103622
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4480
pushq $0x1
popq %rdi
callq 0x524c
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0xb290
jmp 0x5a393
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x5f166
jmp 0x5a2f4
jmp 0x5a358
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0x5a31b
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x5f166
jmp 0x5a313
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xb290
jmp 0x5a35b
jmp 0x5a358
jmp 0x5a353
jmp 0x5a358
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0xb290
jmp 0x5a372
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x4210
jmp 0x5a35b
movq %rax, %rbx
jmp 0x5a372
jmp 0x5a358
movq %rax, %rbx
jmp 0x5a37f
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x37062
leaq 0xa0(%rsp), %rdi
callq 0xa976
leaq 0x160(%rsp), %rdi
callq 0xae22
leaq 0x40(%rsp), %rdi
callq 0x5f204
leaq 0x58(%rsp), %rdi
callq 0xad7e
movq %rbx, %rdi
callq 0x4780
nop