// File: /workspace/github_cpp_makefile_star2_O1/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 0x73bb8
addq $0x10, %r14
leaq 0xe3622(%rip), %rsi     # 0x1569be
movl $0xd, %edx
movq %r14, %rdi
callq 0x44e0
movq %r14, %rdi
movl %ebp, %esi
callq 0x4750
movq %rax, %r12
leaq 0xe2f6b(%rip), %rsi     # 0x156328
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0xe215d(%rip), %r15     # 0x15552e
movl $0x1, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0xe35e4(%rip), %rsi     # 0x1569cc
movl $0x16, %edx
movq %r12, %rdi
callq 0x44e0
movq %r12, %rdi
movl %ebp, %esi
callq 0x4750
movq %rax, %r12
leaq 0xe2f3b(%rip), %rsi     # 0x156344
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 0x73b2d
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 0x73ba7
movq %rcx, %r13
movq %rbx, %r12
leaq (%rbx,%rbx,2), %rbx
leaq (%rax,%rbx,8), %rsi
leaq 0x58(%rsp), %rdi
callq 0xe886
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 0x73b94
movq 0x58(%rsp), %rdi
cmpq %rdi, 0x60(%rsp)
leaq 0xe3fbb(%rip), %r13     # 0x157486
je 0x73aeb
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 0x73b86
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 0x38318
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 0xdfda9(%rip), %rsi     # 0x153433
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 0xe2b7c(%rip), %rsi     # 0x1562b2
callq 0x44e0
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0x73b75
movl (%rax,%rbx,4), %esi
movq %rbp, %rdi
callq 0x4750
movq %rax, %rbp
movl $0x20, %edx
movq %rax, %rdi
leaq 0xe2b55(%rip), %rsi     # 0x1562c7
callq 0x44e0
movl $0x1, %edx
movq %rbp, %rdi
leaq 0xe1da8(%rip), %rsi     # 0x15552e
callq 0x44e0
movq 0xe0(%rsp), %rdi
cmpq %rdi, 0xe8(%rsp)
je 0x73aba
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 0x73b67
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 0x38318
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 0xdfbd7(%rip), %rsi     # 0x153510
callq 0x44e0
leaq 0xe3b41(%rip), %r13     # 0x157486
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 0xe09d5(%rip), %rsi     # 0x15437b
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 0xdfb99(%rip), %rsi     # 0x1535df
callq 0x44e0
movl $0x1, %edx
movq %rbp, %rdi
leaq 0xe1ad4(%rip), %rsi     # 0x15552e
callq 0x44e0
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
movl 0x54(%rsp), %ebx
je 0x73a80
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 0x737a9
movq 0x78(%rsp), %rbx
testq %rdi, %rdi
je 0x73acf
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 0x73517
testq %rdi, %rdi
movq 0x70(%rsp), %rbx
je 0x73b02
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 0x73459
leaq 0xe275a(%rip), %rsi     # 0x15628e
movl $0x1, %edx
movq %r14, %rdi
callq 0x44e0
leaq 0xe19e6(%rip), %rsi     # 0x15552e
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 0xdbb37(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
leaq 0xdbb29(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xdbb18(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
leaq 0xdbb0a(%rip), %rdi     # 0x14f6a5
movq 0x70(%rsp), %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xdbaf7(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
movq 0x123431(%rip), %rdi    # 0x196ff0
leaq 0xe2db3(%rip), %rsi     # 0x156979
callq 0x4440
leaq 0xe195c(%rip), %rbx     # 0x15552e
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
leaq 0xdbf5f(%rip), %rsi     # 0x14fb43
movq %rax, %rdi
callq 0x4440
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4440
movl $0x1, %edi
callq 0x710c
jmp 0x73c05
jmp 0x73c05
movq %rax, %rbx
jmp 0x73c52
jmp 0x73c10
jmp 0x73c10
jmp 0x73c10
movq %rax, %rbx
jmp 0x73c35
movq %rax, %rbx
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x73c35
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x73c52
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x73c69
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780
nop