// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %r14
leaq 0x120(%rsp), %rdi
movq %r14, %rsi
callq 0x3a1e
leaq 0x18(%r14), %rsi
leaq 0x10(%rsp), %rdi
movq %rsi, 0x28(%rsp)
callq 0x3bc8
leaq 0x60(%r14), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x3432
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x343c
leaq 0x10(%rsp), %rdi
callq 0x3cf6
movq 0x18(%r14), %rax
movq 0x20(%r14), %rcx
subq %rcx, %rax
je 0x3458
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rcx
movq %rcx, 0x20(%r14)
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
setne 0xf(%rsp)
je 0x367a
leaq 0x100(%rsp), %r12
leaq 0x98(%rsp), %rbx
xorl %r15d, %r15d
movq 0x10(%rsp), %rdx
cmpq %rdx, 0x18(%rsp)
je 0x34d8
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x34bb
addq %r13, %rdx
movq 0x20(%r14), %rsi
cmpq 0x28(%r14), %rsi
je 0x34b1
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x20(%r14)
jmp 0x34bb
movq 0x28(%rsp), %rdi
callq 0x3cf6
incq %rbp
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rax
subq %rdx, %rax
sarq $0x2, %rax
addq $0x4, %r13
cmpq %rbp, %rax
ja 0x3491
leaq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3bc8
leaq 0xb8(%rsp), %r13
leaq 0x38(%rsp), %rdi
callq 0x2b39
movl %eax, %ebp
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3512
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
testb %bpl, %bpl
jne 0x367a
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x3a1e
leaq 0x50(%rsp), %rdi
callq 0x2eea
movl %eax, 0x34(%rsp)
movq %r13, %rdi
leaq 0x120(%rsp), %rsi
callq 0x3a1e
movq %r13, %rdi
callq 0x2eea
movl %eax, %ebp
movq 0x100(%rsp), %rdi
cmpq %r12, %rdi
je 0x3572
movq (%rdi), %r13
movl $0x18, %esi
callq 0x1100
movq %r13, %rdi
cmpq %r12, %r13
jne 0x355d
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x358f
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x35ac
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x35c9
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x98(%rsp), %rdi
cmpq %rbx, %rdi
je 0x35eb
movq (%rdi), %r13
movl $0x18, %esi
callq 0x1100
movq %r13, %rdi
cmpq %rbx, %r13
jne 0x35d6
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x3608
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x361f
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3636
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
cmpl %ebp, 0x34(%rsp)
jg 0x367a
movq 0x20(%r14), %rax
cmpq %rax, 0x18(%r14)
je 0x365b
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
addq $-0x4, %rax
cmpq %rcx, %rax
jne 0x364e
movq %rax, 0x20(%r14)
incq %r15
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x2, %rax
cmpq %r15, %rax
seta 0xf(%rsp)
ja 0x3480
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3691
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
leaq 0x168(%rsp), %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x36b6
movq (%rdi), %r14
movl $0x18, %esi
callq 0x1100
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x36a1
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x36d3
movq 0x160(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x36f0
movq 0x148(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x370d
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movb 0xf(%rsp), %al
andb $0x1, %al
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x376b
movq %rax, %rbx
jmp 0x3785
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x3ac4
jmp 0x375d
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x376e
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
jmp 0x376e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3ac4
jmp 0x376e
jmp 0x376b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3785
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
leaq 0x120(%rsp), %rdi
callq 0x3ac4
movq %rbx, %rdi
callq 0x1150