// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x120(%rbp)
movq (%rdi), %rax
callq *0x88(%rax)
testb $0x1, %al
jne 0x9a674
leaq -0x28(%rbp), %rdi
movq %rdi, -0x130(%rbp)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5a9c0
movq -0x130(%rbp), %rdi
callq 0x59680
movl %eax, -0x124(%rbp)
jmp 0x9a643
movl -0x124(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5b5b0
jmp 0x9aac5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5b5b0
jmp 0x9aad1
movq -0x120(%rbp), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
testb $0x1, %al
jne 0x9a6dd
leaq -0x48(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x5ca80
movq -0x140(%rbp), %rdi
callq 0x59680
movl %eax, -0x134(%rbp)
jmp 0x9a6ac
movl -0x134(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5a410
jmp 0x9aac5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5a410
jmp 0x9aad1
movl -0x14(%rbp), %eax
testl %eax, %eax
jne 0x9aa6d
jmp 0x9a6ea
movq -0x120(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0x120(%rbp), %rdi
movq %rax, -0x50(%rbp)
callq 0x5bf70
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x58(%rbp)
addq $0x5b8, %rdi            # imm = 0x5B8
callq 0x5ce60
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
cvtsi2sdl -0x60(%rbp), %xmm0
cvtsi2sdl -0x58(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
cvtsi2sdl -0x54(%rbp), %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9a77f
movl -0x60(%rbp), %eax
cmpl -0x58(%rbp), %eax
jle 0x9a77f
cvtsi2sdl -0x58(%rbp), %xmm0
cvtsi2sdl -0x60(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x68(%rbp), %rdi
callq 0x5a7b0
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x9a7ce
cvtsi2sdl -0x5c(%rbp), %xmm0
cvtsi2sdl -0x54(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x60(%rbp), %xmm1
cvtsi2sdl -0x58(%rbp), %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9a7cc
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jle 0x9a7cc
cvtsi2sdl -0x54(%rbp), %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x68(%rbp), %rdi
callq 0x5a7b0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x9a7ce
movq -0x50(%rbp), %rdi
callq 0x5d470
cwtl
cvtsi2sd %eax, %xmm0
leaq -0x68(%rbp), %rdi
callq 0x5a7b0
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
movsd 0xeccc5(%rip), %xmm0    # 0x1874c0
callq 0x5c6b0
movq -0x120(%rbp), %rdi
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x68(%rbp)
movq (%rdi), %rax
callq *0x50(%rax)
movq -0x120(%rbp), %rdi
movq %rax, -0x90(%rbp)
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, -0xb0(%rbp)
movl -0x90(%rbp), %esi
subl -0x68(%rbp), %esi
movl -0x8c(%rbp), %edx
subl -0x64(%rbp), %edx
leaq -0xc0(%rbp), %rdi
callq 0x5c2c0
leaq -0xc0(%rbp), %rdi
movsd 0xecb17(%rip), %xmm0    # 0x187378
callq 0x5cd70
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x5ca20
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x59ff0
movq -0x120(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x148(%rbp)
movq (%rdi), %rax
callq *0x130(%rax)
movq -0x148(%rbp), %rdi
movq %rax, -0xd0(%rbp)
movq %rdx, -0xc8(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x591b0
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x5d9c0
testb $0x1, %al
jne 0x9a8f0
jmp 0x9a981
movq -0x120(%rbp), %rdi
addq $0x5c0, %rdi            # imm = 0x5C0
callq 0x5ce60
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x5d9c0
testb $0x1, %al
jne 0x9a915
jmp 0x9a981
movq -0x120(%rbp), %rsi
addq $0x5b8, %rsi            # imm = 0x5B8
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x150(%rbp)
leaq -0x68(%rbp), %rdx
callq 0x595f0
movq -0x120(%rbp), %rdi
movq -0x150(%rbp), %rsi
addq $0x5c0, %rdi            # imm = 0x5C0
callq 0x5cca0
jmp 0x9a956
leaq -0xd8(%rbp), %rdi
callq 0x5de40
jmp 0x9a981
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x5de40
jmp 0x9aad1
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x59830
testb $0x1, %al
jne 0x9a994
jmp 0x9a9fd
movq -0x120(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, -0x160(%rbp)
addq $0x5b8, %rax            # imm = 0x5B8
movq %rax, -0x158(%rbp)
leaq -0xf0(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x5c2c0
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x59ff0
movq -0x160(%rbp), %rdi
movq -0x158(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x59dd0
jmp 0x9aa64
movq -0x120(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, -0x170(%rbp)
addq $0x5c0, %rax            # imm = 0x5C0
movq %rax, -0x168(%rbp)
leaq -0x108(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x5c2c0
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x59ff0
movq -0x170(%rbp), %rdi
movq -0x168(%rbp), %rsi
leaq -0x100(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x59dd0
movq -0x50(%rbp), %rdi
callq 0x5d270
leaq -0x118(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x5ca80
movq -0x180(%rbp), %rdi
callq 0x59680
movl %eax, -0x174(%rbp)
jmp 0x9aa94
movl -0x174(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x5a410
jmp 0x9aac5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x5a410
jmp 0x9aad1
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x5b6b0
nopw (%rax,%rax)