// File: /workspace/github_cpp_makefile_star2_O3/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 0x492b(%rip), %rdx      # 0x8645
leaq -0x70(%rbp), %rdi
movq %rdx, %rsi
callq 0x63ca
callq 0x4b12
movq 0x72ae(%rip), %rdi      # 0xafe0
leaq -0x2c(%rbp), %rsi
callq 0x20c0
leaq -0x2c(%rbp), %rdi
callq 0x4dec
leaq -0xa0(%rbp), %r14
leaq -0xb0(%rbp), %rbx
movq 0x7277(%rip), %r13      # 0xafd0
leaq -0x2c(%rbp), %r12
leaq -0x90(%rbp), %r15
movl -0x2c(%rbp), %eax
cmpq $0x7, %rax
ja 0x3df1
movl $0x9, %r8d
leaq 0x429e(%rip), %rcx      # 0x801c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x6, %r8d
leaq 0x474b(%rip), %rcx      # 0x84df
jmp 0x3de2
movl $0x6, %r8d
leaq 0x4768(%rip), %rcx      # 0x850b
jmp 0x3de2
movl $0x6, %r8d
leaq 0x4744(%rip), %rcx      # 0x84f6
jmp 0x3de2
movl $0x7, %r8d
leaq 0x473f(%rip), %rcx      # 0x8500
jmp 0x3de2
leaq 0x471f(%rip), %rcx      # 0x84e9
jmp 0x3de2
leaq 0x4742(%rip), %rcx      # 0x8515
jmp 0x3de2
movl $0x5, %r8d
leaq 0x4740(%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 0x5f92
movq -0xc0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x4ea6
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3e39
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x3f60
movl $0xa, %edx
movq %r13, %rdi
leaq 0x420e(%rip), %rsi      # 0x8064
callq 0x2180
movl $0xe, %edx
movq %r13, %rdi
leaq 0x4612(%rip), %rsi      # 0x847c
callq 0x2180
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
je 0x3f3c
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 0x45e9(%rip), %rsi      # 0x848b
callq 0x2180
movq -0x50(%rbp), %rsi
addq %rbx, %rsi
movq %r15, %rdi
callq 0x6922
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 0x3f12
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 0x3e82
movq -0xb8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2b60
leaq -0xa0(%rbp), %r14
leaq -0xb0(%rbp), %rbx
leaq -0x2c(%rbp), %r12
jmp 0x3fb0
movl $0xa, %edx
movq %r13, %rdi
leaq 0x40f5(%rip), %rsi      # 0x8064
callq 0x2180
movl $0xf, %edx
movq %r13, %rdi
leaq 0x44e9(%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 0x6468
movl $0x1a, %edx
movq %r13, %rdi
leaq 0x40a3(%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 0x4b12
movq 0x6fdb(%rip), %rdi      # 0xafe0
movq %r12, %rsi
callq 0x20c0
movq %r12, %rdi
callq 0x4dec
jmp 0x3d64
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x4033
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 0x40ae
jmp 0x4071
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x4095
movq -0xa0(%rbp), %rsi
jmp 0x408d
jmp 0x4071
jmp 0x4071
movq %rax, %rbx
jmp 0x4095
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x4095
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x40ae
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x50(%rbp), %rdi
callq 0x2506
movq %rbx, %rdi
callq 0x2220