// File: /workspace/github_cpp_makefile_star2_O1/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 $0xe8, %rsp
movq %rdi, %rbx
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3a1e
movq 0x18(%r14), %rax
movq 0x20(%r14), %rcx
subq %rcx, %rax
je 0x37db
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rcx
movq %rcx, 0x38(%rsp)
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rdx
xorl %ecx, %ecx
cmpq %rax, %rdx
je 0x3959
movq $0x0, 0x10(%rsp)
leaq 0xc8(%rsp), %r12
leaq 0x80(%rsp), %r13
xorl %r14d, %r14d
movl $0x0, 0xc(%rsp)
movq 0x18(%rbx), %rdx
cmpq %rdx, 0x20(%rbx)
je 0x3869
xorl %ebp, %ebp
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x384e
addq %rbp, %rdx
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x3844
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x384e
leaq 0x30(%rsp), %rdi
callq 0x3cf6
incq %r15
movq 0x18(%rbx), %rdx
movq 0x20(%rbx), %rax
subq %rdx, %rax
sarq $0x2, %rax
addq $0x4, %rbp
cmpq %r15, %rax
ja 0x3821
movq %r13, %r15
movq %r13, %rdi
leaq 0x18(%rsp), %rsi
callq 0x3a1e
movq %r15, %rdi
callq 0x2eea
movl %eax, %ebp
movq 0xc8(%rsp), %rdi
cmpq %r12, %rdi
je 0x38a5
movq (%rdi), %r15
movl $0x18, %esi
callq 0x1100
movq %r15, %rdi
cmpq %r12, %r15
jne 0x3890
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x38c2
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x38df
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x38fc
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x10(%rsp), %rax
cmpl %eax, %ebp
movl 0xc(%rsp), %ecx
cmovgl %r14d, %ecx
movl %ecx, 0xc(%rsp)
cmovgl %ebp, %eax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
cmpq %rax, 0x30(%rsp)
je 0x3936
movq 0x30(%rsp), %rcx
addq $-0x4, %rax
cmpq %rcx, %rax
jne 0x3928
movq %rax, 0x38(%rsp)
incq %r14
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rdx
movq %rdx, %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x3812
movslq 0xc(%rsp), %rcx
leaq (%rax,%rcx,4), %rsi
addq $0x4, %rsi
movl -0x4(%rsi), %ebp
cmpq %rdx, %rsi
je 0x3975
leaq (%rax,%rcx,4), %rdi
subq %rsi, %rdx
callq 0x1140
addq $-0x4, 0x20(%rbx)
leaq 0x60(%rsp), %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x399c
movq (%rdi), %r14
movl $0x18, %esi
callq 0x1100
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x3987
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x39b3
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x39ca
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x39e1
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x1100
movl %ebp, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3a09
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x3ac4
jmp 0x3a0c
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3ac4
movq %rbx, %rdi
callq 0x1150