// File: /workspace/github_cpp_makefile_star2_O2/Doug0855[P]TigerZone/Board.cpp
// Function: Board::getStructures(int, int)
std::vector<Structure> Board::getStructures(int row, int col) {
	//debugging std::cout<<"IN GET STRUCTURES FOR "<<row<<' '<<col<<std::endl;
	std::vector<Structure> structures;
	Tile* tile = m_board[row][col];
	std::vector< std::vector<Block> > tileBlocks = tile->getInnerBlocks();
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			if(!(tileBlocks[i][j].isVisited())) {
				// For each block within the tile we will check it's type and build the structure from there with a Breadth first search
				if(tileBlocks[i][j].getType() == "jungle" || tileBlocks[i][j].getType() == "mixed") {
					Structure struc = checkJungle(tile, tileBlocks, std::pair<int,int>(i,j));
					structures.push_back(struc);
				}
				else if(tileBlocks[i][j].getType() == "lake") {
					Structure struc = checkLake(tile, tileBlocks, std::pair<int,int>(i,j));
					structures.push_back(struc);
				}
				else if(tileBlocks[i][j].getType() == "trail") {
					Structure struc = checkTrail(tile, tileBlocks, std::pair<int,int>(i,j));
					structures.push_back(struc);
				}
			}
		}
	}
	for(int i = 0; i < structures.size(); i++) {
		for(int j = 0; j < structures[i].structureBlocks.size(); j++) {
			structures[i].structureBlocks[j].unVisit();
		}
	}
	//debugging for(int i = 0; i < structures.size(); i++) {
	//debugging 	std::cout<<"Structure is of type "<<structures[i].type<<" with "<<structures[i].structureBlocks.size()
	//debugging 	<<" blocks and starting block at "<<structures[i].startingBlock.first<<' '<<structures[i].startingBlock.second<<std::endl;
	//debugging 	std::cout<<" and how many buffalo? : "<<structures[i].buffaloCount<<std::endl;
	//debugging }
	//debugging std::cout<<"Structures size is "<<structures.size()<<std::endl;
	return structures;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
xorps %xmm0, %xmm0
andq $0x0, 0x10(%rdi)
movq %rdi, -0x30(%rbp)
movups %xmm0, (%rdi)
movslq %edx, %rax
movq %rsi, -0x40(%rbp)
movq (%rsi), %rdx
imulq $0x18, %rax, %rax
movslq %ecx, %rcx
movq (%rdx,%rax), %rax
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
leaq 0xd0(%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0x65ba
xorl %ebx, %ebx
movabsq $0x100000000, %r13      # imm = 0x100000000
leaq -0xb8(%rbp), %r12
cmpq $0x3, %rbx
je 0xcfb3
imulq $0x18, %rbx, %r15
movq %rbx, -0x60(%rbp)
pushq $0x8
popq %r14
cmpq $0x80, %r14
je 0xcfa7
movq -0x58(%rbp), %rax
movq (%rax,%r15), %rsi
cmpb $0x0, -0x7(%rsi,%r14)
jne 0xced2
addq %r14, %rsi
movq %r12, %rdi
callq 0x32c0
movq %r12, %rdi
leaq 0x58e2(%rip), %rsi      # 0x1272b
callq 0x6261
testb %al, %al
je 0xce5c
movq %r12, %rdi
callq 0x3120
jmp 0xcea7
movq -0x58(%rbp), %rax
movq (%rax,%r15), %rsi
addq %r14, %rsi
leaq -0xd8(%rbp), %r13
movq %r13, %rdi
callq 0x32c0
movq %r13, %rdi
leaq 0x5994(%rip), %rsi      # 0x12814
callq 0x6261
movq %r13, %rdi
movl %eax, %r13d
callq 0x3120
movq %r12, %rdi
callq 0x3120
testb %r13b, %r13b
movabsq $0x100000000, %r13      # imm = 0x100000000
je 0xcede
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %rbx, %r8
callq 0xd098
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0xecde
movq %r12, %rdi
callq 0x11a34
addq $0x28, %r14
addq %r13, %rbx
jmp 0xce13
movq -0x58(%rbp), %rax
movq (%rax,%r15), %rsi
addq %r14, %rsi
movq %r12, %rdi
callq 0x32c0
movq %r12, %rdi
leaq 0x5837(%rip), %rsi      # 0x12732
callq 0x6261
movl %eax, %r13d
movq %r12, %rdi
callq 0x3120
testb %r13b, %r13b
je 0xcf3f
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %rbx, %r8
callq 0xdc1a
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0xecde
movabsq $0x100000000, %r13      # imm = 0x100000000
jmp 0xceca
movq -0x58(%rbp), %rax
movq (%rax,%r15), %rsi
addq %r14, %rsi
movq %r12, %rdi
callq 0x32c0
movq %r12, %rdi
leaq 0x57db(%rip), %rsi      # 0x12737
callq 0x6261
movl %eax, %r13d
movq %r12, %rdi
callq 0x3120
testb %r13b, %r13b
movabsq $0x100000000, %r13      # imm = 0x100000000
je 0xced2
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %rbx, %r8
callq 0xe31c
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0xecde
jmp 0xceca
movq -0x60(%rbp), %rbx
incq %rbx
jmp 0xcdfd
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rax
subq %rsi, %rax
pushq $0x58
popq %rcx
cqto
idivq %rcx
movq %rax, %rcx
xorl %edi, %edi
pushq $0x28
popq %r8
cmpq %rcx, %rdi
je 0xd005
imulq $0x58, %rdi, %rax
movq 0x28(%rsi,%rax), %r9
movq 0x30(%rsi,%rax), %rax
subq %r9, %rax
cqto
idivq %r8
incq %r9
subq $0x1, %rax
jb 0xd000
movb $0x0, (%r9)
addq $0x28, %r9
jmp 0xcff0
incq %rdi
jmp 0xcfd2
leaq -0x58(%rbp), %rdi
callq 0xecb2
movq -0x30(%rbp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xd065
jmp 0xd059
jmp 0xd048
jmp 0xd048
jmp 0xd059
jmp 0xd059
jmp 0xd059
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x3120
jmp 0xd05c
jmp 0xd059
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x11a34
jmp 0xd05c
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0xecb2
movq -0x30(%rbp), %rdi
callq 0xa786
movq %rbx, %rdi
callq 0x33c0