// File: 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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
movl 0x108(%rdi), %eax
decl %eax
movslq %eax, %rsi
callq 0x11e20
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0x11fc0
movq %rax, %rdi
movslq -0xc(%rbp), %rsi
callq 0x2e0b0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x2e100
movq -0xd8(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x3c0e0
jmp 0x259eb
leaq -0x30(%rbp), %rdi
callq 0x99e0
movq -0xe0(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl 0x108(%rdi), %eax
decl %eax
movslq %eax, %rsi
callq 0x11e20
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0x11fc0
movq %rax, %rdi
movslq -0xc(%rbp), %rsi
callq 0x2e0b0
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x2e100
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x1dba0
jmp 0x25a56
leaq -0x50(%rbp), %rdi
callq 0x99e0
movq -0xe0(%rbp), %rdi
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
movl 0x108(%rdi), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x11e20
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0x11fc0
movq %rax, %rdi
callq 0xb9d0
movq %rax, %rcx
movl -0xf4(%rbp), %eax
cmpl %ecx, %eax
jge 0x25c18
movq -0xe0(%rbp), %rdi
movl 0x108(%rdi), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x11e20
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0x11fc0
movq %rax, %rdi
movl -0xc(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x2e0b0
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x2e100
leaq -0x60(%rbp), %rdi
callq 0x1ed00
testb $0x1, %al
jne 0x25afb
jmp 0x25c0f
leaq -0x60(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be20
movb %al, -0xf5(%rbp)
jmp 0x25b14
movb -0xf5(%rbp), %al
movsbl %al, %eax
cmpl $0x2e, %eax
jne 0x25c0f
leaq -0x60(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3c0c0
movl %eax, -0xfc(%rbp)
jmp 0x25b3f
movl -0xfc(%rbp), %eax
cmpl $0x0, %eax
jge 0x25c0f
leaq -0x60(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be40
movq %rax, -0x108(%rbp)
jmp 0x25b68
movq -0x108(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x114(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be40
movq %rax, -0x110(%rbp)
jmp 0x25b96
movl -0x114(%rbp), %esi
movq -0xe0(%rbp), %rdi
movq -0x110(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x6c(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
callq 0x25970
jmp 0x25bbf
jmp 0x25c0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x99e0
jmp 0x26081
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x99e0
jmp 0x26081
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x99e0
jmp 0x26081
leaq -0x60(%rbp), %rdi
callq 0x99e0
movq -0xe0(%rbp), %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x118(%rbp)
movl 0x108(%rdi), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x11e20
movq %rax, %rdi
callq 0xb360
movq %rax, %rcx
movl -0x118(%rbp), %eax
cmpl %ecx, %eax
jge 0x25d9d
movq -0xe0(%rbp), %rdi
movl 0x108(%rdi), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x11e20
movq %rax, %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x11fc0
movq %rax, %rdi
movslq -0xc(%rbp), %rsi
callq 0x2e0b0
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x2e100
leaq -0x80(%rbp), %rdi
callq 0x1ed00
testb $0x1, %al
jne 0x25ca8
jmp 0x25d94
leaq -0x80(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be20
movb %al, -0x119(%rbp)
jmp 0x25cc1
movb -0x119(%rbp), %al
movsbl %al, %eax
cmpl $0x2e, %eax
jne 0x25d94
leaq -0x80(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3c0c0
movl %eax, -0x120(%rbp)
jmp 0x25cec
movl -0x120(%rbp), %eax
cmpl $0x0, %eax
jge 0x25d94
leaq -0x80(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be40
movq %rax, -0x128(%rbp)
jmp 0x25d15
movq -0x128(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x88(%rbp), %eax
movl %eax, -0x134(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be40
movq %rax, -0x130(%rbp)
jmp 0x25d49
movl -0x134(%rbp), %esi
movq -0xe0(%rbp), %rdi
movq -0x130(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x8c(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
callq 0x25970
jmp 0x25d78
jmp 0x25d94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x99e0
jmp 0x26081
leaq -0x80(%rbp), %rdi
callq 0x99e0
movl -0xc(%rbp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jl 0x25f0c
movq -0xe0(%rbp), %rdi
movl 0x108(%rdi), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x11e20
movq %rax, %rdi
movslq -0x10(%rbp), %rsi
callq 0x11fc0
movq %rax, %rdi
movl -0xc(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2e0b0
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x2e100
leaq -0xa0(%rbp), %rdi
callq 0x1ed00
testb $0x1, %al
jne 0x25e05
jmp 0x25f00
leaq -0xa0(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be20
movb %al, -0x135(%rbp)
jmp 0x25e21
movb -0x135(%rbp), %al
movsbl %al, %eax
cmpl $0x2e, %eax
jne 0x25f00
leaq -0xa0(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3c0c0
movl %eax, -0x13c(%rbp)
jmp 0x25e4f
movl -0x13c(%rbp), %eax
cmpl $0x0, %eax
jge 0x25f00
leaq -0xa0(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be40
movq %rax, -0x148(%rbp)
jmp 0x25e7b
movq -0x148(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0x154(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be40
movq %rax, -0x150(%rbp)
jmp 0x25eb2
movl -0x154(%rbp), %esi
movq -0xe0(%rbp), %rdi
movq -0x150(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0xac(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
callq 0x25970
jmp 0x25ee1
jmp 0x25f00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x99e0
jmp 0x26081
leaq -0xa0(%rbp), %rdi
callq 0x99e0
movl -0x10(%rbp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jl 0x26078
movq -0xe0(%rbp), %rdi
movl 0x108(%rdi), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x11e20
movq %rax, %rdi
movl -0x10(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x11fc0
movq %rax, %rdi
movslq -0xc(%rbp), %rsi
callq 0x2e0b0
movq %rax, %rsi
leaq -0xc0(%rbp), %rdi
callq 0x2e100
leaq -0xc0(%rbp), %rdi
callq 0x1ed00
testb $0x1, %al
jne 0x25f74
jmp 0x2606c
leaq -0xc0(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be20
movb %al, -0x155(%rbp)
jmp 0x25f90
movb -0x155(%rbp), %al
movsbl %al, %eax
cmpl $0x2e, %eax
jne 0x2606c
leaq -0xc0(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3c0c0
movl %eax, -0x15c(%rbp)
jmp 0x25fbe
movl -0x15c(%rbp), %eax
cmpl $0x0, %eax
jge 0x2606c
leaq -0xc0(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be40
movq %rax, -0x168(%rbp)
jmp 0x25fea
movq -0x168(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
movl %eax, -0x174(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x3be40
movq %rax, -0x170(%rbp)
jmp 0x26021
movl -0x174(%rbp), %esi
movq -0xe0(%rbp), %rdi
movq -0x170(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0xcc(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
callq 0x25970
jmp 0x26050
jmp 0x2606c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x99e0
jmp 0x26081
leaq -0xc0(%rbp), %rdi
callq 0x99e0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x6540
nopw (%rax,%rax)