// File: /workspace/github_cpp_makefile_star2_O3/ljc2154[P]Rummy/rummy.cpp
// Function: removeWorstCard(State&)
int removeWorstCard(State &state)
{
	State testState = state;

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

	int maxEval = 0;
	int maxEvalIndex = 0;
	int eval = 0;

	/* Find the card that when removed produces the highest score */
	for (int i = 0; i < state.agentHand.size(); i++)
	{
		for (int j = 0; j < state.agentHand.size(); j++)
		{
			if (i != j)
				testState.agentHand.push_back(state.agentHand[j]);
		}

		eval = evaluate(testState);
		if (eval > maxEval)
		{
			maxEval = eval;
			maxEvalIndex = i;
		}

		/* Empty agent hand of testState */
		while (testState.agentHand.empty() == false)
			testState.agentHand.pop_back();
	}

	int returnVal = state.agentHand[maxEvalIndex];

	/* Remove worst card */
	state.agentHand.erase(state.agentHand.begin() + maxEvalIndex);

	return returnVal;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3a84
movq 0x18(%r14), %rax
movq 0x20(%r14), %rcx
subq %rcx, %rax
je 0x3856
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rcx
movq %rcx, 0x28(%rsp)
movq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdx
xorl %r13d, %r13d
cmpq %rcx, %rdx
je 0x39bb
leaq 0xb8(%rsp), %r12
xorl %r14d, %r14d
movl $0x0, 0x4(%rsp)
cmpq %rcx, %rdx
je 0x38d6
xorl %ebp, %ebp
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x38c0
leaq (%rcx,%rbp), %rax
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x38ab
movl (%rax), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x38c0
leaq 0x20(%rsp), %rdi
movq %rax, %rdx
callq 0x3d5c
movq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdx
incq %r15
movq %rdx, %rax
subq %rcx, %rax
sarq $0x2, %rax
addq $0x4, %rbp
cmpq %r15, %rax
ja 0x3887
leaq 0x70(%rsp), %r15
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0x3a84
movq %r15, %rdi
callq 0x2f36
movl %eax, %ebp
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3914
movq (%rdi), %r15
movl $0x18, %esi
callq 0x1100
movq %r15, %rdi
cmpq %r12, %r15
jne 0x38ff
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x3931
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x394e
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x3968
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
cmpl %r13d, %ebp
movl 0x4(%rsp), %eax
cmovgl %r14d, %eax
movl %eax, 0x4(%rsp)
cmovgl %ebp, %r13d
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
cmpq %rax, %rcx
je 0x3998
addq $-0x4, %rax
cmpq %rcx, %rax
jne 0x398a
movq %rax, 0x28(%rsp)
incq %r14
movq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdx
movq %rdx, %rax
subq %rcx, %rax
sarq $0x2, %rax
cmpq %r14, %rax
ja 0x387d
movslq 0x4(%rsp), %r13
leaq (%rcx,%r13,4), %rsi
addq $0x4, %rsi
movl -0x4(%rsi), %ebp
cmpq %rdx, %rsi
je 0x39db
leaq (%rcx,%r13,4), %rdi
subq %rsi, %rdx
callq 0x1140
movq 0x20(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x20(%rbx)
leaq 0x50(%rsp), %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x3a05
movq (%rdi), %r14
movl $0x18, %esi
callq 0x1100
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x39f0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3a1c
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3a33
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3a4a
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movl %ebp, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3a6f
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x3b2a
jmp 0x3a72
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3b2a
movq %rbx, %rdi
callq 0x1150