// File: /workspace/github_cpp_makefile_star2_O2/KitchMKelly[P]Team-9-OSU-Hackathon-Winter-2018/BawkBusterFunctions.cpp
// Function: genreSearchMain(Cart&, std::vector<Video, std::allocator<Video>>&)
void genreSearchMain(Cart& newCart, vector<Video>& videoList)
{
	vector<Video> results;		//Initialize an empty vector of movie results
	int genreChoice = -1;		//Initalize new string to hold user input
	string genre = "";
	displayGenreSearchMenu();
	cin >> genreChoice;
	validateGenreMenuChoice(genreChoice); //Get user input, store in 'genreChoice'
	
	while (genreChoice != 0)
	{
		switch(genreChoice) 
		{
			case 1: genre = "Action";
				break;
			case 2: genre = "Adventure"; 
				break;		
			case 3: genre = "Comedy"; 
				break;
			case 4: genre = "Romance"; 
				break;
			case 5: genre = "Horror"; 
				break;
			case 6: genre = "Animation"; 
				break;
			case 7: genre = "Other";	//this one is going to be more complicated
				break;			//since we can't do a simple text match		
		}		

						
		//search for movie titles, return results (if any)
		genreSearchVector(videoList, results, genre);
		if (results.empty())  //if results is empty, we didn't find it
		{
			clearScreen();
			cout << "Nothing found!\n" << endl;
		}
		else
		{
			clearScreen();
			cout << "Movies found:\n";  //results now holds the movie!!
			for (int i = 0; i < results.size(); i++)
			{
				cout << i+1 << ". " << results[i].getTitle() << endl;
			}
			addToCart(newCart, results);	//User decides if (s)he wants to add the movie to the cart,
							//and continues searching.
			//clearScreen();
		}
		results.clear(); //delete everything from the vector to prepare for the next search
		//cin.clear();
		//cin.ignore(1000, '\n');
		std::cout << "Press enter to continue..." << endl;
		displayGenreSearchMenu();
		cin >> genreChoice; //Get user input again, store in 'genreChoice'
		validateGenreMenuChoice(genreChoice);
	}	//As long as the user doesn't enter '0',
		//(s)he can search as many times as desired.	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, -0x60(%rbp)
movq %rdi, -0x58(%rbp)
xorps %xmm0, %xmm0
andq $0x0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
orl $-0x1, -0x2c(%rbp)
leaq 0x3352(%rip), %rsi      # 0x6645
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x4328
callq 0x3bed
movq 0x6cd1(%rip), %rdi      # 0x9fe0
leaq -0x2c(%rbp), %rsi
callq 0x2100
leaq -0x2c(%rbp), %rdi
callq 0x3d2a
leaq -0xc0(%rbp), %r15
leaq -0x80(%rbp), %r12
movq 0x6c9d(%rip), %r14      # 0x9fd0
leaq -0xa0(%rbp), %rbx
movl -0x2c(%rbp), %eax
cmpq $0x7, %rax
ja 0x3396
leaq 0x2cd2(%rip), %rcx      # 0x601c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x3187(%rip), %rsi      # 0x64df
jmpq *%rax
leaq 0x3188(%rip), %rsi      # 0x64e9
jmp 0x338e
leaq 0x31a1(%rip), %rsi      # 0x650b
jmp 0x338e
leaq 0x3183(%rip), %rsi      # 0x64f6
jmp 0x338e
leaq 0x3184(%rip), %rsi      # 0x6500
jmp 0x338e
leaq 0x3190(%rip), %rsi      # 0x6515
jmp 0x338e
leaq 0x3194(%rip), %rsi      # 0x6522
movq %r12, %rdi
callq 0x22a0
movq %r15, %rdi
movq %r12, %rsi
callq 0x21e0
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %r15, %rdx
callq 0x3db1
movq %r15, %rdi
callq 0x20c0
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x3466
callq 0x28a1
movq %r14, %rdi
leaq 0x30a6(%rip), %rsi      # 0x647c
callq 0x2180
xorl %r12d, %r12d
xorl %r15d, %r15d
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
cqto
movl $0x98, %ecx
idivq %rcx
cmpq %r15, %rax
jbe 0x344c
leal 0x1(%r15), %esi
movq %r14, %rdi
callq 0x2240
movq %rax, %rdi
leaq 0x307d(%rip), %rsi      # 0x648b
callq 0x2180
movq %rax, %r13
movq -0x50(%rbp), %rsi
addq %r12, %rsi
movq %rbx, %rdi
callq 0x4e74
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2170
movq %rax, %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x20c0
addq $0x98, %r12
incq %r15
jmp 0x33e1
movq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2908
leaq -0xc0(%rbp), %r15
leaq -0x80(%rbp), %r12
jmp 0x3482
callq 0x28a1
movq %r14, %rdi
leaq 0x2ff7(%rip), %rsi      # 0x646c
callq 0x2180
movq %rax, %rdi
callq 0x20d0
leaq -0x50(%rbp), %rdi
callq 0x4370
movq %r14, %rdi
leaq 0x2bda(%rip), %rsi      # 0x606f
callq 0x2180
movq %rax, %rdi
callq 0x20d0
callq 0x3bed
movq 0x6b32(%rip), %rdi      # 0x9fe0
leaq -0x2c(%rbp), %rsi
callq 0x2100
leaq -0x2c(%rbp), %rdi
callq 0x3d2a
jmp 0x333a
leaq -0x80(%rbp), %rdi
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x2502
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x351d
jmp 0x3511
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x350a
jmp 0x3511
jmp 0x3511
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x20c0
jmp 0x3514
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x2502
movq %rbx, %rdi
callq 0x2250