// File: ljc2154[P]Rummy/rummy.cpp
// Function: playUserTurn(State&)
void playUserTurn(State &state)
{
	/* Give user options for drawing */
	if (state.turnCard < 52)
		cout << "Enter \"t\" to take the turn card." << endl;
	cout << "Enter \"d\" to draw a card from the deck." << endl;
	char choice;
	cin >> choice;
	while (choice != 'd' && (choice != 't' || state.turnCard == 52))
	{
		if (state.turnCard < 52)
			cout << "Enter \"t\" to take the turn card." << endl;
		cout << "Enter \"d\" to draw a card from the deck." << endl;
		cin >> choice;
	}
	/* handle user wants the turn card */
	if (choice == 't')
		state.userHand.push_back(state.turnCard);
	/* handle user wants to draw a new card from the deck */
	else
	{
		state.userHand.push_back(state.deck.back());
		state.deck.pop_back();
	}
	printHand(state.userHand);

	/* Give user options for tossing */
	cout << "Enter \"g\" to give back a card or \"r\" to rearrange your hand.";
	cout << endl;
	cin >> choice;
	while (choice != 'g' && choice != 'r')
	{
		cout << "Enter \"g\" to give back a card or \"r\" to rearrange your hand.";
		cout << endl;
		cin >> choice;
	}
	while (choice != 'g')
	{
		/* Handle user wants to rearrange hand */
		if (choice == 'r')
		{
			char pos1, pos2;
			cout << "Enter the position of first card to swap [1-8]." << endl;
			cin >> pos1;
			while (pos1 < '1' || pos1 > '8')
			{
				cout << "Enter the position of first card to swap [1-8]." << endl;
				cin >> pos1;
			}
			cout << "Enter the position of second card to swap [1-8]." << endl;
			cin >> pos2;
			while (pos2 < '1' || pos2 > '8')
			{
				cout << "Enter the position of second card to swap [1-8]." << endl;
				cin >> pos2;
			}
			/* swap cards */
			swap(state.userHand, pos1-49, pos2-49);		// subtract 48 for ASCII, subtract 1 more for 0 indexing
			printHand(state.userHand);					// print user's hand
		}
		/* Give user options for tossing */
		cout << "Enter \"g\" to give back a card or \"r\" to rearrange your hand.";
		cout << endl;
		cin >> choice;
		while (choice != 'g' && choice != 'r')
		{
			cout << "Enter \"g\" to give back a card or \"r\" to rearrange your hand.";
			cout << endl;
			cin >> choice;
		}
	}
	/* handle user wants to give back a card */
	if (choice == 'g')
	{
		cout << "Enter the position of the card you would like to give back [1-8].";
		cout << endl;
		char pos;
		cin >> pos;
		while (pos < '1' || pos > '8')
		{
			cout << "Enter the position of the card you would like to give back [1-8].";
			cout << endl;
			cin >> pos;
		}
		state.turnCard = state.userHand[pos-49];					// set turn card
		state.remaining.remove(state.turnCard);						// remove from remaining cards
		state.userHand.erase(state.userHand.begin()+pos-49);		// remove from user hand
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x34, 0x60(%rax)
jge 0x18eb
movq 0x9700(%rip), %rdi      # 0xafd0
leaq 0x576e(%rip), %rsi      # 0x7045
callq 0x10f0
movq %rax, %rdi
movq 0x96da(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x96de(%rip), %rdi      # 0xafd0
leaq 0x576d(%rip), %rsi      # 0x7066
callq 0x10f0
movq %rax, %rdi
movq 0x96b8(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x96cc(%rip), %rdi      # 0xafe0
leaq -0x9(%rbp), %rsi
callq 0x1140
movsbl -0x9(%rbp), %ecx
xorl %eax, %eax
cmpl $0x64, %ecx
movb %al, -0x81(%rbp)
je 0x195c
movsbl -0x9(%rbp), %ecx
movb $0x1, %al
cmpl $0x74, %ecx
movb %al, -0x82(%rbp)
jne 0x1950
movq -0x8(%rbp), %rax
cmpl $0x34, 0x60(%rax)
sete %al
movb %al, -0x82(%rbp)
movb -0x82(%rbp), %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x1968
jmp 0x19cb
movq -0x8(%rbp), %rax
cmpl $0x34, 0x60(%rax)
jge 0x1994
movq 0x9657(%rip), %rdi      # 0xafd0
leaq 0x56c5(%rip), %rsi      # 0x7045
callq 0x10f0
movq %rax, %rdi
movq 0x9631(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x9635(%rip), %rdi      # 0xafd0
leaq 0x56c4(%rip), %rsi      # 0x7066
callq 0x10f0
movq %rax, %rdi
movq 0x960f(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x9623(%rip), %rdi      # 0xafe0
leaq -0x9(%rbp), %rsi
callq 0x1140
jmp 0x191d
movsbl -0x9(%rbp), %eax
cmpl $0x74, %eax
jne 0x19eb
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
movq -0x8(%rbp), %rsi
addq $0x60, %rsi
callq 0x4170
jmp 0x1a1b
movq -0x8(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
callq 0x42c0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x4170
movq -0x8(%rbp), %rdi
callq 0x4300
movq -0x8(%rbp), %rsi
addq $0x30, %rsi
leaq -0x28(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x44c0
movq -0x98(%rbp), %rdi
callq 0x27d0
jmp 0x1a41
leaq -0x28(%rbp), %rdi
callq 0x41e0
movq 0x957f(%rip), %rdi      # 0xafd0
leaq 0x5636(%rip), %rsi      # 0x708e
callq 0x10f0
movq 0x956c(%rip), %rdi      # 0xafd0
movq 0x9555(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x9569(%rip), %rdi      # 0xafe0
leaq -0x9(%rbp), %rsi
callq 0x1140
movsbl -0x9(%rbp), %ecx
xorl %eax, %eax
cmpl $0x67, %ecx
movb %al, -0x99(%rbp)
je 0x1aa1
movsbl -0x9(%rbp), %eax
cmpl $0x72, %eax
setne %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x1aad
jmp 0x1aff
movq 0x951c(%rip), %rdi      # 0xafd0
leaq 0x55d3(%rip), %rsi      # 0x708e
callq 0x10f0
movq 0x9509(%rip), %rdi      # 0xafd0
movq 0x94f2(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x9506(%rip), %rdi      # 0xafe0
leaq -0x9(%rbp), %rsi
callq 0x1140
jmp 0x1a80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x41e0
jmp 0x1e92
jmp 0x1b01
movsbl -0x9(%rbp), %eax
cmpl $0x67, %eax
je 0x1d47
movsbl -0x9(%rbp), %eax
cmpl $0x72, %eax
jne 0x1ca7
movq 0x94ae(%rip), %rdi      # 0xafd0
leaq 0x55a2(%rip), %rsi      # 0x70cb
callq 0x10f0
movq %rax, %rdi
movq 0x9488(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x949c(%rip), %rdi      # 0xafe0
leaq -0x35(%rbp), %rsi
callq 0x1140
movsbl -0x35(%rbp), %ecx
movb $0x1, %al
cmpl $0x31, %ecx
movb %al, -0x9a(%rbp)
jl 0x1b6e
movsbl -0x35(%rbp), %eax
cmpl $0x38, %eax
setg %al
movb %al, -0x9a(%rbp)
movb -0x9a(%rbp), %al
testb $0x1, %al
jne 0x1b7a
jmp 0x1bae
movq 0x944f(%rip), %rdi      # 0xafd0
leaq 0x5543(%rip), %rsi      # 0x70cb
callq 0x10f0
movq %rax, %rdi
movq 0x9429(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x943d(%rip), %rdi      # 0xafe0
leaq -0x35(%rbp), %rsi
callq 0x1140
jmp 0x1b4d
movq 0x941b(%rip), %rdi      # 0xafd0
leaq 0x553f(%rip), %rsi      # 0x70fb
callq 0x10f0
movq %rax, %rdi
movq 0x93f5(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x9409(%rip), %rdi      # 0xafe0
leaq -0x36(%rbp), %rsi
callq 0x1140
movsbl -0x36(%rbp), %ecx
movb $0x1, %al
cmpl $0x31, %ecx
movb %al, -0x9b(%rbp)
jl 0x1c01
movsbl -0x36(%rbp), %eax
cmpl $0x38, %eax
setg %al
movb %al, -0x9b(%rbp)
movb -0x9b(%rbp), %al
testb $0x1, %al
jne 0x1c0d
jmp 0x1c41
movq 0x93bc(%rip), %rdi      # 0xafd0
leaq 0x54e0(%rip), %rsi      # 0x70fb
callq 0x10f0
movq %rax, %rdi
movq 0x9396(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x93aa(%rip), %rdi      # 0xafe0
leaq -0x36(%rbp), %rsi
callq 0x1140
jmp 0x1be0
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
movsbl -0x35(%rbp), %esi
addl $-0x31, %esi
movsbl -0x36(%rbp), %edx
addl $-0x31, %edx
callq 0x2000
movq -0x8(%rbp), %rsi
addq $0x30, %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x44c0
movq -0xa8(%rbp), %rdi
callq 0x27d0
jmp 0x1c82
leaq -0x50(%rbp), %rdi
callq 0x41e0
jmp 0x1ca7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x41e0
jmp 0x1e92
movq 0x9322(%rip), %rdi      # 0xafd0
leaq 0x53d9(%rip), %rsi      # 0x708e
callq 0x10f0
movq 0x930f(%rip), %rdi      # 0xafd0
movq 0x92f8(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x930c(%rip), %rdi      # 0xafe0
leaq -0x9(%rbp), %rsi
callq 0x1140
movsbl -0x9(%rbp), %ecx
xorl %eax, %eax
cmpl $0x67, %ecx
movb %al, -0xa9(%rbp)
je 0x1cfe
movsbl -0x9(%rbp), %eax
cmpl $0x72, %eax
setne %al
movb %al, -0xa9(%rbp)
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x1d0a
jmp 0x1d42
movq 0x92bf(%rip), %rdi      # 0xafd0
leaq 0x5376(%rip), %rsi      # 0x708e
callq 0x10f0
movq 0x92ac(%rip), %rdi      # 0xafd0
movq 0x9295(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x92a9(%rip), %rdi      # 0xafe0
leaq -0x9(%rbp), %rsi
callq 0x1140
jmp 0x1cdd
jmp 0x1b01
movsbl -0x9(%rbp), %eax
cmpl $0x67, %eax
jne 0x1e89
movq 0x9275(%rip), %rdi      # 0xafd0
leaq 0x53ca(%rip), %rsi      # 0x712c
callq 0x10f0
movq 0x9262(%rip), %rdi      # 0xafd0
movq 0x924b(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x925f(%rip), %rdi      # 0xafe0
leaq -0x51(%rbp), %rsi
callq 0x1140
movsbl -0x51(%rbp), %ecx
movb $0x1, %al
cmpl $0x31, %ecx
movb %al, -0xaa(%rbp)
jl 0x1dab
movsbl -0x51(%rbp), %eax
cmpl $0x38, %eax
setg %al
movb %al, -0xaa(%rbp)
movb -0xaa(%rbp), %al
testb $0x1, %al
jne 0x1db7
jmp 0x1def
movq 0x9212(%rip), %rdi      # 0xafd0
leaq 0x5367(%rip), %rsi      # 0x712c
callq 0x10f0
movq 0x91ff(%rip), %rdi      # 0xafd0
movq 0x91e8(%rip), %rsi      # 0xafc0
callq 0x1120
movq 0x91fc(%rip), %rdi      # 0xafe0
leaq -0x51(%rbp), %rsi
callq 0x1140
jmp 0x1d8a
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
movsbl -0x51(%rbp), %eax
subl $0x31, %eax
movslq %eax, %rsi
callq 0x4110
movl (%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x8(%rbp), %rdi
addq $0x48, %rdi
movq -0x8(%rbp), %rsi
addq $0x60, %rsi
callq 0x4330
movq -0x8(%rbp), %rax
addq $0x30, %rax
movq %rax, -0xb8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x4620
movq %rax, -0x78(%rbp)
movsbq -0x51(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x4650
movq %rax, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
movl $0x31, %esi
callq 0x4690
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x46d0
movq -0xb8(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x45b0
movq %rax, -0x80(%rbp)
addq $0xc0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x1170
nopl (%rax,%rax)