// File: /workspace/github_cpp_makefile_star2_O1/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, -0xc0(%rbp)
movq %rdi, -0xb8(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x49a4(%rip), %rdx      # 0x8645
leaq -0x70(%rbp), %rdi
movq %rdx, %rsi
callq 0x62ce
callq 0x4a68
movq 0x7327(%rip), %rdi      # 0xafe0
leaq -0x2c(%rbp), %rsi
callq 0x20c0
leaq -0x2c(%rbp), %rdi
callq 0x4d42
leaq -0xa0(%rbp), %r14
leaq -0xb0(%rbp), %rbx
movq 0x72f0(%rip), %r13      # 0xafd0
leaq -0x2c(%rbp), %r12
leaq -0x90(%rbp), %r15
movl -0x2c(%rbp), %eax
cmpq $0x7, %rax
ja 0x3d78
movl $0x9, %r8d
leaq 0x4317(%rip), %rcx      # 0x801c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x6, %r8d
leaq 0x47c4(%rip), %rcx      # 0x84df
jmp 0x3d69
movl $0x6, %r8d
leaq 0x47e1(%rip), %rcx      # 0x850b
jmp 0x3d69
movl $0x6, %r8d
leaq 0x47bd(%rip), %rcx      # 0x84f6
jmp 0x3d69
movl $0x7, %r8d
leaq 0x47b8(%rip), %rcx      # 0x8500
jmp 0x3d69
leaq 0x4798(%rip), %rcx      # 0x84e9
jmp 0x3d69
leaq 0x47bb(%rip), %rcx      # 0x8515
jmp 0x3d69
movl $0x5, %r8d
leaq 0x47b9(%rip), %rcx      # 0x8522
movq -0x68(%rbp), %rdx
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x21d0
movq %r14, -0xb0(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x5e9e
movq -0xc0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x4dfc
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3dc0
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x3ee7
movl $0xa, %edx
movq %r13, %rdi
leaq 0x4287(%rip), %rsi      # 0x8064
callq 0x2180
movl $0xe, %edx
movq %r13, %rdi
leaq 0x468b(%rip), %rsi      # 0x847c
callq 0x2180
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
je 0x3ec3
xorl %ebx, %ebx
xorl %r14d, %r14d
incq %r14
movq %r13, %rdi
movl %r14d, %esi
callq 0x2210
movq %rax, %r12
movl $0x2, %edx
movq %rax, %rdi
leaq 0x4662(%rip), %rsi      # 0x848b
callq 0x2180
movq -0x50(%rbp), %rsi
addq %rbx, %rsi
movq %r15, %rdi
callq 0x6822
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq %r12, %rdi
callq 0x2180
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3e99
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x3, %rax
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rax
addq $0x98, %rbx
cmpq %r14, %rax
ja 0x3e09
movq -0xb8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2b63
leaq -0xa0(%rbp), %r14
leaq -0xb0(%rbp), %rbx
leaq -0x2c(%rbp), %r12
jmp 0x3f37
movl $0xa, %edx
movq %r13, %rdi
leaq 0x416e(%rip), %rsi      # 0x8064
callq 0x2180
movl $0xf, %edx
movq %r13, %rdi
leaq 0x4562(%rip), %rsi      # 0x846c
callq 0x2180
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq -0x50(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x6368
movl $0x1a, %edx
movq %r13, %rdi
leaq 0x411c(%rip), %rsi      # 0x806f
callq 0x2180
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
callq 0x4a68
movq 0x7054(%rip), %rdi      # 0xafe0
movq %r12, %rsi
callq 0x20c0
movq %r12, %rdi
callq 0x4d42
jmp 0x3ceb
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3fba
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x50(%rbp), %rdi
callq 0x2506
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4035
jmp 0x3ff8
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x401c
movq -0xa0(%rbp), %rsi
jmp 0x4014
jmp 0x3ff8
jmp 0x3ff8
movq %rax, %rbx
jmp 0x401c
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x401c
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x4035
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x50(%rbp), %rdi
callq 0x2506
movq %rbx, %rdi
callq 0x2220