// File: /workspace/github_cpp_makefile_star2_O2/KitchMKelly[P]Team-9-OSU-Hackathon-Winter-2018/BawkBusterFunctions.cpp
// Function: titleSearchMain(Cart&, std::vector<Video, std::allocator<Video>>&)
void titleSearchMain(Cart& newCart, vector<Video>& videoList)  //Needed to pass the vector so it's available to search
{
	vector<Video> results;		//Initialize an empty vector of movie results
	string title = "";			//Initalize new string to hold user input

	cin.clear();				//Clear bad input flag
	cin.ignore(10000, '\n');	//Discard input
	clearScreen();				//Clear screen before displaying menu
	cout << "Search Movies by: Title\n" << endl;
	cout << "Enter the complete title of the movie you are searching for,\n" 
		<< "or enter '0' to return to Main Menu." << endl;

	getline(cin, title);		//Get user input, store in 'title'
	while (title != "0")		//As long as the user doesn't enter '0',
								//(s)he can search as many times as desired.
	{							
		//search for movie titles, return results (if any)
		titleSearchVector(videoList, results, title);
		if (results.empty())  //if results is empty, we didn't find it
		{
			clearScreen();
			cout << "Movie not found\n" << endl;
		}
		else
		{
			clearScreen();
			cout << "Movie found!!\n";  //results now holds the movie!!
			addToCart(newCart, results);				//User decides if (s)he wants to add the movie to the cart,
										//and continues searching.
		}
		results.clear(); //delete everything from the vector to prepare for the next search
		cout << "Please enter another movie title,\n"
			 << "or enter '0' to return to Main Menu." << endl;
		getline(cin, title);
	}
	//TODO: Function to add user selections to cart
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
movq %rdi, -0x58(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
leaq 0x3543(%rip), %rsi      # 0x6645
leaq -0x78(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4328
movq 0x6eca(%rip), %rdi      # 0x9fe0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
xorl %esi, %esi
callq 0x2230
movq 0x6eb5(%rip), %rdi      # 0x9fe0
pushq $0xa
popq %rdx
movl $0x2710, %esi           # imm = 0x2710
callq 0x2110
callq 0x28a1
movq 0x6e8c(%rip), %rdi      # 0x9fd0
leaq 0x3260(%rip), %rsi      # 0x63ab
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movq 0x6e71(%rip), %rdi      # 0x9fd0
leaq 0x325e(%rip), %rsi      # 0x63c4
callq 0x2180
leaq 0x3290(%rip), %rsi      # 0x6402
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movq 0x6e57(%rip), %rdi      # 0x9fe0
leaq -0x78(%rbp), %rsi
callq 0x2030
leaq -0x78(%rbp), %r12
leaq -0x98(%rbp), %r13
leaq -0x50(%rbp), %r14
movq 0x6e28(%rip), %r15      # 0x9fd0
movq %r12, %rdi
leaq 0x3275(%rip), %rsi      # 0x6427
callq 0x4363
testb %al, %al
je 0x326a
movq %r13, %rdi
movq %r12, %rsi
callq 0x21e0
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x3a72
movq %r13, %rdi
callq 0x20c0
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x320c
callq 0x28a1
movq %r15, %rdi
leaq 0x3241(%rip), %rsi      # 0x643a
callq 0x2180
movq -0x58(%rbp), %rdi
movq %r14, %rsi
callq 0x2908
jmp 0x3228
callq 0x28a1
movq %r15, %rdi
leaq 0x320e(%rip), %rsi      # 0x6429
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movq %r14, %rdi
callq 0x4370
movq %r15, %rdi
leaq 0x320f(%rip), %rsi      # 0x6449
callq 0x2180
movq %rax, %rdi
leaq 0x31b9(%rip), %rsi      # 0x6402
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movq 0x6d83(%rip), %rdi      # 0x9fe0
movq %r12, %rsi
callq 0x2030
jmp 0x31a8
leaq -0x78(%rbp), %rdi
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x2502
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x32af
jmp 0x32a3
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x20c0
jmp 0x32a6
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x2502
movq %rbx, %rdi
callq 0x2250