// File: Luthaf[P]zeopp/channel.cc
// Function: CHANNEL::writeToVMD(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::basic_fstream<char, std::char_traits<char>>&)
void CHANNEL::writeToVMD(string type, int n, fstream &output){
    if(!output.is_open()){
        cerr << "Error: File stream needed to print" << type << " information was not open." << "\n"
        << "Exiting ..." << "\n";
        exit(1);
    }
    else{
        output << "set " << type << "s(" << n << ") {" << "\n"
        << "{color $" << type << "Colors(" << n << ")}" << "\n";
        
        // Draw the components located in each unit cell
        for(unsigned int i = 0; i < unitCells.size(); i++){
            vector<int> nodeIDs = ucNodes.at(i);
            DELTA_POS disp = unitCells.at(i);
            
            // Iterate over all nodes in the unit cell
            for(unsigned int j = 0; j < nodeIDs.size(); j++){
                DIJKSTRA_NODE curNode = nodes.at(nodeIDs.at(j));
                
                // Find node coordinates
                double xCoord = curNode.x + v_a.x*disp.x + v_b.x*disp.y + v_c.x*disp.z;
                double yCoord = curNode.y + v_a.y*disp.x + v_b.y*disp.y + v_c.y*disp.z;
                double zCoord = curNode.z + v_a.z*disp.x + v_b.z*disp.y + v_c.z*disp.z;
                
                // Command used to draw node
                output << "{sphere {" << xCoord <<  " " << yCoord << " " << zCoord
                << "} radius $nodeRadii(" << nodeIDs.at(j) <<") resolution $sphere_resolution}" << "\n";
                
                // Iterate over all connections stemming from the current node
                for(unsigned int k = 0; k < curNode.connections.size(); k++){
                    CONN curConn = curNode.connections.at(k);
                    DIJKSTRA_NODE otherNode = nodes.at(curConn.to);
                    int dx = disp.x + curConn.deltaPos.x;
                    int dy = disp.y + curConn.deltaPos.y;
                    int dz = disp.z + curConn.deltaPos.z;
                    
                    // Find end of edge coordinates
                    double newX = otherNode.x + v_a.x*dx + v_b.x*dy + v_c.x*dz;
                    double newY = otherNode.y + v_a.y*dx + v_b.y*dy + v_c.y*dz;
                    double newZ = otherNode.z + v_a.z*dx + v_b.z*dy + v_c.z*dz;
                    
                    // Command used to draw edge
                    output << "{line {" << xCoord << " " << yCoord << " " << zCoord << "} {"
                    << newX << " " << newY << " " << newZ<< "}}" <<  "\n";
                }
            }
        }
        output << "}" << "\n";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rsi, -0x170(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x20(%rbp), %rdi
callq 0x58b0
testb $0x1, %al
jne 0xc91f1
movq 0x1a9e60(%rip), %rdi    # 0x272ff0
leaq 0x1325b4(%rip), %rsi    # 0x1fb74b
callq 0x5540
movq -0x170(%rbp), %rsi
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
leaq 0x132556(%rip), %rsi    # 0x1fb70b
callq 0x5540
movq %rax, %rdi
leaq 0x130461(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, %rdi
leaq 0x129a30(%rip), %rsi    # 0x1f2c03
callq 0x5540
movq %rax, %rdi
leaq 0x130443(%rip), %rsi    # 0x1f9625
callq 0x5540
movl $0x1, %edi
callq 0x67c0
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
leaq 0x13256e(%rip), %rsi    # 0x1fb76e
callq 0x5540
movq -0x170(%rbp), %rsi
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
leaq 0x131dc4(%rip), %rsi    # 0x1fafe2
callq 0x5540
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x58d0
movq %rax, %rdi
leaq 0x131e5d(%rip), %rsi    # 0x1fb095
callq 0x5540
movq %rax, %rdi
leaq 0x1303de(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, %rdi
leaq 0x13251d(%rip), %rsi    # 0x1fb773
callq 0x5540
movq -0x170(%rbp), %rsi
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
leaq 0x131d7d(%rip), %rsi    # 0x1faff1
callq 0x5540
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x58d0
movq %rax, %rdi
leaq 0x131e23(%rip), %rsi    # 0x1fb0b1
callq 0x5540
movq %rax, %rdi
leaq 0x130388(%rip), %rsi    # 0x1f9625
callq 0x5540
movl $0x0, -0x24(%rbp)
movq -0x168(%rbp), %rdi
movl -0x24(%rbp), %eax
movq %rax, -0x178(%rbp)
addq $0x90, %rdi
callq 0x706e0
movq %rax, %rcx
movq -0x178(%rbp), %rax
cmpq %rcx, %rax
jae 0xc99fb
movq -0x168(%rbp), %rdi
addq $0xa8, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0xaf5b0
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0xeec0
movq -0x168(%rbp), %rdi
addq $0x90, %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0xcd720
movq %rax, -0x180(%rbp)
jmp 0xc931e
movq -0x180(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x4c(%rbp)
movl 0x8(%rax), %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
movq %rax, -0x188(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x10090
movq %rax, %rcx
movq -0x188(%rbp), %rax
cmpq %rcx, %rax
jae 0xc99d9
movq -0x168(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x198(%rbp)
movl -0x60(%rbp), %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
callq 0x101d0
movq %rax, -0x190(%rbp)
jmp 0xc9388
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rax
movslq (%rax), %rsi
callq 0x10130
movq %rax, -0x1a0(%rbp)
jmp 0xc93a7
movq -0x1a0(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x64400
jmp 0xc93bc
movq -0x168(%rbp), %rax
movsd -0xa0(%rbp), %xmm2
cvtsi2sdl -0x4c(%rbp), %xmm3
movsd 0xc0(%rax), %xmm0
movsd 0xd8(%rax), %xmm1
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
cvtsi2sdl -0x48(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0xf0(%rax), %xmm0
cvtsi2sdl -0x44(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x98(%rbp), %xmm2
cvtsi2sdl -0x4c(%rbp), %xmm3
movsd 0xc8(%rax), %xmm0
movsd 0xe0(%rax), %xmm1
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
cvtsi2sdl -0x48(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0xf8(%rax), %xmm0
cvtsi2sdl -0x44(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x90(%rbp), %xmm2
cvtsi2sdl -0x4c(%rbp), %xmm3
movsd 0xd0(%rax), %xmm0
movsd 0xe8(%rax), %xmm1
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
cvtsi2sdl -0x48(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x100(%rax), %xmm0
cvtsi2sdl -0x44(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
leaq 0x12d01c(%rip), %rsi    # 0x1f64db
callq 0x5540
movq %rax, -0x1a8(%rbp)
jmp 0xc94cd
movq -0x1a8(%rbp), %rdi
movsd -0xb0(%rbp), %xmm0
callq 0x5980
movq %rax, -0x1b0(%rbp)
jmp 0xc94ea
movq -0x1b0(%rbp), %rdi
leaq 0x132db6(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, -0x1b8(%rbp)
jmp 0xc9506
movq -0x1b8(%rbp), %rdi
movsd -0xb8(%rbp), %xmm0
callq 0x5980
movq %rax, -0x1c0(%rbp)
jmp 0xc9523
movq -0x1c0(%rbp), %rdi
leaq 0x132d7d(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, -0x1c8(%rbp)
jmp 0xc953f
movq -0x1c8(%rbp), %rdi
movsd -0xc0(%rbp), %xmm0
callq 0x5980
movq %rax, -0x1d0(%rbp)
jmp 0xc955c
movq -0x1d0(%rbp), %rdi
leaq 0x131ab5(%rip), %rsi    # 0x1fb01f
callq 0x5540
movq %rax, -0x1d8(%rbp)
jmp 0xc9578
movl -0x60(%rbp), %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
callq 0x101d0
movq %rax, -0x1e0(%rbp)
jmp 0xc958f
movq -0x1d8(%rbp), %rdi
movq -0x1e0(%rbp), %rax
movl (%rax), %esi
callq 0x58d0
movq %rax, -0x1e8(%rbp)
jmp 0xc95ad
movq -0x1e8(%rbp), %rdi
leaq 0x131a79(%rip), %rsi    # 0x1fb034
callq 0x5540
movq %rax, -0x1f0(%rbp)
jmp 0xc95c9
movq -0x1f0(%rbp), %rdi
leaq 0x13004e(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc95de
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
movq %rax, -0x1f8(%rbp)
leaq -0xa8(%rbp), %rdi
addq $0x20, %rdi
callq 0x2a9e0
movq %rax, %rcx
movq -0x1f8(%rbp), %rax
cmpq %rcx, %rax
jae 0xc99b1
leaq -0x88(%rbp), %rdi
movl -0xc4(%rbp), %eax
movl %eax, %esi
callq 0x64470
movq %rax, -0x200(%rbp)
jmp 0xc9635
movq -0x168(%rbp), %rdi
movq -0x200(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, -0xd0(%rbp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm1, -0xe0(%rbp)
movaps %xmm0, -0xf0(%rbp)
addq $0x60, %rdi
movslq -0xec(%rbp), %rsi
callq 0x10130
movq %rax, -0x208(%rbp)
jmp 0xc967c
movq -0x208(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0x64400
jmp 0xc9691
movq -0x168(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl -0xd8(%rbp), %edx
addl %edx, %ecx
movl %ecx, -0x13c(%rbp)
movl -0x48(%rbp), %ecx
movl -0xd4(%rbp), %edx
addl %edx, %ecx
movl %ecx, -0x140(%rbp)
movl -0x44(%rbp), %ecx
movl -0xd0(%rbp), %edx
addl %edx, %ecx
movl %ecx, -0x144(%rbp)
movsd -0x130(%rbp), %xmm2
cvtsi2sdl -0x13c(%rbp), %xmm3
movsd 0xc0(%rax), %xmm0
movsd 0xd8(%rax), %xmm1
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
cvtsi2sdl -0x140(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0xf0(%rax), %xmm0
cvtsi2sdl -0x144(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x150(%rbp)
movsd -0x128(%rbp), %xmm2
cvtsi2sdl -0x13c(%rbp), %xmm3
movsd 0xc8(%rax), %xmm0
movsd 0xe0(%rax), %xmm1
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
cvtsi2sdl -0x140(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0xf8(%rax), %xmm0
cvtsi2sdl -0x144(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
movsd -0x120(%rbp), %xmm2
cvtsi2sdl -0x13c(%rbp), %xmm3
movsd 0xd0(%rax), %xmm0
movsd 0xe8(%rax), %xmm1
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
cvtsi2sdl -0x140(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x100(%rax), %xmm0
cvtsi2sdl -0x144(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x160(%rbp)
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
leaq 0x12cdd6(%rip), %rsi    # 0x1f65b8
callq 0x5540
movq %rax, -0x210(%rbp)
jmp 0xc97f0
movq -0x210(%rbp), %rdi
movsd -0xb0(%rbp), %xmm0
callq 0x5980
movq %rax, -0x218(%rbp)
jmp 0xc980d
movq -0x218(%rbp), %rdi
leaq 0x132a93(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, -0x220(%rbp)
jmp 0xc9829
movq -0x220(%rbp), %rdi
movsd -0xb8(%rbp), %xmm0
callq 0x5980
movq %rax, -0x228(%rbp)
jmp 0xc9846
movq -0x228(%rbp), %rdi
leaq 0x132a5a(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, -0x230(%rbp)
jmp 0xc9862
movq -0x230(%rbp), %rdi
movsd -0xc0(%rbp), %xmm0
callq 0x5980
movq %rax, -0x238(%rbp)
jmp 0xc987f
movq -0x238(%rbp), %rdi
leaq 0x12dcae(%rip), %rsi    # 0x1f753b
callq 0x5540
movq %rax, -0x240(%rbp)
jmp 0xc989b
movq -0x240(%rbp), %rdi
movsd -0x150(%rbp), %xmm0
callq 0x5980
movq %rax, -0x248(%rbp)
jmp 0xc98b8
movq -0x248(%rbp), %rdi
leaq 0x1329e8(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, -0x250(%rbp)
jmp 0xc98d4
movq -0x250(%rbp), %rdi
movsd -0x158(%rbp), %xmm0
callq 0x5980
movq %rax, -0x258(%rbp)
jmp 0xc98f1
movq -0x258(%rbp), %rdi
leaq 0x1329af(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, -0x260(%rbp)
jmp 0xc990d
movq -0x260(%rbp), %rdi
movsd -0x160(%rbp), %xmm0
callq 0x5980
movq %rax, -0x268(%rbp)
jmp 0xc992a
movq -0x268(%rbp), %rdi
leaq 0x12cd27(%rip), %rsi    # 0x1f665f
callq 0x5540
movq %rax, -0x270(%rbp)
jmp 0xc9946
movq -0x270(%rbp), %rdi
leaq 0x12fcd1(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc995b
leaq -0x138(%rbp), %rdi
callq 0x100e0
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0xc95e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc99f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc99cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x100e0
jmp 0xc99cb
leaq -0xa8(%rbp), %rdi
callq 0x100e0
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0xc9339
leaq -0xa8(%rbp), %rdi
callq 0x100e0
jmp 0xc99f0
leaq -0x40(%rbp), %rdi
callq 0xec80
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc92a9
leaq -0x40(%rbp), %rdi
callq 0xec80
jmp 0xc9a27
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
leaq 0x1315f1(%rip), %rsi    # 0x1faffb
callq 0x5540
movq %rax, %rdi
leaq 0x12fc0c(%rip), %rsi    # 0x1f9625
callq 0x5540
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x58f0