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

	Rect	 destRect = rightToLeft.TranslateRect(iDestRect);

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

	/* Copy the image.
	 */
	Bitmap	 premultipliedBitmap = bitmap;

	PremultiplyAlpha(premultipliedBitmap);

	Size		 srcSize    = premultipliedBitmap.GetSize();
	cairo_format_t	 srcFormat  = premultipliedBitmap.GetDepth() == 32 ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
	cairo_surface_t	*srcSurface = cairo_image_surface_create_for_data(premultipliedBitmap.GetBytes(), srcFormat, srcSize.cx, srcSize.cy, srcSize.cx * 4);

	if (!painting)
	{
		CreateCairoContext();

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

		DestroyCairoContext();
	}

	cairo_save(paintContextCairo);

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

	cairo_restore(paintContextCairo);

	cairo_surface_destroy(srcSurface);

	return Success();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, 0x50(%rax)
jne 0x12e6e2
leaq -0x38(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x5ca80
movq -0xc0(%rbp), %rdi
callq 0x59680
movl %eax, -0xb4(%rbp)
jmp 0x12e6b1
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5a410
jmp 0x12ed44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5a410
jmp 0x12ed50
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x5c730
testb $0x1, %al
jne 0x12e6f3
jmp 0x12e74d
leaq -0x58(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5a9c0
movq -0xd0(%rbp), %rdi
callq 0x59680
movl %eax, -0xc4(%rbp)
jmp 0x12e71c
movl -0xc4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x5b5b0
jmp 0x12ed44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x5b5b0
jmp 0x12ed50
movq -0xb0(%rbp), %rdi
addq $0x28, %rdi
movq -0x28(%rbp), %rsi
callq 0x73390
movq %rax, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5a5a0
cmpl $0x0, %eax
je 0x12e7a1
movq -0x20(%rbp), %rdi
callq 0x591a0
cmpl $0x0, %eax
je 0x12e7a1
leaq -0x68(%rbp), %rdi
callq 0x5a5a0
cmpl $0x0, %eax
je 0x12e7a1
leaq -0x68(%rbp), %rdi
callq 0x591a0
cmpl $0x0, %eax
jne 0x12e7f6
leaq -0x78(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x5ca80
movq -0xe0(%rbp), %rdi
callq 0x59680
movl %eax, -0xd4(%rbp)
jmp 0x12e7c5
movl -0xd4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5a410
jmp 0x12ed44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5a410
jmp 0x12ed50
movq -0x18(%rbp), %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x5b7e0
movq -0xe8(%rbp), %rdi
callq 0x6fc20
jmp 0x12e818
leaq -0x80(%rbp), %rdi
callq 0x5ce60
movq %rax, -0xf0(%rbp)
jmp 0x12e82a
movq -0xf0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5b190
movb %al, -0xf1(%rbp)
jmp 0x12e84c
movb -0xf1(%rbp), %al
subb $0x20, %al
setne %al
movzbl %al, %eax
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5b750
movq %rax, -0x100(%rbp)
jmp 0x12e872
movq -0x100(%rbp), %rdi
movl -0x8c(%rbp), %esi
movl -0x88(%rbp), %edx
movl -0x84(%rbp), %ecx
movl %edx, %r8d
shll $0x2, %r8d
callq 0x5b7f0
movq %rax, -0x108(%rbp)
jmp 0x12e8a0
movq -0xb0(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rcx, -0x98(%rbp)
cmpw $0x0, 0xa(%rax)
jne 0x12eacb
movq -0xb0(%rbp), %rdi
callq 0x12b760
jmp 0x12e8ce
movq -0xb0(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x128(%rbp)
cvtsi2sdl -0x68(%rbp), %xmm0
movsd %xmm0, -0x120(%rbp)
cvtsi2sdl -0x64(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0x10c(%rbp)
jmp 0x12e90e
movl -0x10c(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x138(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x591a0
movl %eax, -0x12c(%rbp)
jmp 0x12e931
movsd -0x138(%rbp), %xmm2
movsd -0x118(%rbp), %xmm1
movsd -0x120(%rbp), %xmm0
movq -0x128(%rbp), %rdi
movl -0x12c(%rbp), %eax
cvtsi2sd %eax, %xmm3
callq 0x5aa10
jmp 0x12e961
movq -0xb0(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x5c3b0
jmp 0x12e976
movq -0xb0(%rbp), %rax
movq 0xc0(%rax), %rdi
cvtsi2sdl -0x68(%rbp), %xmm0
cvtsi2sdl -0x64(%rbp), %xmm1
callq 0x59bd0
jmp 0x12e995
movq -0xb0(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x148(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0x13c(%rbp)
jmp 0x12e9bb
movl -0x13c(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x150(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0x14c(%rbp)
jmp 0x12e9de
movss -0x150(%rbp), %xmm0
movl -0x14c(%rbp), %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x160(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x591a0
movl %eax, -0x154(%rbp)
jmp 0x12ea11
movl -0x154(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x168(%rbp)
movq -0x20(%rbp), %rdi
callq 0x591a0
movl %eax, -0x164(%rbp)
jmp 0x12ea34
movsd -0x160(%rbp), %xmm0
movq -0x148(%rbp), %rdi
movss -0x168(%rbp), %xmm1
movl -0x164(%rbp), %eax
cvtsi2ss %eax, %xmm2
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
callq 0x5c840
jmp 0x12ea64
movq -0xb0(%rbp), %rax
movq 0xc0(%rax), %rdi
movq -0x98(%rbp), %rsi
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %eax
negl %ecx
cvtsi2sd %ecx, %xmm0
negl %eax
cvtsi2sd %eax, %xmm1
callq 0x5d7e0
jmp 0x12ea95
movq -0xb0(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x59ca0
jmp 0x12eaaa
movq -0xb0(%rbp), %rdi
callq 0x12b7f0
jmp 0x12eab8
jmp 0x12eacb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x12ed39
movq -0xb0(%rbp), %rax
movq 0xd0(%rax), %rdi
callq 0x5b400
jmp 0x12eae0
movq -0xb0(%rbp), %rax
movq 0xd0(%rax), %rax
movq %rax, -0x188(%rbp)
cvtsi2sdl -0x68(%rbp), %xmm0
movsd %xmm0, -0x180(%rbp)
cvtsi2sdl -0x64(%rbp), %xmm0
movsd %xmm0, -0x178(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0x16c(%rbp)
jmp 0x12eb20
movl -0x16c(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x198(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x591a0
movl %eax, -0x18c(%rbp)
jmp 0x12eb43
movsd -0x198(%rbp), %xmm2
movsd -0x178(%rbp), %xmm1
movsd -0x180(%rbp), %xmm0
movq -0x188(%rbp), %rdi
movl -0x18c(%rbp), %eax
cvtsi2sd %eax, %xmm3
callq 0x5aa10
jmp 0x12eb73
movq -0xb0(%rbp), %rax
movq 0xd0(%rax), %rdi
callq 0x5c3b0
jmp 0x12eb88
movq -0xb0(%rbp), %rax
movq 0xd0(%rax), %rdi
cvtsi2sdl -0x68(%rbp), %xmm0
cvtsi2sdl -0x64(%rbp), %xmm1
callq 0x59bd0
jmp 0x12eba7
movq -0xb0(%rbp), %rax
movq 0xd0(%rax), %rax
movq %rax, -0x1a8(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0x19c(%rbp)
jmp 0x12ebcd
movl -0x19c(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x1b0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0x1ac(%rbp)
jmp 0x12ebf0
movss -0x1b0(%rbp), %xmm0
movl -0x1ac(%rbp), %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x1c0(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x591a0
movl %eax, -0x1b4(%rbp)
jmp 0x12ec23
movl -0x1b4(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x1c8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x591a0
movl %eax, -0x1c4(%rbp)
jmp 0x12ec46
movsd -0x1c0(%rbp), %xmm0
movq -0x1a8(%rbp), %rdi
movss -0x1c8(%rbp), %xmm1
movl -0x1c4(%rbp), %eax
cvtsi2ss %eax, %xmm2
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
callq 0x5c840
jmp 0x12ec76
movq -0xb0(%rbp), %rax
movq 0xd0(%rax), %rdi
movq -0x98(%rbp), %rsi
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %eax
negl %ecx
cvtsi2sd %ecx, %xmm0
negl %eax
cvtsi2sd %eax, %xmm1
callq 0x5d7e0
jmp 0x12eca7
movq -0xb0(%rbp), %rax
movq 0xd0(%rax), %rdi
callq 0x59ca0
jmp 0x12ecbc
movq -0xb0(%rbp), %rax
movq 0xd0(%rax), %rdi
callq 0x5c300
jmp 0x12ecd1
movq -0x98(%rbp), %rdi
callq 0x5bd80
jmp 0x12ecdf
leaq -0xa8(%rbp), %rdi
callq 0x5ca80
jmp 0x12eced
leaq -0xa8(%rbp), %rdi
callq 0x59680
movl %eax, -0x1cc(%rbp)
jmp 0x12ed01
movl -0x1cc(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5a410
leaq -0x80(%rbp), %rdi
callq 0x5de40
jmp 0x12ed44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5a410
leaq -0x80(%rbp), %rdi
callq 0x5de40
jmp 0x12ed50
movl -0x4(%rbp), %eax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x5b6b0
nopl (%rax)