// File: /workspace/github_cpp_makefile_star2_O1/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 %esi, %r15d
movq %rdi, %rbx
leal 0x1(%r15), %eax
movslq %eax, %r14
movq %rdx, -0x50(%rbp)
movslq %edx, %r12
movslq %esi, %rax
movq %rax, -0x40(%rbp)
cmpl $0x95, %esi
movq %rdi, -0x38(%rbp)
movq %r12, -0x30(%rbp)
jg 0x113d7
movq (%rbx), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rcx
movq (%rcx,%r12,8), %r13
testq %r13, %r13
je 0x113d7
addq $0x10, %r13
movq -0x40(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r12,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 0x9da8
movq 0x58(%rbx), %rax
movq %rax, 0x20(%r12)
movq %r13, %rdi
movq %r12, %rsi
callq 0x17728
movl %eax, %r13d
movb $0x1, %al
movq -0x38(%rbp), %rbx
movq -0x30(%rbp), %r12
jmp 0x113dc
xorl %eax, %eax
xorl %r13d, %r13d
testb %al, %al
je 0x113ec
leaq -0xf0(%rbp), %rdi
callq 0x176f8
movq (%rbx), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rcx
movq (%rcx,%r12,8), %rdi
testb %r13b, %r13b
je 0x114af
addq $0x10, %rdi
movq -0x40(%rbp), %rcx
leaq (,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %r12
movq (%rax,%r12), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
addq $0x38, %rsi
callq 0x17714
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq (%rax,%r12), %rcx
movq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
addq $0x38, %rdi
shlq $0x3, %r14
leaq (%r14,%r14,2), %rbx
movq (%rax,%rbx), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
addq $0x10, %rsi
callq 0x17714
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq (%rax,%r12), %rcx
movq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movq (%rax,%rbx), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x16f5c
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq (%rax,%rbx), %rcx
movq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movq (%rax,%r12), %rax
movq -0x30(%rbp), %r12
movq -0x38(%rbp), %rbx
movq (%rax,%r12,8), %rsi
callq 0x16f4e
jmp 0x114ff
testq %rdi, %rdi
je 0x114ff
movq 0xdb0d(%rip), %r12      # 0x1efc8
leaq 0x73d8(%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 -0x30(%rbp), %r12
movq -0x38(%rbp), %rbx
callq 0x3030
movq %rax, %rdi
callq 0x3180
leal -0x1(%r15), %r14d
testl %r15d, %r15d
jle 0x11571
movl %r14d, %ecx
movq (%rbx), %rax
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rcx
movq (%rcx,%r12,8), %r13
testq %r13, %r13
je 0x11571
addq $0x38, %r13
movl %r15d, %ecx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r12,8), %rbx
leaq -0xb8(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
addq %rsi, %rdx
leaq -0xc8(%rbp), %r12
movq %r12, %rdi
callq 0x9da8
movq 0x30(%rbx), %rax
movq %rax, 0x20(%r12)
movq %r13, %rdi
movq %r12, %rsi
callq 0x17728
movl %eax, %ebx
movb $0x1, %al
jmp 0x11575
xorl %eax, %eax
xorl %ebx, %ebx
testb %al, %al
je 0x11585
leaq -0xc8(%rbp), %rdi
callq 0x176f8
movslq %r14d, %r12
movq -0x38(%rbp), %r13
movq (%r13), %rax
leaq (%r12,%r12,2), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x30(%rbp), %r15
movq (%rcx,%r15,8), %rdi
testb %bl, %bl
je 0x1162d
addq $0x38, %rdi
movq -0x40(%rbp), %rcx
leaq (,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %r14
movq (%rax,%r14), %rax
movq (%rax,%r15,8), %rsi
addq $0x10, %rsi
callq 0x17714
movq (%r13), %rax
movq (%rax,%r14), %rcx
movq (%rcx,%r15,8), %rdi
addq $0x10, %rdi
shlq $0x3, %r12
leaq (%r12,%r12,2), %rbx
movq (%rax,%rbx), %rax
movq (%rax,%r15,8), %rsi
addq $0x38, %rsi
callq 0x17714
movq (%r13), %rax
movq (%rax,%r14), %rcx
movq (%rcx,%r15,8), %rdi
movq (%rax,%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x16f4e
movq (%r13), %rax
movq (%rax,%rbx), %rcx
movq (%rcx,%r15,8), %rdi
movq (%rax,%r14), %rax
movq (%rax,%r15,8), %rsi
callq 0x16f5c
movq %r13, %r12
jmp 0x11677
testq %rdi, %rdi
movq %r13, %r12
je 0x11677
movq 0xd98c(%rip), %r15      # 0x1efc8
leaq 0x7283(%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
movq -0x50(%rbp), %r13
leal -0x1(%r13), %r14d
testl %r13d, %r13d
jle 0x116f5
movq (%r12), %rax
movq -0x40(%rbp), %rbx
leaq (%rbx,%rbx,2), %rcx
movl %r14d, %edx
movq (%rax,%rcx,8), %rax
movq (%rax,%rdx,8), %r15
testq %r15, %r15
je 0x11700
addq $0x88, %r15
movl %r13d, %ecx
movq (%rax,%rcx,8), %rbx
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
callq 0x9da8
movq 0x80(%rbx), %rax
movq %rax, 0x20(%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0x17728
movl %eax, %r15d
movb $0x1, %al
movq -0x38(%rbp), %r12
jmp 0x116fa
xorl %eax, %eax
xorl %r15d, %r15d
movq -0x40(%rbp), %rbx
jmp 0x11705
xorl %eax, %eax
xorl %r15d, %r15d
testb %al, %al
je 0x11715
leaq -0xa0(%rbp), %rdi
callq 0x176f8
movq (%r12), %rax
leaq (%rbx,%rbx,2), %rcx
movslq %r14d, %r14
movq %rcx, -0x48(%rbp)
movq (%rax,%rcx,8), %rax
movq (%rax,%r14,8), %rdi
testb %r15b, %r15b
je 0x117a7
movl $0x88, %r15d
addq %r15, %rdi
movq -0x30(%rbp), %r13
movq (%rax,%r13,8), %rsi
addq $0x60, %rsi
callq 0x17714
movq (%r12), %rax
leaq (,%rbx,8), %rcx
leaq (%rcx,%rcx,2), %rbx
movq (%rax,%rbx), %rax
movq (%rax,%r13,8), %rdi
addq $0x60, %rdi
addq (%rax,%r14,8), %r15
movq %r15, %rsi
callq 0x17714
movq (%r12), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r13,8), %rdi
movq (%rax,%r14,8), %rsi
callq 0x16f6a
movq (%r12), %rax
movq (%rax,%rbx), %rax
movq -0x40(%rbp), %rbx
movq (%rax,%r14,8), %rdi
movq (%rax,%r13,8), %rsi
movq -0x50(%rbp), %r13
callq 0x16f78
jmp 0x117ee
testq %rdi, %rdi
je 0x117ee
movq 0xd815(%rip), %r15      # 0x1efc8
leaq 0x7136(%rip), %rsi      # 0x188f0
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
leal 0x1(%r13), %eax
movslq %eax, %r15
cmpl $0x95, %r13d
jg 0x1186a
movq (%r12), %rax
movq -0x48(%rbp), %r13
movq (%rax,%r13,8), %rax
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x11875
addq $0x60, %r14
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rbx
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %r12
movq %r12, %rdi
callq 0x9da8
movq 0xa8(%rbx), %rax
movq %rax, 0x20(%r12)
movq %r14, %rdi
movq %r12, %rsi
callq 0x17728
movl %eax, %r14d
movb $0x1, %al
movq -0x38(%rbp), %r12
movq -0x40(%rbp), %rbx
jmp 0x1187a
xorl %eax, %eax
xorl %r14d, %r14d
movq -0x48(%rbp), %r13
jmp 0x1187a
xorl %eax, %eax
xorl %r14d, %r14d
testb %al, %al
je 0x11887
leaq -0x78(%rbp), %rdi
callq 0x176f8
movq (%r12), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r15,8), %rdi
testb %r14b, %r14b
je 0x11902
addq $0x60, %rdi
movl $0x88, %r14d
movq -0x30(%rbp), %r13
movq (%rax,%r13,8), %rsi
addq %r14, %rsi
callq 0x17714
movq (%r12), %rax
shlq $0x3, %rbx
leaq (%rbx,%rbx,2), %rbx
movq (%rax,%rbx), %rax
addq (%rax,%r13,8), %r14
movq (%rax,%r15,8), %rsi
addq $0x60, %rsi
movq %r14, %rdi
callq 0x17714
movq (%r12), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r13,8), %rdi
movq (%rax,%r15,8), %rsi
callq 0x16f78
movq (%r12), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rax,%r13,8), %rsi
callq 0x16f6a
jmp 0x11949
testq %rdi, %rdi
je 0x11949
movq 0xd6ba(%rip), %rbx      # 0x1efc8
leaq 0x7007(%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 0x11961
jmp 0x11961
jmp 0x11961
movq %rax, %rbx
movq %r12, %rdi
callq 0x176f8
movq %rbx, %rdi
callq 0x33f0