// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
movl %ecx, 0x4(%rsp)
movq %rdi, %r14
movslq 0x108(%rdi), %rax
movq (%rdi), %rcx
leaq (%rax,%rax,2), %rax
movq %rdx, 0x30(%rsp)
movslq %edx, %rdx
movq -0x18(%rcx,%rax,8), %rax
leaq (%rdx,%rdx,2), %r15
movq %rsi, 0x18(%rsp)
movslq %esi, %rbp
movq (%rax,%r15,8), %rbx
shlq $0x4, %rbp
movq (%rbx,%rbp), %rdi
leaq 0x160d0(%rip), %rsi     # 0x24d60
leaq 0x15801(%rip), %rdx     # 0x24498
xorl %ecx, %ecx
callq 0x5230
movq 0x8(%rbx,%rbp), %r13
testq %r13, %r13
je 0xecbf
movq 0x16311(%rip), %rcx     # 0x24fc0
cmpb $0x0, (%rcx)
je 0xecba
incl 0x8(%r13)
jmp 0xecbf
lock
incl 0x8(%r13)
movq %rax, %rdi
movl 0x4(%rsp), %esi
callq 0x1aa5c
testq %r13, %r13
je 0xecd8
movq %r13, %rdi
callq 0x7828
movslq 0x108(%r14), %rax
movq (%r14), %rcx
leaq (%rax,%rax,2), %rax
movq -0x18(%rcx,%rax,8), %rax
movq (%rax,%r15,8), %rbx
movq (%rbx,%rbp), %rdi
testq %rdi, %rdi
je 0xed42
leaq 0x16061(%rip), %rsi     # 0x24d60
leaq 0x15792(%rip), %rdx     # 0x24498
xorl %ecx, %ecx
callq 0x5230
testq %rax, %rax
je 0xed42
addq %rbp, %rbx
movq %rax, 0x20(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
movq 0x18(%rsp), %rbx
je 0xed4f
movq 0x1628c(%rip), %rcx     # 0x24fc0
cmpb $0x0, (%rcx)
je 0xedf2
incl 0x8(%rax)
jmp 0xed4f
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x18(%rsp), %rbx
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0xc8ee
movq %r12, 0x8(%rsp)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xed70
callq 0x7828
leal 0x1(%rbx), %eax
movslq 0x108(%r14), %rcx
movq (%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movq -0x18(%rdx,%rcx,8), %rcx
movq (%rcx,%r15,8), %r13
movq 0x8(%rcx,%r15,8), %rcx
subq %r13, %rcx
shrq $0x4, %rcx
cmpl %ecx, %eax
jge 0xee59
movslq %eax, %r12
shlq $0x4, %r12
movq (%r13,%r12), %rdi
testq %rdi, %rdi
je 0xee59
leaq 0x15fa6(%rip), %rsi     # 0x24d60
leaq 0x156d7(%rip), %rdx     # 0x24498
xorl %ecx, %ecx
callq 0x5230
testq %rax, %rax
je 0xee59
movq %rax, %rbx
addq %r12, %r13
movq 0x8(%r13), %r13
testq %r13, %r13
je 0xee00
movq 0x161d9(%rip), %rax     # 0x24fc0
cmpb $0x0, (%rax)
je 0xedfb
incl 0x8(%r13)
jmp 0xee00
lock
incl 0x8(%rax)
jmp 0xed4f
lock
incl 0x8(%r13)
movq %rbx, %rdi
callq 0x1a8d2
movq 0x8(%rsp), %r12
cmpb $0x2e, %al
jne 0xee4c
movq %rbx, %rdi
callq 0x1aa58
testl %eax, %eax
jns 0xee4c
movq %rbx, %rdi
callq 0x1a8d6
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x1a8d6
shrq $0x20, %rax
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %eax, %edx
movl 0x4(%rsp), %ecx
movq %r12, %r8
callq 0xec3e
testq %r13, %r13
je 0xee59
movq %r13, %rdi
callq 0x7828
movq 0x30(%rsp), %rax
incl %eax
movslq 0x108(%r14), %rcx
movq (%r14), %rdx
leaq (%rcx,%rcx,2), %rsi
movq -0x18(%rdx,%rsi,8), %rcx
movq -0x10(%rdx,%rsi,8), %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
imull $0xaaaaaaab, %edx, %edx # imm = 0xAAAAAAAB
cmpl %edx, %eax
jge 0xef3e
cltq
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %r13
movq (%r13,%rbp), %rdi
testq %rdi, %rdi
je 0xef3e
leaq 0x15eb4(%rip), %rsi     # 0x24d60
leaq 0x155e5(%rip), %rdx     # 0x24498
xorl %ecx, %ecx
callq 0x5230
testq %rax, %rax
je 0xef3e
movq %rax, %rbx
addq %rbp, %r13
movq 0x8(%r13), %r13
testq %r13, %r13
movq 0x8(%rsp), %r12
je 0xeeea
movq 0x160e6(%rip), %rax     # 0x24fc0
cmpb $0x0, (%rax)
je 0xeee5
incl 0x8(%r13)
jmp 0xeeea
lock
incl 0x8(%r13)
movq %rbx, %rdi
callq 0x1a8d2
cmpb $0x2e, %al
jne 0xef31
movq %rbx, %rdi
callq 0x1aa58
testl %eax, %eax
jns 0xef31
movq %rbx, %rdi
callq 0x1a8d6
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x1a8d6
shrq $0x20, %rax
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %eax, %edx
movl 0x4(%rsp), %ecx
movq %r12, %r8
callq 0xec3e
testq %r13, %r13
je 0xef3e
movq %r13, %rdi
callq 0x7828
movq 0x18(%rsp), %rdx
testl %edx, %edx
jle 0xf00b
movslq 0x108(%r14), %rax
movq (%r14), %rcx
leaq (%rax,%rax,2), %rax
movq -0x18(%rcx,%rax,8), %rax
movq (%rax,%r15,8), %r15
movl %edx, %r12d
shlq $0x4, %r12
movq -0x10(%r15,%r12), %rdi
testq %rdi, %rdi
je 0xf00b
leaq 0x15de2(%rip), %rsi     # 0x24d60
leaq 0x15513(%rip), %rdx     # 0x24498
xorl %ecx, %ecx
callq 0x5230
testq %rax, %rax
je 0xf00b
movq %rax, %rbx
addq %r12, %r15
movq -0x8(%r15), %r12
testq %r12, %r12
je 0xefb9
movq 0x16019(%rip), %rax     # 0x24fc0
cmpb $0x0, (%rax)
je 0xefb3
incl 0x8(%r12)
jmp 0xefb9
lock
incl 0x8(%r12)
movq %rbx, %rdi
callq 0x1a8d2
cmpb $0x2e, %al
jne 0xeffe
movq %rbx, %rdi
callq 0x1aa58
testl %eax, %eax
jns 0xeffe
movq %rbx, %rdi
callq 0x1a8d6
movq %rax, %r13
movq %rbx, %rdi
callq 0x1a8d6
shrq $0x20, %rax
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
movl 0x4(%rsp), %ecx
movq 0x8(%rsp), %r8
callq 0xec3e
testq %r12, %r12
je 0xf00b
movq %r12, %rdi
callq 0x7828
movq 0x30(%rsp), %rdx
testl %edx, %edx
jle 0xf0d5
movslq 0x108(%r14), %rax
movq (%r14), %rcx
leaq (%rax,%rax,2), %rax
movq -0x18(%rcx,%rax,8), %rax
movl %edx, %ecx
leaq (%rcx,%rcx,2), %rcx
movq -0x18(%rax,%rcx,8), %r15
movq (%r15,%rbp), %rdi
testq %rdi, %rdi
je 0xf0d5
leaq 0x15d16(%rip), %rsi     # 0x24d60
leaq 0x15447(%rip), %rdx     # 0x24498
xorl %ecx, %ecx
callq 0x5230
testq %rax, %rax
je 0xf0d5
movq %rax, %rbx
addq %rbp, %r15
movq 0x8(%r15), %r15
testq %r15, %r15
je 0xf083
movq 0x15f4d(%rip), %rax     # 0x24fc0
cmpb $0x0, (%rax)
je 0xf07e
incl 0x8(%r15)
jmp 0xf083
lock
incl 0x8(%r15)
movq %rbx, %rdi
callq 0x1a8d2
cmpb $0x2e, %al
jne 0xf0c8
movq %rbx, %rdi
callq 0x1aa58
testl %eax, %eax
jns 0xf0c8
movq %rbx, %rdi
callq 0x1a8d6
movq %rax, %r12
movq %rbx, %rdi
callq 0x1a8d6
shrq $0x20, %rax
movq %r14, %rdi
movl %r12d, %esi
movl %eax, %edx
movl 0x4(%rsp), %ecx
movq 0x8(%rsp), %r8
callq 0xec3e
testq %r15, %r15
je 0xf0d5
movq %r15, %rdi
callq 0x7828
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf121
jmp 0xf121
jmp 0xf0f8
jmp 0xf105
jmp 0xf121
jmp 0xf121
jmp 0xf0f8
jmp 0xf105
jmp 0xf121
jmp 0xf121
movq %rax, %rbx
testq %r15, %r15
je 0xf131
movq %r15, %rdi
jmp 0xf12c
movq %rax, %rbx
testq %r12, %r12
je 0xf131
movq %r12, %rdi
jmp 0xf12c
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
jne 0xf12c
jmp 0xf131
movq %rax, %rbx
testq %r13, %r13
je 0xf131
movq %r13, %rdi
callq 0x7828
movq %rbx, %rdi
callq 0x5380
nop