// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
leaq 0x4964(%rip), %rbx      # 0xb160
movq %rbx, %rdi
callq 0x62aa
movl %eax, %r14d
movq %rbx, %rdi
callq 0x62b2
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
movl %r14d, -0x34(%rbp)
testl %eax, %eax
cmovlel %r15d, %eax
movl %eax, -0x30(%rbp)
cmpl -0x30(%rbp), %r15d
je 0x6948
leal 0x1(%r15), %eax
movl %eax, -0x2c(%rbp)
xorl %r12d, %r12d
movq %r15, -0x40(%rbp)
cmpl -0x34(%rbp), %r12d
je 0x693d
leaq 0x4931(%rip), %rdi      # 0xb180
movl %r12d, %esi
movl %r15d, %edx
callq 0x62bc
movq %rax, %rbx
leaq 0x48fc(%rip), %rdi      # 0xb160
movl %r12d, %esi
movl %r15d, %edx
callq 0x62bc
movq %rax, %r13
movq %rbx, %rdi
movq %rax, %rsi
callq 0x697c
testb %al, %al
je 0x6886
incl %r12d
jmp 0x683e
movq 0x474b(%rip), %rdi      # 0xafd8
leaq 0xcb6(%rip), %rsi       # 0x754a
callq 0x3130
movq %rax, %r14
leaq -0x60(%rbp), %r15
movq %r15, %rdi
movl -0x2c(%rbp), %esi
callq 0x4fab
movq %r14, %rdi
movq %r15, %rsi
callq 0x3110
movq %rax, %rdi
pushq $0x3b
popq %rsi
callq 0x3170
movq %rax, %r14
incl %r12d
leaq -0x80(%rbp), %r15
movq %r15, %rdi
movl %r12d, %esi
callq 0x4fab
movq %r14, %rdi
movq %r15, %rsi
callq 0x3110
movq %rax, %rdi
pushq $0x48
popq %rsi
callq 0x3170
movq %r15, %rdi
callq 0x30b0
leaq -0x60(%rbp), %rdi
callq 0x30b0
movl 0x4(%r13), %edi
movl 0x8(%r13), %esi
callq 0x661a
movsbl (%r13), %esi
movq 0x46c2(%rip), %rdi      # 0xafd8
callq 0x3040
callq 0x670e
movb (%r13), %al
movb %al, (%rbx)
movl 0x4(%r13), %eax
movl %eax, 0x4(%rbx)
movl 0x8(%r13), %eax
movl %eax, 0x8(%rbx)
movq -0x40(%rbp), %r15
jmp 0x683e
movl -0x2c(%rbp), %eax
movl %eax, %r15d
jmp 0x6826
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6959
movq %rax, %rbx
jmp 0x696a
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x30b0
leaq -0x60(%rbp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x3230
nop