// File: /workspace/github_cpp_makefile_star2_O3/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 0x4f7c(%rip), %rbx      # 0xc160
movq %rbx, %rdi
callq 0x698a
movl %eax, -0x34(%rbp)
movq %rbx, %rdi
callq 0x6992
movl %eax, -0x38(%rbp)
testl %eax, %eax
jle 0x7460
leaq -0x48(%rbp), %r12
xorl %r13d, %r13d
leal 0x1(%r13), %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x7451
xorl %r14d, %r14d
movq %r13, -0x80(%rbp)
leaq 0x4f58(%rip), %rdi      # 0xc180
movl %r14d, %esi
movl %r13d, %edx
callq 0x699c
movq %rax, %r15
leaq 0x4f23(%rip), %rdi      # 0xc160
movl %r14d, %esi
movl %r13d, %edx
callq 0x699c
movq %rax, %rbx
movb (%r15), %al
cmpb (%rbx), %al
jne 0x726f
movl 0x4(%r15), %eax
cmpl 0x4(%rbx), %eax
jne 0x726f
movl 0x8(%r15), %eax
cmpl 0x8(%rbx), %eax
jne 0x726f
incl %r14d
movl %r14d, %r13d
jmp 0x7440
movq %r15, -0x88(%rbp)
movl $0x2, %edx
movq 0x4d56(%rip), %rdi      # 0xbfd8
leaq 0x12f1(%rip), %rsi      # 0x857a
callq 0x3150
movl $0x1, %r15d
cmpl $0x9, %r13d
jb 0x72e1
movl $0x4, %r15d
movl -0x30(%rbp), %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x72d8
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x72de
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x72e1
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r15d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x72a8
addl $-0x3, %r15d
jmp 0x72e1
addl $-0x2, %r15d
jmp 0x72e1
decl %r15d
movl %r15d, %esi
movq %r12, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
movl $0x2d, %edx
callq 0x3160
movq -0x58(%rbp), %rdi
movl %r15d, %esi
movl -0x30(%rbp), %edx
callq 0x5b24
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0x4cc4(%rip), %rdi      # 0xbfd8
callq 0x3150
movb $0x3b, -0x78(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x78(%rbp), %rsi
callq 0x3150
movq %rax, %r12
leal 0x1(%r14), %r13d
movl $0x1, %r15d
cmpl $0x9, %r14d
leaq -0x68(%rbp), %r14
jb 0x738c
movl $0x4, %r15d
movl %r13d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x7383
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x7389
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x738c
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r15d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x7353
addl $-0x3, %r15d
jmp 0x738c
addl $-0x2, %r15d
jmp 0x738c
decl %r15d
movl %r15d, %esi
movq %r14, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
movl $0x2d, %edx
callq 0x3160
movq -0x78(%rbp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x5b24
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq %r12, %rdi
callq 0x3150
movb $0x48, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3150
movq -0x78(%rbp), %rdi
cmpq %r14, %rdi
je 0x73e3
callq 0x3110
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %r12
cmpq %r12, %rdi
movq -0x88(%rbp), %r15
je 0x73fc
callq 0x3110
movl 0x4(%rbx), %edi
movl 0x8(%rbx), %esi
callq 0x6f64
movsbl (%rbx), %esi
movq 0x4bc7(%rip), %r14      # 0xbfd8
movq %r14, %rdi
callq 0x3040
movl $0x4, %edx
movq %r14, %rdi
leaq 0x1155(%rip), %rsi      # 0x857d
callq 0x3150
movb (%rbx), %al
movb %al, (%r15)
movl 0x4(%rbx), %eax
movl %eax, 0x4(%r15)
movl 0x8(%rbx), %eax
movl %eax, 0x8(%r15)
movl %r13d, %r14d
cmpl -0x34(%rbp), %r13d
movq -0x80(%rbp), %r13
jne 0x7221
movl -0x30(%rbp), %eax
movl %eax, %r13d
cmpl -0x38(%rbp), %eax
jne 0x7209
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7484
movq %rax, %rbx
movq -0x78(%rbp), %rdi
cmpq %r14, %rdi
je 0x7487
callq 0x3110
jmp 0x7487
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x58(%rbp), %rdi
cmpq %rax, %rdi
je 0x7499
callq 0x3110
movq %rbx, %rdi
callq 0x3220
nopl (%rax)