// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/graphics/backends/cairo/surfacecairo.cpp
// Function: smooth::GUI::SurfaceCairo::BlitToBitmap(smooth::GUI::Rect const&, smooth::GUI::Bitmap&, smooth::GUI::Rect const&)
S::Int S::GUI::SurfaceCairo::BlitToBitmap(const Rect &iSrcRect, Bitmap &bitmap, const Rect &destRect)
{
	if (window == NIL) return Success();
	if (bitmap == NIL) return Error();

	Rect	 srcRect = rightToLeft.TranslateRect(iSrcRect);

	if (srcRect.GetWidth()  == 0 || srcRect.GetHeight()  == 0 ||
	    destRect.GetWidth() == 0 || destRect.GetHeight() == 0) return Success();

	/* Copy the image.
	 */
	cairo_surface_t	*bitmapSurface = cairo_image_surface_create_for_data(bitmap.GetBytes(), CAIRO_FORMAT_RGB24, bitmap.GetSize().cx, bitmap.GetSize().cy, bitmap.GetSize().cx * 4);
	cairo_t		*bitmapContext = cairo_create(bitmapSurface);

	cairo_rectangle(bitmapContext, destRect.left, destRect.top, destRect.GetWidth(), destRect.GetHeight());
	cairo_clip(bitmapContext);
	cairo_translate(bitmapContext, destRect.left, destRect.top);
	cairo_scale(bitmapContext, (float) destRect.GetWidth() / srcRect.GetWidth(), (float) destRect.GetHeight() / srcRect.GetHeight());
	cairo_set_source_surface(bitmapContext, surface, -srcRect.left, -srcRect.top);
	cairo_paint(bitmapContext);

	cairo_destroy(bitmapContext);
	cairo_surface_destroy(bitmapSurface);

	return Success();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, 0x50(%rax)
jne 0x12ede2
leaq -0x38(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x5ca80
movq -0xb0(%rbp), %rdi
callq 0x59680
movl %eax, -0xa4(%rbp)
jmp 0x12edb1
movl -0xa4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5a410
jmp 0x12f139
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5a410
jmp 0x12f145
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x5c730
testb $0x1, %al
jne 0x12edf3
jmp 0x12ee4d
leaq -0x58(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5a9c0
movq -0xc0(%rbp), %rdi
callq 0x59680
movl %eax, -0xb4(%rbp)
jmp 0x12ee1c
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x5b5b0
jmp 0x12f139
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x5b5b0
jmp 0x12f145
movq -0xa0(%rbp), %rdi
addq $0x28, %rdi
movq -0x18(%rbp), %rsi
callq 0x73390
movq %rax, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x5a5a0
cmpl $0x0, %eax
je 0x12eea1
leaq -0x68(%rbp), %rdi
callq 0x591a0
cmpl $0x0, %eax
je 0x12eea1
movq -0x28(%rbp), %rdi
callq 0x5a5a0
cmpl $0x0, %eax
je 0x12eea1
movq -0x28(%rbp), %rdi
callq 0x591a0
cmpl $0x0, %eax
jne 0x12eef6
leaq -0x78(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x5ca80
movq -0xd0(%rbp), %rdi
callq 0x59680
movl %eax, -0xc4(%rbp)
jmp 0x12eec5
movl -0xc4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5a410
jmp 0x12f139
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5a410
jmp 0x12f145
movq -0x20(%rbp), %rdi
callq 0x5b750
movq %rax, -0x138(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5ce60
movl (%rax), %eax
movl %eax, -0x130(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5ce60
movl 0x4(%rax), %eax
movl %eax, -0x12c(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5ce60
movq -0x138(%rbp), %rdi
movl -0x130(%rbp), %edx
movl -0x12c(%rbp), %ecx
movl (%rax), %r8d
shll $0x2, %r8d
movl $0x1, %esi
callq 0x5b7f0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x5c9e0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x28(%rbp), %rdi
cvtsi2sdl (%rdi), %xmm0
movsd %xmm0, -0x120(%rbp)
cvtsi2sdl 0x4(%rdi), %xmm0
movsd %xmm0, -0x118(%rbp)
callq 0x5a5a0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x110(%rbp)
movq -0x28(%rbp), %rdi
callq 0x591a0
movq -0x128(%rbp), %rdi
movsd -0x120(%rbp), %xmm0
movsd -0x118(%rbp), %xmm1
movsd -0x110(%rbp), %xmm2
cvtsi2sd %eax, %xmm3
callq 0x5aa10
movq -0x88(%rbp), %rdi
callq 0x5c3b0
movq -0x88(%rbp), %rdi
movq -0x28(%rbp), %rax
cvtsi2sdl (%rax), %xmm0
cvtsi2sdl 0x4(%rax), %xmm1
callq 0x59bd0
movq -0x88(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5a5a0
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x104(%rbp)
leaq -0x68(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x5a5a0
movss -0x104(%rbp), %xmm0
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x591a0
movq -0x100(%rbp), %rdi
cvtsi2ss %eax, %xmm0
movss %xmm0, -0xf4(%rbp)
callq 0x591a0
movss -0xf4(%rbp), %xmm1
movq -0xf0(%rbp), %rdi
movsd -0xe8(%rbp), %xmm0
cvtsi2ss %eax, %xmm2
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
callq 0x5c840
movq -0xa0(%rbp), %rax
movq -0x88(%rbp), %rdi
movq 0xb8(%rax), %rsi
movl -0x68(%rbp), %ecx
movl -0x64(%rbp), %eax
negl %ecx
cvtsi2sd %ecx, %xmm0
negl %eax
cvtsi2sd %eax, %xmm1
callq 0x5d7e0
movq -0x88(%rbp), %rdi
callq 0x59ca0
movq -0x88(%rbp), %rdi
callq 0x5d750
movq -0x80(%rbp), %rdi
callq 0x5bd80
leaq -0x98(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x5ca80
movq -0xe0(%rbp), %rdi
callq 0x59680
movl %eax, -0xd4(%rbp)
jmp 0x12f108
movl -0xd4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5a410
jmp 0x12f139
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5a410
jmp 0x12f145
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x5b6b0
nop