// File: /workspace/github_c_makefile_star2_O1/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, 0x50ea(%rip)      # 0x9148
movl %eax, 0x50e8(%rip)      # 0x914c
cmpl $0x0, 0x58b5(%rip)      # 0x9920
je 0x407c
callq 0x423b
movl $0x0, 0x58a4(%rip)      # 0x9920
cmpl $0x0, 0x5891(%rip)      # 0x9914
jle 0x41e8
movq $0x0, (%rsp)
movl 0x5879(%rip), %eax      # 0x9910
testl %eax, %eax
jle 0x41d2
xorl %ebp, %ebp
movslq (%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq 0x5857(%rip), %r13      # 0x9908
movl 0x5849(%rip), %ecx      # 0x9900
movq (%rsp), %rdx
imull %edx, %ecx
addl %ebp, %ecx
movslq %ecx, %r15
movq 0x584e(%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 0x41c0
movq (%r13,%r15,8), %rax
movq %rax, (%rbx,%r12,8)
movzwl 0x4(%r13,%r15,8), %edi
movzwl 0x6(%r13,%r15,8), %esi
callq 0x42ba
cmpl $0x2, %r14d
jl 0x412e
movl 0x57ec(%rip), %eax      # 0x9910
subl 0xc(%rsp), %eax
incl %eax
cmpl %eax, %ebp
jge 0x4198
movl (%r13,%r15,8), %edx
movl %ebp, %edi
movq (%rsp), %rsi
callq 0x457e
cmpl $0x2, %r14d
jl 0x41c0
movq 0x57cd(%rip), %rcx      # 0x9918
movslq 0x57be(%rip), %rdx      # 0x9910
movl %ebp, %esi
movl %r14d, %eax
imulq 0x10(%rsp), %rdx
shlq $0x3, %rsi
leaq (%rsi,%rdx,8), %rdx
addq %rdx, %rcx
addq $0xe, %rcx
decq %rax
xorl %edx, %edx
movl $0x0, -0x6(%rcx,%rdx,8)
movzwl 0x4(%r13,%r15,8), %esi
movw %si, -0x2(%rcx,%rdx,8)
movzwl 0x6(%r13,%r15,8), %esi
movw %si, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x4171
jmp 0x41c0
cmpl 0x5772(%rip), %ebp      # 0x9910
jge 0x41c0
movl %ebp, %r14d
movl %r14d, %edi
movq (%rsp), %rsi
movl $0x20, %edx
callq 0x457e
incl %r14d
cmpl 0x5752(%rip), %r14d     # 0x9910
jl 0x41a3
addl 0xc(%rsp), %ebp
movl 0x5746(%rip), %eax      # 0x9910
cmpl %eax, %ebp
jl 0x40aa
movq (%rsp), %rax
incl %eax
movq %rax, (%rsp)
cmpl 0x5732(%rip), %eax      # 0x9914
jl 0x4091
movl 0x4f62(%rip), %edi      # 0x9150
cmpl $-0x1, %edi
sete %al
movl 0x4f5a(%rip), %esi      # 0x9154
cmpl $-0x1, %esi
sete %cl
orb %al, %cl
jne 0x4209
callq 0x45e9
movl 0x5681(%rip), %edi      # 0x9890
movq 0x56d2(%rip), %rsi      # 0x98e8
movslq 0x56d3(%rip), %rdx      # 0x98f0
callq 0x30a0
movl $0x0, 0x56c4(%rip)      # 0x98f0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq