// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x48(%rdi), %rax
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
leaq 0x38(%rsp), %r15
pushq $0x1
popq %rbp
movl %esi, 0x18(%rsp)
subl $0x1, %edx
jb 0x8bd9
movl %edx, 0x1c(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %r12
movq 0x8(%rax), %r13
movq %r12, %rcx
testb %sil, %sil
je 0x88f5
cmpq %r13, %rcx
je 0x8997
movq (%rcx), %rdx
movl 0x5c(%rdx), %edx
subl 0x1c(%rax), %edx
cmpl %edx, %r14d
cmovgl %r14d, %edx
addq $0x8, %rcx
movl %edx, %r14d
jmp 0x88d3
cmpq %r13, %rcx
je 0x8ab2
movl 0x18(%rax), %edx
movq (%rcx), %rsi
subl 0x58(%rsi), %edx
cmpl %edx, %r14d
cmovlel %edx, %r14d
addq $0x8, %rcx
jmp 0x88f5
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movl 0x18(%rsi), %edx
movq (%r12), %rdi
movl 0x1c(%rsi), %eax
movl 0x5c(%rdi), %ecx
addl %edx, %ecx
leal (%r14,%rax), %r8d
addl %edx, %eax
subl 0x58(%rdi), %eax
subl %r8d, %ecx
movq (%rsi), %rdx
movq 0x8(%rsi), %rdi
xorl %esi, %esi
cmpq %rdi, %rdx
je 0x895f
movq (%rdx), %r8
cmpl 0x58(%r8), %ecx
jne 0x8959
cmpl 0x5c(%r8), %eax
movzbl %sil, %esi
cmovel %ebp, %esi
addq $0x8, %rdx
jmp 0x8940
testb $0x1, %sil
jne 0x8993
cmpl $0xa, %eax
jg 0x8bfb
movslq %ecx, %rcx
movq 0x78(%rbx), %rdx
imulq $0x18, %rcx, %rcx
cltq
imulq $0x90, %rax, %rdi
addq (%rdx,%rcx), %rdi
callq 0x7fde
testb %al, %al
je 0x8bfb
addq $0x8, %r12
cmpq %r13, %r12
jne 0x8914
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq (%rcx), %rcx
movl 0x64(%rcx), %edx
movl %edx, 0x14(%rsp)
movl 0x60(%rcx), %ecx
andq $0x0, 0x30(%rsp)
movl %ecx, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq (%rax), %r12
movq 0x8(%rax), %r13
cmpq %r13, %r12
je 0x8b4c
movq (%r12), %rax
movq 0x48(%rbx), %rcx
movq 0x78(%rbx), %rdx
movl 0x18(%rcx), %esi
movl 0x1c(%rcx), %ecx
movl 0x5c(%rax), %edi
addl %esi, %edi
subl %r14d, %edi
subl %ecx, %edi
movslq %edi, %rdi
imulq $0x18, %rdi, %rdi
addl %esi, %ecx
subl 0x58(%rax), %ecx
movslq %ecx, %rax
imulq $0x90, %rax, %rax
addq (%rdx,%rdi), %rax
movq %rax, 0x38(%rsp)
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x999a
movq (%r12), %rdi
callq 0x7e68
addq $0x8, %r12
jmp 0x89d1
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movl 0x18(%rsi), %ecx
movq (%r12), %rdx
movl %r14d, %eax
subl %ecx, %eax
subl 0x5c(%rdx), %ecx
movl 0x1c(%rsi), %edi
addl %edi, %eax
addl 0x58(%rdx), %eax
addl %edi, %ecx
movq (%rsi), %rdx
movq 0x8(%rsi), %rdi
xorl %esi, %esi
cmpq %rdi, %rdx
je 0x8a7a
movq (%rdx), %r8
cmpl 0x58(%r8), %ecx
jne 0x8a74
cmpl 0x5c(%r8), %eax
movzbl %sil, %esi
cmovel %ebp, %esi
addq $0x8, %rdx
jmp 0x8a5b
testb $0x1, %sil
jne 0x8aae
cmpl $0xa, %eax
jg 0x8bfb
movslq %ecx, %rcx
movq 0x78(%rbx), %rdx
imulq $0x18, %rcx, %rcx
cltq
imulq $0x90, %rax, %rdi
addq (%rdx,%rcx), %rdi
callq 0x7fde
testb %al, %al
je 0x8bfb
addq $0x8, %r12
cmpq %r13, %r12
jne 0x8a31
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq (%rcx), %rcx
movl 0x64(%rcx), %edx
movl %edx, 0x14(%rsp)
movl 0x60(%rcx), %ecx
andq $0x0, 0x30(%rsp)
movl %ecx, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq (%rax), %r12
movq 0x8(%rax), %r13
cmpq %r13, %r12
je 0x8b88
movq (%r12), %rax
movq 0x48(%rbx), %rcx
movq 0x78(%rbx), %rdx
movl 0x18(%rcx), %esi
movl %r14d, %edi
subl %esi, %edi
subl 0x5c(%rax), %esi
movl 0x1c(%rcx), %ecx
addl %ecx, %esi
movslq %esi, %rsi
imulq $0x18, %rsi, %rsi
addl %ecx, %edi
addl 0x58(%rax), %edi
movslq %edi, %rax
imulq $0x90, %rax, %rax
addq (%rdx,%rsi), %rax
movq %rax, 0x38(%rsp)
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x999a
movq (%r12), %rdi
callq 0x7e68
addq $0x8, %r12
jmp 0x8aec
movq %r15, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x99d1
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xa8f4
leaq 0x40(%rsp), %rdi
callq 0x5c18
movq (%r12), %rdi
callq 0x7394
jmp 0x8bc2
movq %r15, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x99d1
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xa8f4
leaq 0x40(%rsp), %rdi
callq 0x5c18
movq (%r12), %rdi
callq 0x7394
leaq 0x20(%rsp), %rdi
callq 0x75fe
movl 0x1c(%rsp), %edx
movl 0x18(%rsp), %esi
jmp 0x88af
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
testl %eax, %eax
je 0x8bf3
movq (%rbx), %rax
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq *0x20(%rax)
movq %rbx, %rdi
callq 0xda72
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8c18
jmp 0x8c18
jmp 0x8c18
jmp 0x8c18
jmp 0x8c18
jmp 0x8c18
jmp 0x8c18
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x75fe
movq %rbx, %rdi
callq 0x54b0
nop