// File: /workspace/github_cpp_makefile_star2_O1/KitchMKelly[P]Team-9-OSU-Hackathon-Winter-2018/BawkBusterFunctions.cpp
// Function: addToCart(Cart&, std::vector<Video, std::allocator<Video>>&)
void addToCart(Cart &newCart, std::vector<Video> &results)
{
	char addDecision;		//variable to hold user choice
	if(results.size() > 1)
	{
		cout << endl << "There are " << results.size() << " search results" << endl;
		cout << "Would you like to add one of these movies to your cart? (Y/N)" << endl;
		cin >> addDecision;
		//Verify user input
		while ((toupper(addDecision) != 'Y' && toupper(addDecision) != 'N'))
		{	
			cin.clear();	//Clear bad input flag
			cin.ignore(10000, '\n');	//Discard input
			cout << "Please enter either 'Y' to add the movie to your cart, " << endl;
			cout << "or enter 'N' to start a new search." << endl;
			cin >> addDecision;
		}
		//Action based on user input
		if (toupper(addDecision) == 'Y')
		{
			int movieNumber = 0;
			cout << "Please enter the movie number you would like to add." << endl;
			cout << "For example, if you wish to add result \"1. Avatar\", please type 1:" << endl;
			cin.clear();
			cin.ignore(1000, '\n');
			cin >> movieNumber;
			if(movieNumber < 1 || movieNumber > results.size())
			{
				cout << "Try again, options are 1 though " << results.size()  << endl;
				cin.clear();
				cin.ignore(1000, '\n');
				cin >> movieNumber;
			}
			else
			{
				Video vid = results[(movieNumber - 1)];
				//cout << "video title is " << vid.getTitle() << endl;
				newCart.addVidToCart(vid);
				cin.clear();
				cin.ignore(1000, '\n');
				cout << endl << vid.getTitle() << " was added to your cart!" << endl;
				//systemPause();
			}
		}	
		if(toupper(addDecision) == 'N')
		{
			cin.clear();
			cin.ignore(1000, '\n');
			cout << "No movies added to your cart" << endl;			
		}
				
	}
	else if (results.size() == 1)
	{
		cout << "Would you like to add this movie to your cart? (Y/N)" <<endl;
		cin >> addDecision;
	
		//Verify user input
		while ((toupper(addDecision) != 'Y' && toupper(addDecision) != 'N'))
		{
			//cin.clear();	//Clear bad input flag
			//cin.ignore(10000, '\n');	//Discard input
			cout << "Please enter either 'Y' to add the movie to your cart, " << endl;
			cout << "or enter 'N' to start a new search." << endl;
			cin >> addDecision;
		}		

		//Action based on user input
		if (toupper(addDecision) == 'Y')
		{
			cin.clear();
			cin.ignore(1000,'\n');
			Video vid = results[0];
			newCart.addVidToCart(vid);
			clearScreen();
			cout << vid.getTitle() << " was added to your cart!" << endl <<endl;
			//TODO send back to main menu?
		}
		else if (toupper(addDecision) == 'N')
		{
			cin.clear();
			cin.ignore(1000, '\n');
			cout << "No movies added to your cart" << endl;			
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rsi, %r15
movq 0x8(%rsi), %rax
subq (%rsi), %rax
movq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x79435e50d79435e5, %r12 # imm = 0x86BCA1AF286BCA1B
imulq %r12, %rcx
cmpq $0x2, %rcx
jb 0x2d2b
movq %rdi, -0x38(%rbp)
movq 0x8425(%rip), %rbx      # 0xafd0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq %rax, %r14
leaq 0x54ae(%rip), %rsi      # 0x808a
movl $0xa, %edx
movq %rax, %rdi
callq 0x2180
movq 0x8(%r15), %rsi
movq %r15, -0x40(%rbp)
subq (%r15), %rsi
sarq $0x3, %rsi
imulq %r12, %rsi
movq %r14, %rdi
callq 0x20e0
movq %rax, %r14
leaq 0x5487(%rip), %rsi      # 0x8095
movl $0xf, %edx
movq %rax, %rdi
callq 0x2180
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq 0x545c(%rip), %rsi      # 0x80a5
movl $0x3d, %edx
movq %rbx, %rdi
callq 0x2180
movq 0x8383(%rip), %r14      # 0xafe0
leaq -0x29(%rbp), %r13
leaq 0x547b(%rip), %r15      # 0x80e3
leaq 0x54ac(%rip), %r12      # 0x811b
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq %r14, %rdi
movq %r13, %rsi
callq 0x21a0
movsbl -0x29(%rbp), %edi
callq 0x2260
cmpl $0x4e, %eax
je 0x33d0
cmpl $0x59, %eax
je 0x2e0c
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x2710, %esi           # imm = 0x2710
movq %r14, %rdi
movl $0xa, %edx
callq 0x20d0
movl $0x37, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movl $0x23, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2180
jmp 0x2c6f
cmpq $0x98, %rax
jne 0x343c
movq %r15, -0x40(%rbp)
movq %rdi, -0x38(%rbp)
movq 0x828a(%rip), %rbx      # 0xafd0
leaq 0x54c1(%rip), %rsi      # 0x820e
movl $0x34, %edx
movq %rbx, %rdi
callq 0x2180
movq 0x827f(%rip), %r14      # 0xafe0
leaq -0x29(%rbp), %r15
leaq 0x5377(%rip), %r12      # 0x80e3
leaq 0x53a8(%rip), %r13      # 0x811b
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x21a0
movsbl -0x29(%rbp), %edi
callq 0x2260
cmpl $0x4e, %eax
je 0x33de
cmpl $0x59, %eax
je 0x2f80
movl $0x37, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movl $0x23, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2180
jmp 0x2d73
leaq -0x44(%rbp), %r15
movl $0x0, (%r15)
leaq 0x5321(%rip), %rsi      # 0x813f
movl $0x34, %edx
movq %rbx, %rdi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq 0x531b(%rip), %rsi      # 0x8174
movl $0x42, %edx
movq %rbx, %rdi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x3e8, %esi            # imm = 0x3E8
movq %r14, %rdi
movl $0xa, %edx
callq 0x20d0
movq %r14, %rdi
movq %r15, %rsi
callq 0x20c0
movslq (%r15), %rax
testq %rax, %rax
movq -0x40(%rbp), %r12
movabsq $-0x79435e50d79435e5, %r13 # imm = 0x86BCA1AF286BCA1B
jle 0x2eee
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rax, %rdx
jae 0x31b1
movq 0x80db(%rip), %r15      # 0xafd0
leaq 0x52bb(%rip), %rsi      # 0x81b7
movl $0x20, %edx
movq %r15, %rdi
callq 0x2180
movq 0x8(%r12), %rsi
subq (%r12), %rsi
sarq $0x3, %rsi
imulq %r13, %rsi
movq %r15, %rdi
callq 0x20e0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x3e8, %esi            # imm = 0x3E8
movq %r14, %rdi
movl $0xa, %edx
callq 0x20d0
leaq -0x44(%rbp), %rsi
movq %r14, %rdi
callq 0x20c0
jmp 0x33d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x3e8, %esi            # imm = 0x3E8
movq %r14, %rdi
movl $0xa, %edx
callq 0x20d0
movq -0x40(%rbp), %rax
movq (%rax), %rsi
leaq -0x100(%rbp), %rbx
movq %rbx, %rdi
callq 0x5748
leaq -0x198(%rbp), %rdi
movq %rbx, %rsi
callq 0x5748
leaq -0x198(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x6eb0
leaq -0x118(%rbp), %rbx
movq %rbx, %rdi
callq 0x2506
movq -0x20(%rbx), %rdi
leaq -0x128(%rbp), %rax
cmpq %rax, %rdi
je 0x3006
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x148(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3025
movq -0x148(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x168(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3044
movq -0x168(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x188(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3063
movq -0x188(%rbp), %rsi
incq %rsi
callq 0x2160
movq 0x7f66(%rip), %rdi      # 0xafd0
leaq 0x4ff3(%rip), %rsi      # 0x8064
movl $0xa, %edx
callq 0x2180
leaq -0x68(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x6822
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq 0x7f36(%rip), %rdi      # 0xafd0
callq 0x2180
movq %rax, %rbx
leaq 0x512f(%rip), %rsi      # 0x81d8
movl $0x18, %edx
movq %rax, %rdi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3120
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x80(%rbp), %rbx
movq %rbx, %rdi
callq 0x2506
movq -0x20(%rbx), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x314b
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xb0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x316a
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xd0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3189
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xf0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x343c
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x343c
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rsi
addq $-0x98, %rsi
leaq -0x100(%rbp), %r15
movq %r15, %rdi
callq 0x5748
leaq -0x230(%rbp), %rdi
movq %r15, %rsi
callq 0x5748
leaq -0x230(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x6eb0
leaq -0x1b0(%rbp), %r15
movq %r15, %rdi
callq 0x2506
movq -0x20(%r15), %rdi
leaq -0x1c0(%rbp), %rax
cmpq %rax, %rdi
je 0x321f
movq -0x1c0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x1e0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x323e
movq -0x1e0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x200(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x325d
movq -0x200(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x220(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x327c
movq -0x220(%rbp), %rsi
incq %rsi
callq 0x2160
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x2200
movq 0x7d4c(%rip), %rdi      # 0xafe0
movl $0x3e8, %esi            # imm = 0x3E8
movl $0xa, %edx
callq 0x20d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq 0x7d0f(%rip), %rdi      # 0xafd0
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq %rax, %r15
leaq -0x68(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x6822
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r15, %rdi
callq 0x2180
movq %rax, %r15
leaq 0x4edd(%rip), %rsi      # 0x81d8
movl $0x18, %edx
movq %rax, %rdi
callq 0x2180
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3348
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x80(%rbp), %r15
movq %r15, %rdi
callq 0x2506
movq -0x20(%r15), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x3373
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xb0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3392
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xd0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x33b1
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xf0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x33d0
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x2160
movsbl -0x29(%rbp), %edi
callq 0x2260
cmpl $0x4e, %eax
jne 0x343c
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x3e8, %esi            # imm = 0x3E8
movq %r14, %rdi
movl $0xa, %edx
callq 0x20d0
leaq 0x4de9(%rip), %rsi      # 0x81f1
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3473
movq %rax, %rbx
leaq -0x230(%rbp), %rdi
jmp 0x3468
jmp 0x3473
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x56c6
jmp 0x3494
jmp 0x3473
jmp 0x3478
movq %rax, %rbx
jmp 0x3494
movq %rax, %rbx
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3494
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x100(%rbp), %rdi
callq 0x56c6
movq %rbx, %rdi
callq 0x2220