// File: 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
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2680
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
leaq -0x51(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x2350
movq -0xb8(%rbp), %rdx
leaq 0x5910(%rip), %rsi      # 0x9641
leaq -0x50(%rbp), %rdi
callq 0x5590
jmp 0x3d3c
leaq -0x51(%rbp), %rdi
callq 0x2240
callq 0x4ae0
jmp 0x3d4c
movq 0x928d(%rip), %rdi      # 0xcfe0
leaq -0x2c(%rbp), %rsi
callq 0x2140
jmp 0x3d5e
leaq -0x2c(%rbp), %rdi
callq 0x4ca0
jmp 0x3d69
jmp 0x3d6b
cmpl $0x0, -0x2c(%rbp)
je 0x4091
movl -0x2c(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0xc0(%rbp)
subl $0x6, %eax
ja 0x3e5a
movq -0xc0(%rbp), %rax
leaq 0x5282(%rip), %rcx      # 0x901c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x2240
jmp 0x40b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x40ac
leaq 0x5706(%rip), %rsi      # 0x94db
leaq -0x50(%rbp), %rdi
callq 0x22c0
jmp 0x3de0
jmp 0x3e5a
leaq 0x56fc(%rip), %rsi      # 0x94e5
leaq -0x50(%rbp), %rdi
callq 0x22c0
jmp 0x3df4
jmp 0x3e5a
leaq 0x56f5(%rip), %rsi      # 0x94f2
leaq -0x50(%rbp), %rdi
callq 0x22c0
jmp 0x3e08
jmp 0x3e5a
leaq 0x56eb(%rip), %rsi      # 0x94fc
leaq -0x50(%rbp), %rdi
callq 0x22c0
jmp 0x3e1c
jmp 0x3e5a
leaq 0x56e2(%rip), %rsi      # 0x9507
leaq -0x50(%rbp), %rdi
callq 0x22c0
jmp 0x3e30
jmp 0x3e5a
leaq 0x56d8(%rip), %rsi      # 0x9511
leaq -0x50(%rbp), %rdi
callq 0x22c0
jmp 0x3e44
jmp 0x3e5a
leaq 0x56d1(%rip), %rsi      # 0x951e
leaq -0x50(%rbp), %rdi
callq 0x22c0
jmp 0x3e58
jmp 0x3e5a
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x20e0
jmp 0x3e77
movq -0xc8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x4d70
jmp 0x3e90
leaq -0x88(%rbp), %rdi
callq 0x2150
leaq -0x28(%rbp), %rdi
callq 0x5670
testb $0x1, %al
jne 0x3eab
jmp 0x3f05
callq 0x2de0
jmp 0x3eb2
movq 0x9117(%rip), %rdi      # 0xcfd0
leaq 0x55a8(%rip), %rsi      # 0x9468
callq 0x21f0
movq %rax, -0xd0(%rbp)
jmp 0x3ece
movq -0xd0(%rbp), %rdi
movq 0x90e4(%rip), %rsi      # 0xcfc0
callq 0x2220
jmp 0x3ee3
jmp 0x402e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x2150
jmp 0x40ac
callq 0x2de0
jmp 0x3f0c
movq 0x90bd(%rip), %rdi      # 0xcfd0
leaq 0x555e(%rip), %rsi      # 0x9478
callq 0x21f0
jmp 0x3f21
movl $0x0, -0x8c(%rbp)
movslq -0x8c(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5400
movq %rax, %rcx
movq -0xd8(%rbp), %rax
cmpq %rcx, %rax
jae 0x401d
movl -0x8c(%rbp), %esi
incl %esi
movq 0x906c(%rip), %rdi      # 0xcfd0
callq 0x2330
movq %rax, -0xe0(%rbp)
jmp 0x3f72
movq -0xe0(%rbp), %rdi
leaq 0x5507(%rip), %rsi      # 0x9487
callq 0x21f0
movq %rax, -0xe8(%rbp)
jmp 0x3f8e
movslq -0x8c(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x5430
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x7cc0
jmp 0x3faf
movq -0xe8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x21e0
movq %rax, -0xf0(%rbp)
jmp 0x3fcb
movq -0xf0(%rbp), %rdi
movq 0x8fe7(%rip), %rsi      # 0xcfc0
callq 0x2220
jmp 0x3fe0
leaq -0xb0(%rbp), %rdi
callq 0x2150
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x3f2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x2150
jmp 0x40ac
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x2e60
jmp 0x402c
jmp 0x402e
leaq -0x28(%rbp), %rdi
callq 0x56b0
movq 0x8f92(%rip), %rdi      # 0xcfd0
leaq 0x5026(%rip), %rsi      # 0x906b
callq 0x21f0
movq %rax, -0xf8(%rbp)
jmp 0x4053
movq -0xf8(%rbp), %rdi
movq 0x8f5f(%rip), %rsi      # 0xcfc0
callq 0x2220
jmp 0x4068
callq 0x4ae0
jmp 0x406f
movq 0x8f6a(%rip), %rdi      # 0xcfe0
leaq -0x2c(%rbp), %rsi
callq 0x2140
jmp 0x4081
leaq -0x2c(%rbp), %rdi
callq 0x4ca0
jmp 0x408c
jmp 0x3d6b
leaq -0x50(%rbp), %rdi
callq 0x2150
leaq -0x28(%rbp), %rdi
callq 0x26a0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x2150
leaq -0x28(%rbp), %rdi
callq 0x26a0
movq -0x60(%rbp), %rdi
callq 0x2340
nopw (%rax,%rax)