// File: /workspace/github_cpp_makefile_star2_O1/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
movl %esi, 0x40(%rsp)
movq %rdi, %rbx
testl %edx, %edx
je 0x9611
xorl %eax, %eax
movl $0x1, %r9d
xorl %r14d, %r14d
cmpb $0x0, 0x40(%rsp)
movl %edx, 0x44(%rsp)
je 0x927b
movq 0x48(%rbx), %rcx
movq (%rcx), %r13
movq 0x8(%rcx), %r12
cmpq %r12, %r13
je 0x92b2
movl 0x1c(%rcx), %ecx
movq %r13, %rdx
movq (%rdx), %rsi
movl 0x5c(%rsi), %ebp
subl %ecx, %ebp
cmpl %ebp, %eax
cmovgl %eax, %ebp
addq $0x8, %rdx
movl %ebp, %eax
cmpq %r12, %rdx
jne 0x9261
jmp 0x92b4
movq 0x48(%rbx), %rcx
movq (%rcx), %r12
movq 0x8(%rcx), %r13
cmpq %r13, %r12
je 0x9450
movl 0x18(%rcx), %ecx
movq %r12, %rdx
movq (%rdx), %rsi
movl %ecx, %ebp
subl 0x58(%rsi), %ebp
cmpl %ebp, %eax
cmovgl %eax, %ebp
addq $0x8, %rdx
movl %ebp, %eax
cmpq %r13, %rdx
jne 0x9295
jmp 0x9452
movl %eax, %ebp
cmpq %r12, %r13
sete %r15b
je 0x934e
movq 0x48(%rbx), %rsi
movl 0x18(%rsi), %edx
movq (%r13), %rdi
movl 0x1c(%rsi), %eax
movl 0x5c(%rdi), %ecx
addl %edx, %ecx
leal (%rax,%rbp), %r8d
addl %edx, %eax
subl 0x58(%rdi), %eax
subl %r8d, %ecx
movq (%rsi), %rdx
movq 0x8(%rsi), %rsi
cmpq %rsi, %rdx
je 0x9305
movq (%rdx), %rdi
cmpl 0x58(%rdi), %ecx
jne 0x92ff
cmpl 0x5c(%rdi), %eax
movzbl %r14b, %r14d
cmovel %r9d, %r14d
addq $0x8, %rdx
jmp 0x92e7
testb $0x1, %r14b
je 0x9312
movb $0x1, %al
xorl %r14d, %r14d
jmp 0x9341
cmpl $0xa, %eax
jg 0x933f
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 0x8784
movl $0x1, %r9d
testb %al, %al
jne 0x930b
xorl %eax, %eax
testb %al, %al
je 0x934e
addq $0x8, %r13
jmp 0x92b4
testb $0x1, %r15b
je 0x9635
movq 0x48(%rbx), %rax
movq (%rax), %rcx
movq (%rcx), %rcx
movl 0x64(%rcx), %edx
movl %edx, 0xc(%rsp)
movl 0x60(%rcx), %ecx
movl %ecx, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq (%rax), %r15
movq 0x8(%rax), %r12
cmpq %r12, %r15
leaq 0x10(%rsp), %r13
je 0x93ea
movq (%r15), %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 %ebp, %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)
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0xadec
movq (%r15), %rdi
callq 0x85dc
addq $0x8, %r15
cmpq %r12, %r15
jne 0x9392
movq $0x0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
leaq 0x7(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0xbb34
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x50(%rbx), %rdi
movups %xmm0, 0x48(%rbx)
testq %rdi, %rdi
je 0x9433
callq 0x5f3e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x9442
callq 0x5f3e
movq 0x48(%rbx), %rdi
callq 0x7ae0
jmp 0x95e6
movl %eax, %ebp
cmpq %r13, %r12
sete %r15b
je 0x94e9
movq 0x48(%rbx), %rsi
movl 0x18(%rsi), %ecx
movq (%r12), %rdx
movl %ebp, %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 0x94a0
movq (%rdx), %rdi
cmpl 0x58(%rdi), %ecx
jne 0x949a
cmpl 0x5c(%rdi), %eax
movzbl %r14b, %r14d
cmovel %r9d, %r14d
addq $0x8, %rdx
jmp 0x9482
testb $0x1, %r14b
je 0x94ad
movb $0x1, %al
xorl %r14d, %r14d
jmp 0x94dc
cmpl $0xa, %eax
jg 0x94da
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 0x8784
movl $0x1, %r9d
testb %al, %al
jne 0x94a6
xorl %eax, %eax
testb %al, %al
je 0x94e9
addq $0x8, %r12
jmp 0x9452
testb $0x1, %r15b
je 0x9635
movq 0x48(%rbx), %rax
movq (%rax), %rcx
movq (%rcx), %rcx
movl 0x64(%rcx), %edx
movl %edx, 0xc(%rsp)
movl 0x60(%rcx), %ecx
movl %ecx, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq (%rax), %r15
movq 0x8(%rax), %r12
cmpq %r12, %r15
leaq 0x10(%rsp), %r13
je 0x9585
movq (%r15), %rax
movq 0x48(%rbx), %rcx
movq 0x78(%rbx), %rdx
movl 0x18(%rcx), %esi
movl 0x1c(%rcx), %ecx
movl %ebp, %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)
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0xadec
movq (%r15), %rdi
callq 0x85dc
addq $0x8, %r15
cmpq %r12, %r15
jne 0x952d
movq $0x0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
leaq 0x7(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0xbb34
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x50(%rbx), %rdi
movups %xmm0, 0x48(%rbx)
testq %rdi, %rdi
je 0x95ce
callq 0x5f3e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x95dd
callq 0x5f3e
movq 0x48(%rbx), %rdi
callq 0x7ae0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x95fd
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x52e0
movl %ebp, %eax
movl 0x44(%rsp), %edx
decl %edx
movl $0x1, %r9d
jne 0x9240
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
testl %eax, %eax
je 0x962d
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
callq *0x20(%rax)
movq %rbx, %rdi
callq 0xedfe
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9652
jmp 0x9652
jmp 0x9652
jmp 0x9652
jmp 0x9652
jmp 0x9652
jmp 0x9652
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x966c
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x52e0
movq %rbx, %rdi
callq 0x54e0