// File: /workspace/github_cpp_makefile_star2_O2/ryanbarringtoncox[P]AVLTree/AVLTree.cpp
// Function: AVLTree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>::visualPrint(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void AVLTree<T>::visualPrint(T def, T leftLeg, T rightLeg) {
	
	//make a Queue of globs, push in root at 0, 0
	list<Glob<T>*> q;
	int level=0; int spread=0;
	Glob<T>* root_glob = new Glob<T>(*root, level, spread);
	q.push_back (root_glob);
	
	//make 2d vector for glob coordinates, spread is width, level is depth
	int s; int l;
	TwoDArray<T>* tda = new TwoDArray<T>(8, 15, def);
	int spread_middle = 7;
	
	//begin level order traversal of AVLTree and insert into tda
	Node<T>* curr_node;
	while (!(q.empty())) {
		Glob<T>* curr_glob = q.front();
		curr_node = curr_glob->getNodePointer();
		if (curr_node->getLeftChild()!=0) {
			//get level, spread for left node and make a glob
			level = (curr_glob->getLevel())+2;
			spread = (curr_glob->getSpread())-2;
			Glob<T>* new_glob_left = new Glob<T>(*(curr_node->getLeftChild()), level, spread);
			q.push_back (new_glob_left);
			//insert left leg into tda
			tda->insert(level-1, spread_middle+spread+1, leftLeg);
		}
		if (curr_node->getRightChild()!=0) {
			level=(curr_glob->getLevel())+2;
			spread = (curr_glob->getSpread())+2;
			Glob<T>* new_glob_right = new Glob<T>(*(curr_node->getRightChild()), level, spread);
			q.push_back (new_glob_right);
			//insert right leg tda
			tda->insert(level-1, spread_middle+spread-1, rightLeg);			
		}		
		if (curr_node!=0) {
			l = curr_glob->getLevel();
			s = curr_glob->getSpread();
			tda->insert(l, spread_middle+s, curr_glob->getNodePointer()->getValue());
		}
		q.pop_front();	
	}
	tda->print();
	delete tda;
	delete root_glob;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x10
popq %rdi
callq 0x2150
movq %rax, %r14
movq (%r15), %rsi
movq %rax, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x6784
leaq 0x40(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x18(%rsp), %rdi
callq 0x5d46
pushq $0x40
popq %rdi
callq 0x2150
movq %rax, %r14
leaq 0x48(%rsp), %rdi
movq %rbx, %rsi
movq %rax, 0x8(%rsp)
callq 0x2190
pushq $0x8
popq %rsi
pushq $0xf
popq %rdx
leaq 0x48(%rsp), %rcx
movq %r14, %rdi
callq 0x6cfe
leaq 0x48(%rsp), %rdi
callq 0x20a0
leaq 0xa8(%rsp), %r15
leaq 0x18(%rsp), %rbx
movq 0x18(%rsp), %rax
cmpq %rbx, %rax
je 0x5c6c
movq 0x10(%rax), %rbx
movq %rbx, %rdi
callq 0x6790
movq (%rax), %r14
movq %r14, %rdi
callq 0x66b4
cmpq $0x0, (%rax)
je 0x5b7f
movq %rbx, %rdi
callq 0x6794
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6798
movl %eax, %r12d
pushq $0x10
popq %rdi
callq 0x2150
movq %rax, %r13
movq %r14, %rdi
callq 0x66b4
leal 0x2(%rbp), %edx
leal -0x2(%r12), %ecx
movq (%rax), %rsi
movq %r13, %rdi
callq 0x6784
movq %r13, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x5d46
leaq 0x88(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x2190
addl $0x6, %r12d
incl %ebp
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl %r12d, %edx
leaq 0x88(%rsp), %r12
movq %r12, %rcx
callq 0x6eb0
movq %r12, %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x66c0
cmpq $0x0, (%rax)
je 0x5c14
movq %rbx, %rdi
callq 0x6794
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6798
movl %eax, %r12d
pushq $0x10
popq %rdi
callq 0x2150
movq %rax, %r13
movq %r14, %rdi
callq 0x66c0
leal 0x2(%rbp), %edx
leal 0x2(%r12), %ecx
movq (%rax), %rsi
movq %r13, %rdi
callq 0x6784
movq %r13, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x5d46
leaq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x2190
addl $0x8, %r12d
incl %ebp
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl %r12d, %edx
leaq 0x68(%rsp), %r14
movq %r14, %rcx
callq 0x6eb0
movq %r14, %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x6794
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6798
movl %eax, %r14d
movq %rbx, %rdi
callq 0x6790
movq (%rax), %rsi
movq %r15, %rdi
callq 0x668e
addl $0x7, %r14d
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl %r14d, %edx
movq %r15, %rcx
callq 0x6eb0
movq %r15, %rdi
callq 0x20a0
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x5d52
jmp 0x5ac7
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x6f98
movq %rbx, %rdi
callq 0x6e9a
pushq $0x40
popq %rsi
movq %rbx, %rdi
callq 0x2160
movq 0x40(%rsp), %rbx
testq %rbx, %rbx
je 0x5c9e
movq %rbx, %rdi
callq 0x678e
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x2160
leaq 0x18(%rsp), %rdi
callq 0x5e5a
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5d31
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x20a0
jmp 0x5cd9
movq %rax, %rbx
pushq $0x40
popq %rsi
movq 0x8(%rsp), %rdi
jmp 0x5d26
jmp 0x5d31
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r14, %rdi
jmp 0x5d26
jmp 0x5d31
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x5d14
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x5d14
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x20a0
jmp 0x5d34
jmp 0x5d1d
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r13, %rdi
callq 0x2160
jmp 0x5d34
jmp 0x5d31
jmp 0x5d31
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5e5a
movq %rbx, %rdi
callq 0x2210