// File: /workspace/github_cpp_makefile_star2_O2/kaiming[P]Chamber-Crawler-3k/Board/board.cc
// Function: Board::tileDFS(int, int, int, std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>&)
void Board::tileDFS(int x, int y, int chamberNum, std::vector<std::shared_ptr<WalkableTile>>& chamber) {
    
    // Store current tile
    std::dynamic_pointer_cast<WalkableTile>(floors[floorNum - 1][y][x])->setRoom(chamberNum);
    chamber.emplace_back(std::dynamic_pointer_cast<WalkableTile>(floors[floorNum-1][y][x])); 


    // Check all directions around for matching unidentified chamber floor tiles

    // Check to the right
    if (x + 1 < static_cast<int>(floors[floorNum-1][y].size())) {
        std::shared_ptr<WalkableTile> right = std::dynamic_pointer_cast<WalkableTile>(floors[floorNum-1][y][x+1]);
        
        if (right && (right)->getType() == '.' && (right)->getRoom() < 0) {
            tileDFS(right->getCoord().first, right->getCoord().second, chamberNum, chamber);
        }
    }

    // Check below
    if (y + 1 < static_cast<int>(floors[floorNum-1].size())) {
        std::shared_ptr<WalkableTile> down = std::dynamic_pointer_cast<WalkableTile>(floors[floorNum-1][y+1][x]);
        
        if (down && (down)->getType() == '.' && (down)->getRoom() < 0) {
            tileDFS(down->getCoord().first, down->getCoord().second, chamberNum, chamber);
        }
    }
    
    // Check to the left
    if (x - 1 >= 0) {
        std::shared_ptr<WalkableTile> left = std::dynamic_pointer_cast<WalkableTile>(floors[floorNum-1][y][x-1]);
    
        if (left && (left)->getType() == '.' && (left)->getRoom() < 0) {
            tileDFS(left->getCoord().first, left->getCoord().second, chamberNum, chamber);
        }
    }

    // Check above
    if (y -1 >= 0) {
        std::shared_ptr<WalkableTile> above = std::dynamic_pointer_cast<WalkableTile>(floors[floorNum-1][y - 1][x]);
     
        if (above && (above)->getType() == '.' && (above)->getRoom() < 0) {
            tileDFS(above->getCoord().first, above->getCoord().second, chamberNum, chamber);
        }
    }
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %r15
movl %ecx, %ebp
movq %rdi, %r14
movslq 0x108(%rdi), %rax
movq (%rdi), %rcx
imulq $0x18, %rax, %rax
movq %rdx, 0x30(%rsp)
movslq %edx, %rdx
movq -0x18(%rcx,%rax), %rax
imulq $0x18, %rdx, %r12
movq %rsi, 0x28(%rsp)
movslq %esi, %r13
shlq $0x4, %r13
movq (%rax,%r12), %rsi
addq %r13, %rsi
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12363
movq (%rbx), %rdi
movl %ebp, 0x1c(%rsp)
movl %ebp, %esi
callq 0x17486
leaq 0x10(%rsp), %rdi
callq 0x6c00
movslq 0x108(%r14), %rax
movq (%r14), %rcx
imulq $0x18, %rax, %rax
movq -0x18(%rcx,%rax), %rax
movq (%rax,%r12), %rsi
addq %r13, %rsi
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12363
movq %r15, 0x20(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0xbc42
leaq 0x10(%rsp), %rdi
callq 0x6c00
movq 0x28(%rsp), %rbp
leal 0x1(%rbp), %edi
movslq 0x108(%r14), %rax
movq (%r14), %rdx
imulq $0x18, %rax, %rcx
movq -0x18(%rdx,%rcx), %rcx
movq (%rcx,%r12), %rsi
movq 0x8(%rcx,%r12), %r8
subq %rsi, %r8
shrq $0x4, %r8
cmpl %r8d, %edi
movq 0x30(%rsp), %r15
jge 0xe056
movslq %edi, %rax
shlq $0x4, %rax
addq %rax, %rsi
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12363
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xe039
callq 0x173b8
cmpb $0x2e, %al
jne 0xe039
movq 0x8(%rsp), %rdi
callq 0x17482
testl %eax, %eax
jns 0xe039
movq 0x8(%rsp), %rdi
callq 0x173bc
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x173bc
shrq $0x20, %rax
movq %r14, %rdi
movl %ebx, %esi
movl %eax, %edx
movl 0x1c(%rsp), %ecx
movq 0x20(%rsp), %r8
callq 0xdeec
leaq 0x10(%rsp), %rdi
callq 0x6c00
movslq 0x108(%r14), %rax
movq (%r14), %rdx
imulq $0x18, %rax, %rcx
movq -0x18(%rdx,%rcx), %rcx
leal 0x1(%r15), %esi
imulq $0x18, %rax, %rax
movq -0x10(%rdx,%rax), %rax
subq %rcx, %rax
pushq $0x18
popq %rdi
cqto
idivq %rdi
cmpl %eax, %esi
jge 0xe0e6
movslq %esi, %rax
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rsi
addq %r13, %rsi
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12363
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xe0dc
callq 0x173b8
cmpb $0x2e, %al
jne 0xe0dc
movq 0x8(%rsp), %rdi
callq 0x17482
testl %eax, %eax
jns 0xe0dc
movq 0x8(%rsp), %rdi
callq 0x173bc
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x173bc
shrq $0x20, %rax
movq %r14, %rdi
movl %ebx, %esi
movl %eax, %edx
movl 0x1c(%rsp), %ecx
movq 0x20(%rsp), %r8
callq 0xdeec
leaq 0x10(%rsp), %rdi
callq 0x6c00
testl %ebp, %ebp
jle 0xe183
movq %r12, %rdx
movq %r13, %r12
movslq 0x108(%r14), %rax
movq (%r14), %rcx
imulq $0x18, %rax, %rax
movq -0x18(%rcx,%rax), %rax
movq (%rax,%rdx), %rax
movl %ebp, %ecx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x10, %rsi
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12363
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xe176
callq 0x173b8
cmpb $0x2e, %al
jne 0xe176
movq 0x8(%rsp), %rdi
callq 0x17482
testl %eax, %eax
jns 0xe176
movq 0x8(%rsp), %rdi
callq 0x173bc
movq %rax, %r13
movq 0x8(%rsp), %rdi
callq 0x173bc
shrq $0x20, %rax
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
movl 0x1c(%rsp), %ecx
movq 0x20(%rsp), %r8
callq 0xdeec
leaq 0x10(%rsp), %rdi
callq 0x6c00
movq %r12, %r13
testl %r15d, %r15d
jle 0xe218
movslq 0x108(%r14), %rax
movq (%r14), %rcx
imulq $0x18, %rax, %rax
movq -0x18(%rcx,%rax), %rax
movl %r15d, %ecx
imulq $0x18, %rcx, %rcx
addq -0x18(%rax,%rcx), %r13
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x12363
movq (%rbx), %rdi
testq %rdi, %rdi
movq 0x20(%rsp), %rbx
je 0xe20e
callq 0x173b8
cmpb $0x2e, %al
jne 0xe20e
movq 0x8(%rsp), %rdi
callq 0x17482
testl %eax, %eax
jns 0xe20e
movq 0x8(%rsp), %rdi
callq 0x173bc
movq %rax, %r15
movq 0x8(%rsp), %rdi
callq 0x173bc
shrq $0x20, %rax
movq %r14, %rdi
movl %r15d, %esi
movl %eax, %edx
movl 0x1c(%rsp), %ecx
movq %rbx, %r8
callq 0xdeec
leaq 0x10(%rsp), %rdi
callq 0x6c00
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
jmp 0xe241
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6c00
movq %rbx, %rdi
callq 0x5390