// File: /workspace/github_c_makefile_star2_O0/termbox[P]termbox/termbox.c
// Function: tb_blit
void tb_blit(int x, int y, int w, int h, const struct tb_cell *cells) {
    if (x + w < 0 || x >= back_buffer.width)
        return;
    if (y + h < 0 || y >= back_buffer.height)
        return;
    int xo = 0, yo = 0, ww = w, hh = h;
    if (x < 0) {
        xo = -x;
        ww -= xo;
        x = 0;
    }
    if (y < 0) {
        yo = -y;
        hh -= yo;
        y = 0;
    }
    if (ww > back_buffer.width - x)
        ww = back_buffer.width - x;
    if (hh > back_buffer.height - y)
        hh = back_buffer.height - y;

    int sy;
    struct tb_cell *dst = &CELL(&back_buffer, x, y);
    const struct tb_cell *src = cells + yo * w + xo;
    size_t size = sizeof(struct tb_cell) * ww;

    for (sy = 0; sy < hh; ++sy) {
        memcpy(dst, src, size);
        dst += back_buffer.width;
        src += w;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movq %r8, -0x18(%rbp)
movl -0x4(%rbp), %eax
addl -0xc(%rbp), %eax
cmpl $0x0, %eax
jl 0x487e
movl -0x4(%rbp), %eax
cmpl 0x6134(%rip), %eax      # 0xa9b0
jl 0x4883
jmp 0x49da
movl -0x8(%rbp), %eax
addl -0x10(%rbp), %eax
cmpl $0x0, %eax
jl 0x4899
movl -0x8(%rbp), %eax
cmpl 0x611d(%rip), %eax      # 0xa9b4
jl 0x489e
jmp 0x49da
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x4(%rbp)
jge 0x48d8
xorl %eax, %eax
subl -0x4(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x4(%rbp)
cmpl $0x0, -0x8(%rbp)
jge 0x48f8
xorl %eax, %eax
subl -0x8(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %ecx
movl -0x28(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x24(%rbp), %eax
movl 0x60af(%rip), %ecx      # 0xa9b0
subl -0x4(%rbp), %ecx
cmpl %ecx, %eax
jle 0x4914
movl 0x60a2(%rip), %eax      # 0xa9b0
subl -0x4(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
movl 0x6097(%rip), %ecx      # 0xa9b4
subl -0x8(%rbp), %ecx
cmpl %ecx, %eax
jle 0x4930
movl 0x608a(%rip), %eax      # 0xa9b4
subl -0x8(%rbp), %eax
movl %eax, -0x28(%rbp)
movq 0x6081(%rip), %rax      # 0xa9b8
movl -0x8(%rbp), %ecx
imull 0x606f(%rip), %ecx      # 0xa9b0
addl -0x4(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
imull -0xc(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movslq -0x24(%rbp), %rax
shlq $0x3, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x49da
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x3170
movl 0x6008(%rip), %ecx      # 0xa9b0
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0xc(%rbp), %ecx
movq -0x40(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4989
addq $0x50, %rsp
popq %rbp
retq