// File: /workspace/github_cpp_makefile_star2_O1/disjukr[P]Tetris/Console.cc
// Function: Console::Update()
void Console::Update() {
#ifdef _WIN32
    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
#endif
    int width = screen.GetWidth();
    int height = screen.GetHeight();
    for (int j = 0; j < height; ++j) {
        for (int i = 0; i < width; ++i) {
            Cell* prevCell = prevScreen.GetCell(i, j);
            Cell* cell = screen.GetCell(i, j);
            if (*prevCell == *cell) continue;
#ifdef _WIN32
            DWORD count;
            COORD cursorCoord = {(SHORT) i, (SHORT) j};
            SetConsoleCursorPosition(hStdout, cursorCoord);
#else
            cout << "\x1B[" << to_string(j + 1) << ';'
                << to_string(i + 1) << 'H';
            SetColor(cell -> foreground, cell -> background);
#endif
            cout.put(cell -> value);
#ifdef _WIN32
            FillConsoleOutputAttribute(
                hStdout,
                GetAttributes(cell -> foreground, cell -> background),
                1, cursorCoord, &count);
#else
            UnsetColor();
#endif
            prevCell -> value = cell -> value;
            prevCell -> foreground = cell -> foreground;
            prevCell -> background = cell -> background;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x4ea8(%rip), %rbx      # 0xc160
movq %rbx, %rdi
callq 0x6a6a
movl %eax, -0x30(%rbp)
movq %rbx, %rdi
callq 0x6a72
movl %eax, -0x38(%rbp)
testl %eax, %eax
jle 0x7526
leaq -0x68(%rbp), %r15
xorl %r14d, %r14d
cmpl $0x0, -0x30(%rbp)
jle 0x7519
leal 0x1(%r14), %eax
movl %eax, -0x34(%rbp)
xorl %r12d, %r12d
movq %r14, -0x80(%rbp)
leaq 0x4e84(%rip), %rdi      # 0xc180
movl %r12d, %esi
movl %r14d, %edx
callq 0x6a7c
movq %rax, %rbx
leaq 0x4e4f(%rip), %rdi      # 0xc160
movl %r12d, %esi
movl %r14d, %edx
callq 0x6a7c
movq %rax, %r13
movb (%rbx), %al
cmpb (%r13), %al
jne 0x733d
movl 0x4(%rbx), %eax
cmpl 0x4(%r13), %eax
jne 0x733d
movl 0x8(%rbx), %eax
cmpl 0x8(%r13), %eax
je 0x750c
movq %rbx, -0x88(%rbp)
movl $0x2, %edx
movq 0x4c88(%rip), %rdi      # 0xbfd8
leaq 0x1223(%rip), %rsi      # 0x857a
callq 0x3150
movl $0x1, %ebx
cmpl $0x9, %r14d
jb 0x73a9
movl $0x4, %ebx
movl -0x34(%rbp), %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x73a2
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x73a7
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x73a9
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %ebx
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x7374
addl $-0x3, %ebx
jmp 0x73a9
addl $-0x2, %ebx
jmp 0x73a9
decl %ebx
movl %ebx, %esi
movq %r15, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
movl $0x2d, %edx
callq 0x3160
movq -0x78(%rbp), %rdi
movl %ebx, %esi
movl -0x34(%rbp), %edx
callq 0x5b9c
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq 0x4bfe(%rip), %rdi      # 0xbfd8
callq 0x3150
movb $0x3b, -0x58(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x58(%rbp), %rsi
callq 0x3150
movq %rax, %r14
leal 0x1(%r12), %r15d
movl $0x1, %ebx
cmpl $0x9, %r12d
jb 0x7449
movl $0x4, %ebx
movl %r15d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x7442
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x7447
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x7449
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %ebx
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x7414
addl $-0x3, %ebx
jmp 0x7449
addl $-0x2, %ebx
jmp 0x7449
decl %ebx
movl %ebx, %esi
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
movl $0x2d, %edx
callq 0x3160
movq -0x58(%rbp), %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0x5b9c
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %r14, %rdi
callq 0x3150
movb $0x48, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3150
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x74a6
callq 0x3110
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %r15
cmpq %r15, %rdi
movq -0x80(%rbp), %r14
je 0x74bc
callq 0x3110
movl 0x4(%r13), %edi
movl 0x8(%r13), %esi
callq 0x7038
movsbl (%r13), %esi
movq 0x4b03(%rip), %rbx      # 0xbfd8
movq %rbx, %rdi
callq 0x3040
movl $0x4, %edx
movq %rbx, %rdi
leaq 0x1091(%rip), %rsi      # 0x857d
callq 0x3150
movb (%r13), %al
movq -0x88(%rbp), %rcx
movb %al, (%rcx)
movl 0x4(%r13), %eax
movl %eax, 0x4(%rcx)
movl 0x8(%r13), %eax
movl %eax, 0x8(%rcx)
incl %r12d
cmpl -0x30(%rbp), %r12d
jne 0x72f5
incl %r14d
cmpl -0x38(%rbp), %r14d
jne 0x72dd
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x754f
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x754f
callq 0x3110
leaq -0x68(%rbp), %r15
jmp 0x7558
movq %rax, %rbx
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0x7566
callq 0x3110
movq %rbx, %rdi
callq 0x3220
nop