// File: 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
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2680
leaq -0x49(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x2350
movq -0x88(%rbp), %rdx
leaq 0x5bf7(%rip), %rsi      # 0x9641
leaq -0x48(%rbp), %rdi
callq 0x5590
jmp 0x3a55
leaq -0x49(%rbp), %rdi
callq 0x2240
movq 0x957b(%rip), %rdi      # 0xcfe0
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x2320
jmp 0x3a78
movq 0x9561(%rip), %rdi      # 0xcfe0
movl $0x2710, %esi           # imm = 0x2710
movl $0xa, %edx
callq 0x2160
jmp 0x3a90
callq 0x2de0
jmp 0x3a97
movq 0x9532(%rip), %rdi      # 0xcfd0
leaq 0x5902(%rip), %rsi      # 0x93a7
callq 0x21f0
movq %rax, -0x90(%rbp)
jmp 0x3ab3
movq -0x90(%rbp), %rdi
movq 0x94ff(%rip), %rsi      # 0xcfc0
callq 0x2220
jmp 0x3ac8
movq 0x9501(%rip), %rdi      # 0xcfd0
leaq 0x58ea(%rip), %rsi      # 0x93c0
callq 0x21f0
movq %rax, -0x98(%rbp)
jmp 0x3ae4
movq -0x98(%rbp), %rdi
leaq 0x590c(%rip), %rsi      # 0x93fe
callq 0x21f0
movq %rax, -0xa0(%rbp)
jmp 0x3b00
movq -0xa0(%rbp), %rdi
movq 0x94b2(%rip), %rsi      # 0xcfc0
callq 0x2220
jmp 0x3b15
movq 0x94c4(%rip), %rdi      # 0xcfe0
leaq -0x48(%rbp), %rsi
callq 0x2050
jmp 0x3b27
jmp 0x3b29
leaq 0x58f3(%rip), %rsi      # 0x9423
leaq -0x48(%rbp), %rdi
callq 0x5640
movb %al, -0xa1(%rbp)
jmp 0x3b41
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x3b50
jmp 0x3cb1
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x20e0
jmp 0x3b6a
movq -0xb0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4830
jmp 0x3b80
leaq -0x80(%rbp), %rdi
callq 0x2150
leaq -0x28(%rbp), %rdi
callq 0x5670
testb $0x1, %al
jne 0x3b98
jmp 0x3c17
callq 0x2de0
jmp 0x3b9f
movq 0x942a(%rip), %rdi      # 0xcfd0
leaq 0x5878(%rip), %rsi      # 0x9425
callq 0x21f0
movq %rax, -0xb8(%rbp)
jmp 0x3bbb
movq -0xb8(%rbp), %rdi
movq 0x93f7(%rip), %rsi      # 0xcfc0
callq 0x2220
jmp 0x3bd0
jmp 0x3c44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x2240
jmp 0x3cd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3ccc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x2150
jmp 0x3ccc
callq 0x2de0
jmp 0x3c1e
movq 0x93ab(%rip), %rdi      # 0xcfd0
leaq 0x580a(%rip), %rsi      # 0x9436
callq 0x21f0
jmp 0x3c33
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x2e60
jmp 0x3c42
jmp 0x3c44
leaq -0x28(%rbp), %rdi
callq 0x56b0
movq 0x937c(%rip), %rdi      # 0xcfd0
leaq 0x57ea(%rip), %rsi      # 0x9445
callq 0x21f0
movq %rax, -0xc0(%rbp)
jmp 0x3c69
movq -0xc0(%rbp), %rdi
leaq 0x5787(%rip), %rsi      # 0x93fe
callq 0x21f0
movq %rax, -0xc8(%rbp)
jmp 0x3c85
movq -0xc8(%rbp), %rdi
movq 0x932d(%rip), %rsi      # 0xcfc0
callq 0x2220
jmp 0x3c9a
movq 0x933f(%rip), %rdi      # 0xcfe0
leaq -0x48(%rbp), %rsi
callq 0x2050
jmp 0x3cac
jmp 0x3b29
leaq -0x48(%rbp), %rdi
callq 0x2150
leaq -0x28(%rbp), %rdi
callq 0x26a0
addq $0xd0, %rsp
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x2150
leaq -0x28(%rbp), %rdi
callq 0x26a0
movq -0x58(%rbp), %rdi
callq 0x2340
nopw (%rax,%rax)