// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movl %esi, 0x50(%rsp)
movq %rdi, %rbx
testl %edx, %edx
je 0x95ba
xorl %r15d, %r15d
leaq 0x30(%rsp), %r12
movl $0x1, %r14d
movq 0x48(%rbx), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r13
cmpb $0x0, 0x50(%rsp)
movl %edx, 0x54(%rsp)
je 0x9386
cmpq %r13, %rbp
je 0x92f5
movl 0x1c(%rax), %eax
movq %rbp, %rcx
movl %r15d, %edx
movq (%rcx), %rsi
movl 0x5c(%rsi), %r15d
subl %eax, %r15d
cmpl %r15d, %edx
cmovgl %edx, %r15d
addq $0x8, %rcx
cmpq %r13, %rcx
jne 0x9246
jmp 0x92ec
movq 0x48(%rbx), %rsi
movl 0x18(%rsi), %edx
movq (%rbp), %rdi
movl 0x1c(%rsi), %eax
movl 0x5c(%rdi), %ecx
addl %edx, %ecx
leal (%r15,%rax), %r8d
addl %edx, %eax
subl 0x58(%rdi), %eax
subl %r8d, %ecx
movq (%rsi), %rdx
movq 0x8(%rsi), %rsi
cmpq %rsi, %rdx
je 0x92b9
xorl %edi, %edi
movq (%rdx), %r8
cmpl 0x58(%r8), %ecx
jne 0x92aa
cmpl 0x5c(%r8), %eax
movzbl %dil, %edi
cmovel %r14d, %edi
addq $0x8, %rdx
cmpq %rsi, %rdx
jne 0x9295
testb $0x1, %dil
jne 0x92e8
cmpl $0xa, %eax
jg 0x95de
movslq %ecx, %rcx
movq 0x78(%rbx), %rdx
leaq (%rcx,%rcx,2), %rcx
cltq
leaq (%rax,%rax,8), %rdi
shlq $0x4, %rdi
addq (%rdx,%rcx,8), %rdi
callq 0x8760
testb %al, %al
je 0x95de
addq $0x8, %rbp
cmpq %r13, %rbp
jne 0x9268
movq 0x48(%rbx), %rax
movq (%rax), %rcx
movq (%rcx), %rcx
movl 0x64(%rcx), %edx
movl %edx, 0x2c(%rsp)
movl 0x60(%rcx), %ecx
movl %ecx, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq (%rax), %r13
movq 0x8(%rax), %rbp
cmpq %rbp, %r13
je 0x94d3
movq (%r13), %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 %r15d, %edi
subl %ecx, %edi
movslq %edi, %rdi
leaq (%rdi,%rdi,2), %rdi
addl %esi, %ecx
subl 0x58(%rax), %ecx
movslq %ecx, %rax
leaq (%rax,%rax,8), %rax
shlq $0x4, %rax
addq (%rdx,%rdi,8), %rax
movq %rax, 0x10(%rsp)
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0xaca0
movq (%r13), %rdi
callq 0x85bc
addq $0x8, %r13
jmp 0x9325
cmpq %r13, %rbp
je 0x9442
movl 0x18(%rax), %eax
movq %rbp, %rcx
movl %r15d, %edx
movq (%rcx), %rsi
movl %eax, %r15d
subl 0x58(%rsi), %r15d
cmpl %r15d, %edx
cmovgl %edx, %r15d
addq $0x8, %rcx
cmpq %r13, %rcx
jne 0x9395
jmp 0x9439
movq 0x48(%rbx), %rsi
movl 0x18(%rsi), %ecx
movq (%rbp), %rdx
movl %r15d, %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), %rsi
cmpq %rsi, %rdx
je 0x9406
xorl %edi, %edi
movq (%rdx), %r8
cmpl 0x58(%r8), %ecx
jne 0x93f7
cmpl 0x5c(%r8), %eax
movzbl %dil, %edi
cmovel %r14d, %edi
addq $0x8, %rdx
cmpq %rsi, %rdx
jne 0x93e2
testb $0x1, %dil
jne 0x9435
cmpl $0xa, %eax
jg 0x95de
movslq %ecx, %rcx
movq 0x78(%rbx), %rdx
leaq (%rcx,%rcx,2), %rcx
cltq
leaq (%rax,%rax,8), %rdi
shlq $0x4, %rdi
addq (%rdx,%rcx,8), %rdi
callq 0x8760
testb %al, %al
je 0x95de
addq $0x8, %rbp
cmpq %r13, %rbp
jne 0x93b7
movq 0x48(%rbx), %rax
movq (%rax), %rcx
movq (%rcx), %rcx
movl 0x64(%rcx), %edx
movl %edx, 0x2c(%rsp)
movl 0x60(%rcx), %ecx
movl %ecx, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq (%rax), %r13
movq 0x8(%rax), %rbp
cmpq %rbp, %r13
je 0x9536
movq (%r13), %rax
movq 0x48(%rbx), %rcx
movq 0x78(%rbx), %rdx
movl 0x18(%rcx), %esi
movl 0x1c(%rcx), %ecx
movl %r15d, %edi
subl %esi, %edi
subl 0x5c(%rax), %esi
addl %ecx, %esi
movslq %esi, %rsi
leaq (%rsi,%rsi,2), %rsi
addl %ecx, %edi
addl 0x58(%rax), %edi
movslq %edi, %rax
leaq (%rax,%rax,8), %rax
shlq $0x4, %rax
addq (%rdx,%rsi,8), %rax
movq %rax, 0x10(%rsp)
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0xaca0
movq (%r13), %rdi
callq 0x85bc
addq $0x8, %r13
jmp 0x9472
movq $0x0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
leaq 0x28(%rsp), %r8
movq %r12, %r9
callq 0xb9d4
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x50(%rbx), %rdi
movups %xmm0, 0x48(%rbx)
testq %rdi, %rdi
je 0x952b
callq 0x5f5e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x952b
callq 0x5f5e
movq 0x48(%rbx), %rdi
callq 0x7ad0
jmp 0x9597
movq $0x0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
leaq 0x28(%rsp), %r8
movq %r12, %r9
callq 0xb9d4
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x50(%rbx), %rdi
movups %xmm0, 0x48(%rbx)
testq %rdi, %rdi
je 0x958e
callq 0x5f5e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x958e
callq 0x5f5e
movq 0x48(%rbx), %rdi
callq 0x7ad0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x95ae
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x52e0
movl 0x54(%rsp), %edx
decl %edx
jne 0x921d
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
testl %eax, %eax
je 0x95d6
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
callq *0x20(%rax)
movq %rbx, %rdi
callq 0xeb4e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x95fb
jmp 0x95fb
jmp 0x95fb
jmp 0x95fb
jmp 0x95fb
jmp 0x95fb
jmp 0x95fb
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x9615
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x52e0
movq %rbx, %rdi
callq 0x54e0
nop