// File: /workspace/github_cpp_makefile_star2_O3/kaiming[P]Chamber-Crawler-3k/Board/board.cc
// Function: Board::Board(std::vector<std::vector<std::vector<std::shared_ptr<Tile>, std::allocator<std::shared_ptr<Tile>>>, std::allocator<std::vector<std::shared_ptr<Tile>, std::allocator<std::shared_ptr<Tile>>>>>, std::allocator<std::vector<std::vector<std::shared_ptr<Tile>, std::allocator<std::shared_ptr<Tile>>>, std::allocator<std::vector<std::shared_ptr<Tile>, std::allocator<std::shared_ptr<Tile>>>>>>>, std::vector<bool, std::allocator<bool>>, std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>, std::vector<std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>, std::allocator<std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>>>, std::vector<std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>, std::allocator<std::vector<std::shared_ptr<WalkableTile>, std::allocator<std::shared_ptr<WalkableTile>>>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, bool, int)
Board::Board(
        std::vector<std::vector<std::vector<std::shared_ptr<Tile>>>> floors, 
        std::vector<bool> filled, 
        std::vector<std::shared_ptr<WalkableTile>> playerSpawns,
        std::vector<std::vector<std::shared_ptr<WalkableTile>>> enemies,
        std::vector<std::vector<std::shared_ptr<WalkableTile>>> dragonHoards,
        std::string race,
        int seed,
        bool enemyTracking,
        int radius
) : floors{floors}, filled{filled}, playerSpawns{playerSpawns}, enemies{enemies}, dragonHoards{dragonHoards}, enemyTracking{enemyTracking}, radius{radius}, player{static_cast<int>(playerSpawns.size()) > 0 ? playerSpawns[0] : nullptr}, floorNum{1} {

    // Set seed
    if (seed != -1) {
        std::srand(seed);
    }

    // Generate Player by given Race
    if (race == "s") {
        playerPtr = std::make_shared<Shade>();
        defaultAtk = 25;
        defaultDef = 25;
    } else if (race == "d") {
        playerPtr = std::make_shared<Drow>();
        defaultAtk = 25;
        defaultDef = 15;
    } else if (race == "v") {
        playerPtr = std::make_shared<Vampire>();
        defaultAtk = 25;
        defaultDef = 25;
    } else if (race == "g") {
        playerPtr = std::make_shared<Goblin>();
        defaultAtk = 15;
        defaultDef = 20;
    } else if (race == "t") {
        playerPtr = std::make_shared<Troll>();
        defaultAtk = 25;
        defaultDef = 15;
    }

    this->race = playerPtr->getRace(); 

    // First need to identify which tiles are a part of which chamber
    assignChambers();
    
    // If not filled, generate floor pieces
    if (!filled[floorNum - 1]) {
        generateFloor();
    } else {
        // If generated, store player into given tile
        player->setOccupant(playerPtr);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %rbp
movq %r8, %r13
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, %rbx
callq 0x738a
leaq 0x18(%rbx), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x7424
leaq 0x40(%rbx), %rdi
movq %rdi, 0x48(%rsp)
movq %r15, %rsi
movq %r12, 0x50(%rsp)
callq 0x74b6
leaq 0x58(%rbx), %rdi
movq %rdi, 0x40(%rsp)
movq %r13, %rsi
callq 0x7554
leaq 0x70(%rbx), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x7554
movl 0xa8(%rsp), %eax
movl 0x98(%rsp), %edi
movb 0xa0(%rsp), %cl
leaq 0x98(%rbx), %r12
movq %r12, 0x88(%rbx)
movq $0x0, 0x90(%rbx)
movb $0x0, 0x98(%rbx)
movb %cl, 0xa8(%rbx)
movl %eax, 0xac(%rbx)
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
testl %ecx, %ecx
jle 0xd18d
movq (%rax), %rcx
movq %rcx, 0xb8(%rbx)
movq 0x8(%rax), %rax
movq %rax, 0xc0(%rbx)
testq %rax, %rax
je 0xd1a0
movq 0x17e3d(%rip), %rcx     # 0x24fc0
cmpb $0x0, (%rcx)
je 0xd19c
incl 0x8(%rax)
jmp 0xd1a0
leaq 0xb8(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
jmp 0xd1a0
lock
incl 0x8(%rax)
movq 0x90(%rsp), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0xf8(%rbx)
movups %xmm0, 0xe8(%rbx)
movups %xmm0, 0xd8(%rbx)
movups %xmm0, 0xc8(%rbx)
movl $0x1, 0x108(%rbx)
movw $0x0, 0x10c(%rbx)
cmpl $-0x1, %edi
je 0xd1e4
callq 0x51c0
leaq 0x88(%rbx), %rbp
leaq 0xe0fd(%rip), %rsi      # 0x1b2ef
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0xd278
leaq 0xdf64(%rip), %rsi      # 0x1b169
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0xd296
leaq 0xe09f(%rip), %rsi      # 0x1b2bb
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0xd2f0
leaq 0xeebc(%rip), %rsi      # 0x1c0ef
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0xd440
leaq 0xebd4(%rip), %rsi      # 0x1be1e
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
jne 0xd34e
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x16096
jmp 0xd2b2
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0xcfe4
jmp 0xd30c
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x15e4a
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x100(%rbx), %rdi
movups %xmm0, 0xf8(%rbx)
testq %rdi, %rdi
je 0xd2e6
callq 0x7828
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xd2e6
callq 0x7828
movsd 0xe9a2(%rip), %xmm0     # 0x1bc90
jmp 0xd347
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x15f0e
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x100(%rbx), %rdi
movups %xmm0, 0xf8(%rbx)
testq %rdi, %rdi
je 0xd340
callq 0x7828
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xd340
callq 0x7828
movaps 0xe969(%rip), %xmm0     # 0x1bcb0
movlps %xmm0, 0xb0(%rbx)
movq 0xf8(%rbx), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *(%rax)
leaq 0x10(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rsi
callq 0x5270
movq (%r15), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xd389
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x51f0
movq %rbx, %rdi
callq 0xd582
movslq 0x108(%rbx), %rax
decq %rax
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq (%r14), %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
leaq 0x3f(%rdx), %rsi
andq %rax, %rsi
xorl %edi, %edi
cmpq %rdx, %rsi
setbe %dil
movq -0x8(%rcx,%rdi,8), %rcx
btq %rax, %rcx
jae 0xd40a
movq 0xb8(%rbx), %rdi
movq 0xf8(%rbx), %rax
movq %rax, 0x30(%rsp)
movq 0x100(%rbx), %rax
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0xd418
movq 0x17bc0(%rip), %rcx     # 0x24fc0
cmpb $0x0, (%rcx)
je 0xd414
incl 0x8(%rax)
jmp 0xd418
movq %rbx, %rdi
callq 0xd77e
jmp 0xd431
lock
incl 0x8(%rax)
leaq 0x30(%rsp), %rsi
callq 0x1a9ba
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xd431
callq 0x7828
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x15fd2
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x100(%rbx), %rdi
movups %xmm0, 0xf8(%rbx)
testq %rdi, %rdi
je 0xd490
callq 0x7828
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xd490
callq 0x7828
movsd 0xe808(%rip), %xmm0     # 0x1bca0
jmp 0xd347
jmp 0xd4e7
jmp 0xd4e7
jmp 0xd4e7
jmp 0xd4e7
jmp 0xd4e7
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xd4ec
callq 0x7828
jmp 0xd4ec
jmp 0xd4e7
movq %rax, 0x8(%rsp)
jmp 0xd549
movq %rax, 0x8(%rsp)
jmp 0xd553
movq %rax, 0x8(%rsp)
jmp 0xd55d
movq %rax, 0x8(%rsp)
jmp 0xd567
movq %rax, 0x8(%rsp)
leaq 0xc8(%rbx), %r15
leaq 0xe0(%rbx), %r14
movq 0x100(%rbx), %rdi
testq %rdi, %rdi
je 0xd50b
callq 0x7828
movq %r14, %rdi
callq 0x75ee
movq %r15, %rdi
callq 0x77ca
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0xd52c
callq 0x7828
movq (%rbp), %rdi
cmpq %r12, %rdi
je 0xd541
movq (%r12), %rsi
incq %rsi
callq 0x51f0
movq %r13, %rdi
callq 0x75ee
movq 0x40(%rsp), %rdi
callq 0x75ee
movq 0x48(%rsp), %rdi
callq 0x7636
movq 0x50(%rsp), %rdi
callq 0x79c4
movq %rbx, %rdi
callq 0x7684
movq 0x8(%rsp), %rdi
callq 0x5380
movq %rax, %rdi
callq 0x72b9
nop