// File: ljc2154[P]Rummy/rummy.cpp
// Function: takeTurnCard(State)
bool takeTurnCard(State state)
{
	State originalState = state;
	vector<int> testHand = state.agentHand;
	testHand.push_back(state.turnCard);	// add turn card to hand to test

	/* Empty agent hand */
	while (state.agentHand.empty() == false)
		state.agentHand.pop_back();

	/* Check all possible new hands */
	for (int i = 0; i < testHand.size(); i++)
	{
		for (int j = 0; j < testHand.size(); j++)
		{
			if (i != j)
				state.agentHand.push_back(testHand[j]);
		}

		/* Check if new hand is a winner */
		if (isWinner(state.agentHand))
			return true;

		/* Check if new hand is better than old */
		if (evaluate(state) > evaluate(originalState))
			return true;

		while (state.agentHand.empty() == false)
			state.agentHand.pop_back();
	}
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, %rsi
movq %rsi, -0x1a0(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3fe0
movq -0x1a0(%rbp), %rsi
addq $0x18, %rsi
leaq -0x90(%rbp), %rdi
callq 0x44c0
jmp 0x3a1b
movq -0x1a0(%rbp), %rsi
addq $0x60, %rsi
leaq -0x90(%rbp), %rdi
callq 0x4170
jmp 0x3a34
jmp 0x3a36
movq -0x1a0(%rbp), %rdi
addq $0x18, %rdi
callq 0x48b0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x3a90
movq -0x1a0(%rbp), %rdi
addq $0x18, %rdi
callq 0x4300
jmp 0x3a36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x3d1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x3d10
movl $0x0, -0xa0(%rbp)
movslq -0xa0(%rbp), %rax
movq %rax, -0x1a8(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4130
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
cmpq %rcx, %rax
jae 0x3cdf
movl $0x0, -0xa4(%rbp)
movslq -0xa4(%rbp), %rax
movq %rax, -0x1b0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4130
movq %rax, %rcx
movq -0x1b0(%rbp), %rax
cmpq %rcx, %rax
jae 0x3b56
movl -0xa0(%rbp), %eax
cmpl -0xa4(%rbp), %eax
je 0x3b40
movq -0x1a0(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x1b8(%rbp)
movslq -0xa4(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x4110
movq -0x1b8(%rbp), %rdi
movq %rax, %rsi
callq 0x4170
jmp 0x3b3e
jmp 0x3b40
jmp 0x3b42
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x3ad1
movq -0x1a0(%rbp), %rsi
addq $0x18, %rsi
leaq -0xc0(%rbp), %rdi
callq 0x44c0
jmp 0x3b6f
leaq -0xc0(%rbp), %rdi
callq 0x2ad0
movb %al, -0x1b9(%rbp)
jmp 0x3b83
leaq -0xc0(%rbp), %rdi
callq 0x41e0
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x3b9b
jmp 0x3bd1
movb $0x1, -0x1(%rbp)
movl $0x1, -0xc4(%rbp)
jmp 0x3ced
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x41e0
jmp 0x3d10
movq -0x1a0(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x3fe0
jmp 0x3be6
leaq -0x130(%rbp), %rdi
callq 0x3100
movl %eax, -0x1c0(%rbp)
jmp 0x3bfa
leaq -0x198(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3fe0
jmp 0x3c0c
leaq -0x198(%rbp), %rdi
callq 0x3100
movl %eax, -0x1c4(%rbp)
jmp 0x3c20
leaq -0x198(%rbp), %rdi
callq 0x40c0
leaq -0x130(%rbp), %rdi
callq 0x40c0
movl -0x1c4(%rbp), %ecx
movl -0x1c0(%rbp), %eax
cmpl %ecx, %eax
jle 0x3c9b
movb $0x1, -0x1(%rbp)
movl $0x1, -0xc4(%rbp)
jmp 0x3ced
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x3c8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x40c0
leaq -0x130(%rbp), %rdi
callq 0x40c0
jmp 0x3d10
jmp 0x3c9d
movq -0x1a0(%rbp), %rdi
addq $0x18, %rdi
callq 0x48b0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x3cc9
movq -0x1a0(%rbp), %rdi
addq $0x18, %rdi
callq 0x4300
jmp 0x3c9d
jmp 0x3ccb
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x3a9a
movb $0x0, -0x1(%rbp)
movl $0x1, -0xc4(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x41e0
leaq -0x78(%rbp), %rdi
callq 0x40c0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
leaq -0x90(%rbp), %rdi
callq 0x41e0
leaq -0x78(%rbp), %rdi
callq 0x40c0
movq -0x98(%rbp), %rdi
callq 0x1170
nopw %cs:(%rax,%rax)