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

	switch (message)
	{
		case SP_PAINT:
			{
				Surface	*surface = GetDrawSurface();
				Rect	 frame	 = Rect(GetRealPosition(), GetRealSize());

				if (!(flags & BF_NOFRAME))
				{
					surface->Frame(frame, FRAME_DOWN);
					surface->Frame(Rect(GetRealPosition() + Point(1, 1), GetRealSize() - Size(2, 2)), FRAME_UP);
				}

				if (text != NIL)
				{
					Rect	 textRect;

					textRect.left	= frame.left + ((frame.GetWidth() - scaledTextSize.cx) / 2);

					if (bitmap != NIL) textRect.left = frame.left + ((frame.GetWidth() - scaledTextSize.cx - bitmap.GetSize().cx - 7) / 2) + bitmap.GetSize().cx + 7;

					textRect.top	= frame.top + Math::Ceil(Float(frame.GetHeight() - scaledTextSize.cy) / 2) - 1;
					textRect.right	= textRect.left + scaledTextSize.cx + 1;
					textRect.bottom	= textRect.top + Math::Round(scaledTextSize.cy * 1.2);

					Font	 nFont = font;

					if (!IsActive()) nFont.SetColor(Setup::InactiveTextColor);

					surface->Box(textRect, GetBackgroundColor(), Rect::Filled);
					surface->SetText(text, textRect, nFont);
				}

				if (bitmap != NIL)
				{
					Size	 size	  = GetSize();
					Size	 bmpSize  = bitmap.GetSize();

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

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

					Rect	 bmpRect;

					bmpRect.left	= frame.left + (frame.GetWidth() - bmpSize.cx) / 2;

					if (text != NIL) bmpRect.left = frame.left + (frame.GetWidth() - bmpSize.cx - scaledTextSize.cx - 7) / 2;

					bmpRect.top	= frame.top + (frame.GetHeight() - bmpSize.cy) / 2;
					bmpRect.right	= bmpRect.left + bmpSize.cx;
					bmpRect.bottom	= bmpRect.top + bmpSize.cy;

					if (IsActive())
					{
						surface->BlitFromBitmap(bitmap, Rect(Point(0, 0), bitmap.GetSize()), bmpRect);
					}
					else
					{
						Bitmap	 graymap(bitmap);

						graymap.GrayscaleBitmap();

						surface->BlitFromBitmap(graymap, Rect(Point(0, 0), bitmap.GetSize()), bmpRect);
					}
				}
			}

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
je 0x73a74
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testl %ebx, %ebx
jne 0x73a74
testb %al, %al
je 0x73a74
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r13
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %rbx
shrq $0x20, %rbx
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%rax,%r15), %ecx
shrq $0x20, %rax
movl %r15d, 0x8(%rsp)
movl %ebx, 0xc(%rsp)
movl %ecx, 0x10(%rsp)
addl %ebx, %eax
movl %eax, 0x14(%rsp)
testb $0x1, 0x30(%r14)
jne 0x73546
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
movl $0x1, %edx
callq 0x57890
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %rbx
shrq $0x20, %rbx
leal 0x1(%rbx), %ebp
leal 0x1(%rax), %r12d
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%r15,%rax), %ecx
decl %ecx
shrq $0x20, %rax
leaq 0x40(%rsp), %rsi
movl %r12d, (%rsi)
movl %ebp, 0x4(%rsi)
movl %ecx, 0x8(%rsi)
addl %ebx, %eax
decl %eax
movl %eax, 0xc(%rsi)
movq %r13, %rdi
xorl %edx, %edx
callq 0x57890
leaq 0xf0(%r14), %rbp
movq %rbp, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
movq %rbp, 0x38(%rsp)
je 0x736f8
movl 0x8(%rsp), %eax
movl 0x10(%rsp), %ecx
movl 0x188(%r14), %edx
addl %eax, %edx
subl %edx, %ecx
movl %ecx, %ebx
shrl $0x1f, %ebx
addl %ecx, %ebx
sarl %ebx
addl %eax, %ebx
movl %ebx, 0x20(%rsp)
leaq 0x5b8(%r14), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x563f0
testb %al, %al
je 0x735f6
movl 0x8(%rsp), %ebx
movl 0x10(%rsp), %r15d
movq %r13, %rbp
movl 0x188(%r14), %r13d
addl %ebx, %r13d
movq %r12, %rdi
callq 0x58410
addl (%rax), %r13d
movl %r15d, %eax
subl %r13d, %eax
negl %r13d
leal (%r15,%r13), %ecx
addl $-0x7, %ecx
movq %rbp, %r13
movq 0x38(%rsp), %rbp
shrl $0x1f, %ecx
leal (%rcx,%rax), %r15d
addl $-0x7, %r15d
sarl %r15d
movq %r12, %rdi
callq 0x58410
addl (%rax), %ebx
addl %r15d, %ebx
addl $0x7, %ebx
movl %ebx, 0x20(%rsp)
movl 0xc(%rsp), %r15d
movl 0x14(%rsp), %eax
movl 0x18c(%r14), %ecx
addl %r15d, %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd 0x7fd81(%rip), %xmm0    # 0xf3398
callq 0x56cb0
movl %r15d, %ecx
addl %eax, %ecx
addl %r15d, %eax
decl %eax
movl %eax, 0x24(%rsp)
movl 0x188(%r14), %eax
leal 0x1(%rbx,%rax), %eax
movl %eax, 0x28(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x18c(%r14), %xmm0
mulsd 0x8259b(%rip), %xmm0    # 0xf5be8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x824d7(%rip), %rdx     # 0xf5b38
addsd (%rdx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
leal -0x1(%rax,%rcx), %eax
movl %eax, 0x2c(%rsp)
leaq 0x140(%r14), %rsi
leaq 0x40(%rsp), %rdi
callq 0x55b70
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x736a5
movq 0xf82b5(%rip), %rsi     # 0x16b950
leaq 0x40(%rsp), %rdi
callq 0x58650
movq (%r14), %rax
movq %r14, %rdi
callq *0x140(%rax)
movq 0xf88f0(%rip), %rcx     # 0x16bfa8
movl (%rcx), %ecx
leaq 0x18(%rsp), %r8
movq $0x0, (%r8)
leaq 0x20(%rsp), %rsi
movq %r13, %rdi
movq %rax, %rdx
callq 0x57930
leaq 0x20(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %r13, %rdi
movq %rbp, %rsi
xorl %r8d, %r8d
callq 0x57b80
leaq 0x40(%rsp), %rdi
callq 0x56720
leaq 0x5b8(%r14), %r12
xorl %ebp, %ebp
movq %r12, %rdi
xorl %esi, %esi
callq 0x563f0
testb %al, %al
je 0x73a74
movq %r13, 0x30(%rsp)
movsd 0xb0(%r14), %xmm0
movaps %xmm0, 0x80(%rsp)
movq %r12, %rdi
callq 0x58410
movdqa 0x80(%rsp), %xmm4
movq (%rax), %xmm1
cvtdq2pd %xmm1, %xmm0
cvtdq2pd %xmm4, %xmm3
movapd %xmm0, %xmm2
divpd %xmm3, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
ucomisd %xmm3, %xmm2
movd %xmm1, %r13d
jb 0x737e5
movd %xmm4, %eax
addl $-0xc, %eax
cmpl %r13d, %eax
jge 0x737e5
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm2
mulsd %xmm0, %xmm2
xorpd %xmm3, %xmm3
movapd %xmm2, %xmm4
cmpltsd %xmm3, %xmm4
movsd 0x7fbf7(%rip), %xmm5    # 0xf3390
movapd %xmm4, %xmm6
andpd %xmm5, %xmm6
movsd 0x7fbef(%rip), %xmm7    # 0xf3398
andnpd %xmm7, %xmm4
orpd %xmm6, %xmm4
addsd %xmm2, %xmm4
cvttsd2si %xmm4, %r13
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
mulsd %xmm1, %xmm0
movapd %xmm0, %xmm1
cmpltsd %xmm3, %xmm1
andpd %xmm1, %xmm5
andnpd %xmm7, %xmm1
orpd %xmm5, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rbx
jmp 0x73873
ucomisd %xmm2, %xmm3
pshufd $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
movd %xmm1, %ebx
jb 0x73873
pshufd $0x55, %xmm4, %xmm1     # xmm1 = xmm4[1,1,1,1]
movd %xmm1, %eax
addl $-0xc, %eax
cmpl %ebx, %eax
jge 0x73873
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
xorpd %xmm3, %xmm3
movapd %xmm0, %xmm4
cmpltsd %xmm3, %xmm4
movsd 0x7fb60(%rip), %xmm5    # 0xf3390
movapd %xmm4, %xmm6
andpd %xmm5, %xmm6
movsd 0x7fb58(%rip), %xmm7    # 0xf3398
andnpd %xmm7, %xmm4
orpd %xmm6, %xmm4
addsd %xmm0, %xmm4
cvttsd2si %xmm4, %r13
mulsd %xmm2, %xmm1
movapd %xmm1, %xmm0
cmpltsd %xmm3, %xmm0
andpd %xmm0, %xmm5
andnpd %xmm7, %xmm0
orpd %xmm5, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rbx
movq 0x30(%rsp), %rdi
callq 0x58930
cwtl
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
xorps %xmm4, %xmm4
cvtsi2sd %r13d, %xmm4
mulsd %xmm3, %xmm4
xorpd %xmm1, %xmm1
movapd %xmm4, %xmm5
cmpltsd %xmm1, %xmm5
movsd 0x7faea(%rip), %xmm0    # 0xf3390
movapd %xmm5, %xmm6
andpd %xmm0, %xmm6
movsd 0x7fae2(%rip), %xmm2    # 0xf3398
andnpd %xmm2, %xmm5
orpd %xmm6, %xmm5
addsd %xmm4, %xmm5
cvttsd2si %xmm5, %rax
xorps %xmm4, %xmm4
cvtsi2sd %ebx, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm4, %xmm3
cmpltsd %xmm1, %xmm3
movapd %xmm3, %xmm5
andpd %xmm0, %xmm5
andnpd %xmm2, %xmm3
orpd %xmm5, %xmm3
addsd %xmm4, %xmm3
cvttsd2si %xmm3, %rcx
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
movsd 0x7fdb5(%rip), %xmm4    # 0xf36b8
divsd %xmm4, %xmm3
movapd %xmm3, %xmm5
cmpltsd %xmm1, %xmm5
movapd %xmm5, %xmm6
andpd %xmm0, %xmm6
andnpd %xmm2, %xmm5
orpd %xmm6, %xmm5
addsd %xmm3, %xmm5
cvttsd2si %xmm5, %r13
xorps %xmm3, %xmm3
cvtsi2sd %ecx, %xmm3
divsd %xmm4, %xmm3
movapd %xmm3, %xmm4
cmpltsd %xmm1, %xmm4
andpd %xmm4, %xmm0
andnpd %xmm2, %xmm4
orpd %xmm0, %xmm4
addsd %xmm3, %xmm4
cvttsd2si %xmm4, %rbx
movl 0x8(%rsp), %eax
movl 0x10(%rsp), %ecx
subl %eax, %ecx
subl %r13d, %ecx
movl %ecx, %r15d
shrl $0x1f, %r15d
addl %ecx, %r15d
sarl %r15d
addl %eax, %r15d
movl %r15d, 0x40(%rsp)
movq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0x739b8
movl 0x8(%rsp), %eax
movl 0x10(%rsp), %ecx
leal (%rax,%r13), %edx
addl 0x188(%r14), %edx
movl %ecx, %esi
subl %edx, %esi
negl %edx
addl %edx, %ecx
addl $-0x7, %ecx
shrl $0x1f, %ecx
leal (%rcx,%rsi), %r15d
addl $-0x7, %r15d
sarl %r15d
addl %eax, %r15d
movl %r15d, 0x40(%rsp)
movl 0xc(%rsp), %eax
movl 0x14(%rsp), %ecx
subl %eax, %ecx
subl %ebx, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
addl %eax, %edx
movl %edx, 0x44(%rsp)
addl %r13d, %r15d
movl %r15d, 0x48(%rsp)
addl %ebx, %edx
movl %edx, 0x4c(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
je 0x73a20
movq %r12, %rdi
callq 0x58410
leaq 0x20(%rsp), %rdx
movq $0x0, (%rdx)
movq (%rax), %rax
movq %rax, 0x8(%rdx)
leaq 0x40(%rsp), %rcx
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x55ba0
jmp 0x73a74
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x57160
movq %r14, %rdi
callq 0x56db0
movq 0x30(%rsp), %rbx
movq %r12, %rdi
callq 0x58410
leaq 0x20(%rsp), %rdx
movq $0x0, (%rdx)
movq (%rax), %rax
movq %rax, 0x8(%rdx)
leaq 0x18(%rsp), %rsi
leaq 0x40(%rsp), %rcx
movq %rbx, %rdi
callq 0x55ba0
leaq 0x18(%rsp), %rdi
callq 0x59148
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x73a8a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x59148
jmp 0x73aa8
jmp 0x73a9b
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x56720
movq %rbx, %rdi
callq 0x57090