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

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

				surface->StartPaint(frame);

				if (message == SP_PAINT)
				{
					Font	 nFont = font;

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

					surface->Box(frame, GetBackgroundColor(), Rect::Filled);
					surface->SetText(text, frame + Point(frame.GetHeight(), Math::Ceil(Float(frame.GetHeight() - scaledTextSize.cy) / 2) - 1), nFont);
				}

				Float	 scaleFactor = surface->GetSurfaceDPI() / 96.0;
				Int	 inset	     = 3 * scaleFactor;

				Point	 lineStart   = Point(frame.left, frame.top) + Point(3, 3) * scaleFactor + Point(inset + (IsRightToLeft() ? 1 : 0), 0);
				Point	 lineEnd     = lineStart + Point(11 * scaleFactor - 2 * inset, 0);

				Int	 lightColor  = Color(Math::Min(Setup::BackgroundColor.GetRed() + 64, 255), Math::Min(Setup::BackgroundColor.GetGreen() + 64, 255), Math::Min(Setup::BackgroundColor.GetBlue() + 64, 255));
				Int	 darkColor   = Color(Math::Max(Setup::BackgroundColor.GetRed() - 64, 0), Math::Max(Setup::BackgroundColor.GetGreen() - 64, 0), Math::Max(Setup::BackgroundColor.GetBlue() - 64, 0));

				Int	 innerColor  = (IsActive() ? Setup::ClientColor : Setup::BackgroundColor);

				surface->Line(lineStart, lineEnd, darkColor);

				for (Int i = 0; i < Int(11 * scaleFactor) - 2; i++)
				{
					if	(i <			      inset) { lineStart.x--; lineEnd.x++; }
					else if (i > (11 * scaleFactor) - 2 - inset) { lineStart.x++; lineEnd.x--; }

					lineStart.y++;
					lineEnd.y++;

					surface->Line(lineStart, lineEnd, innerColor);

					Int	 leftColor  = (i > (11 * scaleFactor) - 2 - inset) ? lightColor : (IsRightToLeft() ? lightColor : darkColor);
					Int	 rightColor = (i > (11 * scaleFactor) - 2 - inset) ? lightColor : (IsRightToLeft() ? darkColor : lightColor);

					surface->SetPixel(lineStart, leftColor);
					surface->SetPixel(lineEnd - Point(1, 0), rightColor);
				}

				lineStart.x++;
				lineStart.y++;
				lineEnd.x--;
				lineEnd.y++;

				surface->Line(lineStart, lineEnd, lightColor);

				if (*variable == code)
				{
					for (Int i = 0; i < 2; i++)
					{
						Int	 color	= IsActive() ? Setup::DividerDarkColor : Setup::DividerDarkColor.Average(Setup::BackgroundColor);
						Point	 offset	= Point(IsRightToLeft() ? 0 : 1, 0);

						if (i == 1)
						{
							color	= IsActive() ? Setup::ClientTextColor : Setup::InactiveTextColor;
							offset -= Point(IsRightToLeft() ? -i : i, i);
						}

						Int	 inset	    = 2 * scaleFactor;

						Point	 lineStart  = Point(frame.left, frame.top) + Point(6, 6) * scaleFactor + offset + Point(inset, 0);
						Point	 lineEnd    = lineStart + Point(5 * scaleFactor - 2 * inset, 0);

						for (Int j = 0; j < Int(5 * scaleFactor); j++)
						{
							if	(j <			 inset) { lineStart.x--; lineEnd.x++; }
							else if (j > (5 * scaleFactor) - inset) { lineStart.x++; lineEnd.x--; }

							lineStart.y++;
							lineEnd.y++;

							surface->Line(lineStart, lineEnd, color);
						}
					}
				}

				surface->EndPaint();
			}

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %esi, %ebp
movq %rdi, %r12
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb %al, %al
je 0x79e63
movq (%r12), %rax
movq %r12, %rdi
callq *0x90(%rax)
xorl %ecx, %ecx
cmpl $0x1, %ebp
ja 0x79e63
testb %al, %al
je 0x79e63
movq (%r12), %rax
movq %r12, %rdi
callq *0x40(%rax)
movq %rax, %r14
movq (%r12), %rax
movq %r12, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %rbx
shrq $0x20, %rbx
movq (%r12), %rax
movq %r12, %rdi
callq *0x50(%rax)
leal (%rax,%r15), %ecx
shrq $0x20, %rax
leaq 0x28(%rsp), %rsi
movl %r15d, (%rsi)
movl %ebx, 0x4(%rsi)
movl %ecx, 0x8(%rsi)
addl %ebx, %eax
movl %eax, 0xc(%rsi)
movq %r14, %rdi
callq 0x55160
testl %ebp, %ebp
jne 0x798ed
leaq 0x140(%r12), %rsi
leaq 0x70(%rsp), %rdi
callq 0x55b70
movq (%r12), %rax
movq %r12, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x79846
movq 0xf3114(%rip), %rsi     # 0x16c950
leaq 0x70(%rsp), %rdi
callq 0x58650
movq (%r12), %rax
movq %r12, %rdi
callq *0x140(%rax)
movq 0xf374e(%rip), %rcx     # 0x16cfa8
movl (%rcx), %ecx
leaq 0x60(%rsp), %r8
movq $0x0, (%r8)
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
movq %rax, %rdx
callq 0x57930
movl 0x34(%rsp), %ebx
subl 0x2c(%rsp), %ebx
movl %ebx, %eax
subl 0x18c(%r12), %eax
cvtsi2sd %eax, %xmm0
mulsd 0x7ab02(%rip), %xmm0    # 0xf4398
callq 0x56cb0
leaq 0xf0(%r12), %rsi
decl %eax
movl 0x28(%rsp), %ecx
addl %ebx, %ecx
movl 0x2c(%rsp), %edx
addl %eax, %edx
shlq $0x20, %rdx
addl 0x30(%rsp), %ebx
addl 0x34(%rsp), %eax
orq %rdx, %rcx
shlq $0x20, %rax
orq %rax, %rbx
leaq 0x60(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, 0x8(%rdx)
leaq 0x70(%rsp), %rcx
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x57b80
leaq 0x70(%rsp), %rdi
callq 0x56720
movq %r14, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm1
divsd 0x7abee(%rip), %xmm1    # 0xf44f0
movsd %xmm1, 0x50(%rsp)
movsd 0x7ac50(%rip), %xmm0    # 0xf4560
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
cvttsd2si %xmm0, %r15d
leaq 0x7ae63(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rbx
movq %r14, 0xb0(%rsp)
movl 0x2c(%rsp), %r14d
addl %ebx, %r14d
shlq $0x20, %r14
movq (%r12), %rax
movl 0x28(%rsp), %ebp
addl %r15d, %ebp
movq %r12, %rdi
callq *0x160(%rax)
movzbl %al, %ecx
addl %ebp, %ecx
addl %ebx, %ecx
leaq (%rcx,%r14), %rax
leaq 0x60(%rsp), %rdx
movq %rax, (%rdx)
movq %r15, 0x40(%rsp)
leal (%r15,%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x7d5e6(%rip), %xmm1    # 0xf6f70
mulsd 0x50(%rsp), %xmm1
movsd %xmm1, (%rsp)
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
addl %ecx, %eax
movl 0x4(%rdx), %ecx
shlq $0x20, %rcx
orq %rcx, %rax
movq 0xf2b20(%rip), %r14     # 0x16c4d0
movl 0x8(%r14), %ecx
movl $0xff, %r9d
movl %ecx, %edx
andl %r9d, %edx
movl $0xbf, %esi
cmpl %esi, %edx
movl $0xbf, %r8d
cmovll %edx, %r8d
addl $0x40, %r8d
movq %r12, %rdi
movl %ecx, %r13d
shrl $0x8, %r13d
andl %r9d, %r13d
cmpl %esi, %r13d
movl $0xbf, %ebx
cmovll %r13d, %ebx
shrl $0x10, %ecx
andl %r9d, %ecx
cmpl %esi, %ecx
cmovll %ecx, %esi
shll $0x10, %esi
addl $0x400000, %esi         # imm = 0x400000
shll $0x8, %ebx
addl $0x4000, %ebx           # imm = 0x4000
orl %r8d, %ebx
orl %esi, %ebx
cmpl $0x41, %edx
movl $0x40, %esi
cmovll %esi, %edx
addl $-0x40, %edx
cmpl $0x41, %r13d
cmovll %esi, %r13d
movq 0xb0(%rsp), %r12
leaq 0x10(%rsp), %r8
cmpl $0x41, %ecx
cmovll %esi, %ecx
movq %rax, (%r8)
shll $0x10, %ecx
addl $0xffc00000, %ecx       # imm = 0xFFC00000
shll $0x8, %r13d
addl $0xffffc000, %r13d      # imm = 0xFFFFC000
orl %edx, %r13d
orl %ecx, %r13d
movq (%rdi), %rax
movq %rdi, 0x48(%rsp)
callq *0x98(%rax)
movl %eax, %r15d
movq 0xf2c03(%rip), %rax     # 0x16c670
movq 0x8(%rax), %rbp
movq 0x8(%r14), %r14
leaq 0x70(%rsp), %rcx
movq %r13, 0x38(%rsp)
movq %r13, 0x8(%rcx)
movl $0x0, (%rcx)
movq %r12, %r13
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x58300
xorpd %xmm1, %xmm1
movsd (%rsp), %xmm2
cvttsd2si %xmm2, %eax
movl %eax, 0xc(%rsp)
cmpl $0x3, %eax
jl 0x79c16
testb %r15b, %r15b
cmovneq %rbp, %r14
addsd 0x7d4b1(%rip), %xmm2    # 0xf6f78
cvtsi2sdl 0x40(%rsp), %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, (%rsp)
movslq %r14d, %rax
movq %rax, 0xc0(%rsp)
addl $-0x2, 0xc(%rsp)
xorl %r15d, %r15d
cmpl 0x40(%rsp), %r15d
movsd %xmm1, 0x20(%rsp)
jge 0x79b00
decl 0x60(%rsp)
incl 0x10(%rsp)
jmp 0x79b0f
ucomisd (%rsp), %xmm1
jbe 0x79b0f
incl 0x60(%rsp)
decl 0x10(%rsp)
incl 0x64(%rsp)
incl 0x14(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x78(%rsp)
movl $0x0, 0x70(%rsp)
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x70(%rsp), %rcx
callq 0x58300
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
ucomisd (%rsp), %xmm0
movq %rbx, %rbp
ja 0x79b80
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
movsd %xmm0, 0xb8(%rsp)
callq *0x160(%rax)
movsd 0xb8(%rsp), %xmm0
testb %al, %al
movq 0x38(%rsp), %rbp
cmovneq %rbx, %rbp
ucomisd (%rsp), %xmm0
movq %rbx, %r14
ja 0x79ba3
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
callq *0x160(%rax)
testb %al, %al
movq %rbx, %r14
cmovneq 0x38(%rsp), %r14
movq %rbp, 0x78(%rsp)
xorl %eax, %eax
movl %eax, 0x70(%rsp)
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
movq %rbx, %r12
leaq 0x70(%rsp), %rbx
movq %rbx, %rdx
callq 0x55120
movl 0x10(%rsp), %eax
movl 0x14(%rsp), %ecx
decl %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x18(%rsp)
movq %r14, 0x78(%rsp)
xorl %eax, %eax
movl %eax, 0x70(%rsp)
movq %r13, %rdi
leaq 0x18(%rsp), %rsi
movq %rbx, %rdx
movq %r12, %rbx
callq 0x55120
movsd 0x20(%rsp), %xmm1
addsd 0x7a780(%rip), %xmm1    # 0xf4388
incl %r15d
cmpl %r15d, 0xc(%rsp)
jne 0x79ae9
leaq 0x60(%rsp), %rsi
incl (%rsi)
incl 0x4(%rsi)
leaq 0x10(%rsp), %rdx
decl (%rdx)
incl 0x4(%rdx)
leaq 0x70(%rsp), %rcx
movq %rbx, 0x8(%rcx)
movl $0x0, (%rcx)
movq %r13, %rdi
callq 0x58300
movq 0x48(%rsp), %r12
movq 0x5b8(%r12), %rax
movl (%rax), %eax
cmpl 0x5c0(%r12), %eax
jne 0x79e59
movsd 0x50(%rsp), %xmm3
movapd %xmm3, %xmm0
addsd %xmm3, %xmm0
cvttsd2si %xmm0, %r15d
movsd 0x7d1a7(%rip), %xmm1    # 0xf6e20
mulsd %xmm3, %xmm1
xorpd %xmm2, %xmm2
xorl %eax, %eax
ucomisd %xmm1, %xmm2
seta %al
leaq 0x7aaff(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm1
cvttsd2si %xmm1, %rcx
movq %rcx, 0x40(%rsp)
leal (%rcx,%r15), %eax
movl %eax, 0xc(%rsp)
leal (%r15,%r15), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x7d2c5(%rip), %xmm3    # 0xf6f80
movapd %xmm3, %xmm2
subsd %xmm1, %xmm2
cvttsd2si %xmm2, %eax
movl %eax, 0x38(%rsp)
cvttsd2si %xmm3, %ebx
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
subsd %xmm0, %xmm3
movsd %xmm3, 0x50(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x70(%rsp), %rbp
movq (%r12), %rax
movq %r12, %rdi
callq *0x98(%rax)
testb %al, %al
je 0x79d18
movq 0xf2b81(%rip), %rcx     # 0x16c888
movq 0x8(%rcx), %rax
movq %rax, 0x78(%rsp)
movl (%rcx), %eax
movl %eax, 0x70(%rsp)
jmp 0x79d2e
movq %rbp, %rdi
movq 0xf2b66(%rip), %rsi     # 0x16c888
movq 0xf27a7(%rip), %rdx     # 0x16c4d0
callq 0x58200
movq 0x78(%rsp), %rax
movq %rax, (%rsp)
movq (%r12), %rax
movq %r12, %rdi
callq *0x160(%rax)
xorb $0x1, %al
movzbl %al, %r14d
xorl %eax, %eax
cmpl $0x1, 0x20(%rsp)
jne 0x79d9a
movq (%r12), %rax
movq %r12, %rdi
callq *0x98(%rax)
movq 0xf2be9(%rip), %rcx     # 0x16c950
testb %al, %al
je 0x79d72
movq 0xf307e(%rip), %rcx     # 0x16cdf0
movq 0x8(%rcx), %rax
movq %rax, (%rsp)
movq (%r12), %rax
movq %r12, %rdi
callq *0x160(%rax)
movzbl %al, %ecx
decl %ecx
orl $0x1, %ecx
addl %r14d, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %ecx, %r14d
addl 0x40(%rsp), %eax
addl 0x2c(%rsp), %eax
addl 0xc(%rsp), %r14d
shlq $0x20, %rax
addl 0x28(%rsp), %r14d
addq %r14, %rax
movq %rax, 0x18(%rsp)
addl 0x38(%rsp), %r14d
movl 0x1c(%rsp), %eax
shlq $0x20, %rax
orq %rax, %r14
movq %r14, 0x58(%rsp)
testl %ebx, %ebx
jle 0x79e3f
movslq (%rsp), %r14
xorl %r12d, %r12d
xorpd %xmm0, %xmm0
cmpl %r15d, %r12d
movsd %xmm0, (%rsp)
jge 0x79df0
decl 0x18(%rsp)
incl 0x58(%rsp)
jmp 0x79e00
ucomisd 0x50(%rsp), %xmm0
jbe 0x79e00
incl 0x18(%rsp)
decl 0x58(%rsp)
incl 0x1c(%rsp)
incl 0x5c(%rsp)
movq %r14, 0x78(%rsp)
movl $0x0, 0x70(%rsp)
movq %r13, %rdi
leaq 0x18(%rsp), %rsi
leaq 0x58(%rsp), %rdx
movq %rbp, %rcx
callq 0x58300
movsd (%rsp), %xmm0
addsd 0x7a551(%rip), %xmm0    # 0xf4388
incl %r12d
cmpl %r12d, %ebx
jne 0x79ddc
movq 0x20(%rsp), %rcx
leal 0x1(%rcx), %eax
testl %ecx, %ecx
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %r12
je 0x79cef
movq %r13, %rdi
callq 0x58780
xorl %ecx, %ecx
movl %ecx, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x79e7b
jmp 0x79e7b
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x56720
movq %rbx, %rdi
callq 0x57090