// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/channel.cc
// Function: PORE::reconstruct()
void PORE::reconstruct(){
    vector<bool> haveVisited = vector<bool>(nodes.size(),false);
    vector<DELTA_POS> displacements = vector<DELTA_POS>(nodes.size());
    unsigned int visitCount = 0;
    
    //Search through the PORE, emphasizing nodes located in the current unit
    //cell or in previously visited unit cells. Record the unit cell within which
    //each node is encountered
    comparer = ReconstructorComparator();
    HEAP< pair<int,DELTA_POS> > stack (compareNodes);
    stack.insert(pair<int,DELTA_POS> (0, DELTA_POS(0,0,0))); // Pick the first node as the starting point
    DELTA_POS curPos = DELTA_POS(0,0,0);
    
    // Continue reconstruction until all nodes have been visited
    while(visitCount < nodes.size()){
        if(stack.size() == 0){
            cerr << "Error: Stack empties prior to pore reconstruction completion." << "\n"
            << "Please contact the source code provided with this message." << "\n"
            << "Exiting..." << "\n"
            << "Nnodes = " << nodes.size() << "  visitCount= " << visitCount << "\n";
            
            exit(1);
        }
        
        pair<int,DELTA_POS> best = stack.pop();
        
        if(!haveVisited.at(best.first)){
            visitCount++;
            haveVisited.at(best.first) = true;
            displacements.at(best.first) = best.second;
            
            // If changed unit cell, need to restructure heap
            if(!best.second.equals(curPos)){
                comparer.setPosition(best.second);
                stack.reHeapify();
                curPos = best.second;
            }
            
            // Add all the nodes from the current node to the stack that
            // have not yet been visited
            DIJKSTRA_NODE curNode = nodes.at(best.first);
            for(unsigned int j = 0; j < curNode.connections.size(); j++){
                CONN curConn = curNode.connections.at(j);
                if(!haveVisited.at(curConn.to)){
                    DELTA_POS newPos = curPos + curConn.deltaPos;
                    stack.insert(pair<int,DELTA_POS>(curConn.to,newPos));
                }
            }
        }
    }
    
    map<DELTA_POS, vector<int> ,  bool(*)(DELTA_POS,DELTA_POS)> results (fn_pt);
    
    //Store the list of nodes and unit cells in a usable format
    for(unsigned int i = 0; i < nodes.size(); i++){
        map<DELTA_POS, vector<int> >::iterator iter = results.find(displacements.at(i));
        if(iter == results.end()){
            vector<int> newList; newList.push_back(i);
            results.insert(pair<DELTA_POS, vector<int> > (displacements.at(i),newList));
        }
        else
            iter->second.push_back(i);
    }
    
    // Copy the unit cells visited and their corresponding node ids to intrinsic
    // data structures
    map<DELTA_POS, vector<int> >::iterator rIter = results.begin();
    while(rIter != results.end()){
        unitCells.push_back(rIter->first);
        ucNodes.push_back(rIter->second);
        rIter++;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
movq 0x68(%rdi), %rsi
subq 0x60(%rdi), %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %r14 # imm = 0x8E38E38E38E38E39
imulq %r14, %rsi
leaq 0xc0(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rcx
callq 0x383b0
movq 0x68(%rbx), %rsi
subq 0x60(%rbx), %rsi
sarq $0x3, %rsi
imulq %r14, %rsi
leaq 0x80(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x768c2
leaq 0xc0(%rsp), %rdi
callq 0x73180
leaq 0xd0(%rsp), %r14
movl -0x8(%r14), %eax
movl %eax, 0x12750b(%rip)    # 0x197730
movq -0x10(%r14), %rax
movq %rax, 0x1274f8(%rip)    # 0x197728
movq (%r14), %rax
movq %rax, 0x1274fe(%rip)    # 0x197738
leaq 0x1274f7(%rip), %rdi    # 0x197738
callq 0x76f4c
movq 0x10(%r14), %rax
testq %rax, %rax
je 0x70299
leaq 0xd8(%rsp), %rcx
movl (%rcx), %edx
movl %edx, 0x1274e1(%rip)    # 0x197740
leaq 0x1274da(%rip), %rdx    # 0x197740
movq %rax, 0x1274db(%rip)    # 0x197748
movups 0x10(%rcx), %xmm0
movups %xmm0, 0x1274d8(%rip)   # 0x197750
movq %rdx, 0x8(%rax)
movq 0x20(%rcx), %rax
movq %rax, 0x1274d9(%rip)    # 0x197760
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq %r14, %rdi
callq 0x39430
leaq 0x30a3(%rip), %rsi      # 0x7334b
leaq 0x30(%rsp), %rdi
callq 0x76954
leaq 0xc0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
movq 0xc4(%rsp), %rdx
movl 0xc0(%rsp), %esi
shlq $0x20, %rsi
leaq 0x30(%rsp), %rdi
callq 0x76996
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
movq 0x68(%rbx), %rax
cmpq 0x60(%rbx), %rax
je 0x706f3
movabsq $0xffffffff0, %r12      # imm = 0xFFFFFFFF0
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
xorl %r13d, %r13d
testq %r12, %rax
je 0x709e7
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
callq 0x76a00
movq %rax, (%rsp)
movq %rdx, 0x8(%rsp)
movslq %eax, %rsi
leaq 0x98(%rsp), %rdi
callq 0xedb6
testq %rdx, (%rax)
jne 0x705b1
movslq (%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0xedb6
orq %rdx, (%rax)
movslq (%rsp), %rsi
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x709cb
leaq (%rsi,%rsi,2), %rcx
leaq 0x4(%rsp), %rdi
movl 0x8(%rdi), %edx
movl %edx, 0x8(%rax,%rcx,4)
movq (%rdi), %rdx
movq %rdx, (%rax,%rcx,4)
movq 0x20(%rsp), %rsi
movl 0x28(%rsp), %edx
callq 0x509e2
testb %al, %al
jne 0x70442
movq 0x4(%rsp), %rax
movl 0xc(%rsp), %ecx
movq %rax, 0xc0(%rsp)
movl %ecx, 0xc8(%rsp)
leaq 0x127357(%rip), %rdi    # 0x197738
leaq 0xc0(%rsp), %rsi
callq 0x3c878
movl 0xc8(%rsp), %eax
movl %eax, 0x127335(%rip)    # 0x197730
movq 0xc0(%rsp), %rax
movq %rax, 0x12731e(%rip)    # 0x197728
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x48(%rsp), %rax
movq %rax, 0xc0(%rsp)
leaq 0xc0(%rsp), %rdx
callq 0x77db8
leaq 0x4(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x20(%rsp)
movl 0x8(%rcx), %eax
movl %eax, 0x28(%rsp)
movslq (%rsp), %rsi
movq 0x60(%rbx), %r14
movq 0x68(%rbx), %rdx
subq %r14, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rax # imm = 0x8E38E38E38E38E39
imulq %rax, %rdx
cmpq %rsi, %rdx
jbe 0x709d9
movq %r13, %r15
movq %r12, %r13
leaq (%rsi,%rsi,8), %r12
leaq (%r14,%r12,8), %rsi
addq $0x20, %rsi
movups -0x20(%rsi), %xmm0
movups -0x10(%rsi), %xmm1
movaps %xmm1, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
leaq 0xe0(%rsp), %rbp
movq %rbp, %rdi
callq 0x38318
leaq (%r14,%r12,8), %rax
movb 0x40(%rax), %cl
movb %cl, 0x20(%rbp)
movq 0x38(%rax), %rax
movq %rax, 0x18(%rbp)
movq 0xe0(%rsp), %rdi
cmpq %rdi, 0xe8(%rsp)
je 0x7058e
movl $0x1, %r14d
xorl %eax, %eax
movq %r13, %r12
movq %r15, %r13
leaq 0x68(%rsp), %r15
leaq 0x30(%rsp), %rbp
leaq (%rax,%rax,4), %rax
movups (%rdi,%rax,8), %xmm0
movups 0x10(%rdi,%rax,8), %xmm1
movaps %xmm0, 0x50(%rsp)
movq 0x20(%rdi,%rax,8), %rax
movq %rax, 0x70(%rsp)
movaps %xmm1, 0x60(%rsp)
movslq 0x54(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0xedb6
testq %rdx, (%rax)
jne 0x70558
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x50a30
movq %rax, 0x108(%rsp)
movl %edx, 0x110(%rsp)
movl 0x54(%rsp), %ecx
movq 0x10c(%rsp), %rdx
shlq $0x20, %rax
orq %rcx, %rax
movq %rbp, %rdi
movq %rax, %rsi
callq 0x76996
movl %r14d, %eax
movq 0xe0(%rsp), %rdi
movq 0xe8(%rsp), %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdx, %rcx
incl %r14d
cmpq %rax, %rcx
ja 0x704e6
jmp 0x70599
movq %r13, %r12
movq %r15, %r13
leaq 0x30(%rsp), %rbp
testq %rdi, %rdi
je 0x705ae
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
incl %r13d
movq 0x68(%rbx), %rax
subq 0x60(%rbx), %rax
movl %r13d, %r14d
sarq $0x3, %rax
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rax
cmpq %r14, %rax
jbe 0x706f3
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
testq %r12, %rax
jne 0x70325
movq 0x1269ff(%rip), %rdi    # 0x196ff0
leaq 0xe62ef(%rip), %rsi     # 0x1568e7
movl $0x3d, %edx
callq 0x44e0
movq 0x1269e7(%rip), %rdi    # 0x196ff0
leaq 0xe4f1e(%rip), %rsi     # 0x15552e
movl $0x1, %edx
callq 0x44e0
movq 0x1269cf(%rip), %rdi    # 0x196ff0
leaq 0xe62fd(%rip), %rsi     # 0x156925
movl $0x3a, %edx
callq 0x44e0
movq 0x1269b7(%rip), %rdi    # 0x196ff0
leaq 0xe4eee(%rip), %rsi     # 0x15552e
movl $0x1, %edx
callq 0x44e0
movq 0x12699f(%rip), %rdi    # 0x196ff0
leaq 0xe5f5a(%rip), %rsi     # 0x1565b2
movl $0xa, %edx
callq 0x44e0
movq 0x126987(%rip), %rdi    # 0x196ff0
leaq 0xe4ebe(%rip), %rsi     # 0x15552e
movl $0x1, %edx
callq 0x44e0
movq 0x12696f(%rip), %rdi    # 0x196ff0
leaq 0xe62d8(%rip), %rsi     # 0x156960
movl $0x9, %edx
callq 0x44e0
movq 0x68(%rbx), %rsi
subq 0x60(%rbx), %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %rax # imm = 0x8E38E38E38E38E39
imulq %rax, %rsi
movq 0x12693d(%rip), %rdi    # 0x196ff0
callq 0x42b0
movq %rax, %rbx
leaq 0xe62a8(%rip), %rsi     # 0x15696a
movl $0xe, %edx
movq %rax, %rdi
callq 0x44e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42b0
leaq 0xe4e4d(%rip), %rsi     # 0x15552e
movq %rax, %rdi
callq 0x4440
movl $0x1, %edi
callq 0x710c
movq 0x126d5e(%rip), %rax    # 0x197458
leaq 0xc8(%rsp), %r13
movq %rax, -0x8(%r13)
movl $0x0, (%r13)
xorl %eax, %eax
movq %rax, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
movq %rax, 0x20(%r13)
movq 0x68(%rbx), %rax
cmpq 0x60(%rbx), %rax
je 0x708a8
movl $0x1, %r12d
xorl %ebp, %ebp
leaq 0xc0(%rsp), %r15
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x709a9
leaq (,%rbp,2), %r14
addq %rbp, %r14
leaq (%rax,%r14,4), %rsi
movq %r15, %rdi
callq 0x77e32
leal -0x1(%r12), %ecx
cmpq %r13, %rax
je 0x707aa
movl %ecx, 0x50(%rsp)
movq 0x38(%rax), %rsi
cmpq 0x40(%rax), %rsi
je 0x707d5
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rax)
jmp 0x7087f
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl %ecx, 0x50(%rsp)
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x707eb
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x707f8
addq $0x30, %rax
movq %rax, %rdi
leaq 0x50(%rsp), %rdx
callq 0x1422c
jmp 0x7087f
movq %rsp, %rdi
leaq 0x50(%rsp), %rdx
callq 0x1422c
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x709ba
movl 0x8(%rax,%r14,4), %ecx
movl %ecx, 0x58(%rsp)
movq (%rax,%r14,4), %rax
movq %rax, 0x50(%rsp)
leaq 0x60(%rsp), %rdi
movq %rsp, %rsi
callq 0xe886
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
callq 0x77ea6
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x70869
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x7087f
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movl %r12d, %ebp
movq 0x68(%rbx), %rax
subq 0x60(%rbx), %rax
sarq $0x3, %rax
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rax
incl %r12d
cmpq %rbp, %rax
ja 0x7073e
movq 0xd8(%rsp), %r14
cmpq %r13, %r14
je 0x70911
leaq 0x90(%rbx), %r15
leaq 0xa8(%rbx), %r12
leaq 0x20(%r14), %rdx
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0x708ed
movl 0x8(%rdx), %eax
movl %eax, 0x8(%rsi)
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0xc, 0x98(%rbx)
jmp 0x708f5
movq %r15, %rdi
callq 0x78056
leaq 0x30(%r14), %rsi
movq %r12, %rdi
callq 0xefae
movq %r14, %rdi
callq 0x42d0
movq %rax, %r14
cmpq %r13, %rax
jne 0x708c3
leaq 0xc0(%rsp), %rdi
callq 0x76f7a
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x70935
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x70952
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x70997
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x98(%rsp)
movl %eax, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
movl %eax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdecf5(%rip), %rdi     # 0x14f6a5
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xdece4(%rip), %rdi     # 0x14f6a5
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xdecd3(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
leaq 0xdecc5(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
xorl %r14d, %r14d
jmp 0x705ea
movq %rax, %rbx
jmp 0x70a9e
movq %rax, %rbx
jmp 0x70abb
jmp 0x70a60
jmp 0x70a2b
jmp 0x70a4e
jmp 0x70a60
jmp 0x70a60
jmp 0x70a60
jmp 0x70a60
jmp 0x70a2b
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x70a2e
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
jmp 0x70a2e
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x70a51
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
jmp 0x70a51
jmp 0x70a60
jmp 0x70a4e
jmp 0x70a4e
jmp 0x70a60
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x76f7a
jmp 0x70a87
movq %rax, %rbx
jmp 0x70a87
jmp 0x70a67
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x70a87
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x70a9e
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x70abb
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x70b00
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x98(%rsp)
movl %eax, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
movl %eax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movq %rbx, %rdi
callq 0x4780