// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/gui/widgets/basic/image.cpp
// Function: smooth::GUI::Image::Paint(int)
S::Int S::GUI::Image::Paint(Int message)
{
	if (!IsRegistered()) return Error();
	if (!IsVisible())    return Success();

	switch (message)
	{
		case SP_PAINT:
			{
				Surface	*surface = GetDrawSurface();

				/* Scale image if necessary.
				 */
				Size	 size	  = GetSize();
				Size	 bmpSize  = bitmap.GetSize();
				Size	 newSize  = bmpSize;

				if	(Float(bmpSize.cx) / size.cx >= Float(bmpSize.cy) / size.cy && bmpSize.cx > size.cx) newSize = newSize * (Float(size.cx) / bmpSize.cx);
				else if (Float(bmpSize.cy) / size.cy >= Float(bmpSize.cx) / size.cx && bmpSize.cy > size.cy) newSize = newSize * (Float(size.cy) / bmpSize.cy);

				newSize = newSize * surface->GetSurfaceDPI() / 96.0;

				/* Draw image centered.
				 */
				Size	 realSize = GetRealSize();
				Rect	 bmpRect  = Rect(GetRealPosition() + Point(realSize.cx - newSize.cx, realSize.cy - newSize.cy) / 2, newSize);

				surface->StartPaint(GetVisibleArea());

				if (bmpSize != newSize && bitmapScaled.GetSize() != newSize) bitmapScaled = bitmap.Scale(newSize);

				if (bmpSize == newSize) surface->BlitFromBitmap(bitmap,	      Rect(Point(0, 0), bmpSize), bmpRect);
				else			surface->BlitFromBitmap(bitmapScaled, Rect(Point(0, 0), newSize), bmpRect);

				surface->EndPaint();
			}

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %al, %al
je 0x786a7
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
xorl %ebx, %ebx
testl %ebp, %ebp
jne 0x786a7
testb %al, %al
je 0x786a7
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, 0x8(%rsp)
movl 0xb0(%r14), %r15d
movl 0xb4(%r14), %r13d
leaq 0x5b8(%r14), %rdi
movq %rdi, 0x10(%rsp)
callq 0x58410
movq (%rax), %r12
movq %r12, %rbp
shrq $0x20, %rbp
cvtsi2sd %r12d, %xmm3
cvtsi2sd %r15d, %xmm1
movq %r12, (%rsp)
movapd %xmm3, %xmm4
cvtsi2sd %ebp, %xmm2
divsd %xmm1, %xmm4
cvtsi2sd %r13d, %xmm0
movapd %xmm2, %xmm5
divsd %xmm0, %xmm5
ucomisd %xmm5, %xmm4
setae %al
cmpl %r12d, %r15d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x78373
divsd %xmm3, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl (%rsp), %xmm0
mulsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
movapd %xmm0, %xmm3
cmpltsd %xmm2, %xmm3
movsd 0x7c06e(%rip), %xmm4    # 0xf4390
movapd %xmm3, %xmm5
andpd %xmm4, %xmm5
movsd 0x7c066(%rip), %xmm6    # 0xf4398
andnpd %xmm6, %xmm3
orpd %xmm5, %xmm3
addsd %xmm0, %xmm3
cvttsd2si %xmm3, %rax
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%rsp), %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, %xmm1
cmpltsd %xmm2, %xmm1
andpd %xmm1, %xmm4
andnpd %xmm6, %xmm1
orpd %xmm4, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
jmp 0x783f8
ucomisd %xmm4, %xmm5
setae %al
cmpl %ebp, %r13d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x78405
divsd %xmm2, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl (%rsp), %xmm1
mulsd %xmm0, %xmm1
xorpd %xmm2, %xmm2
movapd %xmm1, %xmm3
cmpltsd %xmm2, %xmm3
movsd 0x7bfe4(%rip), %xmm4    # 0xf4390
movapd %xmm3, %xmm5
andpd %xmm4, %xmm5
movsd 0x7bfdc(%rip), %xmm6    # 0xf4398
andnpd %xmm6, %xmm3
orpd %xmm5, %xmm3
addsd %xmm1, %xmm3
cvttsd2si %xmm3, %rax
xorps %xmm1, %xmm1
cvtsi2sdl 0x4(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
cmpltsd %xmm2, %xmm0
andpd %xmm0, %xmm4
andnpd %xmm6, %xmm0
orpd %xmm4, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
shlq $0x20, %rcx
movl %eax, %eax
orq %rcx, %rax
movq %rax, (%rsp)
movq 0x8(%rsp), %rdi
callq 0x58930
cwtl
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl (%rsp), %xmm1
mulsd %xmm0, %xmm1
xorpd %xmm3, %xmm3
movapd %xmm1, %xmm2
cmpltsd %xmm3, %xmm2
movsd 0x7bf58(%rip), %xmm4    # 0xf4390
movapd %xmm2, %xmm3
andpd %xmm4, %xmm3
movsd 0x7bf50(%rip), %xmm5    # 0xf4398
andnpd %xmm5, %xmm2
orpd %xmm3, %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
xorps %xmm1, %xmm1
cvtsi2sdl 0x4(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
xorpd %xmm3, %xmm3
cmpltsd %xmm3, %xmm0
movapd %xmm0, %xmm2
andpd %xmm4, %xmm2
andnpd %xmm5, %xmm0
movapd %xmm5, %xmm6
orpd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x7c051(%rip), %xmm1    # 0xf44f0
divsd %xmm1, %xmm0
movapd %xmm0, %xmm2
cmpltsd %xmm3, %xmm2
xorpd %xmm5, %xmm5
movapd %xmm2, %xmm3
andpd %xmm4, %xmm3
andnpd %xmm6, %xmm2
orpd %xmm3, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %rax
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
divsd %xmm1, %xmm0
movapd %xmm0, %xmm1
cmpltsd %xmm5, %xmm1
movapd %xmm1, %xmm2
andpd %xmm4, %xmm2
andnpd %xmm6, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
shlq $0x20, %rcx
movl %eax, %eax
orq %rcx, %rax
movq %rax, (%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, %r13
movq %rax, %r15
shrq $0x20, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %rsi
shrq $0x20, %rsi
movl (%rsp), %edx
movl 0x4(%rsp), %ecx
subl %edx, %r13d
subl %ecx, %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd 0x7be55(%rip), %xmm3    # 0xf4398
mulsd %xmm3, %xmm0
movapd %xmm0, %xmm1
xorpd %xmm5, %xmm5
cmpltsd %xmm5, %xmm1
movapd %xmm1, %xmm2
movsd 0x7be30(%rip), %xmm4    # 0xf4390
andpd %xmm4, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rdi
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
mulsd %xmm3, %xmm0
movapd %xmm0, %xmm1
cmpltsd %xmm5, %xmm1
movapd %xmm4, %xmm2
andpd %xmm1, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %r8
addl %edi, %eax
addl %esi, %r8d
movl %eax, 0x28(%rsp)
movl %r8d, 0x2c(%rsp)
addl %edx, %eax
movl %eax, 0x30(%rsp)
addl %ecx, %r8d
movl %r8d, 0x34(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x130(%rax)
leaq 0x18(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq 0x8(%rsp), %rdi
callq 0x55160
cmpl %r12d, (%rsp)
jne 0x785ed
cmpl %ebp, 0x4(%rsp)
je 0x78636
leaq 0x5c0(%r14), %r13
movq %r13, %rdi
callq 0x58410
movl (%rax), %ecx
cmpl (%rsp), %ecx
jne 0x7860c
movl 0x4(%rsp), %ecx
cmpl %ecx, 0x4(%rax)
je 0x78636
leaq 0x18(%rsp), %r15
movq %rsp, %rdx
movq %r15, %rdi
movq 0x10(%rsp), %rsi
callq 0x554c0
movq %r13, %rdi
movq %r15, %rsi
callq 0x582c0
leaq 0x18(%rsp), %rdi
callq 0x59148
movl (%rsp), %eax
movl 0x4(%rsp), %ecx
movl %eax, %edx
xorl %r12d, %edx
movl %ecx, %esi
xorl %ebp, %esi
orl %edx, %esi
jne 0x78671
leaq 0x18(%rsp), %rdx
movq $0x0, (%rdx)
movl %r12d, 0x8(%rdx)
movl %ebp, 0xc(%rdx)
leaq 0x28(%rsp), %rcx
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq 0x10(%rsp), %rsi
jmp 0x7869a
addq $0x5c0, %r14            # imm = 0x5C0
leaq 0x18(%rsp), %rdx
movq $0x0, (%rdx)
movl %eax, 0x8(%rdx)
movl %ecx, 0xc(%rdx)
leaq 0x28(%rsp), %rcx
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x55ba0
movq %r15, %rdi
callq 0x58780
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x59148
movq %rbx, %rdi
callq 0x57090
nopl (%rax)