// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/channel.cc
// Function: CHANNEL::writeToVMD(int, std::basic_fstream<char, std::char_traits<char>>&)
void CHANNEL::writeToVMD(int n, fstream &output){
    if(!output.is_open()){
        cerr << "Error: File stream needed to print channel information was not open." << "\n"
        << "Exiting ..." << "\n";
        exit(1);
    }
    else{
        output << "set channels(" << n << ") {" << "\n"
        << "{color $channelColors(" << 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 $0x158, %rsp            # imm = 0x158
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x80(%rdx), %rdi
callq 0x4120
testb %al, %al
je 0x72eb4
addq $0x10, %r14
leaq 0xe243e(%rip), %rsi     # 0x154ad6
movl $0xd, %edx
movq %r14, %rdi
callq 0x44e0
movq %r14, %rdi
movl %ebp, %esi
callq 0x4750
movq %rax, %r12
leaq 0xe1d5f(%rip), %rsi     # 0x154418
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0xe0f51(%rip), %r15     # 0x15361e
movl $0x1, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0xe2400(%rip), %rsi     # 0x154ae4
movl $0x16, %edx
movq %r12, %rdi
callq 0x44e0
movq %r12, %rdi
movl %ebp, %esi
callq 0x4750
movq %rax, %r12
leaq 0xe1d2f(%rip), %rsi     # 0x154434
movl $0x2, %edx
movq %rax, %rdi
callq 0x44e0
movl $0x1, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x44e0
movq 0x98(%rbx), %rax
cmpq 0x90(%rbx), %rax
je 0x72e29
movq %rbx, %r15
xorl %ebx, %ebx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
movq %r15, 0x80(%rsp)
movq %r14, 0xa0(%rsp)
movq 0xa8(%r15), %rax
movq 0xb0(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %rcx, %rdx
cmpq %rbx, %rdx
jbe 0x72ea3
movq %rcx, %r13
movq %rbx, %r12
leaq (%rbx,%rbx,2), %rbx
leaq (%rax,%rbx,8), %rsi
leaq 0x58(%rsp), %rdi
callq 0xe8f8
movq 0x90(%r15), %rax
movq 0x98(%r15), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
imulq %r13, %rdx
movq %r12, 0x70(%rsp)
cmpq %r12, %rdx
jbe 0x72e90
movq 0x58(%rsp), %rdi
cmpq %rdi, 0x60(%rsp)
leaq 0xe2e0f(%rip), %r13     # 0x1555d6
je 0x72de7
movl (%rax,%rbx,4), %ecx
movl 0x4(%rax,%rbx,4), %edx
movl %ecx, 0x50(%rsp)
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x98(%rsp)
movl %edx, 0x4c(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0x90(%rsp)
movl 0x8(%rax,%rbx,4), %eax
movl %eax, 0x48(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x88(%rsp)
xorl %ebx, %ebx
movq %rbx, 0x78(%rsp)
movslq (%rdi,%rbx,4), %rsi
movq 0x60(%r15), %rbx
movq 0x68(%r15), %rdx
subq %rbx, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rax # imm = 0x8E38E38E38E38E39
imulq %rax, %rdx
cmpq %rsi, %rdx
jbe 0x72e82
leaq (%rsi,%rsi,8), %r15
leaq (%rbx,%r15,8), %rsi
addq $0x20, %rsi
movupd -0x20(%rsi), %xmm0
movupd -0x10(%rsi), %xmm1
movapd %xmm1, 0xd0(%rsp)
movapd %xmm0, 0xc0(%rsp)
leaq 0xe0(%rsp), %r12
movq %r12, %rdi
callq 0x37e9e
leaq (%rbx,%r15,8), %rax
movb 0x40(%rax), %cl
movb %cl, 0x20(%r12)
movq 0x38(%rax), %rax
movq %rax, 0x18(%r12)
movq 0x80(%rsp), %r15
movsd 0xc0(%r15), %xmm1
movsd 0x98(%rsp), %xmm0
mulsd %xmm0, %xmm1
addsd 0xc8(%rsp), %xmm1
movsd %xmm1, 0x40(%rsp)
movsd 0xd8(%r15), %xmm2
movsd 0x90(%rsp), %xmm1
mulsd %xmm1, %xmm2
movsd %xmm2, 0x38(%rsp)
movsd 0xf0(%r15), %xmm3
movsd 0x88(%rsp), %xmm2
mulsd %xmm2, %xmm3
movsd %xmm3, 0x10(%rsp)
movsd 0xc8(%r15), %xmm3
mulsd %xmm0, %xmm3
addsd 0xd0(%rsp), %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0xe0(%r15), %xmm3
mulsd %xmm1, %xmm3
movsd %xmm3, 0x28(%rsp)
movsd 0xf8(%r15), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x8(%rsp)
movsd 0xd0(%r15), %xmm3
mulsd %xmm0, %xmm3
addsd 0xd8(%rsp), %xmm3
movsd %xmm3, 0x20(%rsp)
movsd 0xe8(%r15), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x100(%r15), %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, (%rsp)
movl $0x9, %edx
movq %r14, %rdi
leaq 0xdeb3d(%rip), %rsi     # 0x1514c3
callq 0x44e0
movq 0x78(%rsp), %rbx
movsd 0x38(%rsp), %xmm1
addsd 0x40(%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %r14, %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0x28(%rsp), %xmm1
addsd 0x30(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rbp, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0x18(%rsp), %xmm1
addsd 0x20(%rsp), %xmm1
movsd (%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rbp, %rdi
movsd %xmm0, (%rsp)
callq 0x46b0
movq %rax, %rbp
movl $0x14, %edx
movq %rax, %rdi
leaq 0xe1970(%rip), %rsi     # 0x1543a2
callq 0x44e0
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0x72e71
movl (%rax,%rbx,4), %esi
movq %rbp, %rdi
callq 0x4750
movq %rax, %rbp
movl $0x20, %edx
movq %rax, %rdi
leaq 0xe1949(%rip), %rsi     # 0x1543b7
callq 0x44e0
movl $0x1, %edx
movq %rbp, %rdi
leaq 0xe0b9c(%rip), %rsi     # 0x15361e
callq 0x44e0
movq 0xe0(%rsp), %rdi
cmpq %rdi, 0xe8(%rsp)
je 0x72db6
movl $0x1, %r8d
xorl %eax, %eax
leaq (%rax,%rax,4), %rax
movslq 0x4(%rdi,%rax,8), %rsi
movq 0x60(%r15), %rbx
movq 0x68(%r15), %rdx
subq %rbx, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x72e63
movl %r8d, 0x54(%rsp)
movl 0x18(%rdi,%rax,8), %r15d
movl 0x1c(%rdi,%rax,8), %r13d
movl 0x20(%rdi,%rax,8), %ebp
leaq (%rsi,%rsi,8), %r14
leaq 0x20(%rbx,%r14,8), %rsi
movupd -0x20(%rsi), %xmm0
movupd -0x10(%rsi), %xmm1
movapd %xmm1, 0x120(%rsp)
movapd %xmm0, 0x110(%rsp)
leaq 0x130(%rsp), %r12
movq %r12, %rdi
callq 0x37e9e
leaq (%rbx,%r14,8), %rax
movb 0x40(%rax), %cl
movb %cl, 0x20(%r12)
movq 0x38(%rax), %rax
movq %rax, 0x18(%r12)
addl 0x50(%rsp), %r15d
addl 0x4c(%rsp), %r13d
addl 0x48(%rsp), %ebp
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movq 0x80(%rsp), %r15
movsd 0xc0(%r15), %xmm1
mulsd %xmm0, %xmm1
addsd 0x118(%rsp), %xmm1
movsd %xmm1, 0x40(%rsp)
cvtsi2sd %r13d, %xmm2
movsd 0xd8(%r15), %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, 0x30(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xf0(%r15), %xmm3
mulsd %xmm1, %xmm3
movsd %xmm3, 0x38(%rsp)
movsd 0xc8(%r15), %xmm3
mulsd %xmm0, %xmm3
addsd 0x120(%rsp), %xmm3
movsd %xmm3, 0x28(%rsp)
movsd 0xe0(%r15), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x18(%rsp)
movsd 0xf8(%r15), %xmm3
mulsd %xmm1, %xmm3
movsd %xmm3, 0x20(%rsp)
mulsd 0xd0(%r15), %xmm0
addsd 0x128(%rsp), %xmm0
movsd %xmm0, 0xb8(%rsp)
mulsd 0xe8(%r15), %xmm2
movsd %xmm2, 0xa8(%rsp)
mulsd 0x100(%r15), %xmm1
movsd %xmm1, 0xb0(%rsp)
movl $0x7, %edx
movq 0xa0(%rsp), %r14
movq %r14, %rdi
leaq 0xde96b(%rip), %rsi     # 0x1515a0
callq 0x44e0
leaq 0xe2995(%rip), %r13     # 0x1555d6
movq %r14, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movq %rbp, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movq %rbp, %rdi
movsd (%rsp), %xmm0
callq 0x46b0
movq %rax, %rbp
movl $0x3, %edx
movq %rax, %rdi
leaq 0xdf789(%rip), %rsi     # 0x15242b
callq 0x44e0
movsd 0x30(%rsp), %xmm1
addsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rbp, %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0x18(%rsp), %xmm1
addsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rbp, %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
movsd 0xa8(%rsp), %xmm1
addsd 0xb8(%rsp), %xmm1
movsd 0xb0(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %rbp, %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
leaq 0xde94d(%rip), %rsi     # 0x15168f
callq 0x44e0
movl $0x1, %edx
movq %rbp, %rdi
leaq 0xe08c8(%rip), %rsi     # 0x15361e
callq 0x44e0
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
movl 0x54(%rsp), %ebx
je 0x72d7c
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movl %ebx, %eax
movq 0xe0(%rsp), %rdi
movq 0xe8(%rsp), %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdx, %rcx
incl %ebx
cmpq %rax, %rcx
movl %ebx, %r8d
ja 0x72aa5
movq 0x78(%rsp), %rbx
testq %rdi, %rdi
je 0x72dcb
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
incl %ebx
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq %rbx, %rax
ja 0x72813
testq %rdi, %rdi
movq 0x70(%rsp), %rbx
je 0x72dfe
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x98(%r15), %rax
subq 0x90(%r15), %rax
incl %ebx
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rbx, %rax
ja 0x72755
leaq 0xe154e(%rip), %rsi     # 0x15437e
movl $0x1, %edx
movq %r14, %rdi
callq 0x44e0
leaq 0xe07da(%rip), %rsi     # 0x15361e
movl $0x1, %edx
movq %r14, %rdi
callq 0x44e0
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xda88b(%rip), %rdi     # 0x14d6f5
xorl %eax, %eax
callq 0x4630
leaq 0xda87d(%rip), %rdi     # 0x14d6f5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xda86c(%rip), %rdi     # 0x14d6f5
xorl %eax, %eax
callq 0x4630
leaq 0xda85e(%rip), %rdi     # 0x14d6f5
movq 0x70(%rsp), %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xda84b(%rip), %rdi     # 0x14d6f5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
movq 0x122135(%rip), %rdi    # 0x194ff0
leaq 0xe1bcf(%rip), %rsi     # 0x154a91
callq 0x4440
leaq 0xe0750(%rip), %rbx     # 0x15361e
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
leaq 0xdacd3(%rip), %rsi     # 0x14dbb3
movq %rax, %rdi
callq 0x4440
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
movl $0x1, %edi
callq 0x72bc
jmp 0x72f01
jmp 0x72f01
movq %rax, %rbx
jmp 0x72f4e
jmp 0x72f0c
jmp 0x72f0c
jmp 0x72f0c
movq %rax, %rbx
jmp 0x72f31
movq %rax, %rbx
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x72f31
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x72f4e
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x72f65
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780
nop