// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb %al, %al
je 0x78330
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
xorl %ecx, %ecx
testl %ebp, %ebp
jne 0x78330
testb %al, %al
je 0x78330
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %rbx
movl 0xb0(%r14), %r15d
movl 0xb4(%r14), %ebp
leaq 0x5b8(%r14), %rdi
movq %rdi, 0x10(%rsp)
callq 0x58410
movq (%rax), %rdx
movq %rdx, %rsi
cvtsi2sd %edx, %xmm1
cvtsi2sd %r15d, %xmm3
shrq $0x20, %rsi
movapd %xmm1, %xmm4
cvtsi2sd %esi, %xmm0
divsd %xmm3, %xmm4
cvtsi2sd %ebp, %xmm2
movapd %xmm0, %xmm5
divsd %xmm2, %xmm5
ucomisd %xmm5, %xmm4
setae %al
cmpl %edx, %r15d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
movq %rsi, 0x18(%rsp)
movq %rdx, 0x40(%rsp)
jne 0x78018
divsd %xmm1, %xmm3
mulsd %xmm3, %xmm1
xorpd %xmm2, %xmm2
movapd %xmm1, %xmm4
cmpltsd %xmm2, %xmm4
movsd 0x7b3b8(%rip), %xmm5    # 0xf3390
movapd %xmm4, %xmm6
andpd %xmm5, %xmm6
movsd 0x7b3b0(%rip), %xmm7    # 0xf3398
andnpd %xmm7, %xmm4
orpd %xmm6, %xmm4
addsd %xmm1, %xmm4
cvttsd2si %xmm4, %r15
mulsd %xmm0, %xmm3
movapd %xmm3, %xmm0
cmpltsd %xmm2, %xmm0
andpd %xmm0, %xmm5
andnpd %xmm7, %xmm0
orpd %xmm5, %xmm0
addsd %xmm3, %xmm0
jmp 0x7808c
ucomisd %xmm4, %xmm5
setae %al
cmpl %esi, %ebp
setl %cl
andb %al, %cl
movq %rsi, %r13
movl %edx, %r15d
cmpb $0x1, %cl
jne 0x78091
divsd %xmm0, %xmm2
mulsd %xmm2, %xmm1
xorpd %xmm3, %xmm3
movapd %xmm1, %xmm4
cmpltsd %xmm3, %xmm4
movsd 0x7b342(%rip), %xmm5    # 0xf3390
movapd %xmm4, %xmm6
andpd %xmm5, %xmm6
movsd 0x7b33a(%rip), %xmm7    # 0xf3398
andnpd %xmm7, %xmm4
orpd %xmm6, %xmm4
addsd %xmm1, %xmm4
cvttsd2si %xmm4, %r15
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm0
cmpltsd %xmm3, %xmm0
andpd %xmm0, %xmm5
andnpd %xmm7, %xmm0
orpd %xmm5, %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %r13
movq %rbx, %rdi
callq 0x58930
cwtl
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
mulsd %xmm0, %xmm1
xorpd %xmm3, %xmm3
movapd %xmm1, %xmm2
cmpltsd %xmm3, %xmm2
movsd 0x7b2ce(%rip), %xmm4    # 0xf3390
movapd %xmm2, %xmm3
andpd %xmm4, %xmm3
movsd 0x7b2c6(%rip), %xmm5    # 0xf3398
andnpd %xmm5, %xmm2
orpd %xmm3, %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %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 0x7b590(%rip), %xmm1    # 0xf36b8
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, %r15
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, %rbp
movq %rbp, %rax
shlq $0x20, %rax
movl %r15d, %ecx
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, %r13
movq %rax, %r12
shrq $0x20, %r12
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %rcx
shrq $0x20, %rcx
subl %r15d, %r13d
subl %ebp, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd 0x7b1ce(%rip), %xmm3    # 0xf3398
mulsd %xmm3, %xmm0
movapd %xmm0, %xmm1
xorpd %xmm5, %xmm5
cmpltsd %xmm5, %xmm1
movapd %xmm1, %xmm2
movsd 0x7b1a9(%rip), %xmm4    # 0xf3390
andpd %xmm4, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movq %rbx, %r12
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, %rsi
addl %edx, %eax
addl %ecx, %esi
movl %eax, 0x30(%rsp)
movl %esi, 0x34(%rsp)
addl %r15d, %eax
movl %eax, 0x38(%rsp)
addl %ebp, %esi
movl %esi, 0x3c(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x130(%rax)
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x55160
movq 0x40(%rsp), %rbx
cmpl %ebx, %r15d
jne 0x7827d
movq 0x18(%rsp), %rax
movl %eax, %ecx
movl %ebx, %esi
cmpl %eax, %ebp
je 0x782cf
leaq 0x5c0(%r14), %r13
movq %r13, %rdi
callq 0x58410
cmpl %r15d, (%rax)
jne 0x7829b
movl %ebp, %ecx
movl %r15d, %esi
cmpl %ebp, 0x4(%rax)
je 0x782cf
leaq 0x20(%rsp), %r15
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
movq 0x10(%rsp), %rsi
callq 0x554c0
movq %r13, %rdi
movq %r15, %rsi
callq 0x582c0
leaq 0x20(%rsp), %rdi
callq 0x59148
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %ecx
cmpl %ebx, %esi
movq 0x18(%rsp), %rax
jne 0x782fd
cmpl %eax, %ecx
jne 0x782fd
leaq 0x20(%rsp), %rdx
movq $0x0, (%rdx)
movl %ebx, 0x8(%rdx)
movl %eax, 0xc(%rdx)
leaq 0x30(%rsp), %rcx
movq %r12, %rdi
movq 0x10(%rsp), %rsi
jmp 0x78321
addq $0x5c0, %r14            # imm = 0x5C0
leaq 0x20(%rsp), %rdx
movq $0x0, (%rdx)
movl %esi, 0x8(%rdx)
movl %ecx, 0xc(%rdx)
leaq 0x30(%rsp), %rcx
movq %r12, %rdi
movq %r14, %rsi
callq 0x55ba0
movq %r12, %rdi
callq 0x58780
xorl %ecx, %ecx
movl %ecx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x59148
movq %rbx, %rdi
callq 0x57090
nop