// File: /workspace/github_cpp_makefile_star2_O1/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 0x745a
leaq 0x18(%rbx), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x74f4
leaq 0x40(%rbx), %rdi
movq %rdi, 0x48(%rsp)
movq %r15, %rsi
movq %r12, 0x50(%rsp)
callq 0x7586
leaq 0x58(%rbx), %rdi
movq %rdi, 0x40(%rsp)
movq %r13, %rsi
callq 0x7624
leaq 0x70(%rbx), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x7624
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 0xd329
movq (%rax), %rcx
movq %rcx, 0xb8(%rbx)
movq 0x8(%rax), %rax
movq %rax, 0xc0(%rbx)
testq %rax, %rax
je 0xd33c
movq 0x18ca1(%rip), %rcx     # 0x25fc0
cmpb $0x0, (%rcx)
je 0xd338
incl 0x8(%rax)
jmp 0xd33c
leaq 0xb8(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
jmp 0xd33c
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 0xd380
callq 0x51d0
leaq 0x88(%rbx), %rbp
leaq 0xef61(%rip), %rsi      # 0x1c2ef
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0xd414
leaq 0xedc8(%rip), %rsi      # 0x1c169
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0xd432
leaq 0xef03(%rip), %rsi      # 0x1c2bb
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0xd48e
leaq 0xfce0(%rip), %rsi      # 0x1d0af
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0xd5e8
leaq 0xf9f8(%rip), %rsi      # 0x1cdde
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
jne 0xd4f4
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x164a4
jmp 0xd44e
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0xd17a
jmp 0xd4aa
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x16246
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x100(%rbx), %rdi
movups %xmm0, 0xf8(%rbx)
testq %rdi, %rdi
je 0xd473
callq 0x78e4
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xd482
callq 0x78e4
movl $0xf, %ecx
movl $0x19, %eax
jmp 0xd4e8
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x16310
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x100(%rbx), %rdi
movups %xmm0, 0xf8(%rbx)
testq %rdi, %rdi
je 0xd4cf
callq 0x78e4
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xd4de
callq 0x78e4
movl $0x19, %eax
movl $0x19, %ecx
movl %eax, 0xb0(%rbx)
movl %ecx, 0xb4(%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 0x5280
movq (%r15), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xd52f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x5200
movq %rbx, %rdi
callq 0xd72c
movslq 0x108(%rbx), %rax
leaq -0x1(%rax), %rcx
addq $0x3e, %rax
testq %rcx, %rcx
cmovnsq %rcx, %rax
sarq $0x6, %rax
shlq $0x3, %rax
addq (%r14), %rax
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
leaq 0x3f(%rdx), %rsi
andq %rcx, %rsi
xorl %edi, %edi
cmpq %rdx, %rsi
setbe %dil
movq -0x8(%rax,%rdi,8), %rax
btq %rcx, %rax
jae 0xd5b2
movq 0xb8(%rbx), %rdi
movq 0xf8(%rbx), %rax
movq %rax, 0x30(%rsp)
movq 0x100(%rbx), %rax
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0xd5c0
movq 0x18a18(%rip), %rcx     # 0x25fc0
cmpb $0x0, (%rcx)
je 0xd5bc
incl 0x8(%rax)
jmp 0xd5c0
movq %rbx, %rdi
callq 0xd93e
jmp 0xd5d9
lock
incl 0x8(%rax)
leaq 0x30(%rsp), %rsi
callq 0x1ae7a
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xd5d9
callq 0x78e4
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 0x163da
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x100(%rbx), %rdi
movups %xmm0, 0xf8(%rbx)
testq %rdi, %rdi
je 0xd629
callq 0x78e4
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xd638
callq 0x78e4
movl $0x14, %ecx
movl $0xf, %eax
jmp 0xd4e8
jmp 0xd691
jmp 0xd691
jmp 0xd691
jmp 0xd691
jmp 0xd691
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xd696
callq 0x78e4
jmp 0xd696
jmp 0xd691
movq %rax, 0x8(%rsp)
jmp 0xd6f3
movq %rax, 0x8(%rsp)
jmp 0xd6fd
movq %rax, 0x8(%rsp)
jmp 0xd707
movq %rax, 0x8(%rsp)
jmp 0xd711
movq %rax, 0x8(%rsp)
leaq 0xc8(%rbx), %r15
leaq 0xe0(%rbx), %r14
movq 0x100(%rbx), %rdi
testq %rdi, %rdi
je 0xd6b5
callq 0x78e4
movq %r14, %rdi
callq 0x76be
movq %r15, %rdi
callq 0x7888
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0xd6d6
callq 0x78e4
movq (%rbp), %rdi
cmpq %r12, %rdi
je 0xd6eb
movq (%r12), %rsi
incq %rsi
callq 0x5200
movq %r13, %rdi
callq 0x76be
movq 0x40(%rsp), %rdi
callq 0x76be
movq 0x48(%rsp), %rdi
callq 0x7700
movq 0x50(%rsp), %rdi
callq 0x7a6e
movq %rbx, %rdi
callq 0x7748
movq 0x8(%rsp), %rdi
callq 0x5390
movq %rax, %rdi
callq 0x7388
nop