// File: /workspace/github_cpp_makefile_star2_O1/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, 0x10(%rsp)
movl %ecx, 0x4(%rsp)
movl %edx, %r12d
movl %esi, %r15d
movq %rdi, %r14
movslq 0x108(%rdi), %rax
movq (%rdi), %rcx
leaq (%rax,%rax,2), %rax
movslq %edx, %rdx
movq -0x18(%rcx,%rax,8), %rax
leaq (%rdx,%rdx,2), %rcx
movslq %esi, %rbp
movq %rcx, 0x18(%rsp)
movq (%rax,%rcx,8), %rbx
shlq $0x4, %rbp
movq (%rbx,%rbp), %rdi
addq %rbp, %rbx
testq %rdi, %rdi
je 0xf0d4
leaq 0x16c9f(%rip), %rsi     # 0x25d60
leaq 0x163d0(%rip), %rdx     # 0x25498
xorl %ecx, %ecx
callq 0x5240
movq %rax, %rdi
jmp 0xf0d6
xorl %edi, %edi
movq 0x8(%rbx), %r13
testq %r13, %r13
je 0xf0f6
movq 0x16eda(%rip), %rax     # 0x25fc0
cmpb $0x0, (%rax)
je 0xf0f1
incl 0x8(%r13)
jmp 0xf0f6
lock
incl 0x8(%r13)
movl 0x4(%rsp), %esi
callq 0x1af1c
testq %r13, %r13
je 0xf10c
movq %r13, %rdi
callq 0x78e4
movslq 0x108(%r14), %rax
movq (%r14), %rcx
leaq (%rax,%rax,2), %rax
movq -0x18(%rcx,%rax,8), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rbx
movq (%rbx,%rbp), %rdi
testq %rdi, %rdi
je 0xf148
leaq 0x16c28(%rip), %rsi     # 0x25d60
leaq 0x16359(%rip), %rdx     # 0x25498
xorl %ecx, %ecx
callq 0x5240
jmp 0xf14a
xorl %eax, %eax
testq %rax, %rax
je 0xf176
addq %rbp, %rbx
movq %rax, 0x20(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0xf184
movq 0x16e54(%rip), %rcx     # 0x25fc0
cmpb $0x0, (%rcx)
je 0xf180
incl 0x8(%rax)
jmp 0xf184
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
jmp 0xf184
lock
incl 0x8(%rax)
leaq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xca46
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xf1a2
callq 0x78e4
leal 0x1(%r15), %eax
movslq 0x108(%r14), %rcx
movq (%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movq -0x18(%rdx,%rcx,8), %rcx
movq 0x18(%rsp), %rdx
movq (%rcx,%rdx,8), %r13
movq 0x8(%rcx,%rdx,8), %rcx
subq %r13, %rcx
shrq $0x4, %rcx
cmpl %ecx, %eax
jge 0xf29d
movq %r15, 0x8(%rsp)
movq %r12, %r15
movslq %eax, %r12
shlq $0x4, %r12
movq (%r13,%r12), %rdi
testq %rdi, %rdi
je 0xf209
leaq 0x16b6a(%rip), %rsi     # 0x25d60
leaq 0x1629b(%rip), %rdx     # 0x25498
xorl %ecx, %ecx
callq 0x5240
movq %rax, %rbx
jmp 0xf20b
xorl %ebx, %ebx
testq %rbx, %rbx
je 0xf235
addq %r12, %r13
movq 0x8(%r13), %r13
testq %r13, %r13
je 0xf23a
movq 0x16d9d(%rip), %rax     # 0x25fc0
cmpb $0x0, (%rax)
movq %r15, %r12
je 0xf32e
incl 0x8(%r13)
jmp 0xf23d
xorl %ebx, %ebx
xorl %r13d, %r13d
movq %r15, %r12
movq 0x8(%rsp), %r15
testq %rbx, %rbx
je 0xf290
movq %rbx, %rdi
callq 0x1ad92
cmpb $0x2e, %al
jne 0xf290
movq %rbx, %rdi
callq 0x1af18
testl %eax, %eax
jns 0xf290
movq %rbx, %rdi
callq 0x1ad96
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x1ad96
shrq $0x20, %rax
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movl %eax, %edx
movl 0x4(%rsp), %ecx
movq 0x10(%rsp), %r8
callq 0xf064
testq %r13, %r13
je 0xf29d
movq %r13, %rdi
callq 0x78e4
movq %r12, 0x8(%rsp)
leal 0x1(%r12), %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 0xf394
cltq
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %r12
movq (%r12,%rbp), %rdi
testq %rdi, %rdi
je 0xf301
leaq 0x16a72(%rip), %rsi     # 0x25d60
leaq 0x161a3(%rip), %rdx     # 0x25498
xorl %ecx, %ecx
callq 0x5240
movq %rax, %rbx
jmp 0xf303
xorl %ebx, %ebx
testq %rbx, %rbx
je 0xf327
addq %rbp, %r12
movq 0x8(%r12), %r13
testq %r13, %r13
je 0xf33d
movq 0x16ca4(%rip), %rax     # 0x25fc0
cmpb $0x0, (%rax)
je 0xf338
incl 0x8(%r13)
jmp 0xf33d
xorl %ebx, %ebx
xorl %r13d, %r13d
jmp 0xf33d
lock
incl 0x8(%r13)
jmp 0xf23d
lock
incl 0x8(%r13)
testq %rbx, %rbx
je 0xf387
movq %rbx, %rdi
callq 0x1ad92
cmpb $0x2e, %al
jne 0xf387
movq %rbx, %rdi
callq 0x1af18
testl %eax, %eax
jns 0xf387
movq %rbx, %rdi
callq 0x1ad96
movq %rax, %r12
movq %rbx, %rdi
callq 0x1ad96
shrq $0x20, %rax
movq %r14, %rdi
movl %r12d, %esi
movl %eax, %edx
movl 0x4(%rsp), %ecx
movq 0x10(%rsp), %r8
callq 0xf064
testq %r13, %r13
je 0xf394
movq %r13, %rdi
callq 0x78e4
testl %r15d, %r15d
jle 0xf471
movslq 0x108(%r14), %rax
movq (%r14), %rcx
leaq (%rax,%rax,2), %rax
movq -0x18(%rcx,%rax,8), %rax
movq %r15, %rcx
movq 0x18(%rsp), %rdx
movq (%rax,%rdx,8), %r15
movl %ecx, %r12d
shlq $0x4, %r12
movq -0x10(%r15,%r12), %rdi
testq %rdi, %rdi
je 0xf3e7
leaq 0x1698c(%rip), %rsi     # 0x25d60
leaq 0x160bd(%rip), %rdx     # 0x25498
xorl %ecx, %ecx
callq 0x5240
movq %rax, %rbx
jmp 0xf3e9
xorl %ebx, %ebx
testq %rbx, %rbx
je 0xf40d
addq %r12, %r15
movq -0x8(%r15), %r12
testq %r12, %r12
je 0xf41a
movq 0x16bbf(%rip), %rax     # 0x25fc0
cmpb $0x0, (%rax)
je 0xf414
incl 0x8(%r12)
jmp 0xf41a
xorl %ebx, %ebx
xorl %r12d, %r12d
jmp 0xf41a
lock
incl 0x8(%r12)
testq %rbx, %rbx
je 0xf464
movq %rbx, %rdi
callq 0x1ad92
cmpb $0x2e, %al
jne 0xf464
movq %rbx, %rdi
callq 0x1af18
testl %eax, %eax
jns 0xf464
movq %rbx, %rdi
callq 0x1ad96
movq %rax, %r13
movq %rbx, %rdi
callq 0x1ad96
shrq $0x20, %rax
movq %r14, %rdi
movl %r13d, %esi
movl %eax, %edx
movl 0x4(%rsp), %ecx
movq 0x10(%rsp), %r8
callq 0xf064
testq %r12, %r12
je 0xf471
movq %r12, %rdi
callq 0x78e4
movq 0x8(%rsp), %rdx
testl %edx, %edx
jle 0xf547
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 0xf4bf
leaq 0x168b4(%rip), %rsi     # 0x25d60
leaq 0x15fe5(%rip), %rdx     # 0x25498
xorl %ecx, %ecx
callq 0x5240
movq %rax, %rbx
jmp 0xf4c1
xorl %ebx, %ebx
testq %rbx, %rbx
je 0xf4e4
addq %rbp, %r15
movq 0x8(%r15), %r15
testq %r15, %r15
je 0xf4f0
movq 0x16ae7(%rip), %rax     # 0x25fc0
cmpb $0x0, (%rax)
je 0xf4eb
incl 0x8(%r15)
jmp 0xf4f0
xorl %ebx, %ebx
xorl %r15d, %r15d
jmp 0xf4f0
lock
incl 0x8(%r15)
testq %rbx, %rbx
je 0xf53a
movq %rbx, %rdi
callq 0x1ad92
cmpb $0x2e, %al
jne 0xf53a
movq %rbx, %rdi
callq 0x1af18
testl %eax, %eax
jns 0xf53a
movq %rbx, %rdi
callq 0x1ad96
movq %rax, %r12
movq %rbx, %rdi
callq 0x1ad96
shrq $0x20, %rax
movq %r14, %rdi
movl %r12d, %esi
movl %eax, %edx
movl 0x4(%rsp), %ecx
movq 0x10(%rsp), %r8
callq 0xf064
testq %r15, %r15
je 0xf547
movq %r15, %rdi
callq 0x78e4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf593
jmp 0xf593
jmp 0xf56a
jmp 0xf577
jmp 0xf593
jmp 0xf593
jmp 0xf56a
jmp 0xf577
jmp 0xf593
jmp 0xf593
movq %rax, %rbx
testq %r15, %r15
je 0xf5a3
movq %r15, %rdi
jmp 0xf59e
movq %rax, %rbx
testq %r12, %r12
je 0xf5a3
movq %r12, %rdi
jmp 0xf59e
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
jne 0xf59e
jmp 0xf5a3
movq %rax, %rbx
testq %r13, %r13
je 0xf5a3
movq %r13, %rdi
callq 0x78e4
movq %rbx, %rdi
callq 0x5390
nop