// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rsi, -0x90(%rbp)
movq %rdi, -0x88(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x4c96(%rip), %rdx      # 0x8645
leaq -0x48(%rbp), %rdi
movq %rdx, %rsi
callq 0x63ca
movq 0x761e(%rip), %rdi      # 0xafe0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
xorl %esi, %esi
callq 0x2200
movq 0x7609(%rip), %rbx      # 0xafe0
movl $0x2710, %esi           # imm = 0x2710
movq %rbx, %rdi
movl $0xa, %edx
callq 0x20d0
movq 0x75e0(%rip), %rdi      # 0xafd0
leaq 0x466d(%rip), %rsi      # 0x8064
movl $0xa, %edx
callq 0x2180
movq 0x75c8(%rip), %r14      # 0xafd0
leaq 0x499c(%rip), %rsi      # 0x83ab
movl $0x18, %edx
movq %r14, %rdi
callq 0x2180
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq 0x7596(%rip), %rdi      # 0xafd0
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq 0x7582(%rip), %rdi      # 0xafd0
leaq 0x496f(%rip), %rsi      # 0x83c4
movl $0x3d, %edx
callq 0x2180
movq 0x756a(%rip), %r14      # 0xafd0
leaq 0x4995(%rip), %rsi      # 0x8402
movl $0x24, %edx
movq %r14, %rdi
callq 0x2180
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq 0x7538(%rip), %r15      # 0xafd0
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %edx
movq 0x751a(%rip), %r12      # 0xafe0
leaq -0x48(%rbp), %rsi
movq %r12, %rdi
callq 0x2250
leaq -0x48(%rbp), %r14
leaq -0x80(%rbp), %r13
leaq -0x60(%rbp), %rbx
movq %r14, %rdi
leaq 0x493f(%rip), %rsi      # 0x8427
callq 0x2070
testl %eax, %eax
je 0x3c50
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x5f92
movq -0x90(%rbp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x48b3
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x3b3b
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
je 0x3b7e
movl $0xa, %edx
movq %r15, %rdi
leaq 0x4510(%rip), %rsi      # 0x8064
callq 0x2180
movl $0xe, %edx
movq %r15, %rdi
leaq 0x48d2(%rip), %rsi      # 0x843a
callq 0x2180
movq -0x88(%rbp), %rdi
movq %rbx, %rsi
callq 0x2b60
jmp 0x3bcd
movl $0xa, %edx
movq %r15, %rdi
leaq 0x44d7(%rip), %rsi      # 0x8064
callq 0x2180
movl $0x10, %edx
movq %r15, %rdi
leaq 0x4888(%rip), %rsi      # 0x8429
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
movq -0x60(%rbp), %rsi
movq %rbx, %rdi
callq 0x6468
movl $0x22, %edx
movq %r15, %rdi
leaq 0x4861(%rip), %rsi      # 0x8449
callq 0x2180
movl $0x24, %edx
movq %r15, %rdi
leaq 0x4806(%rip), %rsi      # 0x8402
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
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x2250
jmp 0x3ade
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3c69
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x60(%rbp), %rdi
callq 0x2506
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3cc2
jmp 0x3ca6
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x3ca9
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x3ca9
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3cc2
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x60(%rbp), %rdi
callq 0x2506
movq %rbx, %rdi
callq 0x2220