// File: /workspace/github_cpp_makefile_star2_O3/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 0x2d56
movq %rdi, -0x38(%rbp)
movq 0x8428(%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 0x54b1(%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 0x548a(%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 0x545f(%rip), %rsi      # 0x80a5
movl $0x3d, %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 0x835f(%rip), %r14      # 0xafe0
leaq -0x29(%rbp), %r13
leaq 0x548f(%rip), %r12      # 0x811b
movq %r14, %r15
movq %r14, %rdi
movq %r13, %rsi
callq 0x21a0
movsbl -0x29(%rbp), %r14d
movl %r14d, %edi
callq 0x2260
cmpl $0x4e, %eax
je 0x344a
cmpl $0x59, %eax
je 0x2e5e
movq %r15, %r14
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x2710, %esi           # imm = 0x2710
movq %r15, %rdi
movl $0xa, %edx
callq 0x20d0
movl $0x37, %edx
movq %rbx, %rdi
leaq 0x53f5(%rip), %rsi      # 0x80e3
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
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
jmp 0x2c8c
cmpq $0x98, %rax
jne 0x34b5
movq %r15, -0x40(%rbp)
movq %rdi, -0x38(%rbp)
movq 0x825f(%rip), %rbx      # 0xafd0
leaq 0x5496(%rip), %rsi      # 0x820e
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
movq 0x822d(%rip), %r14      # 0xafe0
leaq -0x29(%rbp), %r15
leaq 0x5325(%rip), %r12      # 0x80e3
leaq 0x5356(%rip), %r13      # 0x811b
movq %r14, %rdi
movq %r15, %rsi
callq 0x21a0
movsbl -0x29(%rbp), %edi
callq 0x2260
cmpl $0x4e, %eax
je 0x3205
cmpl $0x59, %eax
je 0x2fd4
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
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
jmp 0x2dc5
leaq -0x44(%rbp), %r12
movl $0x0, (%r12)
leaq 0x52ce(%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 0x52c8(%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 (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x3e8, %esi            # imm = 0x3E8
movq %r15, %rdi
movl $0xa, %edx
callq 0x20d0
movq %r15, %rdi
movq %r12, %rsi
callq 0x20c0
movslq (%r12), %rax
testq %rax, %rax
movq -0x40(%rbp), %r12
movabsq $-0x79435e50d79435e5, %r13 # imm = 0x86BCA1AF286BCA1B
jle 0x2f42
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rax, %rdx
jae 0x3223
movq 0x8087(%rip), %r14      # 0xafd0
leaq 0x5267(%rip), %rsi      # 0x81b7
movl $0x20, %edx
movq %r14, %rdi
callq 0x2180
movq 0x8(%r12), %rsi
subq (%r12), %rsi
sarq $0x3, %rsi
imulq %r13, %rsi
movq %r14, %rdi
callq 0x20e0
movq %rax, %r14
movq (%rax), %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
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x3e8, %esi            # imm = 0x3E8
movq %r15, %rdi
movl $0xa, %edx
callq 0x20d0
leaq -0x44(%rbp), %rsi
movq %r15, %rdi
callq 0x20c0
jmp 0x3445
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 0x581a
leaq -0x198(%rbp), %rdi
movq %rbx, %rsi
callq 0x581a
leaq -0x198(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x6fb4
leaq -0x118(%rbp), %rbx
movq %rbx, %rdi
callq 0x2506
movq -0x20(%rbx), %rdi
leaq -0x128(%rbp), %rax
cmpq %rax, %rdi
je 0x305a
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x148(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3079
movq -0x148(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x168(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3098
movq -0x168(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x188(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x30b7
movq -0x188(%rbp), %rsi
incq %rsi
callq 0x2160
movq 0x7f12(%rip), %rdi      # 0xafd0
leaq 0x4f9f(%rip), %rsi      # 0x8064
movl $0xa, %edx
callq 0x2180
leaq -0x68(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x6922
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq 0x7ee2(%rip), %rdi      # 0xafd0
callq 0x2180
movq %rax, %rbx
leaq 0x50db(%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 0x3174
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 0x319f
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xb0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x31be
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xd0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x31dd
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xf0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34b5
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x34b5
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x3e8, %esi            # imm = 0x3E8
movq %r14, %rdi
jmp 0x3470
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rsi
addq $-0x98, %rsi
leaq -0x100(%rbp), %r14
movq %r14, %rdi
callq 0x581a
leaq -0x230(%rbp), %rdi
movq %r14, %rsi
callq 0x581a
leaq -0x230(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x6fb4
leaq -0x1b0(%rbp), %r14
movq %r14, %rdi
callq 0x2506
movq -0x20(%r14), %rdi
leaq -0x1c0(%rbp), %rax
cmpq %rax, %rdi
je 0x3291
movq -0x1c0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x1e0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x32b0
movq -0x1e0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x200(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq %r15, %r14
je 0x32d2
movq -0x200(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x220(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x32f1
movq -0x220(%rbp), %rsi
incq %rsi
callq 0x2160
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x2200
movq 0x7cd7(%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 0x7c9a(%rip), %rdi      # 0xafd0
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq %rax, %r14
leaq -0x68(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x6922
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r14, %rdi
callq 0x2180
movq %rax, %r14
leaq 0x4e68(%rip), %rsi      # 0x81d8
movl $0x18, %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 -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x33bd
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x80(%rbp), %r14
movq %r14, %rdi
callq 0x2506
movq -0x20(%r14), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x33e8
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xb0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3407
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xd0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3426
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xf0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3445
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x2160
movsbl -0x29(%rbp), %r14d
movl %r14d, %edi
callq 0x2260
cmpl $0x4e, %eax
jne 0x34b5
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
xorl %esi, %esi
callq 0x2200
movl $0x3e8, %esi            # imm = 0x3E8
movq %r15, %rdi
movl $0xa, %edx
callq 0x20d0
leaq 0x4d70(%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 0x34ec
movq %rax, %rbx
leaq -0x230(%rbp), %rdi
jmp 0x34e1
jmp 0x34ec
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x5798
jmp 0x350d
jmp 0x34ec
jmp 0x34f1
movq %rax, %rbx
jmp 0x350d
movq %rax, %rbx
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x350d
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x100(%rbp), %rdi
callq 0x5798
movq %rbx, %rdi
callq 0x2220