// File: 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
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rsi, -0x138(%rbp)
movq %rdx, -0x130(%rbp)
movq %rcx, -0x128(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x95c0
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x10, %edi
callq 0x21b0
movq %rax, -0x118(%rbp)
jmp 0x8fc5
movq -0x118(%rbp), %rdi
movq -0x120(%rbp), %rax
movq (%rax), %rsi
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
callq 0xd270
jmp 0x8fe3
movq -0x118(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x95e0
jmp 0x8ffd
movl $0x40, %edi
callq 0x21b0
movq %rax, -0x140(%rbp)
jmp 0x9010
movq -0x138(%rbp), %rsi
movb $0x1, -0x89(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x20a0
jmp 0x902c
movq -0x140(%rbp), %rdi
movl $0x8, %esi
movl $0xf, %edx
leaq -0x88(%rbp), %rcx
callq 0xdf80
jmp 0x904b
movb $0x0, -0x89(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x2100
movq -0x140(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x7, -0x90(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9620
xorb $-0x1, %al
testb $0x1, %al
jne 0x9087
jmp 0x9529
leaq -0x38(%rbp), %rdi
callq 0x9640
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0xd2b0
movq %rax, -0x148(%rbp)
jmp 0x90af
movq -0x148(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0xd000
movq %rax, -0x150(%rbp)
jmp 0x90d5
movq -0x150(%rbp), %rax
cmpq $0x0, (%rax)
je 0x92b9
movq -0xa0(%rbp), %rdi
callq 0xd2c0
movl %eax, -0x154(%rbp)
jmp 0x90fa
movl -0x154(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x3c(%rbp)
movq -0xa0(%rbp), %rdi
callq 0xd2e0
movl %eax, -0x158(%rbp)
jmp 0x911a
movl -0x158(%rbp), %eax
addl $-0x2, %eax
movl %eax, -0x40(%rbp)
movl $0x10, %edi
callq 0x21b0
movq %rax, -0x160(%rbp)
jmp 0x9139
movq -0x98(%rbp), %rdi
callq 0xd000
movq %rax, -0x168(%rbp)
jmp 0x914e
movq -0x160(%rbp), %rdi
movq -0x168(%rbp), %rax
movq (%rax), %rsi
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
callq 0xd270
jmp 0x916c
movq -0x160(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x95e0
jmp 0x918c
movq -0x130(%rbp), %rsi
movq -0x68(%rbp), %rax
movq %rax, -0x178(%rbp)
movl -0x3c(%rbp), %eax
decl %eax
movl %eax, -0x170(%rbp)
movl -0x90(%rbp), %edx
movl -0x40(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x1(%rax,%rcx), %eax
movl %eax, -0x16c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x20a0
jmp 0x91ce
movl -0x16c(%rbp), %edx
movl -0x170(%rbp), %esi
movq -0x178(%rbp), %rdi
leaq -0xc8(%rbp), %rcx
callq 0xe310
jmp 0x91ef
leaq -0xc8(%rbp), %rdi
callq 0x2100
jmp 0x92b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x95a2
movq -0x118(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x10, %esi
callq 0x21c0
jmp 0x95a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x9259
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x2100
testb $0x1, -0x89(%rbp)
jne 0x9264
jmp 0x9275
movq -0x140(%rbp), %rdi
movl $0x40, %esi
callq 0x21c0
jmp 0x95a2
movq -0x160(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x10, %esi
callq 0x21c0
jmp 0x95a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x2100
jmp 0x95a2
movq -0x98(%rbp), %rdi
callq 0xd040
movq %rax, -0x180(%rbp)
jmp 0x92ce
movq -0x180(%rbp), %rax
cmpq $0x0, (%rax)
je 0x9435
movq -0xa0(%rbp), %rdi
callq 0xd2c0
movl %eax, -0x184(%rbp)
jmp 0x92f3
movl -0x184(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x3c(%rbp)
movq -0xa0(%rbp), %rdi
callq 0xd2e0
movl %eax, -0x188(%rbp)
jmp 0x9313
movl -0x188(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x40(%rbp)
movl $0x10, %edi
callq 0x21b0
movq %rax, -0x190(%rbp)
jmp 0x9332
movq -0x98(%rbp), %rdi
callq 0xd040
movq %rax, -0x198(%rbp)
jmp 0x9347
movq -0x190(%rbp), %rdi
movq -0x198(%rbp), %rax
movq (%rax), %rsi
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
callq 0xd270
jmp 0x9365
movq -0x190(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x95e0
jmp 0x9385
movq -0x128(%rbp), %rsi
movq -0x68(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movl -0x3c(%rbp), %eax
decl %eax
movl %eax, -0x1a0(%rbp)
movl -0x90(%rbp), %edx
movl -0x40(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal -0x1(%rax,%rcx), %eax
movl %eax, -0x19c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x20a0
jmp 0x93c7
movl -0x19c(%rbp), %edx
movl -0x1a0(%rbp), %esi
movq -0x1a8(%rbp), %rdi
leaq -0xf0(%rbp), %rcx
callq 0xe310
jmp 0x93e8
leaq -0xf0(%rbp), %rdi
callq 0x2100
jmp 0x9435
movq -0x190(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x10, %esi
callq 0x21c0
jmp 0x95a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x2100
jmp 0x95a2
cmpq $0x0, -0x98(%rbp)
je 0x951b
movq -0xa0(%rbp), %rdi
callq 0xd2c0
movl %eax, -0x1ac(%rbp)
jmp 0x9457
movl -0x1ac(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0xa0(%rbp), %rdi
callq 0xd2e0
movl %eax, -0x1b0(%rbp)
jmp 0x9474
movl -0x1b0(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x1c0(%rbp)
movl -0x90(%rbp), %eax
movl -0x58(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x1bc(%rbp)
movq -0xa0(%rbp), %rdi
callq 0xd2b0
movq %rax, -0x1b8(%rbp)
jmp 0x94b7
movq -0x1b8(%rbp), %rax
movq (%rax), %rsi
leaq -0x110(%rbp), %rdi
callq 0xcf30
jmp 0x94cf
movl -0x1bc(%rbp), %edx
movl -0x1c0(%rbp), %esi
movq -0x1c8(%rbp), %rdi
leaq -0x110(%rbp), %rcx
callq 0xe310
jmp 0x94f0
leaq -0x110(%rbp), %rdi
callq 0x2100
jmp 0x951b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x2100
jmp 0x95a2
leaq -0x38(%rbp), %rdi
callq 0x9670
jmp 0x9073
movq -0x68(%rbp), %rdi
callq 0xe540
jmp 0x9534
movq -0x68(%rbp), %rax
movq %rax, -0x1d0(%rbp)
cmpq $0x0, %rax
je 0x9562
movq -0x1d0(%rbp), %rdi
callq 0xe2e0
movq -0x1d0(%rbp), %rdi
movl $0x40, %esi
callq 0x21c0
movq -0x48(%rbp), %rax
movq %rax, -0x1d8(%rbp)
cmpq $0x0, %rax
je 0x9590
movq -0x1d8(%rbp), %rdi
callq 0xd2a0
movq -0x1d8(%rbp), %rdi
movl $0x10, %esi
callq 0x21c0
leaq -0x38(%rbp), %rdi
callq 0x96a0
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x96a0
movq -0x50(%rbp), %rdi
callq 0x22c0
nopw %cs:(%rax,%rax)
nop