// File: /workspace/github_cpp_makefile_star2_O3/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
movups %xmm0, (%rdi)
movq %rdi, -0x30(%rbp)
movq $0x0, 0x10(%rdi)
movslq %edx, %rax
movq %rsi, -0x40(%rbp)
movq (%rsi), %rdx
leaq (%rax,%rax,2), %rax
movslq %ecx, %rcx
movq (%rdx,%rax,8), %rax
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
leaq 0xd0(%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0x8cd0
leaq -0xa8(%rbp), %rbx
xorl %r13d, %r13d
leaq -0xb8(%rbp), %r12
leaq (,%r13,2), %r15
addq %r13, %r15
xorl %r14d, %r14d
movq %r13, -0x60(%rbp)
movq -0x58(%rbp), %rax
movq (%rax,%r15,8), %rax
cmpb $0x0, 0x1(%rax,%r14)
jne 0x11b4f
movq %rbx, -0xb8(%rbp)
movq 0x8(%rax,%r14), %rsi
movq 0x10(%rax,%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x9cc4
movq %r12, %rdi
leaq 0x6e1f(%rip), %rsi      # 0x187ab
callq 0x30b0
testl %eax, %eax
je 0x119f8
movq -0x58(%rbp), %rax
movq (%rax,%r15,8), %rax
leaq -0xc8(%rbp), %rbx
movq %rbx, -0xd8(%rbp)
movq 0x8(%rax,%r14), %rsi
movq 0x10(%rax,%r14), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %r12
movq %r12, %rdi
callq 0x9cc4
movq %r12, %rdi
leaq 0x6ec3(%rip), %rsi      # 0x18894
callq 0x30b0
testl %eax, %eax
movq %rbx, %rax
sete %bl
movq -0xd8(%rbp), %rdi
cmpq %rax, %rdi
je 0x119ef
callq 0x3200
leaq -0xb8(%rbp), %r12
jmp 0x119fa
movb $0x1, %bl
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x11a12
callq 0x3200
testb %bl, %bl
je 0x11a45
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %r13, %r8
callq 0x11c8a
leaq -0xa8(%rbp), %rbx
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x13e1c
jmp 0x11b47
movq -0x58(%rbp), %rax
movq (%rax,%r15,8), %rax
leaq -0xa8(%rbp), %rbx
movq %rbx, -0xb8(%rbp)
movq 0x8(%rax,%r14), %rsi
movq 0x10(%rax,%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x9cc4
movq %r12, %rdi
leaq 0x6d38(%rip), %rsi      # 0x187b2
callq 0x30b0
movq %rbx, %rcx
movl %eax, %ebx
movq -0xb8(%rbp), %rdi
cmpq %rcx, %rdi
je 0x11a95
callq 0x3200
testl %ebx, %ebx
je 0x11b1d
movq -0x58(%rbp), %rax
movq (%rax,%r15,8), %rax
leaq -0xa8(%rbp), %rbx
movq %rbx, -0xb8(%rbp)
movq 0x8(%rax,%r14), %rsi
movq 0x10(%rax,%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x9cc4
movq %r12, %rdi
leaq 0x6ce5(%rip), %rsi      # 0x187b7
callq 0x30b0
movq %rbx, %rcx
movl %eax, %ebx
movq -0xb8(%rbp), %rdi
cmpq %rcx, %rdi
je 0x11aed
callq 0x3200
testl %ebx, %ebx
leaq -0xa8(%rbp), %rbx
jne 0x11b4f
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %r13, %r8
callq 0x132c0
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x13e1c
jmp 0x11b47
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %r13, %r8
callq 0x12aa8
leaq -0xa8(%rbp), %rbx
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x13e1c
movq %r12, %rdi
callq 0x177a0
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r13
addq $0x28, %r14
cmpq $0x78, %r14
jne 0x11952
movq -0x60(%rbp), %r13
incq %r13
cmpq $0x3, %r13
jne 0x11940
movq -0x30(%rbp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
je 0x11beb
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rdx, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
imulq $0x58, %rdx, %r8
movq 0x28(%rax,%r8), %rdi
movq 0x30(%rax,%r8), %r8
subq %rdi, %r8
je 0x11be3
sarq $0x3, %r8
imulq %rsi, %r8
cmpq $0x1, %r8
adcq $0x0, %r8
incq %rdi
movb $0x0, (%rdi)
addq $0x28, %rdi
decq %r8
jne 0x11bd7
incq %rdx
cmpq %rcx, %rdx
jne 0x11bb1
leaq -0x58(%rbp), %rdi
callq 0x13dcc
movq -0x30(%rbp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x11c57
jmp 0x11c1b
jmp 0x11c4b
jmp 0x11c4b
jmp 0x11c1b
jmp 0x11c4b
jmp 0x11c4b
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x177a0
jmp 0x11c4e
jmp 0x11c4b
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x11c4e
callq 0x3200
jmp 0x11c4e
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x13dcc
movq -0x30(%rbp), %rdi
callq 0xeb0e
movq %rbx, %rdi
callq 0x33f0