// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
leaq 0x120(%rsp), %rdi
movq %rbx, %rsi
callq 0x3a84
leaq 0x18(%rbx), %rsi
leaq 0x10(%rsp), %rdi
movq %rsi, 0x30(%rsp)
callq 0x3c2e
leaq 0x60(%rbx), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x3499
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x34a3
leaq 0x10(%rsp), %rdi
callq 0x3d5c
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
subq %rcx, %rax
je 0x34bf
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rcx
movq %rcx, 0x20(%rbx)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
cmpq %rdi, %rax
je 0x36fc
leaq 0x100(%rsp), %r15
leaq 0x98(%rsp), %rbp
xorl %r14d, %r14d
cmpq %rdi, %rax
je 0x353b
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x3525
leaq (%rdi,%r12), %rdx
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x3511
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x20(%rbx)
jmp 0x3525
movq 0x30(%rsp), %rdi
callq 0x3d5c
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
incq %r13
movq %rax, %rcx
subq %rdi, %rcx
sarq $0x2, %rcx
addq $0x4, %r12
cmpq %r13, %rcx
ja 0x34f0
leaq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3c2e
leaq 0xb8(%rsp), %r13
leaq 0x38(%rsp), %rdi
callq 0x2b79
movl %eax, %r12d
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3576
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movb $0x1, %al
movl %eax, 0xc(%rsp)
testb %r12b, %r12b
jne 0x36f1
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x3a84
leaq 0x50(%rsp), %rdi
callq 0x2f36
movl %eax, %r12d
movq %r13, %rdi
leaq 0x120(%rsp), %rsi
callq 0x3a84
movl %r12d, 0x2c(%rsp)
movq %r13, %rdi
callq 0x2f36
movl %eax, %r13d
movq 0x100(%rsp), %rdi
cmpq %r15, %rdi
je 0x35e1
movq (%rdi), %r12
movl $0x18, %esi
callq 0x1100
movq %r12, %rdi
cmpq %r15, %r12
jne 0x35cc
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x35fe
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x361b
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x3638
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x98(%rsp), %rdi
cmpq %rbp, %rdi
je 0x365a
movq (%rdi), %r12
movl $0x18, %esi
callq 0x1100
movq %r12, %rdi
cmpq %rbp, %r12
jne 0x3645
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x3677
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
movl 0x2c(%rsp), %r12d
je 0x3693
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x36aa
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
cmpl %r13d, %r12d
jg 0x36f1
movq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rax
cmpq %rax, %rcx
je 0x36c9
addq $-0x4, %rax
cmpq %rcx, %rax
jne 0x36bc
movq %rax, 0x20(%rbx)
incq %r14
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, %rcx
subq %rdi, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x34e5
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %ebp
jmp 0x36fe
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x3710
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
leaq 0x168(%rsp), %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x3735
movq (%rdi), %r14
movl $0x18, %esi
callq 0x1100
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x3720
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x3752
movq 0x160(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x376f
movq 0x148(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x378c
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movl %ebp, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37e6
movq %rax, %rbx
jmp 0x3800
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x3b2a
jmp 0x37d8
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x37e9
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
jmp 0x37e9
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3b2a
jmp 0x37e9
jmp 0x37e6
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3800
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
leaq 0x120(%rsp), %rdi
callq 0x3b2a
movq %rbx, %rdi
callq 0x1150