// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1b8, %rsp            # imm = 0x1B8
movl %ecx, %r15d
movl %edx, %r14d
movq %rsi, %r12
movq %rdi, %rbx
leaq -0x1e0(%rbp), %rdi
callq 0x7668
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movl %r14d, -0x2c(%rbp)
movslq %r14d, %rax
movq (%r12), %rcx
imulq $0x18, %rax, %rax
movslq %r15d, %rdx
movq (%rcx,%rax), %rax
movq (%rax,%rdx,8), %rsi
leaq -0x70(%rbp), %rdi
callq 0xa70e
leaq -0x68(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x32c0
leaq 0x82f6(%rip), %rsi      # 0x12716
leaq -0x90(%rbp), %r13
movq %r13, %rdi
callq 0x6261
movl %eax, %r14d
movq %r13, %rdi
callq 0x3120
leaq -0x70(%rbp), %rdi
callq 0x118de
testb %r14b, %r14b
je 0xa474
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %r12, %rdi
movl -0x2c(%rbp), %esi
movl %r15d, %edx
callq 0xd076
leaq 0x82b3(%rip), %rsi      # 0x1271a
movq %rbx, %rdi
callq 0x33f0
jmp 0xa58d
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
movl -0x2c(%rbp), %edx
movl %r15d, %ecx
callq 0xcd9a
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rsi
movq %rsi, %rax
subq %rcx, %rax
pushq $0x58
popq %rdi
cqto
idivq %rdi
cmpq %rcx, %rsi
je 0xa506
leaq 0x50(%rcx), %rsi
xorl %edx, %edx
cmpq %rdx, %rax
je 0xa4ba
cmpb $0x1, (%rsi)
jne 0xa4bd
incq %rdx
addq $0x58, %rsi
jmp 0xa4a7
movq %rax, %rdx
movslq %edx, %rdx
imulq $0x58, %rdx, %r14
leaq (%r14,%rcx), %r8
addq $-0x58, %r8
leaq -0x1(%rdx), %rdi
incq %rdi
cmpq %rax, %rdi
jae 0xa501
leaq 0x58(%r8), %rsi
cmpb $0x0, 0xa8(%r8)
movq %rsi, %r8
jne 0xa4d0
leaq -0xe8(%rbp), %rdi
callq 0xa736
leaq -0xe8(%rbp), %rsi
callq 0xa604
cmpq %rdx, %rax
jne 0xa517
leaq 0x81ce(%rip), %rsi      # 0x126db
movq %rbx, %rdi
callq 0x33f0
jmp 0xa584
movq 0x20(%rcx,%r14), %rcx
movq %r12, %rdi
movl -0x2c(%rbp), %esi
movl %r15d, %edx
callq 0xd076
movq -0x48(%rbp), %rax
movq 0x20(%rax,%r14), %rsi
leaq -0x1e0(%rbp), %rdi
callq 0x8206
leaq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x646c
leaq 0x81d2(%rip), %rsi      # 0x12723
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x64fa
leaq -0x90(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3280
movq %r14, %rdi
callq 0x3120
leaq -0x70(%rbp), %rdi
callq 0x3120
leaq -0x48(%rbp), %rdi
callq 0xa786
leaq -0x1e0(%rbp), %rdi
callq 0x7716
movq %rbx, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x70(%rbp), %rdi
callq 0x3120
jmp 0xa5de
jmp 0xa5db
jmp 0xa5db
jmp 0xa5db
jmp 0xa5d6
jmp 0xa5d6
jmp 0xa5d6
movq %rax, %r14
leaq -0x70(%rbp), %rdi
callq 0x118de
jmp 0xa5e7
movq %rax, %r14
jmp 0xa5e7
movq %rax, %r14
leaq -0x48(%rbp), %rdi
callq 0xa786
movq %rbx, %rdi
callq 0x3120
leaq -0x1e0(%rbp), %rdi
callq 0x7716
movq %r14, %rdi
callq 0x33c0
nop