// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/gui/window/window.cpp
// Function: smooth::GUI::Window::Paint(int)
S::Int S::GUI::Window::Paint(Int message)
{
	if (!IsRegistered()) return Error();
	if (!created)	     return Success();
	if (!IsVisible())    return Success();

	if (updateRect.GetWidth() == 0 || updateRect.GetHeight() == 0) return Success();

	EnterProtectedRegion();

	Surface	*surface = GetDrawSurface();

#ifdef __WIN32__
	static Bool	 flatStyle = Backends::BackendWin32::IsWindowsVersionAtLeast(VER_PLATFORM_WIN32_NT, 6, 2);
#else
	static Bool	 flatStyle = True;
#endif

	Size	 realSize = GetRealSize();
	Float	 fontSize = surface->GetSurfaceDPI() / 96.0;

	if (updateRect.left < frameWidth)		  updateRect.left   = frameWidth - 1;
	if (updateRect.top  < frameWidth)		  updateRect.top    = frameWidth - 1;
	if (realSize.cx - updateRect.right  < frameWidth) updateRect.right  = realSize.cx - frameWidth + 1;
	if (realSize.cy - updateRect.bottom < frameWidth) updateRect.bottom = realSize.cy - frameWidth + 1;

	Rect	 workArea = System::Screen::GetVirtualScreenMetrics();

	if (message == SP_UPDATE				 &&
	    GetPosition().x		   > workArea.left   - 2 &&
	    GetPosition().y		   > workArea.top    - 2 &&
	    GetPosition().x + GetSize().cx < workArea.right  + 2 &&
	    GetPosition().y + GetSize().cy < workArea.bottom + 2)
	{
		surface->PaintRect(updateRect);
	}
	else
	{
		RightToLeftModifier	 rightToLeft;

		rightToLeft.SetSurfaceSize(surface->GetSize());
		rightToLeft.SetRightToLeft(IsRightToLeft());

		surface->StartPaint(rightToLeft.TranslateRect(updateRect));

		surface->Box(updateRect, Setup::BackgroundColor, Rect::Filled);

		if (type != ToolWindow::classID)
		{
			Widget	*lastTopWidget = NIL;
			Int	 topoffset = frameWidth;
			Int	 positions = 0;

			for (Int i = 0; i < GetNOfObjects(); i++)
			{
				Widget	*object = GetNthObject(i);

				positions |= object->GetOrientation();

				if (object->GetOrientation() == OR_TOP)
				{
					lastTopWidget = object;

					if (object->subtype == WO_SEPARATOR)
					{
						topoffset += object->GetSize().cy + 3;

						Point	 p1 = Point(frameWidth * fontSize, topoffset * fontSize - 2);
						Point	 p2 = Point(realSize.cx - frameWidth, p1.y);

#ifndef __APPLE__
						if (!flatStyle && icon != NIL) p1.x += Math::Round(18 * fontSize);
#endif

						surface->Bar(p1, p2, OR_HORZ);
					}
					else
					{
						topoffset += object->GetSize().cy;
					}
				}
			}

			if (positions & OR_TOP)
			{
				Point	 p1 = Point(frameWidth, topoffset * fontSize - 2);
				Point	 p2 = Point(realSize.cx - frameWidth, p1.y);

				if (lastTopWidget != NIL && lastTopWidget->subtype == WO_NOSEPARATOR)
				{
					p1.y += Math::Round(3 * surface->GetSurfaceDPI() / 96.0);
					p2.y += Math::Round(3 * surface->GetSurfaceDPI() / 96.0);
				}

				surface->Bar(p1, p2, OR_HORZ);
				surface->Bar(p1 + Point(0, 2), p2 + Point(0, 2), OR_HORZ);
			}

			if (positions & OR_BOTTOM)
			{
				Point	 p1 = Point(frameWidth, realSize.cy - innerOffset.bottom * fontSize + 1);
				Point	 p2 = Point(realSize.cx - frameWidth, p1.y);

				surface->Bar(p1, p2, OR_HORZ);
				surface->Bar(p1 + Point(0, 2), p2 + Point(0, 2), OR_HORZ);
			}

			if (positions & OR_LEFT)
			{
				Point	 p1 = Point(innerOffset.left * fontSize - 3, innerOffset.top);
				Point	 p2 = Point(p1.x, realSize.cy - innerOffset.bottom - 1);

				surface->Bar(p1, p2, OR_VERT);
			}

			if (positions & OR_RIGHT)
			{
				Point	 p1 = Point(realSize.cx - innerOffset.right * fontSize + 1, innerOffset.top);
				Point	 p2 = Point(p1.x, realSize.cy - innerOffset.bottom - 1);

				surface->Bar(p1, p2, OR_VERT);
			}
		}

		for (Int i = 0; i < GetNOfObjects(); i++)
		{
			Widget	*widget = GetNthObject(i);

			if (widget->GetObjectType() != Layer::classID && widget->IsAffected(updateRect)) widget->Paint(SP_PAINT);
		}

		for (Int i = 0; i < GetNOfObjects(); i++)
		{
			Widget	*widget = GetNthObject(i);

			if (widget->GetObjectType() == Layer::classID && widget->IsAffected(updateRect)) widget->Paint(SP_PAINT);
		}

		onPaint.Emit();

		surface->EndPaint();
	}

	LeaveProtectedRegion();

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x94fbd
xorl %ebx, %ebx
cmpb $0x1, 0x5ca(%r14)
jne 0x94fc0
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
testb %al, %al
je 0x94fc0
movl 0x5f4(%r14), %eax
cmpl 0x5ec(%r14), %eax
je 0x94fc0
movl 0x5f8(%r14), %eax
cmpl 0x5f0(%r14), %eax
je 0x94fc0
leaq 0x5ec(%r14), %rax
movq %rax, 0x30(%rsp)
leaq 0x1c(%r14), %r13
movq %r13, %rdi
callq 0x58b40
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movq %r15, %rdi
callq 0x59c60
movl %eax, %r15d
movl 0x5e8(%r14), %eax
cmpl %eax, 0x5ec(%r14)
jge 0x94efe
leal -0x1(%rax), %ecx
movq 0x30(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x18(%rsp), %rcx
shrq $0x20, %rcx
movq %rcx, 0x38(%rsp)
cmpl %eax, 0x5f0(%r14)
jge 0x94f1f
leal -0x1(%rax), %ecx
movl %ecx, 0x5f0(%r14)
movq 0x18(%rsp), %rcx
subl 0x5f4(%r14), %ecx
cmpl %eax, %ecx
jge 0x94f3f
movq 0x18(%rsp), %rcx
subl %eax, %ecx
incl %ecx
movl %ecx, 0x5f4(%r14)
movq 0x38(%rsp), %rcx
subl 0x5f8(%r14), %ecx
cmpl %eax, %ecx
jge 0x94f5f
movq 0x38(%rsp), %rcx
subl %eax, %ecx
incl %ecx
movl %ecx, 0x5f8(%r14)
callq 0x571b0
cmpl $0x1, %ebp
jne 0x94fd1
movl 0xa8(%r14), %esi
leal -0x2(%rax), %ecx
cmpl %ecx, %esi
jle 0x94fd1
movl 0xac(%r14), %ecx
shrq $0x20, %rax
addl $-0x2, %eax
cmpl %eax, %ecx
jle 0x94fd1
addl 0xb0(%r14), %esi
leal 0x2(%rdx), %eax
cmpl %eax, %esi
jge 0x94fd1
addl 0xb4(%r14), %ecx
shrq $0x20, %rdx
addl $0x2, %edx
cmpl %edx, %ecx
jge 0x94fd1
movq 0x10(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x599e0
jmp 0x954c2
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x54(%rsp), %rdi
callq 0x63dd0
movq 0x10(%rsp), %rdi
callq 0x58cc0
leaq 0x54(%rsp), %rdi
movq %rax, %rsi
callq 0x63e50
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %esi
leaq 0x54(%rsp), %rdi
callq 0x63e5c
leaq 0x54(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x63e10
movq 0x10(%rsp), %r12
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %r12, %rdi
callq 0x56160
movq 0xccf6e(%rip), %rax     # 0x161fa8
movl (%rax), %ecx
leaq 0x20(%rsp), %r8
andq $0x0, (%r8)
movq 0xcc484(%rip), %rdx     # 0x1614d0
movq %r12, %rdi
movq 0x30(%rsp), %rsi
callq 0x58b80
leaq 0x20(%r14), %rdi
movq 0xccc74(%rip), %rax     # 0x161cd8
movswl (%rax), %esi
callq 0x5a150
testb %al, %al
je 0x953f5
movq %r13, 0x60(%rsp)
movswl %r15w, %eax
cvtsi2sd %eax, %xmm0
divsd 0x4e487(%rip), %xmm0    # 0xe3510
movsd %xmm0, 0x40(%rsp)
movl 0x5e8(%r14), %ebx
movq $0x0, 0x48(%rsp)
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpl 0x40(%r14), %r15d
jge 0x95176
movl %r12d, %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x58c90
movq %rax, %rbp
movq (%rax), %rax
movq %rbp, %rdi
callq *0x128(%rax)
movl %eax, %r12d
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x128(%rax)
cmpl $0x4, %eax
jne 0x95158
cmpw $0x1, 0x1a0(%rbp)
movl 0xb4(%rbp), %eax
jne 0x9515f
addl %eax, %ebx
addl $0x3, %ebx
movl 0x5e8(%r14), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sd %ebx, %xmm1
movsd 0x40(%rsp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
addsd 0x50ea5(%rip), %xmm1    # 0xe5fc0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
cvttpd2dq %xmm0, %xmm0
movlpd %xmm0, 0x20(%rsp)
movq 0x18(%rsp), %rcx
subl %eax, %ecx
movl %ecx, 0x8(%rsp)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, 0xc(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x5a330
jmp 0x95163
movq 0x48(%rsp), %rbp
jmp 0x95163
addl %ebx, %eax
movl %eax, %ebx
orl %r12d, %r13d
movl %r13d, %r12d
incl %r15d
movq %rbp, 0x48(%rsp)
jmp 0x950a5
testb $0x4, %r12b
je 0x95293
cvtsi2sd %ebx, %xmm0
mulsd 0x40(%rsp), %xmm0
addsd 0x50e2e(%rip), %xmm0    # 0xe5fc0
cvttsd2si %xmm0, %eax
movl 0x5e8(%r14), %ecx
movl %ecx, 0x20(%rsp)
movl %eax, 0x24(%rsp)
movq 0x18(%rsp), %rdx
subl %ecx, %edx
movl %edx, 0x8(%rsp)
movl %eax, 0xc(%rsp)
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0x9523a
cmpw $0x2, 0x1a0(%rax)
jne 0x9523a
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x59c60
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x4e32b(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x4e777(%rip), %rbx     # 0xe3970
addsd (%rbx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addl %eax, 0x24(%rsp)
movq %r15, %rdi
callq 0x59c60
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x4e2f1(%rip), %xmm0    # 0xe3510
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
addsd (%rbx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addl %eax, 0xc(%rsp)
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdx
pushq $0x1
popq %rcx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x5a330
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
addl $0x2, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
leaq 0x70(%rsp), %rsi
movq %rcx, (%rsi)
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
addl $0x2, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
leaq 0x68(%rsp), %rdx
movq %rcx, (%rdx)
pushq $0x1
popq %rcx
movq %rbx, %rdi
callq 0x5a330
testb $0x8, %r12b
movl $0x0, %ebx
movq 0x60(%rsp), %r13
je 0x9533f
movl 0x5e8(%r14), %eax
cvtsi2sdl 0x38(%rsp), %xmm0
cvtsi2sdl 0x5e4(%r14), %xmm1
mulsd 0x40(%rsp), %xmm1
subsd %xmm1, %xmm0
addsd 0x4e0a1(%rip), %xmm0    # 0xe3370
cvttsd2si %xmm0, %ecx
leaq 0x20(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movq 0x18(%rsp), %rdx
movl %edx, %edi
subl %eax, %edi
leaq 0x8(%rsp), %rdx
movl %edi, (%rdx)
movl %ecx, 0x4(%rdx)
pushq $0x1
popq %rcx
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x5a330
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
addl $0x2, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
leaq 0x70(%rsp), %rsi
movq %rcx, (%rsi)
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
addl $0x2, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
leaq 0x68(%rsp), %rdx
movq %rcx, (%rdx)
pushq $0x1
popq %rcx
movq %r15, %rdi
callq 0x5a330
testb $0x10, %r12b
je 0x95395
cvtsi2sdl 0x5d8(%r14), %xmm0
mulsd 0x40(%rsp), %xmm0
addsd 0x5171c(%rip), %xmm0    # 0xe6a78
cvttsd2si %xmm0, %eax
movl 0x5dc(%r14), %ecx
leaq 0x20(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movl 0x5e4(%r14), %ecx
notl %ecx
addl 0x38(%rsp), %ecx
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movl %ecx, 0x4(%rdx)
pushq $0x2
popq %rcx
movq 0x10(%rsp), %rdi
callq 0x5a330
testb $0x20, %r12b
je 0x953f5
cvtsi2sdl 0x18(%rsp), %xmm0
cvtsi2sdl 0x5e0(%r14), %xmm1
mulsd 0x40(%rsp), %xmm1
subsd %xmm1, %xmm0
addsd 0x4dfb4(%rip), %xmm0    # 0xe3370
cvttsd2si %xmm0, %eax
movl 0x5dc(%r14), %ecx
leaq 0x20(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movl 0x5e4(%r14), %ecx
notl %ecx
addl 0x38(%rsp), %ecx
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movl %ecx, 0x4(%rdx)
pushq $0x2
popq %rcx
movq 0x10(%rsp), %rdi
callq 0x5a330
movq 0xcc404(%rip), %rax     # 0x161800
xorl %r15d, %r15d
movswl (%rax), %ebp
movl 0x40(%r14), %eax
cmpl %eax, %r15d
jge 0x9544f
movq %r14, %rdi
movl %r15d, %esi
callq 0x58c90
movq %rax, %r12
leaq 0x20(%rax), %rdi
movl %ebp, %esi
callq 0x5a150
testb %al, %al
je 0x9544a
movq (%r12), %rax
movq %r12, %rdi
movq 0x30(%rsp), %rsi
callq *0x158(%rax)
testb %al, %al
je 0x9544a
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x78(%rax)
incl %r15d
jmp 0x95402
xorl %r15d, %r15d
cmpl %eax, %r15d
jge 0x9549f
movq %r14, %rdi
movl %r15d, %esi
callq 0x58c90
movq %rax, %r12
leaq 0x20(%rax), %rdi
movl %ebp, %esi
callq 0x58720
testb %al, %al
je 0x95496
movq (%r12), %rax
movq %r12, %rdi
movq 0x30(%rsp), %rsi
callq *0x158(%rax)
testb %al, %al
je 0x95496
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x78(%rax)
incl %r15d
movl 0x40(%r14), %eax
jmp 0x95452
addq $0x648, %r14            # imm = 0x648
movq %r14, %rdi
callq 0x70196
movq 0x10(%rsp), %rdi
callq 0x59a80
leaq 0x54(%rsp), %rdi
callq 0x63dda
movq %r13, %rdi
callq 0x56d60
jmp 0x94fc0
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
jmp 0x954e7
movq %rax, %rbx
leaq 0x54(%rsp), %rdi
callq 0x63dda
movq %rbx, %rdi
callq 0x58260