// File: /workspace/github_cpp_makefile_star2_O2/Doug0855[P]TigerZone/Board.cpp
// Function: Board::connectFaces(int, int)
void Board::connectFaces(int row, int col)
{
	if(row+1 <= 150 && m_board[row+1][col] != NULL &&
		 (*m_board[row+1][col]->getUpFace()).faceEquals(*m_board[row][col]->getDownFace()))
	{
		(*m_board[row + 1][col]->getUpFace()).setNeighborFace(*m_board[row][col]->getDownFace());
		(*m_board[row][col]->getDownFace()).setNeighborFace(*m_board[row + 1][col]->getUpFace());


		// Set adjacent tiles now after setting faces

		// std::cout<<"**********DOWN TILE BEFORE SETTING IS "<<m_board[row][col]->getDownTile()<<std::endl;
		(m_board[row][col])->setNeighborDownTile(*m_board[row + 1][col]);
		// std::cout<<"**********DOWN TILE AFTER SETTING IS "<<m_board[row][col]->getDownTile()<<std::endl;
		// std::cout<<"72 72 up tile before setting is "<<m_board[row+1][col]->getUpTile()<<std::endl;
		(m_board[row+1][col])->setNeighborUpTile(*m_board[row][col]);
		// std::cout<<"72 72 up tile after setting is "<<m_board[row+1][col]->getUpTile()<<std::endl;

		//std::cout << "Neighbor of the up face of " << row + 1 << ' ' << col << " is " << m_board[row + 1][col]->getUpFace()->getNeighborFace() << std::endl;
		//std::cout << "Neighbor of the down face of " << row << ' ' << col << " is " << m_board[row][col]->getDownFace()->getNeighborFace() << std::endl;
	}
	else if(m_board[row+1][col] != NULL)// && !m_board[row+1][col]->getUpFace()->faceEquals(*m_board[row][col]->getDownFace()))
	{
		std::cout << "ERROR: FACES DON'T MATCH for tile down face" << std::endl;
	}
	// Connect top face of tile to existing tile above it
	if(row-1 >= 0 && m_board[row-1][col] != NULL &&
		 (*m_board[row-1][col]->getDownFace()).faceEquals(*m_board[row][col]->getUpFace()))
	{
		(*m_board[row - 1][col]->getDownFace()).setNeighborFace(*m_board[row][col]->getUpFace());
		(*m_board[row][col]->getUpFace()).setNeighborFace(*m_board[row - 1][col]->getDownFace());

		// Set adjacent tiles now after setting faces
		(m_board[row][col])->setNeighborUpTile(*m_board[row - 1][col]);
		(m_board[row - 1][col])->setNeighborDownTile(*m_board[row][col]);

		//std::cout << "Neighbor of the down face of " << row - 1 << ' ' << col << " is " << m_board[row - 1][col]->getDownFace()->getNeighborFace() << std::endl;
		//std::cout << "Neighbor of the up face of " << row << ' ' << col << " is " << m_board[row][col]->getUpFace()->getNeighborFace() << std::endl;
	}
	else if(m_board[row-1][col] != NULL)// && !m_board[row-1][col]->getDownFace()->faceEquals(*m_board[row][col]->getUpFace()))
	{
		std::cout << "ERROR: FACES DON'T MATCH for tile up face" << std::endl;
	}
	// Connect left face of tile to existing tile to the left of it
	if (col-1 >= 0 && m_board[row][col-1] != NULL &&
		  (*m_board[row][col-1]->getRightFace()).faceEquals(*m_board[row][col]->getLeftFace()))
	{
		(*m_board[row][col - 1]->getRightFace()).setNeighborFace(*m_board[row][col]->getLeftFace());
		(*m_board[row][col]->getLeftFace()).setNeighborFace(*m_board[row][col - 1]->getRightFace());

		// Set adjacent tiles now after setting faces
		(m_board[row][col])->setNeighborLeftTile(*m_board[row][col - 1]);
		(m_board[row][col - 1])->setNeighborRightTile(*m_board[row][col]);

		//std::cout << "Neighbor of the right face of " << row << ' ' << col - 1 << " is " << m_board[row][col - 1]->getRightFace()->getNeighborFace() << std::endl;
		//std::cout << "Neighbor of the left face of " << row << ' ' << col << " is " << m_board[row][col]->getLeftFace()->getNeighborFace() << std::endl;
	}
	else if(m_board[row][col-1] != NULL)// && !m_board[row][col-1]->getRightFace()->faceEquals(*m_board[row][col]->getLeftFace()))
	{
		std::cout << "ERROR: FACES DON'T MATCH for tile left face" << std::endl;
	}
	// Connect right face of tile to the existing tile to the right of it
	if (col+1 <= 150 && m_board[row][col+1] != NULL &&
		  (*m_board[row][col+1]->getLeftFace()).faceEquals(*m_board[row][col]->getRightFace()))
	{
		(*m_board[row][col + 1]->getLeftFace()).setNeighborFace(*m_board[row][col]->getRightFace());
		(*m_board[row][col]->getRightFace()).setNeighborFace(*m_board[row][col + 1]->getLeftFace());

		// Set adjacent tiles now after setting faces
		(m_board[row][col])->setNeighborRightTile(*m_board[row][col + 1]);
		(m_board[row][col + 1])->setNeighborLeftTile(*m_board[row][col]);

		//std::cout << "Neighbor of the left face of " << row << ' ' << col + 1 << " is " << m_board[row][col + 1]->getLeftFace()->getNeighborFace() << std::endl;
		//std::cout << "Neighbor of the right face of " << row << ' ' << col << " is " << m_board[row][col]->getRightFace()->getNeighborFace() << std::endl;
	}
	else if(m_board[row][col+1] != NULL )//&& !m_board[row][col+1]->getLeftFace()->faceEquals(*m_board[row][col]->getRightFace()))
	{
		std::cout << "ERROR: FACES DON'T MATCH for tile right face" << std::endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %edx, %r8d
movl %esi, %r15d
movq %rdi, %r12
leal 0x1(%r15), %ecx
movq (%rdi), %rax
movslq %esi, %rdx
movq %rdx, -0x40(%rbp)
cmpl $0x96, %esi
movq %rdi, -0x48(%rbp)
movq %r8, -0x30(%rbp)
jge 0xc9e5
movslq %ecx, %r14
imulq $0x18, %r14, %rdx
movslq %r8d, %rbx
movq (%rax,%rdx), %rcx
movq (%rcx,%rbx,8), %r13
testq %r13, %r13
je 0xc9f1
movq %rdx, -0x38(%rbp)
addq $0x10, %r13
imulq $0x18, -0x40(%rbp), %rcx
movq %rcx, -0x50(%rbp)
movq (%rax,%rcx), %rax
movq (%rax,%rbx,8), %rsi
addq $0x38, %rsi
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
callq 0x659a
movq %r13, %rdi
movq %r12, %rsi
callq 0x11786
movl %eax, %r13d
leaq -0xf0(%rbp), %rdi
callq 0x11768
movq -0x48(%rbp), %r12
movq (%r12), %rax
testb %r13b, %r13b
je 0xc9ed
movq -0x38(%rbp), %r14
movq (%rax,%r14), %rcx
movq (%rcx,%rbx,8), %rdi
addq $0x10, %rdi
movq -0x50(%rbp), %r13
movq (%rax,%r13), %rax
movq (%rax,%rbx,8), %rsi
addq $0x38, %rsi
callq 0x11772
movq (%r12), %rax
movq (%rax,%r13), %rcx
movq (%rcx,%rbx,8), %rdi
addq $0x38, %rdi
movq (%rax,%r14), %rax
movq (%rax,%rbx,8), %rsi
addq $0x10, %rsi
callq 0x11772
movq (%r12), %rax
movq (%rax,%r13), %rcx
movq (%rcx,%rbx,8), %rdi
movq (%rax,%r14), %rax
movq (%rax,%rbx,8), %rsi
callq 0x11188
movq (%r12), %rax
movq (%rax,%r14), %rcx
movq (%rcx,%rbx,8), %rdi
movq (%rax,%r13), %rax
movq (%rax,%rbx,8), %rsi
callq 0x1117a
jmp 0xca1b
movslq %r8d, %rbx
movl %ecx, %r14d
jmp 0xc9f1
movq -0x30(%rbp), %r8
imulq $0x18, %r14, %rcx
movq (%rax,%rcx), %rax
cmpq $0x0, (%rax,%rbx,8)
je 0xca1f
movq 0xc5b9(%rip), %rdi      # 0x18fc0
leaq 0x5e0c(%rip), %rsi      # 0x1281a
callq 0x3200
movq %rax, %rdi
callq 0x3140
movq -0x30(%rbp), %r8
leal -0x1(%r15), %r14d
movq (%r12), %rax
testl %r15d, %r15d
jle 0xcb1a
movl %r14d, %ecx
imulq $0x18, %rcx, %rdx
movslq %r8d, %rbx
movq (%rax,%rdx), %rcx
movq (%rcx,%rbx,8), %r13
testq %r13, %r13
je 0xcb23
movq %rdx, -0x38(%rbp)
addq $0x38, %r13
movl %r15d, %ecx
imulq $0x18, %rcx, %rcx
movq %rcx, -0x50(%rbp)
movq (%rax,%rcx), %rax
movq (%rax,%rbx,8), %rsi
addq $0x10, %rsi
leaq -0xc8(%rbp), %r12
movq %r12, %rdi
callq 0x659a
movq %r13, %rdi
movq %r12, %rsi
callq 0x11786
movl %eax, %r15d
leaq -0xc8(%rbp), %rdi
callq 0x11768
movq -0x48(%rbp), %r12
movq (%r12), %rax
testb %r15b, %r15b
je 0xcb1f
movq -0x38(%rbp), %r14
movq (%rax,%r14), %rcx
movq (%rcx,%rbx,8), %rdi
addq $0x38, %rdi
movq -0x50(%rbp), %r15
movq (%rax,%r15), %rax
movq (%rax,%rbx,8), %rsi
addq $0x10, %rsi
callq 0x11772
movq (%r12), %rax
movq (%rax,%r15), %rcx
movq (%rcx,%rbx,8), %rdi
addq $0x10, %rdi
movq (%rax,%r14), %rax
movq (%rax,%rbx,8), %rsi
addq $0x38, %rsi
callq 0x11772
movq (%r12), %rax
movq (%rax,%r15), %rcx
movq (%rcx,%rbx,8), %rdi
movq (%rax,%r14), %rax
movq (%rax,%rbx,8), %rsi
callq 0x1117a
movq (%r12), %rax
movq (%rax,%r14), %rcx
movq (%rcx,%rbx,8), %rdi
movq (%rax,%r15), %rax
movq (%rax,%rbx,8), %rsi
callq 0x11188
jmp 0xcb50
movslq %r8d, %rbx
jmp 0xcb23
movq -0x30(%rbp), %r8
movslq %r14d, %rcx
imulq $0x18, %rcx, %rcx
movq (%rax,%rcx), %rax
cmpq $0x0, (%rax,%rbx,8)
je 0xcb54
movq 0xc484(%rip), %rdi      # 0x18fc0
leaq 0x5d03(%rip), %rsi      # 0x12846
callq 0x3200
movq %rax, %rdi
callq 0x3140
movq -0x30(%rbp), %r8
leal -0x1(%r8), %r13d
movq (%r12), %rax
testl %r8d, %r8d
jle 0xcc38
imulq $0x18, -0x40(%rbp), %r14
movl %r13d, %ebx
movq (%rax,%r14), %rcx
movq (%rcx,%rbx,8), %r15
testq %r15, %r15
je 0xcc38
addq $0x88, %r15
movl %r8d, %eax
movq %rax, -0x38(%rbp)
movq (%rcx,%rax,8), %rsi
addq $0x60, %rsi
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
callq 0x659a
movq %r15, %rdi
movq %r12, %rsi
callq 0x11786
movl %eax, %r15d
leaq -0xa0(%rbp), %rdi
callq 0x11768
movq -0x48(%rbp), %r12
movq (%r12), %rax
testb %r15b, %r15b
je 0xcc34
movq (%rax,%r14), %rax
movl $0x88, %r15d
movq (%rax,%rbx,8), %rdi
addq %r15, %rdi
movq -0x38(%rbp), %r13
movq (%rax,%r13,8), %rsi
addq $0x60, %rsi
callq 0x11772
movq (%r12), %rax
movq (%rax,%r14), %rax
movq (%rax,%r13,8), %rdi
addq $0x60, %rdi
addq (%rax,%rbx,8), %r15
movq %r15, %rsi
callq 0x11772
movq (%r12), %rax
movq (%rax,%r14), %rax
movq (%rax,%r13,8), %rdi
movq (%rax,%rbx,8), %rsi
callq 0x11196
movq (%r12), %rax
movq (%rax,%r14), %rax
movq (%rax,%rbx,8), %rdi
movq (%rax,%r13,8), %rsi
callq 0x111a4
jmp 0xcc66
movq -0x30(%rbp), %r8
imulq $0x18, -0x40(%rbp), %rcx
movslq %r13d, %rdx
movq (%rax,%rcx), %rax
cmpq $0x0, (%rax,%rdx,8)
je 0xcc6a
movq 0xc36e(%rip), %rdi      # 0x18fc0
leaq 0x5c17(%rip), %rsi      # 0x12870
callq 0x3200
movq %rax, %rdi
callq 0x3140
movq -0x30(%rbp), %r8
leal 0x1(%r8), %ecx
movq (%r12), %rax
cmpl $0x96, %r8d
jge 0xcd42
imulq $0x18, -0x40(%rbp), %r13
movslq %ecx, %rbx
movq (%rax,%r13), %rcx
movq (%rcx,%rbx,8), %r15
testq %r15, %r15
je 0xcd44
addq $0x60, %r15
movslq %r8d, %rax
movl $0x88, %esi
movq %rax, -0x30(%rbp)
addq (%rcx,%rax,8), %rsi
leaq -0x78(%rbp), %r12
movq %r12, %rdi
callq 0x659a
movq %r15, %rdi
movq %r12, %rsi
callq 0x11786
movl %eax, %r14d
leaq -0x78(%rbp), %rdi
callq 0x11768
movq -0x48(%rbp), %r15
movq (%r15), %rax
testb %r14b, %r14b
je 0xcd44
movq (%rax,%r13), %rax
movq (%rax,%rbx,8), %rdi
addq $0x60, %rdi
movl $0x88, %r14d
movq -0x30(%rbp), %r12
movq (%rax,%r12,8), %rsi
addq %r14, %rsi
callq 0x11772
movq (%r15), %rax
movq (%rax,%r13), %rax
addq (%rax,%r12,8), %r14
movq (%rax,%rbx,8), %rsi
addq $0x60, %rsi
movq %r14, %rdi
callq 0x11772
movq (%r15), %rax
movq (%rax,%r13), %rax
movq (%rax,%r12,8), %rdi
movq (%rax,%rbx,8), %rsi
callq 0x111a4
movq (%r15), %rax
movq (%rax,%r13), %rax
movq (%rax,%rbx,8), %rdi
movq (%rax,%r12,8), %rsi
callq 0x11196
jmp 0xcd6f
movl %ecx, %ebx
imulq $0x18, -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
cmpq $0x0, (%rax,%rbx,8)
je 0xcd6f
movq 0xc265(%rip), %rdi      # 0x18fc0
leaq 0x5b3a(%rip), %rsi      # 0x1289c
callq 0x3200
movq %rax, %rdi
callq 0x3140
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xcd87
jmp 0xcd87
jmp 0xcd87
movq %rax, %rbx
movq %r12, %rdi
callq 0x11768
movq %rbx, %rdi
callq 0x33c0