// File: /workspace/github_cpp_makefile_star2_O1/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 0x8e08
leaq -0xb0(%rbp), %r12
xorl %r13d, %r13d
leaq -0xc0(%rbp), %rbx
leaq (,%r13,2), %r15
addq %r13, %r15
xorl %r14d, %r14d
movq %r13, -0x60(%rbp)
movq %r15, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq (%rax,%r15,8), %rcx
cmpb $0x0, 0x1(%rcx,%r14)
jne 0x11bf9
leaq (%rax,%r15,8), %rax
movq (%rax), %rax
movq %r12, -0xc0(%rbp)
movq 0x8(%rax,%r14), %rsi
movq 0x10(%rax,%r14), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x9da8
movq %rbx, %rdi
leaq 0x6d7c(%rip), %rsi      # 0x187ab
callq 0x30b0
movl %eax, %ebx
testl %eax, %eax
je 0x11a83
movq -0x58(%rbp), %rax
movq (%rax,%r15,8), %rax
leaq -0xd0(%rbp), %rcx
movq %rcx, -0xe0(%rbp)
movq 0x8(%rax,%r14), %rsi
movq 0x10(%rax,%r14), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %r15
movq %r15, %rdi
callq 0x9da8
movq %r15, %rdi
leaq 0x6e1e(%rip), %rsi      # 0x18894
callq 0x30b0
testl %eax, %eax
sete %r12b
jmp 0x11a86
movb $0x1, %r12b
testl %ebx, %ebx
leaq -0xc0(%rbp), %rbx
je 0x11aa9
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x11aa9
callq 0x3200
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
movq -0x68(%rbp), %r15
je 0x11ac5
callq 0x3200
testb %r12b, %r12b
je 0x11af9
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %r13, %r8
callq 0x11d2e
leaq -0xb0(%rbp), %r12
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x141bc
jmp 0x11bf1
movq -0x58(%rbp), %rax
movq (%rax,%r15,8), %rax
leaq -0xb0(%rbp), %r12
movq %r12, -0xc0(%rbp)
movq 0x8(%rax,%r14), %rsi
movq 0x10(%rax,%r14), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x9da8
movq %rbx, %rdi
leaq 0x6c84(%rip), %rsi      # 0x187b2
callq 0x30b0
movl %eax, %ebx
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x11b46
callq 0x3200
testl %ebx, %ebx
je 0x11bc7
movq -0x58(%rbp), %rax
movq (%rax,%r15,8), %rax
movq %r12, -0xc0(%rbp)
movq 0x8(%rax,%r14), %rsi
movq 0x10(%rax,%r14), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
callq 0x9da8
movq %rbx, %rdi
leaq 0x6c38(%rip), %rsi      # 0x187b7
callq 0x30b0
movl %eax, %ebx
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x11b97
callq 0x3200
testl %ebx, %ebx
leaq -0xc0(%rbp), %rbx
jne 0x11bf9
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %r13, %r8
callq 0x135d4
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x141bc
jmp 0x11bf1
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
movq %r13, %r8
callq 0x12cf4
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x141bc
movq %rbx, %rdi
callq 0x17ad8
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r13
addq $0x28, %r14
cmpq $0x78, %r14
jne 0x119ee
movq -0x60(%rbp), %r13
incq %r13
cmpq $0x3, %r13
jne 0x119d8
movq -0x30(%rbp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
je 0x11c95
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 0x11c8d
sarq $0x3, %r8
imulq %rsi, %r8
cmpq $0x1, %r8
adcq $0x0, %r8
incq %rdi
movb $0x0, (%rdi)
addq $0x28, %rdi
decq %r8
jne 0x11c81
incq %rdx
cmpq %rcx, %rdx
jne 0x11c5b
leaq -0x58(%rbp), %rdi
callq 0x14176
movq -0x30(%rbp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x11cfa
jmp 0x11cc5
jmp 0x11cee
jmp 0x11cee
jmp 0x11cc5
jmp 0x11cee
jmp 0x11cee
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x17ad8
jmp 0x11cf1
jmp 0x11cee
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x11cf1
callq 0x3200
jmp 0x11cf1
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x14176
movq -0x30(%rbp), %rdi
callq 0xec22
movq %rbx, %rdi
callq 0x33f0
nop