// File: XxAdi101xX[P]ChamberCrawler/Main/MainHelpers.cc
// Function: getValidMove(std::vector<int, std::allocator<int>>)
Direction getValidMove(vector<int> base) {
	// safety check
	vector<Direction>  checkedDirections;
	vector <int> tempCoordinates;
	Direction tempDirection;

	do {
		shared_ptr<Cell> tempCell = currentFloor.getCell(base);
		tempDirection = rng.genDirection();

		tempCoordinates
			= (tempCell->getNeighbour(tempDirection))->getCoords();

		bool checked = false;

		// checks if this direction has been logged
		for (auto direction: checkedDirections) {
			if (direction == tempDirection) {
				checked = true;
				break;
			}
		}

		// if directions was not logged, log it
		if (!(checked)) {
			checkedDirections.emplace_back(tempDirection);
		}

		// checks if all directions were tried
		if (checkedDirections.size() == DIRECTION_ENUMERATION) {
			// no valid move
			throw 1;
		}

		// reroll if cell in direction is not a FloorTile
		// or has an occupant already
	} while (!(isValidCoordinates(tempCoordinates))
		|| isOccupied(tempCoordinates));

	return tempDirection;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x218f0
leaq -0x38(%rbp), %rdi
callq 0x19550
movq -0x108(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x19880
jmp 0x20d4a
leaq 0x473bf(%rip), %rsi     # 0x68110
leaq -0x50(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x3ffb0
jmp 0x20d60
leaq -0x68(%rbp), %rdi
callq 0x19640
leaq 0x47170(%rip), %rdi     # 0x67ee0
callq 0x34240
movl %eax, -0x10c(%rbp)
jmp 0x20d7d
movl -0x10c(%rbp), %eax
movl %eax, -0x3c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x19df0
movq %rax, %rsi
movl -0x3c(%rbp), %edx
leaq -0xa0(%rbp), %rdi
callq 0x2cca0
jmp 0x20da3
leaq -0xa0(%rbp), %rdi
callq 0x19df0
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x2cbb0
jmp 0x20dc0
leaq -0x38(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x19610
leaq -0x90(%rbp), %rdi
callq 0x19640
leaq -0xa0(%rbp), %rdi
callq 0x199a0
movb $0x0, -0xa1(%rbp)
leaq -0x20(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x21910
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x21940
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x21970
testb $0x1, %al
jne 0x20e3c
jmp 0x20ed0
leaq -0xb8(%rbp), %rdi
callq 0x219b0
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x20ebd
movb $0x1, -0xa1(%rbp)
jmp 0x20ed0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x21058
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x19640
jmp 0x21058
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2100e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x199a0
jmp 0x2100e
jmp 0x20ebf
leaq -0xb8(%rbp), %rdi
callq 0x219d0
jmp 0x20e20
testb $0x1, -0xa1(%rbp)
jne 0x20eea
leaq -0x20(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x219f0
jmp 0x20ee8
jmp 0x20eea
leaq -0x20(%rbp), %rdi
callq 0x21a70
cmpq $0x8, %rax
jne 0x20f21
movl $0x4, %edi
callq 0x61a0
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x4605d(%rip), %rsi     # 0x66f70
xorl %eax, %eax
movl %eax, %edx
callq 0x6520
jmp 0x21073
leaq -0x50(%rbp), %rdi
callq 0x199a0
movb $0x0, -0xf9(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x19880
jmp 0x20f43
leaq -0xe0(%rbp), %rdi
callq 0x20420
movb %al, -0x10d(%rbp)
jmp 0x20f57
movb -0x10d(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x10e(%rbp)
jne 0x20f6c
jmp 0x20fa7
leaq -0xf8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x19880
jmp 0x20f7e
movb $0x1, -0xf9(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x204d0
movb %al, -0x10f(%rbp)
jmp 0x20f99
movb -0x10f(%rbp), %al
movb %al, -0x10e(%rbp)
jmp 0x20fa7
movb -0x10e(%rbp), %al
movb %al, -0x110(%rbp)
testb $0x1, -0xf9(%rbp)
jne 0x20fbe
jmp 0x20fca
leaq -0xf8(%rbp), %rdi
callq 0x19640
leaq -0xe0(%rbp), %rdi
callq 0x19640
movb -0x110(%rbp), %al
testb $0x1, %al
jne 0x20d38
movl -0x3c(%rbp), %eax
movl %eax, -0x114(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x19640
leaq -0x20(%rbp), %rdi
callq 0x21a90
movl -0x114(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x199a0
jmp 0x21058
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2104c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
testb $0x1, -0xf9(%rbp)
jne 0x2103e
jmp 0x2104a
leaq -0xf8(%rbp), %rdi
callq 0x19640
jmp 0x2104c
leaq -0xe0(%rbp), %rdi
callq 0x19640
leaq -0x38(%rbp), %rdi
callq 0x19640
leaq -0x20(%rbp), %rdi
callq 0x21a90
movq -0x70(%rbp), %rdi
callq 0x6550
nopw %cs:(%rax,%rax)