// File: /workspace/github_cpp_makefile_star2_O3/Doug0855[P]TigerZone/Game.cpp
// Function: Game::meepleAi[abi:cxx11](int, int)
std::string Game::meepleAi(int i, int j)
{
  Adapter adapter;
  std::string tiger;
	// always place at a den if you can
	if (gameboard.m_board[i][j]->getCenter().getType() == "den")
	{
		gameboard.placeMeeple(i, j, std::pair<int,int> (1,1));
		tiger = " TIGER 5";
		return tiger;
	}
	// if there wasn't a den in the middle then get all the structures in the current tile
	std::vector<Structure> structures = gameboard.getStructures(i, j);
	// if you found structures
	if (structures.size() > 0)
	{
		int mostPoints = 0;
		int bestStruct = structures.size();
		// find the first structure that doesn't have a meeple
		for (size_t ii = 0; ii < structures.size(); ii++)
		{
			if (!structures[ii].hasMeeple)
			{
				bestStruct = ii;
				break;
			}
		}
		// for all the strucutres that don't have meeples count up the point values
		for (size_t ii = bestStruct; ii < structures.size(); ii++)
		{
			if (!structures[ii].hasMeeple)
			{
				int points = structurePoints(structures[ii]);
				// select the one with the highest point values
				if (points > mostPoints)
				{
					mostPoints = points;
					bestStruct = ii;
				}
			}
		}
		// as long as you found a stucutre without a meeple place the meele at the one with the highest points
		if (bestStruct != structures.size())
		{
		  gameboard.placeMeeple(i, j, structures[bestStruct].startingBlock);
		  std::string temp = std::to_string(adapter.convertZone(structures[bestStruct].startingBlock));
		  tiger = " TIGER " + temp;
		  return tiger;
		}
	}
	tiger = " NONE";
	return tiger;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movl %ecx, %r14d
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %rbx
leaq -0x1f8(%rbp), %rdi
callq 0x9e20
leaq 0x10(%rbx), %r13
movq %r13, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movl %r15d, -0x2c(%rbp)
movslq %r15d, %rax
movq %r12, -0x40(%rbp)
movq (%r12), %rcx
leaq (%rax,%rax,2), %rax
movl %r14d, %r15d
movslq %r14d, %rdx
movq (%rcx,%rax,8), %rax
movq (%rax,%rdx,8), %rax
movq 0xd0(%rax), %rax
movq 0x18(%rax), %rax
movzwl 0x28(%rax), %ecx
leaq -0x78(%rbp), %rdi
movw %cx, -0x8(%rdi)
leaq -0x68(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq 0x30(%rax), %rsi
movq 0x38(%rax), %rdx
addq %rsi, %rdx
movq %rbx, -0x38(%rbp)
movq %r13, -0x88(%rbp)
callq 0x9cc4
leaq -0x98(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rdi
callq 0x9cc4
leaq 0xa0d1(%rip), %rsi      # 0x18796
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
callq 0x30b0
movl %eax, %r13d
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0xe6e4
callq 0x3200
leaq -0x80(%rbp), %rdi
callq 0x175da
testl %r13d, %r13d
movq -0x38(%rbp), %rbx
movl %r15d, %r14d
je 0xe7b1
leaq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %r15d
movl %r15d, %edx
movl %r14d, %ecx
callq 0x118dc
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rdx
subq %rax, %rdx
je 0xe788
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rdx, %rcx
cmpq $0x1, %rcx
movq %rcx, %rsi
adcq $0x0, %rsi
leaq 0x50(%rax), %rdi
xorl %edx, %edx
cmpb $0x1, (%rdi)
jne 0xe758
incq %rdx
addq $0x58, %rdi
cmpq %rdx, %rsi
jne 0xe744
movq %rcx, %rdx
movslq %edx, %rdx
movq %rcx, %rsi
subq %rdx, %rsi
jbe 0xe783
imulq $0x58, %rdx, %rdi
leaq (%rdi,%rax), %r13
addq $0x28, %r13
cmpb $0x0, 0x28(%r13)
je 0xe926
addq $0x58, %r13
decq %rsi
jne 0xe76f
cmpq %rdx, %rcx
jne 0xe7ea
movq 0x8(%rbx), %rdx
leaq 0x9fc8(%rip), %rcx      # 0x1875b
movl $0x5, %r8d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3370
leaq -0x58(%rbp), %rdi
callq 0xeb0e
jmp 0xe905
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq -0x40(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl %r14d, %edx
callq 0x11c68
movq 0x8(%rbx), %rdx
leaq 0x9fc5(%rip), %rcx      # 0x1879a
movl $0x8, %r8d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3370
jmp 0xe905
imulq $0x58, %rdx, %rbx
movq 0x20(%rax,%rbx), %rcx
movq -0x40(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x11c68
movq -0x58(%rbp), %rax
movq 0x20(%rax,%rbx), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0xad88
movl %eax, %r15d
movl %eax, %r14d
negl %r14d
cmovsl %eax, %r14d
movl $0x1, %r12d
cmpl $0xa, %r14d
jb 0xe87a
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xe871
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xe877
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xe87a
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xe83e
addl $-0x3, %r12d
jmp 0xe87a
addl $-0x2, %r12d
jmp 0xe87a
decl %r12d
shrl $0x1f, %r15d
leal (%r12,%r15), %esi
leaq -0x70(%rbp), %r13
movq %r13, -0x10(%r13)
leaq -0x80(%rbp), %rdi
movl $0x2d, %edx
callq 0x3290
movl %r15d, %edi
leaq -0x80(%rbp), %rbx
addq (%rbx), %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x9c52
leaq 0x9eef(%rip), %rsi      # 0x187a3
leaq -0xa8(%rbp), %rdi
movq %rbx, %rdx
callq 0x8c44
leaq -0xa8(%rbp), %rbx
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
callq 0x32b0
movq (%rbx), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xe8ea
callq 0x3200
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0xe8f8
callq 0x3200
leaq -0x58(%rbp), %rdi
callq 0xeb0e
movq -0x38(%rbp), %rbx
leaq -0x1f8(%rbp), %rdi
callq 0x9ec6
movq %rbx, %rax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0xf0(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq -0x28(%r13), %rsi
movq -0x20(%r13), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %rdi
callq 0x9cc4
movq -0x8(%r13), %rax
leaq -0xd8(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %r13, %rsi
callq 0x8e28
movb 0x28(%r13), %al
leaq -0x100(%rbp), %rsi
movb %al, 0x50(%rsi)
movups 0x18(%r13), %xmm0
movups %xmm0, 0x40(%rsi)
callq 0xe9f4
movq %rax, %r14
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
jne 0xe9b7
jmp 0xe9c1
jmp 0xe9be
jmp 0xe9a3
jmp 0xe9a3
jmp 0xe9be
jmp 0xe9be
jmp 0xe9a3
movq %rax, %r14
leaq -0x80(%rbp), %rdi
callq 0x175da
jmp 0xe9ca
movq %rax, %r14
jmp 0xe9ca
movq %rax, %r14
movq -0x100(%rbp), %rdi
cmpq %rbx, %rdi
je 0xe9c1
callq 0x3200
jmp 0xe9c1
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0xeb0e
movq -0x38(%rbp), %rax
movq (%rax), %rdi
cmpq -0x88(%rbp), %rdi
je 0xe9df
callq 0x3200
leaq -0x1f8(%rbp), %rdi
callq 0x9ec6
movq %r14, %rdi
callq 0x33f0
nop