// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/feature.cc
// Function: FEATURE::createSegments(ATOM_NETWORK*, VORONOI_NETWORK*, DIJKSTRA_NETWORK*, std::basic_fstream<char, std::char_traits<char>>&, int)
int FEATURE::createSegments(ATOM_NETWORK *uc,VORONOI_NETWORK *origVNet, DIJKSTRA_NETWORK *origDNet, std::fstream &output, int initIndex){
    nsegments = 0;
    segments = std::vector<int> ();
    segmentChannel(uc);
    if(nsegments == 0){
        std::cerr << "Error occurred during channel segmentation. No segments were found." << "\n"
        << "Exiting..." << "\n";
        exit(1);
    }
    
    std::vector< std::vector<int> > nodesForSegments = std::vector < std::vector<int> > (nsegments, std::vector<int> ());
    std::vector<CHANNEL> segChannels = std::vector<CHANNEL> ();
    for(unsigned int i = 0; i < segments.size(); i++){
        nodesForSegments[segments[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 < nsegments; i++){
        DIJKSTRA_NETWORK segNet;
        DIJKSTRA_NETWORK::filterDnetEdges(nodesForSegments[i], origVNet, &segNet);
        std::vector<bool> infoStorage; std::vector<CHANNEL> channels;
        findChannels(&segNet, &infoStorage, &channels);
        int dim;
        if(channels.size() != 0){
            dim = channels[0].dimensionality;
            segChannels.push_back(CHANNEL(nodesForSegments[i], origDNet, dim, channels[0].basis));
        }
        else{
            dim = 0;
            segChannels.push_back(CHANNEL(nodesForSegments[i], origDNet, 0, zeroVecs));
        }
        segChannels[i].writeToVMD("segment", initIndex + i, output);
    }
    return nsegments;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movl %r9d, %ebx
movq %r8, 0x90(%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, 0x98(%rsp)
movq %rsi, %r14
movq %rdi, %r12
movl $0x0, 0x138(%rdi)
movq 0x140(%rdi), %rdi
movq 0x150(%r12), %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x140(%r12)
movq $0x0, 0x150(%r12)
testq %rdi, %rdi
je 0x7a2bb
subq %rdi, %rsi
callq 0x4470
movq %r12, %rdi
movq %r14, %rsi
callq 0x78840
movslq 0x138(%r12), %rsi
testq %rsi, %rsi
je 0x7a77c
xorps %xmm0, %xmm0
leaq 0x140(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq 0x48(%rsp), %rdi
leaq 0x278(%rsp), %rcx
callq 0x6757e
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x7a31c
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x140(%r12), %rax
cmpq %rax, 0x148(%r12)
je 0x7a3dd
leaq 0x140(%r12), %r14
leaq 0x38(%r12), %r15
xorl %r13d, %r13d
movq 0x40(%r12), %rsi
movq %r15, %rdx
testq %rsi, %rsi
je 0x7a38d
movq %r15, %rcx
xorl %edx, %edx
cmpl %r13d, 0x20(%rsi)
setl %dl
cmovgeq %rsi, %rcx
movq 0x10(%rsi,%rdx,8), %rsi
testq %rsi, %rsi
jne 0x7a363
movq %r15, %rdx
cmpq %r15, %rcx
je 0x7a38d
cmpl 0x20(%rcx), %r13d
cmovlq %r15, %rcx
movq %rcx, %rdx
movslq (%rax,%r13,4), %rcx
leaq (%rcx,%rcx,2), %rdi
shlq $0x3, %rdi
addq 0x48(%rsp), %rdi
addq $0x24, %rdx
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x7a3ba
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x7a3c2
callq 0xf864
movq (%r14), %rax
incl %r13d
movq 0x148(%r12), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
ja 0x7a353
xorps %xmm0, %xmm0
movaps %xmm0, 0x120(%rsp)
movaps %xmm0, 0x110(%rsp)
movl $0x0, 0x130(%rsp)
movl 0x138(%r12), %r14d
testl %r14d, %r14d
jle 0x7a753
movq %r12, 0x80(%rsp)
leaq 0x140(%rsp), %rax
addq $0xa8, %rax
movq %rax, (%rsp)
movl %ebx, %eax
movq %rax, 0x88(%rsp)
leaq 0x278(%rsp), %r15
leaq 0xa0(%rsp), %r12
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x50b12
movq %r15, %r14
movq 0x48(%rsp), %rsi
addq %r13, %rsi
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
callq 0xe8f8
movq %r15, %rdi
movq 0x98(%rsp), %rsi
movq %r14, %r15
movq %r14, %rdx
callq 0x50ddc
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
leaq 0x140(%rsp), %r14
je 0x7a4a5
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0xb8(%rsp)
movl %eax, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
movl %eax, 0xd0(%rsp)
movq %rax, 0xd8(%rsp)
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %r15, %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x739cc
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x7a5ce
movl 0x108(%rax), %r14d
movq 0x48(%rsp), %rsi
addq %r13, %rsi
movq %r12, %rdi
callq 0xe8f8
movq %r12, %rsi
movq 0x10(%rsp), %r8
movl $0x10c, %eax            # imm = 0x10C
addq %rax, %r8
leaq 0x140(%rsp), %r12
movq %r12, %rdi
movq 0x8(%rsp), %rdx
movl %r14d, %ecx
callq 0x7edf0
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x774f4
movq (%rsp), %rdi
callq 0xf066
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a571
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x7a58e
movq 0x1c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x1a0(%rsp), %rdi
callq 0xf10e
leaq 0x170(%rsp), %rdi
callq 0xf1b6
movq %r12, %rdi
callq 0xf1b6
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a68f
movq 0xb0(%rsp), %rsi
jmp 0x7a687
movq 0x48(%rsp), %rsi
addq %r13, %rsi
leaq 0xe0(%rsp), %r12
movq %r12, %rdi
callq 0xe8f8
movq %r14, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rdx
xorl %ecx, %ecx
leaq 0x110(%rsp), %r8
callq 0x7edf0
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x774f4
movq (%rsp), %rdi
callq 0xf066
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a633
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x7a650
movq 0x1c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x1a0(%rsp), %rdi
callq 0xf10e
leaq 0x170(%rsp), %rdi
callq 0xf1b6
movq %r14, %rdi
callq 0xf1b6
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a68f
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %r14
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x60(%rsp), %r12
movq %r12, %rdi
leaq 0xda694(%rip), %rsi     # 0x154d41
leaq 0xda694(%rip), %rdx     # 0x154d48
callq 0x22538
addq %rbp, %r14
movq 0x88(%rsp), %rax
leal (%rax,%rbx), %edx
movq %r14, %rdi
movq %r12, %rsi
movq 0x90(%rsp), %rcx
callq 0x72f6e
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
leaq 0xa0(%rsp), %r12
je 0x7a6fe
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x10(%rsp), %rdi
callq 0x48bbc
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x7a725
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %r15, %rdi
callq 0xf10e
incq %rbx
movq 0x80(%rsp), %rax
movslq 0x138(%rax), %r14
addq $0x18, %r13
addq $0x130, %rbp            # imm = 0x130
cmpq %r14, %rbx
jl 0x7a447
leaq 0x30(%rsp), %rdi
callq 0x48bbc
leaq 0x48(%rsp), %rdi
callq 0xf066
movl %r14d, %eax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11a86d(%rip), %rdi    # 0x194ff0
leaq 0xda573(%rip), %rsi     # 0x154cfd
callq 0x4440
leaq 0xd8e88(%rip), %rbx     # 0x15361e
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
leaq 0xd9f22(%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 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x7a8e5
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
jmp 0x7a8e5
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x7602c
jmp 0x7a803
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a89d
movq 0xf0(%rsp), %rsi
jmp 0x7a84e
jmp 0x7a879
jmp 0x7a853
jmp 0x7a879
movq %rax, %rbx
jmp 0x7a839
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x7602c
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a89d
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
jmp 0x7a898
movq %rax, %rbx
jmp 0x7a8d1
movq %rax, %rbx
jmp 0x7a8c4
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x7a8c4
movq 0x108(%rsp), %rsi
jmp 0x7a8bc
jmp 0x7a879
movq %rax, %rbx
jmp 0x7a89d
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x7a89d
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x10(%rsp), %rdi
callq 0x48bbc
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x7a8c4
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x278(%rsp), %rdi
callq 0xf10e
leaq 0x30(%rsp), %rdi
callq 0x48bbc
leaq 0x48(%rsp), %rdi
callq 0xf066
movq %rbx, %rdi
callq 0x4780
nop