// File: /workspace/github_c_makefile_star2_O0/adsr[P]phpspy/vendor/termbox2/termbox2.h
// Function: tb_present
int tb_present(void) {
    if_not_init_return();

    int rv;

    // TODO Assert global.back.(width,height) == global.front.(width,height)

    global.last_x = -1;
    global.last_y = -1;

    int x, y, i;
    for (y = 0; y < global.front.height; y++) {
        for (x = 0; x < global.front.width;) {
            struct tb_cell *back, *front;
            if_err_return(rv, cellbuf_get(&global.back, x, y, &back));
            if_err_return(rv, cellbuf_get(&global.front, x, y, &front));

            int w;
            {
#ifdef TB_OPT_EGC
                if (back->nech > 0)
                    w = wcswidth((wchar_t *)back->ech, back->nech);
                else
#endif
                    /* wcwidth() simply returns -1 on overflow of wchar_t */
                    w = wcwidth((wchar_t)back->ch);
            }
            if (w < 1) {
                w = 1;
            }

            if (cell_cmp(back, front) != 0) {
                cell_copy(front, back);

                send_attr(back->fg, back->bg);
                if (w > 1 && x >= global.front.width - (w - 1)) {
                    for (i = x; i < global.front.width; i++) {
                        send_char(i, y, ' ');
                    }
                } else {
                    {
#ifdef TB_OPT_EGC
                        if (back->nech > 0)
                            send_cluster(x, y, back->ech, back->nech);
                        else
#endif
                            send_char(x, y, back->ch);
                    }
                    for (i = 1; i < w; i++) {
                        struct tb_cell *front_wide;
                        if_err_return(rv,
                            cellbuf_get(&global.front, x + i, y, &front_wide));
                        if_err_return(rv,
                            cell_set(front_wide, 0, 1, back->fg, back->bg));
                    }
                }
            }
            x += w;
        }
    }

    if_err_return(rv, send_cursor_if(global.cursor_x, global.cursor_y));
    if_err_return(rv, bytebuf_flush(&global.out, global.wfd));

    return TB_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
cmpl $0x0, 0x34ded(%rip)     # 0x3c0bc
jne 0x72dd
movl $0xfffffff8, -0x4(%rbp) # imm = 0xFFFFFFF8
jmp 0x752e
movl $0xffffffff, 0x34bd9(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x34bd3(%rip) # imm = 0xFFFFFFFF
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl 0x34d6b(%rip), %eax     # 0x3c06c
jge 0x74dd
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x34d51(%rip), %eax     # 0x3c068
jge 0x74cd
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
leaq 0x34b6e(%rip), %rdi     # 0x3be98
addq $0x1c0, %rdi            # imm = 0x1C0
leaq -0x20(%rbp), %rcx
callq 0x7540
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
je 0x734d
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x752e
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
leaq 0x34b3e(%rip), %rdi     # 0x3be98
addq $0x1d0, %rdi            # imm = 0x1D0
leaq -0x28(%rbp), %rcx
callq 0x7540
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
je 0x737d
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x752e
movq -0x20(%rbp), %rax
movl (%rax), %edi
callq 0x63c0
movl %eax, -0x2c(%rbp)
cmpl $0x1, -0x2c(%rbp)
jge 0x7398
movl $0x1, -0x2c(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x75c0
cmpl $0x0, %eax
je 0x74bf
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x7620
movq -0x20(%rbp), %rax
movw 0x4(%rax), %cx
movq -0x20(%rbp), %rax
movzwl %cx, %edi
movzwl 0x6(%rax), %esi
callq 0x7660
cmpl $0x1, -0x2c(%rbp)
jle 0x741f
movl -0xc(%rbp), %eax
movl 0x34c86(%rip), %ecx     # 0x3c068
movl -0x2c(%rbp), %edx
subl $0x1, %edx
subl %edx, %ecx
cmpl %ecx, %eax
jl 0x741f
movl -0xc(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x34c6b(%rip), %eax     # 0x3c068
jge 0x741a
movl -0x14(%rbp), %edi
movl -0x10(%rbp), %esi
movl $0x20, %edx
callq 0x7a20
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x73f4
jmp 0x74bd
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
movq -0x20(%rbp), %rax
movl (%rax), %edx
callq 0x7a20
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x74bb
movl -0xc(%rbp), %esi
addl -0x14(%rbp), %esi
movl -0x10(%rbp), %edx
leaq 0x34a49(%rip), %rdi     # 0x3be98
addq $0x1d0, %rdi            # imm = 0x1D0
leaq -0x38(%rbp), %rcx
callq 0x7540
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
je 0x7472
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x752e
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movw 0x4(%rax), %cx
movq -0x20(%rbp), %rax
xorl %edx, %edx
movl %edx, %esi
movl $0x1, %edx
movzwl %cx, %ecx
movzwl 0x6(%rax), %r8d
callq 0x7a50
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
je 0x74ab
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x752e
jmp 0x74ad
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7437
jmp 0x74bd
jmp 0x74bf
movl -0x2c(%rbp), %eax
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x730e
jmp 0x74cf
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x72f8
movl 0x349d5(%rip), %edi     # 0x3beb8
movl 0x349d3(%rip), %esi     # 0x3bebc
callq 0x7ab0
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
je 0x74fe
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x752e
movl 0x3499c(%rip), %esi     # 0x3bea0
leaq 0x3498d(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7c00
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
je 0x7527
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x752e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)