// File: /workspace/github_c_makefile_star2_O3/termbox[P]termbox/termbox.c
// Function: tb_present
void tb_present(void) {
    int x, y, w, i;
    struct tb_cell *back, *front;

    /* invalidate cursor position */
    lastx = LAST_COORD_INIT;
    lasty = LAST_COORD_INIT;

    if (buffer_size_change_request) {
        update_size();
        buffer_size_change_request = 0;
    }

    for (y = 0; y < front_buffer.height; ++y) {
        for (x = 0; x < front_buffer.width;) {
            back = &CELL(&back_buffer, x, y);
            front = &CELL(&front_buffer, x, y);
            w = wcwidth(back->ch);
            if (w < 1)
                w = 1;
            if (memcmp(back, front, sizeof(struct tb_cell)) == 0) {
                x += w;
                continue;
            }
            memcpy(front, back, sizeof(struct tb_cell));
            send_attr(back->fg, back->bg);
            if (w > 1 && x >= front_buffer.width - (w - 1)) {
                // Not enough room for wide ch, so send spaces
                for (i = x; i < front_buffer.width; ++i) {
                    send_char(i, y, ' ');
                }
            } else {
                send_char(x, y, back->ch);
                for (i = 1; i < w; ++i) {
                    front = &CELL(&front_buffer, x + i, y);
                    front->ch = 0;
                    front->fg = back->fg;
                    front->bg = back->bg;
                }
            }
            x += w;
        }
    }
    if (!IS_CURSOR_HIDDEN(cursor_x, cursor_y))
        write_cursor(cursor_x, cursor_y);
    bytebuffer_flush(&output_buffer, inout);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x5144(%rip)      # 0x9148
movl %eax, 0x5142(%rip)      # 0x914c
cmpl $0x0, 0x590f(%rip)      # 0x9920
je 0x4022
callq 0x41e7
movl $0x0, 0x58fe(%rip)      # 0x9920
movl 0x58ec(%rip), %ecx      # 0x9914
testl %ecx, %ecx
jle 0x4194
movq $0x0, (%rsp)
movl 0x58d2(%rip), %eax      # 0x9910
testl %eax, %eax
jle 0x4182
xorl %ebp, %ebp
movslq (%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq 0x58b0(%rip), %r13      # 0x9908
movl 0x58a2(%rip), %ecx      # 0x9900
movq (%rsp), %rdx
imull %edx, %ecx
addl %ebp, %ecx
movslq %ecx, %r15
movq 0x58a7(%rip), %rbx      # 0x9918
imull %edx, %eax
addl %ebp, %eax
movslq %eax, %r12
movl (%r13,%r15,8), %edi
callq 0x31a0
movl %eax, %r14d
cmpl $0x2, %eax
movl $0x1, %eax
cmovgel %r14d, %eax
movl %eax, 0xc(%rsp)
movq (%r13,%r15,8), %rax
cmpq (%rbx,%r12,8), %rax
je 0x4142
movq (%r13,%r15,8), %rax
movq %rax, (%rbx,%r12,8)
movzwl 0x4(%r13,%r15,8), %edi
movzwl 0x6(%r13,%r15,8), %esi
callq 0x4266
cmpl $0x2, %r14d
jl 0x4132
movl 0x5845(%rip), %eax      # 0x9910
movl %eax, %ecx
subl 0xc(%rsp), %ecx
incl %ecx
cmpl %ecx, %ebp
jge 0x4156
movl (%r13,%r15,8), %edx
movl %ebp, %edi
movq (%rsp), %rsi
callq 0x452e
movq 0x582a(%rip), %rcx      # 0x9918
movslq 0x581b(%rip), %rdx      # 0x9910
movl %ebp, %esi
movl %r14d, %eax
movss 0x4(%r13,%r15,8), %xmm0
imulq 0x10(%rsp), %rdx
shlq $0x3, %rsi
leaq (%rsi,%rdx,8), %rdx
addq %rdx, %rcx
addq $0xc, %rcx
decq %rax
xorl %edx, %edx
movl $0x0, -0x4(%rcx,%rdx,8)
movss %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x411b
jmp 0x4142
movl (%r13,%r15,8), %edx
movl %ebp, %edi
movq (%rsp), %rsi
callq 0x452e
addl 0xc(%rsp), %ebp
movl 0x57c4(%rip), %eax      # 0x9910
cmpl %eax, %ebp
jl 0x4051
jmp 0x417c
cmpl %eax, %ebp
jge 0x4142
movl %ebp, %r14d
movl %r14d, %edi
movq (%rsp), %rsi
movl $0x20, %edx
callq 0x452e
incl %r14d
cmpl 0x5798(%rip), %r14d     # 0x9910
jl 0x415d
jmp 0x4142
movl 0x5792(%rip), %ecx      # 0x9914
movq (%rsp), %rdx
incl %edx
movq %rdx, (%rsp)
cmpl %ecx, %edx
jl 0x403e
movl 0x4fb6(%rip), %edi      # 0x9150
cmpl $-0x1, %edi
sete %al
movl 0x4fae(%rip), %esi      # 0x9154
cmpl $-0x1, %esi
sete %cl
orb %al, %cl
jne 0x41b5
callq 0x4599
movl 0x56d5(%rip), %edi      # 0x9890
movq 0x5726(%rip), %rsi      # 0x98e8
movslq 0x5727(%rip), %rdx      # 0x98f0
callq 0x30a0
movl $0x0, 0x5718(%rip)      # 0x98f0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq