// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x80(%rcx), %rdi
callq 0x4130
testb %al, %al
je 0x55928
addq $0x10, %rbx
leaq 0xae77b(%rip), %rsi     # 0x103a76
movq %rbx, %rdi
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x43f0
leaq 0xadfb0(%rip), %rsi     # 0x1032c5
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movl %ebp, %esi
callq 0x4760
leaq 0xae04a(%rip), %rsi     # 0x103378
movq %rax, %rdi
callq 0x4480
leaq 0xad241(%rip), %r12     # 0x10257e
movq %rax, %rdi
movq %r12, %rsi
callq 0x4480
leaq 0xae72c(%rip), %rsi     # 0x103a7b
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x43f0
leaq 0xadf6b(%rip), %rsi     # 0x1032d4
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movl %ebp, %esi
callq 0x4760
leaq 0xae012(%rip), %rsi     # 0x103394
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movq %r12, %rsi
callq 0x4480
leaq 0x90(%r14), %rax
movq %rax, 0x90(%rsp)
leaq 0xa8(%r14), %rax
movq %rax, 0x88(%rsp)
leaq 0x60(%r14), %rax
movq %rax, 0x68(%rsp)
xorl %r15d, %r15d
leaq 0xaf14c(%rip), %r13     # 0x104512
movq %r14, %rbp
movl %r15d, %r15d
movq 0x98(%rbp), %rax
subq 0x90(%rbp), %rax
cqto
pushq $0xc
popq %rcx
idivq %rcx
cmpq %r15, %rax
jbe 0x558f8
movq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x4bbec
leaq 0x70(%rsp), %rdi
movq %rax, %rsi
callq 0xa6ce
movq 0x90(%rsp), %rdi
movq %r15, 0x98(%rsp)
movq %r15, %rsi
callq 0x576b6
movl (%rax), %ecx
movl 0x4(%rax), %edx
movl %ecx, 0x5c(%rsp)
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0xb0(%rsp)
movl %edx, 0x58(%rsp)
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0xa8(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x54(%rsp)
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0xa0(%rsp)
xorl %esi, %esi
movl %esi, %esi
movq 0x78(%rsp), %rax
subq 0x70(%rsp), %rax
sarq $0x2, %rax
cmpq %rsi, %rax
jbe 0x558de
leaq 0x70(%rsp), %rdi
movq %rsi, 0x60(%rsp)
callq 0xac00
movslq (%rax), %rsi
movq 0x68(%rsp), %rdi
callq 0xabe2
leaq 0xd8(%rsp), %rdi
movq %rax, %rsi
callq 0x29ebe
movsd 0xc0(%rbp), %xmm1
movsd 0xb0(%rsp), %xmm0
mulsd %xmm0, %xmm1
addsd 0xe0(%rsp), %xmm1
movsd %xmm1, 0x48(%rsp)
movsd 0xd8(%rbp), %xmm2
movsd 0xa8(%rsp), %xmm1
mulsd %xmm1, %xmm2
movsd %xmm2, 0x40(%rsp)
movsd 0xf0(%rbp), %xmm3
movsd 0xa0(%rsp), %xmm2
mulsd %xmm2, %xmm3
movsd %xmm3, 0x18(%rsp)
movsd 0xc8(%rbp), %xmm3
mulsd %xmm0, %xmm3
addsd 0xe8(%rsp), %xmm3
movsd %xmm3, 0x38(%rsp)
movsd 0xe0(%rbp), %xmm3
mulsd %xmm1, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0xf8(%rbp), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x10(%rsp)
movsd 0xd0(%rbp), %xmm3
mulsd %xmm0, %xmm3
addsd 0xf0(%rsp), %xmm3
movsd %xmm3, 0x28(%rsp)
movsd 0xe8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x100(%rbp), %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
leaq 0xaaecf(%rip), %rsi     # 0x100453
callq 0x4480
movsd 0x40(%rsp), %xmm1
addsd 0x48(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rax, %rdi
movsd %xmm0, 0x18(%rsp)
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd 0x30(%rsp), %xmm1
addsd 0x38(%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rax, %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd 0x20(%rsp), %xmm1
addsd 0x28(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rax, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x46c0
movq %rax, %rdi
leaq 0xadced(%rip), %rsi     # 0x103302
callq 0x4480
movq %rax, %r12
leaq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0xac00
movl (%rax), %esi
movq %r12, %rdi
callq 0x4760
movq %rax, %rdi
leaq 0xadcd7(%rip), %rsi     # 0x103317
callq 0x4480
movq %rax, %rdi
leaq 0xacf2f(%rip), %rsi     # 0x10257e
callq 0x4480
xorl %r14d, %r14d
movl %r14d, %r14d
movq 0x100(%rsp), %rax
subq 0xf8(%rsp), %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cmpq %r14, %rax
jbe 0x558c5
leaq 0xf8(%rsp), %rdi
movq %r14, %rsi
callq 0x29efa
movq %r14, 0xb8(%rsp)
movq %rbp, %r12
movq %r13, %r14
movq %rbx, %r15
movslq 0x4(%rax), %rsi
movl 0x18(%rax), %ebp
movl 0x1c(%rax), %ebx
movl 0x20(%rax), %r13d
movq 0x68(%rsp), %rdi
callq 0xabe2
leaq 0x120(%rsp), %rdi
movq %rax, %rsi
callq 0x29ebe
addl 0x5c(%rsp), %ebp
addl 0x58(%rsp), %ebx
addl 0x54(%rsp), %r13d
cvtsi2sd %ebp, %xmm0
movq %r12, %rbp
movsd 0xc0(%r12), %xmm1
mulsd %xmm0, %xmm1
addsd 0x128(%rsp), %xmm1
movsd %xmm1, 0x48(%rsp)
cvtsi2sd %ebx, %xmm2
movsd 0xd8(%r12), %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, 0x38(%rsp)
cvtsi2sd %r13d, %xmm1
movsd 0xf0(%r12), %xmm3
mulsd %xmm1, %xmm3
movsd %xmm3, 0x40(%rsp)
movsd 0xc8(%r12), %xmm3
mulsd %xmm0, %xmm3
addsd 0x130(%rsp), %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0xe0(%r12), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x20(%rsp)
movsd 0xf8(%r12), %xmm3
mulsd %xmm1, %xmm3
movsd %xmm3, 0x28(%rsp)
mulsd 0xd0(%r12), %xmm0
addsd 0x138(%rsp), %xmm0
movsd %xmm0, 0xd0(%rsp)
mulsd 0xe8(%r12), %xmm2
movsd %xmm2, 0xc0(%rsp)
mulsd 0x100(%r12), %xmm1
movsd %xmm1, 0xc8(%rsp)
movq %r15, %rbx
movq %r15, %rdi
leaq 0xaad76(%rip), %rsi     # 0x100530
callq 0x4480
movq %r14, %r13
movq %rax, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x46c0
movq %rax, %rdi
leaq 0xabb8f(%rip), %rsi     # 0x10139b
callq 0x4480
movsd 0x38(%rsp), %xmm1
addsd 0x48(%rsp), %xmm1
movsd 0x40(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd 0x20(%rsp), %xmm1
addsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd 0xc0(%rsp), %xmm1
addsd 0xd0(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
leaq 0xaad6b(%rip), %rsi     # 0x1005ff
callq 0x4480
movq %rax, %rdi
leaq 0xaccdb(%rip), %rsi     # 0x10257e
callq 0x4480
leaq 0x140(%rsp), %rdi
callq 0xaf14
movq 0xb8(%rsp), %r14
incl %r14d
jmp 0x55657
leaq 0xf8(%rsp), %rdi
callq 0xaf14
movq 0x60(%rsp), %rsi
incl %esi
jmp 0x5545d
leaq 0x70(%rsp), %rdi
callq 0xb290
movq 0x98(%rsp), %r15
incl %r15d
jmp 0x553c9
leaq 0xad9df(%rip), %rsi     # 0x1032de
movq %rbx, %rdi
callq 0x4480
leaq 0xacc70(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfa6c1(%rip), %rdi     # 0x14fff0
leaq 0xae11d(%rip), %rsi     # 0x103a53
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x43f0
leaq 0xae0c6(%rip), %rsi     # 0x103a13
movq %rax, %rdi
callq 0x4480
leaq 0xacc22(%rip), %rbx     # 0x10257e
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4480
leaq 0xa7245(%rip), %rsi     # 0xfcbb3
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4480
pushq $0x1
popq %rdi
callq 0x524c
jmp 0x5598b
movq %rax, %rbx
jmp 0x559b6
jmp 0x55994
jmp 0x55994
movq %rax, %rbx
jmp 0x559a9
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0xaf14
leaq 0xf8(%rsp), %rdi
callq 0xaf14
leaq 0x70(%rsp), %rdi
callq 0xb290
movq %rbx, %rdi
callq 0x4780