// File: /workspace/github_cpp_makefile_star2_O1/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 0x9efc
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 0x9da8
leaq -0x98(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rdi
callq 0x9da8
leaq 0x9fcf(%rip), %rsi      # 0x18796
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
callq 0x30b0
movl %eax, %r13d
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0xe7e6
callq 0x3200
leaq -0x80(%rbp), %rdi
callq 0x17912
testl %r13d, %r13d
movq -0x38(%rbp), %rbx
movl %r15d, %r14d
je 0xe8c6
leaq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %r15d
movl %r15d, %edx
movl %r14d, %ecx
callq 0x11974
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
subq %rdx, %rcx
je 0xe89d
sarq $0x3, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rax # imm = 0x2E8BA2E8BA2E8BA3
imulq %rax, %rcx
cmpq $0x1, %rcx
movq %rcx, %rdi
adcq $0x0, %rdi
addq $0x50, %rdx
xorl %esi, %esi
cmpb $0x1, (%rdx)
jne 0xe85a
incq %rsi
addq $0x58, %rdx
cmpq %rsi, %rdi
jne 0xe846
movq %rcx, %rsi
movslq %esi, %rcx
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rsi
subq %rdx, %rsi
sarq $0x3, %rsi
imulq %rax, %rsi
movq %rsi, %rax
subq %rcx, %rax
jbe 0xe898
imulq $0x58, %rcx, %rdi
leaq (%rdi,%rdx), %r13
addq $0x28, %r13
cmpb $0x0, 0x28(%r13)
je 0xea3b
addq $0x58, %r13
decq %rax
jne 0xe884
cmpq %rcx, %rsi
jne 0xe8ff
movq 0x8(%rbx), %rdx
leaq 0x9eb3(%rip), %rcx      # 0x1875b
movl $0x5, %r8d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3370
leaq -0x58(%rbp), %rdi
callq 0xec22
jmp 0xea1a
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq -0x40(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl %r14d, %edx
callq 0x11d0c
movq 0x8(%rbx), %rdx
leaq 0x9eb0(%rip), %rcx      # 0x1879a
movl $0x8, %r8d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3370
jmp 0xea1a
imulq $0x58, %rcx, %rbx
movq 0x20(%rdx,%rbx), %rcx
movq -0x40(%rbp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x11d0c
movq -0x58(%rbp), %rax
movq 0x20(%rax,%rbx), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0xae7e
movl %eax, %r15d
movl %eax, %r14d
negl %r14d
cmovsl %eax, %r14d
movl $0x1, %r12d
cmpl $0xa, %r14d
jb 0xe98f
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xe986
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xe98c
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xe98f
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xe953
addl $-0x3, %r12d
jmp 0xe98f
addl $-0x2, %r12d
jmp 0xe98f
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 0x9d36
leaq 0x9dda(%rip), %rsi      # 0x187a3
leaq -0xa8(%rbp), %rdi
movq %rbx, %rdx
callq 0x8d7c
leaq -0xa8(%rbp), %rbx
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
callq 0x32b0
movq (%rbx), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xe9ff
callq 0x3200
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0xea0d
callq 0x3200
leaq -0x58(%rbp), %rdi
callq 0xec22
movq -0x38(%rbp), %rbx
leaq -0x1f8(%rbp), %rdi
callq 0x9fa2
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 0x9da8
movq -0x8(%r13), %rax
leaq -0xd8(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %r13, %rsi
callq 0x8f60
movb 0x28(%r13), %al
leaq -0x100(%rbp), %rsi
movb %al, 0x50(%rsi)
movups 0x18(%r13), %xmm0
movups %xmm0, 0x40(%rsi)
callq 0xeb08
movq %rax, %r14
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
jne 0xeacc
jmp 0xead6
jmp 0xead3
jmp 0xeab8
jmp 0xeab8
jmp 0xead3
jmp 0xead3
jmp 0xeab8
movq %rax, %r14
leaq -0x80(%rbp), %rdi
callq 0x17912
jmp 0xeadf
movq %rax, %r14
jmp 0xeadf
movq %rax, %r14
movq -0x100(%rbp), %rdi
cmpq %rbx, %rdi
je 0xead6
callq 0x3200
jmp 0xead6
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0xec22
movq -0x38(%rbp), %rax
movq (%rax), %rdi
cmpq -0x88(%rbp), %rdi
je 0xeaf4
callq 0x3200
leaq -0x1f8(%rbp), %rdi
callq 0x9fa2
movq %r14, %rdi
callq 0x33f0