// File: Luthaf[P]zeopp/channel.cc
// Function: PORE::PORE(std::vector<int, std::allocator<int>>, DIJKSTRA_NETWORK*, int, int (*) [3])
PORE::PORE(vector<int> nodeIDs, DIJKSTRA_NETWORK *dnet, int dim, int basisVecs[3][3]){
    idMappings = map<int,int> ();
    reverseIDMappings = map<int,int> ();
    nodes = vector<DIJKSTRA_NODE> ();
    connections = vector<CONN> ();
    
    // Reindex the nodes to facilitate storage
    for(unsigned int i = 0; i < nodeIDs.size(); i++){
        idMappings.insert(pair<int,int>(nodeIDs.at(i),i));
        reverseIDMappings.insert(pair<int,int>(i,nodeIDs.at(i)));
    }
    
    // Iterate over all nodes in list
    for(unsigned int i = 0; i < nodeIDs.size(); i++){
        DIJKSTRA_NODE oldNode = dnet->nodes.at(nodeIDs.at(i));
        DIJKSTRA_NODE newNode = DIJKSTRA_NODE(i, oldNode.x, oldNode.y, oldNode.z, oldNode.max_radius);
        
        // Include connection only if end node is in pore
        // Reindex connection start and end ids
        for(unsigned int j = 0; j < oldNode.connections.size(); j++){
            CONN oldConn = oldNode.connections.at(j);
            map<int,int>::iterator id1Iter = idMappings.find(oldConn.from);
            map<int,int>::iterator id2Iter = idMappings.find(oldConn.to);
            if(id2Iter != idMappings.end()){
                CONN newConn = CONN(id1Iter->second,id2Iter->second,oldConn.length,oldConn.max_radius,oldConn.deltaPos);
                newNode.connections.push_back(newConn);
                connections.push_back(newConn);
            }
        }
        nodes.push_back(newNode);
    }
    
    basis[0][0] = basisVecs[0][0];  basis[0][1] = basisVecs[0][1];  basis[0][2] = basisVecs[0][2];
    basis[1][0] = basisVecs[1][0];  basis[1][1] = basisVecs[1][1];  basis[1][2] = basisVecs[1][2];
    basis[2][0] = basisVecs[2][0];  basis[2][1] = basisVecs[2][1];  basis[2][2] = basisVecs[2][2];
    dimensionality = dim;
    
    // Store unit cell vectors
    v_a = dnet->v_a;
    v_b = dnet->v_b;
    v_c = dnet->v_c;
    reconstruct();    // Reconstruct pore
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rsi, -0x270(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x238(%rbp)
movq %rdi, %rax
movq %rax, -0x268(%rbp)
callq 0xf6b0
movq -0x238(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x260(%rbp)
callq 0xf6b0
movq -0x238(%rbp), %rdi
addq $0x60, %rdi
movq %rdi, -0x258(%rbp)
callq 0x64310
movq -0x238(%rbp), %rdi
addq $0x78, %rdi
movq %rdi, -0x250(%rbp)
callq 0x64770
movq -0x238(%rbp), %rdi
addq $0x90, %rdi
movq %rdi, -0x248(%rbp)
callq 0x658a0
movq -0x238(%rbp), %rdi
addq $0xa8, %rdi
movq %rdi, -0x240(%rbp)
callq 0x10580
movq -0x238(%rbp), %rdi
addq $0xc0, %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xc4356
movq -0x268(%rbp), %rdi
addq $0xd8, %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xc4374
movq -0x268(%rbp), %rdi
addq $0xf0, %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xc4392
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x52a0
leaq -0x68(%rbp), %rdi
callq 0xf6b0
movq -0x268(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1dc90
leaq -0x68(%rbp), %rdi
callq 0xf860
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x52a0
leaq -0x98(%rbp), %rdi
callq 0xf6b0
movq -0x268(%rbp), %rdi
addq $0x30, %rdi
leaq -0x98(%rbp), %rsi
callq 0x1dc90
leaq -0x98(%rbp), %rdi
callq 0xf860
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x52a0
leaq -0xb0(%rbp), %rdi
callq 0x64310
movq -0x268(%rbp), %rdi
addq $0x60, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x64330
leaq -0xb0(%rbp), %rdi
callq 0x10e40
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x52a0
leaq -0xc8(%rbp), %rdi
callq 0x64770
movq -0x268(%rbp), %rdi
addq $0x78, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x6c840
leaq -0xc8(%rbp), %rdi
callq 0x11230
movl $0x0, -0xcc(%rbp)
movq -0x270(%rbp), %rdi
movl -0xcc(%rbp), %eax
movq %rax, -0x278(%rbp)
callq 0x10090
movq %rax, %rcx
movq -0x278(%rbp), %rax
cmpq %rcx, %rax
jae 0xc45ef
movq -0x270(%rbp), %rdi
movq -0x268(%rbp), %rax
movq %rax, -0x288(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, %esi
callq 0x101d0
movq %rax, -0x280(%rbp)
jmp 0xc44eb
movq -0x280(%rbp), %rsi
leaq -0xd4(%rbp), %rdi
leaq -0xcc(%rbp), %rdx
callq 0xcd170
jmp 0xc4507
movq -0x288(%rbp), %rdi
leaq -0xd4(%rbp), %rsi
callq 0xf550
movb %dl, -0x291(%rbp)
movq %rax, -0x290(%rbp)
jmp 0xc4529
movq -0x270(%rbp), %rdi
movq -0x268(%rbp), %rax
movb -0x291(%rbp), %cl
movq -0x290(%rbp), %rdx
movq %rdx, -0xe8(%rbp)
movb %cl, -0xe0(%rbp)
addq $0x30, %rax
movq %rax, -0x2a8(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, %esi
callq 0x101d0
movq %rax, -0x2a0(%rbp)
jmp 0xc4572
movq -0x2a0(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
leaq -0xcc(%rbp), %rsi
callq 0xcd1a0
jmp 0xc458e
movq -0x2a8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xf550
movb %dl, -0x2b1(%rbp)
movq %rax, -0x2b0(%rbp)
jmp 0xc45b0
movb -0x2b1(%rbp), %al
movq -0x2b0(%rbp), %rcx
movq %rcx, -0x100(%rbp)
movb %al, -0xf8(%rbp)
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0xc4494
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xc49eb
movl $0x0, -0x104(%rbp)
movq -0x270(%rbp), %rdi
movl -0x104(%rbp), %eax
movq %rax, -0x2c0(%rbp)
callq 0x10090
movq %rax, %rcx
movq -0x2c0(%rbp), %rax
cmpq %rcx, %rax
jae 0xc4909
movq -0x270(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movl -0x104(%rbp), %eax
movl %eax, %esi
callq 0x101d0
movq %rax, -0x2c8(%rbp)
jmp 0xc464d
movq -0x2d0(%rbp), %rdi
movq -0x2c8(%rbp), %rax
movslq (%rax), %rsi
callq 0x10130
movq %rax, -0x2d8(%rbp)
jmp 0xc466c
movq -0x2d8(%rbp), %rsi
leaq -0x150(%rbp), %rdi
callq 0x64400
jmp 0xc4681
movl -0x104(%rbp), %esi
movsd -0x148(%rbp), %xmm0
movsd -0x140(%rbp), %xmm1
movsd -0x138(%rbp), %xmm2
movsd -0x118(%rbp), %xmm3
leaq -0x198(%rbp), %rdi
movl $0x1, %edx
callq 0x94580
jmp 0xc46ba
movl $0x0, -0x19c(%rbp)
movl -0x19c(%rbp), %eax
movq %rax, -0x2e0(%rbp)
leaq -0x150(%rbp), %rdi
addq $0x20, %rdi
callq 0x2a9e0
movq %rax, %rcx
movq -0x2e0(%rbp), %rax
cmpq %rcx, %rax
jae 0xc48b3
leaq -0x130(%rbp), %rdi
movl -0x19c(%rbp), %eax
movl %eax, %esi
callq 0x64470
movq %rax, -0x2e8(%rbp)
jmp 0xc4711
movq -0x268(%rbp), %rdi
movq -0x2e8(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, -0x1b0(%rbp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm1, -0x1c0(%rbp)
movaps %xmm0, -0x1d0(%rbp)
leaq -0x1d0(%rbp), %rsi
callq 0x102e0
movq %rax, -0x2f0(%rbp)
jmp 0xc4754
movq -0x268(%rbp), %rdi
movq -0x2f0(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x1cc(%rbp), %rsi
callq 0x102e0
movq %rax, -0x2f8(%rbp)
jmp 0xc477e
movq -0x268(%rbp), %rdi
movq -0x2f8(%rbp), %rax
movq %rax, -0x1e0(%rbp)
callq 0x658c0
movq %rax, -0x1e8(%rbp)
leaq -0x1e0(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0xaed30
testb $0x1, %al
jne 0xc47bb
jmp 0xc489d
leaq -0x1d8(%rbp), %rdi
callq 0x10350
movl 0x4(%rax), %eax
movl %eax, -0x2fc(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x10350
movl -0x2fc(%rbp), %esi
movl 0x4(%rax), %edx
movsd -0x1c8(%rbp), %xmm0
movsd -0x1c0(%rbp), %xmm1
movl -0x1b0(%rbp), %eax
movl %eax, -0x218(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x220(%rbp)
movl -0x218(%rbp), %eax
movl %eax, -0x228(%rbp)
movq -0x220(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x230(%rbp), %rcx
movl -0x228(%rbp), %r8d
leaq -0x210(%rbp), %rdi
callq 0x94400
jmp 0xc4845
leaq -0x178(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x64790
jmp 0xc485a
movq -0x268(%rbp), %rdi
addq $0x78, %rdi
leaq -0x210(%rbp), %rsi
callq 0x64790
jmp 0xc4873
jmp 0xc489d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xc48f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x100e0
jmp 0xc48f8
jmp 0xc489f
movl -0x19c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x19c(%rbp)
jmp 0xc46c4
movq -0x268(%rbp), %rdi
addq $0x60, %rdi
leaq -0x198(%rbp), %rsi
callq 0x94e60
jmp 0xc48cc
leaq -0x198(%rbp), %rdi
callq 0x100e0
leaq -0x150(%rbp), %rdi
callq 0x100e0
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0xc45f9
leaq -0x150(%rbp), %rdi
callq 0x100e0
jmp 0xc49eb
movq -0x268(%rbp), %rdi
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, 0x10c(%rdi)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x110(%rdi)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x114(%rdi)
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, 0x118(%rdi)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, 0x11c(%rdi)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, 0x120(%rdi)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, 0x124(%rdi)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, 0x128(%rdi)
movq -0x28(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x12c(%rdi)
movl -0x1c(%rbp), %eax
movl %eax, 0x108(%rdi)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq %rcx, 0xd0(%rdi)
movups 0x18(%rax), %xmm0
movups %xmm0, 0xc0(%rdi)
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rcx
movq %rcx, 0xe8(%rdi)
movups 0x30(%rax), %xmm0
movups %xmm0, 0xd8(%rdi)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rcx
movq %rcx, 0x100(%rdi)
movups 0x48(%rax), %xmm0
movups %xmm0, 0xf0(%rdi)
callq 0xc4a40
jmp 0xc49e2
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq -0x240(%rbp), %rdi
callq 0x108b0
movq -0x248(%rbp), %rdi
callq 0x14c80
movq -0x250(%rbp), %rdi
callq 0x11230
movq -0x258(%rbp), %rdi
callq 0x10e40
movq -0x260(%rbp), %rdi
callq 0xf860
movq -0x238(%rbp), %rdi
callq 0xf860
movq -0x30(%rbp), %rdi
callq 0x58f0
nopl (%rax)