// File: /workspace/github_c_makefile_star2_O2/michaelforney[P]wld/nouveau.c
// Function: renderer_copy_rectangle
void
renderer_copy_rectangle(struct wld_renderer *base,
                        struct buffer *buffer_base,
                        int32_t dst_x, int32_t dst_y,
                        int32_t src_x, int32_t src_y,
                        uint32_t width, uint32_t height)
{
	struct nouveau_renderer *renderer = nouveau_renderer(base);

	if (buffer_base->base.impl != &wld_buffer_impl)
		return;

	struct nouveau_buffer *src = nouveau_buffer(&buffer_base->base),
	                      *dst = renderer->target;
	uint32_t src_format, dst_format;

	if (!ensure_space(renderer->pushbuf, 33))
		return;

	src_format = nvc0_format(src->base.base.format);
	dst_format = nvc0_format(dst->base.base.format);

	nouveau_bufctx_reset(renderer->bufctx, 0);
	nvc0_2d_use_buffer(renderer, src, G80_2D_SRC_FORMAT, src_format);
	nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, dst_format);
	nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);

	if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
		return;

	nvc0_2d_inline(renderer->pushbuf, G80_GRAPH_SERIALIZE, 0);
	nvc0_2d_inline(renderer->pushbuf, G80_2D_BLIT_CONTROL,
	               G80_2D_BLIT_CONTROL_ORIGIN_CENTER
	                   | G80_2D_BLIT_CONTROL_FILTER_POINT_SAMPLE);
	nvc0_2d(renderer->pushbuf, G80_2D_BLIT_DST_X, 12,
	        dst_x, dst_y, width, height, 0, 1, 0, 1, 0, src_x, 0, src_y);

	renderer_flush(base);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, 0x68(%rsp)
movl %r8d, 0x6c(%rsp)
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r13
movq %rdi, %rbx
movl 0xb8(%rsp), %r12d
movl 0xb0(%rsp), %r15d
callq 0xc79d
leaq 0xc82d(%rip), %rax      # 0x18ad8
cmpq %rax, (%r13)
jne 0xc396
movq %r13, %rdi
callq 0xc76f
movq 0x18(%rbx), %rdi
movq 0x30(%rbx), %rax
movq %rax, 0x70(%rsp)
pushq $0x21
popq %rsi
callq 0xc021
testb %al, %al
je 0xc396
movl %r12d, 0x58(%rsp)
movl 0x14(%r13), %r12d
xorl %eax, %eax
movl $0x34325241, %ecx       # imm = 0x34325241
cmpl %ecx, %r12d
movl %r14d, 0x60(%rsp)
movl $0xcf, %r14d
movl %r15d, 0x5c(%rsp)
movl $0x0, %r15d
cmovel %r14d, %r15d
movl %ebp, 0x64(%rsp)
movq 0x70(%rsp), %rdx
movl 0x14(%rdx), %ebp
cmpl %ecx, %ebp
cmovnel %eax, %r14d
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0x9110
movl $0x34325258, %eax       # imm = 0x34325258
cmpl %eax, %r12d
movl $0xe6, %r12d
cmovel %r12d, %r15d
movq %rbx, %rdi
movq %r13, %rsi
movl $0x230, %edx            # imm = 0x230
movl %r15d, %ecx
movl 0x5c(%rsp), %r15d
callq 0xc7cb
movl $0x34325258, %eax       # imm = 0x34325258
cmpl %eax, %ebp
movl 0x64(%rsp), %ebp
cmovel %r12d, %r14d
movl 0x58(%rsp), %r12d
movq %rbx, %rdi
movq 0x70(%rsp), %rsi
movl $0x200, %edx            # imm = 0x200
movl %r14d, %ecx
movl 0x60(%rsp), %r14d
callq 0xc7cb
movq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rsi
callq 0x92d0
movq 0x18(%rbx), %rdi
callq 0x9460
testl %eax, %eax
je 0xc3a5
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rdi
movq 0x30(%rdi), %rax
movl $0x80006044, (%rax)     # imm = 0x80006044
leaq 0x8(%rax), %rcx
movq %rcx, 0x30(%rdi)
movl $0x80006223, 0x4(%rax)  # imm = 0x80006223
movl 0x68(%rsp), %eax
movl %eax, 0x48(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, 0x38(%rsp)
pushq $0x1
popq %rax
movl %eax, 0x28(%rsp)
andl $0x0, 0x40(%rsp)
movl %eax, 0x18(%rsp)
andl $0x0, 0x30(%rsp)
movl %r12d, 0x8(%rsp)
andl $0x0, 0x20(%rsp)
movl %r15d, (%rsp)
andl $0x0, 0x10(%rsp)
pushq $0xc
popq %rcx
xorl %esi, %esi
movl $0x8b0, %edx            # imm = 0x8B0
movl %r14d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
callq 0xc04a
movq %rbx, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc688