// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
orl $-0x1, 0x5283(%rip)     # 0x9148
orl $-0x1, 0x5280(%rip)     # 0x914c
cmpl $0x0, 0x5a4d(%rip)      # 0x9920
je 0x3ee4
callq 0x4052
movl $0x0, 0x5a3c(%rip)      # 0x9920
xorl %ebx, %ebx
cmpl 0x5a28(%rip), %ebx      # 0x9914
jge 0x4018
xorl %edx, %edx
movl 0x5a16(%rip), %eax      # 0x9910
cmpl %eax, %edx
jge 0x4011
movq 0x59ff(%rip), %r12      # 0x9908
movl 0x59f1(%rip), %ecx      # 0x9900
imull %ebx, %ecx
addl %edx, %ecx
movslq %ecx, %rbp
movq 0x59fa(%rip), %r13      # 0x9918
imull %ebx, %eax
movl %edx, 0x4(%rsp)
addl %edx, %eax
movslq %eax, %r14
movl (%r12,%rbp,8), %edi
callq 0x31a0
movl %eax, %r15d
cmpl $0x2, %eax
pushq $0x1
popq %rax
cmovgel %r15d, %eax
movl %eax, (%rsp)
movq (%r12,%rbp,8), %rax
cmpq (%r13,%r14,8), %rax
je 0x4005
leaq (%r12,%rbp,8), %r12
leaq (,%r14,8), %rax
addq %r13, %rax
movq (%r12), %rcx
movq %rcx, (%rax)
movzwl 0x4(%r12), %edi
movzwl 0x6(%r12), %esi
callq 0x4099
cmpl $0x2, %r15d
movl 0x4(%rsp), %r15d
jl 0x3f96
movl 0x5986(%rip), %eax      # 0x9910
movl %eax, %ecx
subl (%rsp), %ecx
incl %ecx
cmpl %ecx, %r15d
jge 0x3fe8
movl (%r12), %edx
movl %r15d, %edi
movl %ebx, %esi
callq 0x430d
movq 0x596d(%rip), %rcx      # 0x9918
movl %r15d, %edx
movl (%rsp), %eax
movl 0x5959(%rip), %esi      # 0x9910
imull %ebx, %esi
movslq %esi, %rsi
shlq $0x3, %rdx
leaq (%rdx,%rsi,8), %rdx
addq %rdx, %rcx
addq $0xc, %rcx
decq %rax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x4005
andl $0x0, -0x4(%rcx,%rdx,8)
movl 0x4(%r12), %esi
movl %esi, (%rcx,%rdx,8)
incq %rdx
jmp 0x3fd1
cmpl %eax, %r15d
jge 0x4005
movl %r15d, %edi
movl %ebx, %esi
pushq $0x20
popq %rdx
callq 0x430d
incl %r15d
movl 0x590d(%rip), %eax      # 0x9910
jmp 0x3fe8
movl 0x4(%rsp), %edx
addl (%rsp), %edx
jmp 0x3ef4
incl %ebx
jmp 0x3ee6
movl 0x5132(%rip), %edi      # 0x9150
cmpl $-0x1, %edi
sete %al
movl 0x512a(%rip), %esi      # 0x9154
cmpl $-0x1, %esi
sete %cl
orb %al, %cl
jne 0x4039
callq 0x4378
movl 0x5851(%rip), %edi      # 0x9890
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3e85