// File: MatthewZMD[P]TetrisDual/concreteboard.cc
// Function: ConcreteBoard::rotate(bool, int)
void ConcreteBoard::rotate(bool isClockwise, int time){
    int rmLength = 0;
    int newRow = 0;
    int newCol = 0;
    bool exist = false;
    while (time != 0) {
        if (isClockwise){
            for (auto &i : thisBlock->cells){
                if (rmLength < i->pos.col - thisBlock->btmLft.col){
                    rmLength = i->pos.col - thisBlock->btmLft.col;
                }
            }
            for (auto &i : thisBlock->cells){
                newRow = thisBlock->btmLft.row + i->pos.col - thisBlock->btmLft.col - rmLength;
                newCol = thisBlock->btmLft.col + thisBlock->btmLft.row - i->pos.row;
                for (auto &j : thisBlock->cells) {
                    if (newRow == j->pos.row && newCol == j->pos.col) {
                        exist = true;
                    }
                }
                if (!exist) {
                    if (newCol > 10 || !allCells[newRow][newCol].isEmpty()) {
                        return;
                    }
                }
                exist = false;
            }
            CellType curType = thisBlock->cells[0]->type;
            int curLevel = thisBlock->cells[0]->blockLevel;
            std::vector<Cell*> temp;
            for (auto &i : thisBlock->cells){
                temp.emplace_back(&(allCells[thisBlock->btmLft.row + i->pos.col - thisBlock->btmLft.col - rmLength][thisBlock->btmLft.col + thisBlock->btmLft.row - i->pos.row]));
                i->restore();
            }
            thisBlock = std::make_shared<Block>(curType, curLevel, temp);
            thisBlock->recaliBtmLft();
        } else {
            for (auto &i : thisBlock->cells){
                if (rmLength < thisBlock->btmLft.row - i->pos.row){
                    rmLength = thisBlock->btmLft.row - i->pos.row;
                }
            }
            for (auto &i : thisBlock->cells){
                newRow = thisBlock->btmLft.row - i->pos.col + thisBlock->btmLft.col;
                newCol = thisBlock->btmLft.col - thisBlock->btmLft.row + i->pos.row + rmLength;
                for (auto &j : thisBlock->cells) {
                    if (newRow == j->pos.row && newCol == j->pos.col) {
                        exist = true;
                    }
                }
                if (!exist) {
                    if (newCol > 10 || !allCells[newRow][newCol].isEmpty()) {
                        return;
                    }
                }
                exist = false;
            }
            CellType curType = thisBlock->cells[0]->type;
            int curLevel = thisBlock->cells[0]->blockLevel;
            std::vector<Cell*> temp;
            for (auto &i : thisBlock->cells){
                temp.emplace_back(&(allCells[thisBlock->btmLft.row - i->pos.col + thisBlock->btmLft.col][thisBlock->btmLft.col - thisBlock->btmLft.row + i->pos.row + rmLength]));
                i->restore();
            }
            thisBlock = std::make_shared<Block>(curType, curLevel, temp);
            thisBlock->recaliBtmLft();
        }
        --time;
    }
    if (level->heavyOffset()) {
	    down(1);
    }
    notifyObservers();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movb $0x0, -0x1d(%rbp)
cmpl $0x0, -0x10(%rbp)
je 0x120cd
testb $0x1, -0x9(%rbp)
je 0x11b9c
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0xd190
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0xd1c0
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0x11706
jmp 0x11791
leaq -0x30(%rbp), %rdi
callq 0xd230
movq -0x1a8(%rbp), %rdi
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1ac(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x1b0(%rbp)
addq $0x48, %rdi
callq 0x13e70
movl -0x1b0(%rbp), %ecx
movq %rax, %rdx
movl -0x1ac(%rbp), %eax
subl 0x1c(%rdx), %ecx
cmpl %ecx, %eax
jge 0x11781
movq -0x1a8(%rbp), %rdi
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x1b4(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq %rax, %rcx
movl -0x1b4(%rbp), %eax
subl 0x1c(%rcx), %eax
movl %eax, -0x14(%rbp)
jmp 0x11783
leaq -0x30(%rbp), %rdi
callq 0xd2d0
jmp 0x116f0
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0xd190
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0xd1c0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0x117d5
jmp 0x11937
leaq -0x50(%rbp), %rdi
callq 0xd230
movq -0x1a8(%rbp), %rdi
movq %rax, -0x60(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq -0x1a8(%rbp), %rdi
movl 0x18(%rax), %eax
movq -0x60(%rbp), %rcx
movq (%rcx), %rcx
addl 0x5c(%rcx), %eax
movl %eax, -0x1bc(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl -0x1bc(%rbp), %eax
subl 0x1c(%rcx), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq -0x1a8(%rbp), %rdi
movl 0x1c(%rax), %eax
movl %eax, -0x1b8(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl -0x1b8(%rbp), %eax
addl 0x18(%rcx), %eax
movq -0x60(%rbp), %rcx
movq (%rcx), %rcx
subl 0x58(%rcx), %eax
movl %eax, -0x1c(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0xd190
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0xd1c0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0x118aa
jmp 0x118e6
leaq -0x70(%rbp), %rdi
callq 0xd230
movq %rax, -0x80(%rbp)
movl -0x18(%rbp), %eax
movq -0x80(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x58(%rcx), %eax
jne 0x118d9
movl -0x1c(%rbp), %eax
movq -0x80(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x5c(%rcx), %eax
jne 0x118d9
movb $0x1, -0x1d(%rbp)
jmp 0x118db
leaq -0x70(%rbp), %rdi
callq 0xd2d0
jmp 0x11897
testb $0x1, -0x1d(%rbp)
jne 0x11925
cmpl $0xa, -0x1c(%rbp)
jg 0x1191e
movq -0x1a8(%rbp), %rdi
addq $0x78, %rdi
movslq -0x18(%rbp), %rsi
callq 0x13d50
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x13d70
movq %rax, %rdi
callq 0xffc0
testb $0x1, %al
jne 0x11923
jmp 0x12109
jmp 0x11925
movb $0x0, -0x1d(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xd2d0
jmp 0x117bf
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xd480
movq -0x1a8(%rbp), %rdi
movq (%rax), %rax
movl 0x64(%rax), %eax
movl %eax, -0x84(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xd480
movq (%rax), %rax
movl 0x60(%rax), %eax
movl %eax, -0x88(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xd170
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
callq 0xd190
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdi
callq 0xd1c0
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0x119ec
jmp 0x11b21
leaq -0xb0(%rbp), %rdi
callq 0xd230
movq -0x1a8(%rbp), %rdi
movq %rax, -0xc0(%rbp)
movq %rdi, %rax
addq $0x78, %rax
movq %rax, -0x1e0(%rbp)
addq $0x48, %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x13e70
movq -0x1d0(%rbp), %rdi
movl 0x18(%rax), %eax
movq -0xc0(%rbp), %rcx
movq (%rcx), %rcx
movl 0x5c(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x1d4(%rbp)
callq 0x13e70
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movl -0x1d4(%rbp), %eax
movl 0x1c(%rcx), %ecx
subl %ecx, %eax
movl -0x14(%rbp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
callq 0x13d50
movq -0x1d0(%rbp), %rdi
movq %rax, -0x1c8(%rbp)
callq 0x13e70
movq -0x1d0(%rbp), %rdi
movl 0x1c(%rax), %eax
movl %eax, -0x1c0(%rbp)
callq 0x13e70
movq -0x1c8(%rbp), %rdi
movq %rax, %rcx
movl -0x1c0(%rbp), %eax
movl 0x18(%rcx), %ecx
addl %ecx, %eax
movq -0xc0(%rbp), %rcx
movq (%rcx), %rcx
movl 0x58(%rcx), %ecx
subl %ecx, %eax
movslq %eax, %rsi
callq 0x13d70
movq %rax, -0xc8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x13e90
jmp 0x11ada
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
callq 0xfce0
jmp 0x11aeb
jmp 0x11aed
leaq -0xb0(%rbp), %rdi
callq 0xd2d0
jmp 0x119d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xd2f0
jmp 0x12112
leaq -0xe8(%rbp), %rdi
leaq -0x84(%rbp), %rsi
leaq -0x88(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x13f10
jmp 0x11b44
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x1e8(%rbp)
leaq -0xe8(%rbp), %rsi
movq %rsi, -0x1f0(%rbp)
callq 0x13f90
movq -0x1f0(%rbp), %rdi
callq 0x13e50
movq -0x1e8(%rbp), %rdi
callq 0x13e70
movq %rax, %rdi
callq 0xcd40
jmp 0x11b8b
leaq -0xa0(%rbp), %rdi
callq 0xd2f0
jmp 0x120bf
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
callq 0xd190
movq %rax, -0xf8(%rbp)
movq -0xf0(%rbp), %rdi
callq 0xd1c0
movq %rax, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0x11bf2
jmp 0x11c71
leaq -0xf8(%rbp), %rdi
callq 0xd230
movq -0x1a8(%rbp), %rdi
movq %rax, -0x108(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1f4(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq %rax, %rcx
movl -0x1f4(%rbp), %eax
movl 0x18(%rcx), %ecx
movq -0x108(%rbp), %rdx
movq (%rdx), %rdx
subl 0x58(%rdx), %ecx
cmpl %ecx, %eax
jge 0x11c5e
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movl 0x18(%rax), %eax
movq -0x108(%rbp), %rcx
movq (%rcx), %rcx
subl 0x58(%rcx), %eax
movl %eax, -0x14(%rbp)
jmp 0x11c60
leaq -0xf8(%rbp), %rdi
callq 0xd2d0
jmp 0x11bd9
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rdi
callq 0xd190
movq %rax, -0x118(%rbp)
movq -0x110(%rbp), %rdi
callq 0xd1c0
movq %rax, -0x120(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0x11cca
jmp 0x11e5f
leaq -0x118(%rbp), %rdi
callq 0xd230
movq -0x1a8(%rbp), %rdi
movq %rax, -0x128(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq -0x1a8(%rbp), %rdi
movl 0x18(%rax), %eax
movq -0x128(%rbp), %rcx
movq (%rcx), %rcx
subl 0x5c(%rcx), %eax
movl %eax, -0x1fc(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl -0x1fc(%rbp), %eax
addl 0x1c(%rcx), %eax
movl %eax, -0x18(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq -0x1a8(%rbp), %rdi
movl 0x1c(%rax), %eax
movl %eax, -0x1f8(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl -0x1f8(%rbp), %eax
subl 0x18(%rcx), %eax
movq -0x128(%rbp), %rcx
movq (%rcx), %rcx
addl 0x58(%rcx), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rdi
callq 0xd190
movq %rax, -0x138(%rbp)
movq -0x130(%rbp), %rdi
callq 0xd1c0
movq %rax, -0x140(%rbp)
leaq -0x138(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0x11dc0
jmp 0x11e0b
leaq -0x138(%rbp), %rdi
callq 0xd230
movq %rax, -0x148(%rbp)
movl -0x18(%rbp), %eax
movq -0x148(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x58(%rcx), %eax
jne 0x11dfb
movl -0x1c(%rbp), %eax
movq -0x148(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x5c(%rcx), %eax
jne 0x11dfb
movb $0x1, -0x1d(%rbp)
jmp 0x11dfd
leaq -0x138(%rbp), %rdi
callq 0xd2d0
jmp 0x11da7
testb $0x1, -0x1d(%rbp)
jne 0x11e4a
cmpl $0xa, -0x1c(%rbp)
jg 0x11e43
movq -0x1a8(%rbp), %rdi
addq $0x78, %rdi
movslq -0x18(%rbp), %rsi
callq 0x13d50
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x13d70
movq %rax, %rdi
callq 0xffc0
testb $0x1, %al
jne 0x11e48
jmp 0x12109
jmp 0x11e4a
movb $0x0, -0x1d(%rbp)
leaq -0x118(%rbp), %rdi
callq 0xd2d0
jmp 0x11cae
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xd480
movq -0x1a8(%rbp), %rdi
movq (%rax), %rax
movl 0x64(%rax), %eax
movl %eax, -0x14c(%rbp)
addq $0x48, %rdi
callq 0x13e70
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xd480
movq (%rax), %rax
movl 0x60(%rax), %eax
movl %eax, -0x150(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xd170
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
callq 0x13e70
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rdi
callq 0xd190
movq %rax, -0x178(%rbp)
movq -0x170(%rbp), %rdi
callq 0xd1c0
movq %rax, -0x180(%rbp)
leaq -0x178(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0x11f14
jmp 0x12049
leaq -0x178(%rbp), %rdi
callq 0xd230
movq -0x1a8(%rbp), %rdi
movq %rax, -0x188(%rbp)
movq %rdi, %rax
addq $0x78, %rax
movq %rax, -0x220(%rbp)
addq $0x48, %rdi
movq %rdi, -0x210(%rbp)
callq 0x13e70
movq -0x210(%rbp), %rdi
movl 0x18(%rax), %eax
movq -0x188(%rbp), %rcx
movq (%rcx), %rcx
movl 0x5c(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x214(%rbp)
callq 0x13e70
movq -0x220(%rbp), %rdi
movq %rax, %rcx
movl -0x214(%rbp), %eax
movl 0x1c(%rcx), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x13d50
movq -0x210(%rbp), %rdi
movq %rax, -0x208(%rbp)
callq 0x13e70
movq -0x210(%rbp), %rdi
movl 0x1c(%rax), %eax
movl %eax, -0x200(%rbp)
callq 0x13e70
movq -0x208(%rbp), %rdi
movq %rax, %rcx
movl -0x200(%rbp), %eax
movl 0x18(%rcx), %ecx
subl %ecx, %eax
movq -0x188(%rbp), %rcx
movq (%rcx), %rcx
movl 0x58(%rcx), %ecx
addl %ecx, %eax
movl -0x14(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x13d70
movq %rax, -0x190(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x13e90
jmp 0x12002
movq -0x188(%rbp), %rax
movq (%rax), %rdi
callq 0xfce0
jmp 0x12013
jmp 0x12015
leaq -0x178(%rbp), %rdi
callq 0xd2d0
jmp 0x11ef8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xd2f0
jmp 0x12112
leaq -0x1a0(%rbp), %rdi
leaq -0x14c(%rbp), %rsi
leaq -0x150(%rbp), %rdx
leaq -0x168(%rbp), %rcx
callq 0x13f10
jmp 0x1206c
movq -0x1a8(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x228(%rbp)
leaq -0x1a0(%rbp), %rsi
movq %rsi, -0x230(%rbp)
callq 0x13f90
movq -0x230(%rbp), %rdi
callq 0x13e50
movq -0x228(%rbp), %rdi
callq 0x13e70
movq %rax, %rdi
callq 0xcd40
jmp 0x120b3
leaq -0x168(%rbp), %rdi
callq 0xd2f0
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x116ae
movq -0x1a8(%rbp), %rdi
addq $0x60, %rdi
callq 0x13b10
movq %rax, %rdi
movq (%rdi), %rax
callq *0x18(%rax)
cmpl $0x0, %eax
je 0x120fd
movq -0x1a8(%rbp), %rdi
movq (%rdi), %rax
movl $0x1, %esi
callq *0x20(%rax)
movq -0x1a8(%rbp), %rdi
callq 0x25430
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x6630
nop