// File: /workspace/github_cpp_makefile_star2_O3/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, %r12d
movl %esi, %r15d
leal 0x1(%r15), %ecx
movq (%rdi), %rax
movslq %esi, %rdx
movq %rdx, -0x48(%rbp)
cmpl $0x96, %esi
movq %rdi, -0x40(%rbp)
movq %r12, -0x38(%rbp)
jge 0x113d5
movslq %ecx, %r14
leaq (%r14,%r14,2), %rcx
movslq %r12d, %rdx
movq (%rax,%rcx,8), %rcx
movq (%rcx,%rdx,8), %r13
testq %r13, %r13
je 0x113e0
addq $0x10, %r13
movq -0x48(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq %rdx, -0x30(%rbp)
movq (%rax,%rdx,8), %rbx
leaq -0xe0(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
callq 0x9cc4
movq 0x58(%rbx), %rax
movq %rax, 0x20(%r12)
movq %r13, %rdi
movq %r12, %rsi
callq 0x173e0
movl %eax, %r13d
leaq -0xf0(%rbp), %rdi
callq 0x173b0
movq -0x40(%rbp), %rbx
movq (%rbx), %rax
testb %r13b, %r13b
je 0x113e6
shlq $0x3, %r14
leaq (%r14,%r14,2), %r14
movq (%rax,%r14), %rcx
movq -0x30(%rbp), %r13
movq (%rcx,%r13,8), %rdi
addq $0x10, %rdi
movq -0x48(%rbp), %rcx
leaq (,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %r12
movq (%rax,%r12), %rax
movq (%rax,%r13,8), %rsi
addq $0x38, %rsi
callq 0x173cc
movq (%rbx), %rax
movq (%rax,%r12), %rcx
movq (%rcx,%r13,8), %rdi
addq $0x38, %rdi
movq (%rax,%r14), %rax
movq (%rax,%r13,8), %rsi
addq $0x10, %rsi
callq 0x173cc
movq (%rbx), %rax
movq (%rax,%r12), %rcx
movq (%rcx,%r13,8), %rdi
movq (%rax,%r14), %rax
movq (%rax,%r13,8), %rsi
callq 0x16c14
movq (%rbx), %rax
movq (%rax,%r14), %rcx
movq (%rcx,%r13,8), %rdi
movq (%rax,%r12), %rax
movq (%rax,%r13,8), %rsi
callq 0x16c06
movq %rbx, %r13
movq -0x38(%rbp), %r12
jmp 0x11447
movq %rdi, %r13
movslq %r12d, %rdx
movl %ecx, %r14d
jmp 0x113f1
movq -0x40(%rbp), %r13
jmp 0x113f1
movq %rbx, %r13
movq -0x38(%rbp), %r12
movq -0x30(%rbp), %rdx
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, (%rax,%rdx,8)
je 0x11447
movq 0xdbc1(%rip), %r12      # 0x1efc8
leaq 0x748c(%rip), %rsi      # 0x1889a
movl $0x2b, %edx
movq %r12, %rdi
callq 0x3280
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r12, %rdi
movq -0x38(%rbp), %r12
callq 0x3030
movq %rax, %rdi
callq 0x3180
leal -0x1(%r15), %r14d
movq (%r13), %rax
testl %r15d, %r15d
jle 0x11575
movl %r14d, %edx
leaq (%rdx,%rdx,2), %rcx
movslq %r12d, %rbx
movq (%rax,%rcx,8), %rcx
movq (%rcx,%rbx,8), %r13
testq %r13, %r13
je 0x1157a
movq %rdx, -0x30(%rbp)
addq $0x38, %r13
movl %r15d, %ecx
movq %rcx, -0x50(%rbp)
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%rbx,8), %r15
leaq -0xb8(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
leaq -0xc8(%rbp), %r12
movq %r12, %rdi
callq 0x9cc4
movq 0x30(%r15), %rax
movq %rax, 0x20(%r12)
movq %r13, %rdi
movq %r12, %rsi
callq 0x173e0
movl %eax, %r15d
leaq -0xc8(%rbp), %rdi
callq 0x173b0
movq -0x40(%rbp), %r13
movq (%r13), %rax
testb %r15b, %r15b
je 0x11580
movq -0x30(%rbp), %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %r14
movq (%rax,%r14), %rcx
movq (%rcx,%rbx,8), %rdi
addq $0x38, %rdi
movq -0x50(%rbp), %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %r15
movq (%rax,%r15), %rax
movq (%rax,%rbx,8), %rsi
addq $0x10, %rsi
callq 0x173cc
movq (%r13), %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 0x173cc
movq (%r13), %rax
movq (%rax,%r15), %rcx
movq (%rcx,%rbx,8), %rdi
movq (%rax,%r14), %rax
movq (%rax,%rbx,8), %rsi
callq 0x16c06
movq (%r13), %rax
movq (%rax,%r14), %rcx
movq (%rcx,%rbx,8), %rdi
movq (%rax,%r15), %rax
movq (%rax,%rbx,8), %rsi
callq 0x16c14
movq -0x38(%rbp), %r12
jmp 0x115d8
movslq %r12d, %rbx
jmp 0x11584
movq -0x40(%rbp), %r13
jmp 0x11584
movq -0x38(%rbp), %r12
movslq %r14d, %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, (%rax,%rbx,8)
je 0x115d8
movq 0xda2b(%rip), %r15      # 0x1efc8
leaq 0x7322(%rip), %rsi      # 0x188c6
movl $0x29, %edx
movq %r15, %rdi
callq 0x3280
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
leal -0x1(%r12), %r14d
movq (%r13), %rax
movq -0x48(%rbp), %rcx
leaq (%rcx,%rcx,2), %rdx
testl %r12d, %r12d
jle 0x11702
movl %r14d, %ebx
movq (%rax,%rdx,8), %rcx
movq (%rcx,%rbx,8), %r15
testq %r15, %r15
je 0x11702
movq %rdx, -0x30(%rbp)
addq $0x88, %r15
movl %r12d, %eax
movq %rax, -0x50(%rbp)
movq (%rcx,%rax,8), %r13
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x60(%r13), %rsi
movq 0x68(%r13), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
callq 0x9cc4
movq 0x80(%r13), %rax
movq %rax, 0x20(%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0x173e0
movl %eax, %r15d
leaq -0xa0(%rbp), %rdi
callq 0x173b0
movq -0x40(%rbp), %r13
movq (%r13), %rax
testb %r15b, %r15b
je 0x116fa
movq -0x48(%rbp), %rcx
leaq (,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %r14
movq (%rax,%r14), %rax
movl $0x88, %r15d
movq (%rax,%rbx,8), %rdi
addq %r15, %rdi
movq -0x50(%rbp), %r12
movq (%rax,%r12,8), %rsi
addq $0x60, %rsi
callq 0x173cc
movq (%r13), %rax
movq (%rax,%r14), %rax
movq (%rax,%r12,8), %rdi
addq $0x60, %rdi
addq (%rax,%rbx,8), %r15
movq %r15, %rsi
callq 0x173cc
movq (%r13), %rax
movq (%rax,%r14), %rax
movq (%rax,%r12,8), %rdi
movq (%rax,%rbx,8), %rsi
callq 0x16c22
movq (%r13), %rax
movq (%rax,%r14), %rax
movq (%rax,%rbx,8), %rdi
movq (%rax,%r12,8), %rsi
callq 0x16c30
movq -0x38(%rbp), %r12
movq -0x30(%rbp), %rdx
jmp 0x11758
movq -0x38(%rbp), %r12
movq -0x30(%rbp), %rdx
movslq %r14d, %rcx
movq (%rax,%rdx,8), %rax
cmpq $0x0, (%rax,%rcx,8)
je 0x11758
movq 0xd8b1(%rip), %r15      # 0x1efc8
leaq 0x71d2(%rip), %rsi      # 0x188f0
movq %rdx, %rbx
movl $0x2b, %edx
movq %r15, %rdi
callq 0x3280
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq %rbx, %rdx
leal 0x1(%r12), %ecx
movq (%r13), %rax
cmpl $0x96, %r12d
jge 0x1185c
movslq %ecx, %rbx
movq (%rax,%rdx,8), %rcx
movq (%rcx,%rbx,8), %r15
testq %r15, %r15
je 0x11864
movq %rdx, -0x30(%rbp)
addq $0x60, %r15
movslq %r12d, %rax
movq %rax, -0x38(%rbp)
movq (%rcx,%rax,8), %r14
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x88(%r14), %rsi
movq 0x90(%r14), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %r12
movq %r12, %rdi
callq 0x9cc4
movq 0xa8(%r14), %rax
movq %rax, 0x20(%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0x173e0
movl %eax, %r14d
leaq -0x78(%rbp), %rdi
callq 0x173b0
movq (%r13), %rax
testb %r14b, %r14b
je 0x11860
movq -0x48(%rbp), %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %r15
movq (%rax,%r15), %rax
movq (%rax,%rbx,8), %rdi
addq $0x60, %rdi
movl $0x88, %r14d
movq -0x38(%rbp), %r12
movq (%rax,%r12,8), %rsi
addq %r14, %rsi
callq 0x173cc
movq (%r13), %rax
movq (%rax,%r15), %rax
addq (%rax,%r12,8), %r14
movq (%rax,%rbx,8), %rsi
addq $0x60, %rsi
movq %r14, %rdi
callq 0x173cc
movq (%r13), %rax
movq (%rax,%r15), %rax
movq (%rax,%r12,8), %rdi
movq (%rax,%rbx,8), %rsi
callq 0x16c30
movq (%r13), %rax
movq (%rax,%r15), %rax
movq (%rax,%rbx,8), %rdi
movq (%rax,%r12,8), %rsi
callq 0x16c22
jmp 0x118b1
movl %ecx, %ebx
jmp 0x11864
movq -0x30(%rbp), %rdx
movq (%rax,%rdx,8), %rax
cmpq $0x0, (%rax,%rbx,8)
je 0x118b1
movq 0xd752(%rip), %rbx      # 0x1efc8
leaq 0x709f(%rip), %rsi      # 0x1891c
movl $0x2c, %edx
movq %rbx, %rdi
callq 0x3280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x118c9
jmp 0x118c9
jmp 0x118c9
movq %rax, %rbx
movq %r12, %rdi
callq 0x173b0
movq %rbx, %rdi
callq 0x33f0