// File: XxAdi101xX[P]ChamberCrawler/Floor/Floor.cc
// Function: operator>>(std::istream&, Floor&)
std::istream &operator>>(std::istream &in, Floor &f) {

    f.theFloor = std::vector<std::vector<std::shared_ptr<Cell>>>();

    bool endFloor = false;

    while (!in.eof()) {
        std::string row;
        std::getline(in, row);
        if (row == "") break;

        f.theFloor.push_back(std::vector<std::shared_ptr<Cell>>());
        int horizontalWallCount = 0;
        for (auto r: row) {
            std::shared_ptr<Cell> cell = std::make_shared<Cell>();
            cell->setCoords(std::vector<int>{static_cast<int>(f.theFloor.size()) - 1, static_cast<int>(f.theFloor.back().size())});
            switch (r) {
                case '|':
                    cell->setCellType(CellType::Wall);
                    break;
                case '-':
                    horizontalWallCount++;
                    cell->setCellType(CellType::Wall);
                    break;
                case '+':
                    cell->setCellType(CellType::DoorWay);
                    break;
                case '#':
                    cell->setCellType(CellType::Passage);
                    break;
                case ' ':
                    cell->setCellType(CellType::Null);
                    break;
				case '\\':
                    cell->setCellType(CellType::Stairs);
                    break;
                default:
                    cell->setCellType(CellType::FloorTile);
                    break;
            }

            f.theFloor.back().push_back(std::move(cell));
        }

        if (horizontalWallCount == static_cast<int>(row.size()) - 2 && endFloor == false) {
            endFloor = true;
        }
        else if (horizontalWallCount == static_cast<int>(row.size()) - 2 && endFloor == true) {
            break;
        }
    }

    f.floorDimensions = std::vector<int>{static_cast<int>(f.theFloor.size()), static_cast<int>(f.theFloor[0].size())};
/*
    for (int i = 0; i < f.floorDimensions[0]; ++i) {
            std::cout << "Size: " << i << " " << f.theFloor[i].size() << endl;
            for (int j = 0; j < f.floorDimensions[1]; ++j) {
                std::cout << f.theFloor[i][j]->getCoords().size() << endl;
                std::cout << f.theFloor[i][j].use_count() << endl;
            }
    }
    */
    f.initialize();

    return in;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x61c0
leaq -0x28(%rbp), %rdi
callq 0x40610
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x40980
leaq -0x28(%rbp), %rdi
callq 0x22840
movb $0x0, -0x29(%rbp)
movq -0x8(%rbp), %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x6590
xorb $-0x1, %al
testb $0x1, %al
jne 0x400c1
jmp 0x4052e
leaq -0x50(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x6440
movq -0x130(%rbp), %rsi
movq -0x8(%rbp), %rdi
callq 0x60c0
jmp 0x400e3
leaq 0x518f(%rip), %rsi      # 0x45279
leaq -0x50(%rbp), %rdi
callq 0x409b0
movb %al, -0x131(%rbp)
jmp 0x400fb
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x40107
jmp 0x40124
movl $0x3, -0x60(%rbp)
jmp 0x40507
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x40520
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x196c0
movq -0x148(%rbp), %rdi
movq -0x140(%rbp), %rsi
callq 0x409e0
jmp 0x40163
leaq -0x80(%rbp), %rdi
callq 0x1a2f0
movl $0x0, -0x84(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x62c0
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rdi
callq 0x61e0
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x192a0
testb $0x1, %al
jne 0x401c3
jmp 0x4048b
leaq -0x98(%rbp), %rdi
callq 0x192e0
movb (%rax), %al
movb %al, -0xa1(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x40710
jmp 0x401e5
leaq -0xb8(%rbp), %rdi
callq 0x19df0
movq %rax, -0x158(%rbp)
movq -0x10(%rbp), %rdi
callq 0x40a10
decl %eax
movl %eax, -0xe8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x40a40
movq %rax, %rdi
callq 0x19ef0
movl %eax, -0xe4(%rbp)
leaq -0xe8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq $0x2, -0xd8(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x19570
movq -0x150(%rbp), %rcx
movq -0xe0(%rbp), %rsi
movq -0xd8(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0x19590
jmp 0x4026f
movq -0x158(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2c820
jmp 0x40284
leaq -0xd0(%rbp), %rdi
callq 0x19640
leaq -0xe9(%rbp), %rdi
callq 0x196a0
movsbl -0xa1(%rbp), %eax
movl %eax, -0x15c(%rbp)
subl $0x20, %eax
je 0x403ec
jmp 0x402b4
movl -0x15c(%rbp), %eax
subl $0x23, %eax
je 0x403cf
jmp 0x402c5
movl -0x15c(%rbp), %eax
subl $0x2b, %eax
je 0x403b2
jmp 0x402d6
movl -0x15c(%rbp), %eax
subl $0x2d, %eax
je 0x40387
jmp 0x402e7
movl -0x15c(%rbp), %eax
subl $0x5c, %eax
je 0x40409
jmp 0x402f8
movl -0x15c(%rbp), %eax
subl $0x7c, %eax
je 0x40359
jmp 0x40426
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x1a2f0
jmp 0x40520
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x40348
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x19640
leaq -0xe9(%rbp), %rdi
callq 0x196a0
jmp 0x4047a
leaq -0xb8(%rbp), %rdi
callq 0x19df0
movq %rax, %rdi
xorl %esi, %esi
callq 0x2c7f0
jmp 0x40371
jmp 0x40443
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4047a
movl -0x84(%rbp), %eax
incl %eax
movl %eax, -0x84(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x19df0
movq %rax, %rdi
xorl %esi, %esi
callq 0x2c7f0
jmp 0x403ad
jmp 0x40443
leaq -0xb8(%rbp), %rdi
callq 0x19df0
movq %rax, %rdi
movl $0x2, %esi
callq 0x2c7f0
jmp 0x403cd
jmp 0x40443
leaq -0xb8(%rbp), %rdi
callq 0x19df0
movq %rax, %rdi
movl $0x3, %esi
callq 0x2c7f0
jmp 0x403ea
jmp 0x40443
leaq -0xb8(%rbp), %rdi
callq 0x19df0
movq %rax, %rdi
movl $0x5, %esi
callq 0x2c7f0
jmp 0x40407
jmp 0x40443
leaq -0xb8(%rbp), %rdi
callq 0x19df0
movq %rax, %rdi
movl $0x4, %esi
callq 0x2c7f0
jmp 0x40424
jmp 0x40443
leaq -0xb8(%rbp), %rdi
callq 0x19df0
movq %rax, %rdi
movl $0x1, %esi
callq 0x2c7f0
jmp 0x40441
jmp 0x40443
movq -0x10(%rbp), %rdi
callq 0x40a40
movq %rax, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x40a80
jmp 0x4045d
leaq -0xb8(%rbp), %rdi
callq 0x199a0
leaq -0x98(%rbp), %rdi
callq 0x19300
jmp 0x401a7
leaq -0xb8(%rbp), %rdi
callq 0x199a0
jmp 0x40520
movl -0x84(%rbp), %eax
movl %eax, -0x160(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6240
movq %rax, %rcx
movl -0x160(%rbp), %eax
subl $0x2, %ecx
cmpl %ecx, %eax
jne 0x404c3
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x404c3
movb $0x1, -0x29(%rbp)
jmp 0x40500
movl -0x84(%rbp), %eax
movl %eax, -0x164(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6240
movq %rax, %rcx
movl -0x164(%rbp), %eax
subl $0x2, %ecx
cmpl %ecx, %eax
jne 0x404fe
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x404fe
movl $0x3, -0x60(%rbp)
jmp 0x40507
jmp 0x40500
movl $0x0, -0x60(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x65e8
movl -0x60(%rbp), %eax
testl %eax, %eax
je 0x4051b
jmp 0x40519
jmp 0x4052e
jmp 0x400a6
leaq -0x50(%rbp), %rdi
callq 0x65e8
jmp 0x40601
movq -0x10(%rbp), %rdi
callq 0x40a10
movl %eax, -0x120(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x40630
movq %rax, %rdi
callq 0x19ef0
movl %eax, -0x11c(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x118(%rbp)
movq $0x2, -0x110(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x19570
movq -0x170(%rbp), %rcx
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdx
leaq -0x108(%rbp), %rdi
callq 0x19590
jmp 0x405a7
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
leaq -0x108(%rbp), %rsi
callq 0x19610
leaq -0x108(%rbp), %rdi
callq 0x19640
leaq -0x121(%rbp), %rdi
callq 0x196a0
movq -0x10(%rbp), %rdi
callq 0x3ecd0
movq -0x8(%rbp), %rax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x121(%rbp), %rdi
callq 0x196a0
movq -0x58(%rbp), %rdi
callq 0x6550
nopw (%rax,%rax)