// File: /workspace/github_cpp_makefile_star2_O2/Doug0855[P]TigerZone/Board.cpp
// Function: Board::positionPoints(int, int)
int Board::positionPoints(int i, int j)
{
	const int LAKE_POINTS = 6;
	const int JUNGLE_POINTS = 3;
	const int TRAIL_POINTS = 1;

	int points = 0;
	// for the following if statements you'll be checking the positions adjacent tiles and adding points based on 
	// the adjacents tile's face as well as existing animals within that tile.
	if (m_board[i + 1][j] != NULL)
	{
		points += animalPoints(i + 1, j);
		if (m_board[i + 1][j]->getUpFace()->getType() == "lake")
		{
			points += LAKE_POINTS;
		}
		else if (m_board[i + 1][j]->getUpFace()->getType() == "jungle")
		{
			points += JUNGLE_POINTS;
		}
		else if (m_board[i + 1][j]->getUpFace()->getType() == "trail")
		{
			points += TRAIL_POINTS;
		}
	}
	if (m_board[i - 1][j] != NULL)
	{
		points += animalPoints(i - 1, j);
		if (m_board[i - 1][j]->getDownFace()->getType() == "lake")
		{
			points += LAKE_POINTS;
		}
		else if (m_board[i - 1][j]->getDownFace()->getType() == "jungle")
		{
			points += JUNGLE_POINTS;
		}
		else if (m_board[i - 1][j]->getDownFace()->getType() == "trail")
		{
			points += TRAIL_POINTS;
		}
	}
	if (m_board[i][j + 1] != NULL)
	{
		points += animalPoints(i, j + 1);
		if (m_board[i][j + 1]->getLeftFace()->getType() == "lake")
		{
			points += LAKE_POINTS;
		}
		else if (m_board[i][j + 1]->getLeftFace()->getType() == "jungle")
		{
			points += JUNGLE_POINTS;
		}
		else if (m_board[i][j + 1]->getLeftFace()->getType() == "trail")
		{
			points += TRAIL_POINTS;
		}
	}
	if (m_board[i][j - 1] != NULL)
	{
		points += animalPoints(i, j - 1);
		if (m_board[i][j - 1]->getRightFace()->getType() == "lake")
		{
			points += LAKE_POINTS;
		}
		else if (m_board[i][j - 1]->getRightFace()->getType() == "jungle")
		{
			points += JUNGLE_POINTS;
		}
		else if (m_board[i][j - 1]->getRightFace()->getType() == "trail")
		{
			points += TRAIL_POINTS;
		}
	}
	return points;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %r8d
movq %rdi, %r15
leal 0x1(%r8), %esi
movslq %esi, %rax
movq (%rdi), %rcx
imulq $0x18, %rax, %rbx
movslq %edx, %r14
movq (%rcx,%rbx), %rax
cmpq $0x0, (%rax,%r14,8)
movq %r8, -0x30(%rbp)
movq %rdi, -0x38(%rbp)
je 0xc3ab
movq %r15, %rdi
movl %r14d, %edx
callq 0xc76e
movl %eax, %r12d
movq (%r15), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r14,8), %rsi
addq $0x10, %rsi
leaq -0x70(%rbp), %r15
movq %r15, %rdi
callq 0x32c0
leaq 0x63a5(%rip), %rsi      # 0x12732
movq %r15, %rdi
callq 0x6261
movl %eax, %r13d
movq %r15, %rdi
callq 0x3120
testb %r13b, %r13b
je 0xc3b3
addl $0x6, %r12d
jmp 0xc3f1
xorl %r12d, %r12d
jmp 0xc43b
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r14,8), %rsi
addq $0x10, %rsi
movq %r15, %rdi
callq 0x32c0
leaq 0x6356(%rip), %rsi      # 0x1272b
movq %r15, %rdi
callq 0x6261
movl %eax, %r13d
movq %r15, %rdi
callq 0x3120
testb %r13b, %r13b
je 0xc3f7
addl $0x3, %r12d
movq -0x38(%rbp), %r15
jmp 0xc437
movq -0x38(%rbp), %r15
movq (%r15), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r14,8), %rsi
addq $0x10, %rsi
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0x32c0
leaq 0x631a(%rip), %rsi      # 0x12737
movq %rbx, %rdi
callq 0x6261
movl %eax, %r13d
movq %rbx, %rdi
callq 0x3120
movzbl %r13b, %eax
addl %eax, %r12d
movq -0x30(%rbp), %r8
leal -0x1(%r8), %esi
movslq %esi, %rax
movq (%r15), %rcx
imulq $0x18, %rax, %rbx
movq (%rcx,%rbx), %rax
cmpq $0x0, (%rax,%r14,8)
je 0xc537
movq %r15, %rdi
movl %r14d, %edx
callq 0xc76e
movl %eax, %r13d
addl %r12d, %r13d
movq (%r15), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r14,8), %rsi
addq $0x38, %rsi
leaq -0x70(%rbp), %r15
movq %r15, %rdi
callq 0x32c0
leaq 0x62a7(%rip), %rsi      # 0x12732
movq %r15, %rdi
callq 0x6261
movl %eax, %r12d
movq %r15, %rdi
callq 0x3120
testb %r12b, %r12b
je 0xc4a9
addl $0x6, %r13d
jmp 0xc4e7
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r14,8), %rsi
addq $0x38, %rsi
movq %r15, %rdi
callq 0x32c0
leaq 0x6260(%rip), %rsi      # 0x1272b
movq %r15, %rdi
callq 0x6261
movl %eax, %r12d
movq %r15, %rdi
callq 0x3120
testb %r12b, %r12b
je 0xc4f0
addl $0x3, %r13d
movl %r13d, %r12d
movq -0x38(%rbp), %r15
jmp 0xc533
movq -0x38(%rbp), %r15
movq (%r15), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r14,8), %rsi
addq $0x38, %rsi
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0x32c0
leaq 0x6221(%rip), %rsi      # 0x12737
movq %rbx, %rdi
callq 0x6261
movl %eax, %r12d
movq %rbx, %rdi
callq 0x3120
movzbl %r12b, %eax
addl %eax, %r13d
movl %r13d, %r12d
movq -0x30(%rbp), %r8
movslq %r8d, %rax
movq (%r15), %rcx
imulq $0x18, %rax, %rbx
movq (%rcx,%rbx), %rax
cmpq $0x0, 0x8(%rax,%r14,8)
movq %rbx, -0x40(%rbp)
je 0xc65f
movq %r14, -0x48(%rbp)
incq %r14
movq %r15, %rdi
movl %r8d, %esi
movl %r14d, %edx
callq 0xc76e
movl %eax, %r13d
addl %r12d, %r13d
movq (%r15), %rax
movq (%rax,%rbx), %rax
movq %r14, -0x50(%rbp)
movq (%rax,%r14,8), %rsi
addq $0x60, %rsi
leaq -0x70(%rbp), %r12
movq %r12, %rdi
callq 0x32c0
leaq 0x619c(%rip), %rsi      # 0x12732
movq %r12, %rdi
callq 0x6261
movq %r15, %rbx
movl %eax, %r15d
movq %r12, %rdi
callq 0x3120
testb %r15b, %r15b
je 0xc5b7
addl $0x6, %r13d
jmp 0xc5fd
movq (%rbx), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
addq $0x60, %rsi
leaq -0x70(%rbp), %r15
movq %r15, %rdi
callq 0x32c0
leaq 0x614a(%rip), %rsi      # 0x1272b
movq %r15, %rdi
callq 0x6261
movl %eax, %r12d
movq %r15, %rdi
callq 0x3120
testb %r12b, %r12b
je 0xc60d
addl $0x3, %r13d
movl %r13d, %r12d
movq %rbx, %r15
movq -0x30(%rbp), %r8
movq -0x40(%rbp), %rbx
jmp 0xc65b
movq %rbx, %r15
movq (%rbx), %rax
movq -0x40(%rbp), %rbx
movq (%rax,%rbx), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
addq $0x60, %rsi
leaq -0x70(%rbp), %r14
movq %r14, %rdi
callq 0x32c0
leaq 0x60fd(%rip), %rsi      # 0x12737
movq %r14, %rdi
callq 0x6261
movl %eax, %r12d
movq %r14, %rdi
callq 0x3120
movzbl %r12b, %eax
addl %eax, %r13d
movl %r13d, %r12d
movq -0x30(%rbp), %r8
movq -0x48(%rbp), %r14
movq (%r15), %rax
movq (%rax,%rbx), %rax
cmpq $0x0, -0x8(%rax,%r14,8)
je 0xc75b
decq %r14
movq %r15, %rdi
movl %r8d, %esi
movl %r14d, %edx
callq 0xc76e
movq %r15, %rcx
movl %eax, %r15d
addl %r12d, %r15d
movq (%rcx), %rax
movq (%rax,%rbx), %rax
movl $0x88, %r12d
movq (%rax,%r14,8), %rsi
addq %r12, %rsi
leaq -0x70(%rbp), %r13
movq %r13, %rdi
callq 0x32c0
leaq 0x607f(%rip), %rsi      # 0x12732
movq %r13, %rdi
callq 0x6261
movl %eax, %ebx
movq %r13, %rdi
callq 0x3120
testb %bl, %bl
je 0xc6d2
addl $0x6, %r15d
jmp 0xc758
movq -0x38(%rbp), %r13
movq (%r13), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
addq (%rax,%r14,8), %r12
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x32c0
leaq 0x602f(%rip), %rsi      # 0x1272b
movq %rbx, %rdi
callq 0x6261
movl %eax, %r12d
movq %rbx, %rdi
callq 0x3120
testb %r12b, %r12b
je 0xc71a
addl $0x3, %r15d
jmp 0xc758
movq (%r13), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
movl $0x88, %esi
addq (%rax,%r14,8), %rsi
movq %rbx, %rdi
callq 0x32c0
leaq 0x5ff9(%rip), %rsi      # 0x12737
movq %rbx, %rdi
callq 0x6261
movl %eax, %r14d
movq %rbx, %rdi
callq 0x3120
movzbl %r14b, %eax
addl %eax, %r15d
movl %r15d, %r12d
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop