// File: /workspace/github_c_makefile_star2_O3/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)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %al, %al
je 0x99205
xorl %ebx, %ebx
cmpb $0x1, 0x5ca(%r14)
jne 0x99205
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
testb %al, %al
je 0x99205
movl 0x5f4(%r14), %eax
cmpl 0x5ec(%r14), %eax
je 0x99205
movl 0x5f8(%r14), %eax
cmpl 0x5f0(%r14), %eax
je 0x99205
leaq 0x5ec(%r14), %rax
movq %rax, 0x18(%rsp)
leaq 0x1c(%r14), %rdi
movq %rdi, 0x58(%rsp)
callq 0x578f0
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r12
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, %r13
movq %r12, %rdi
callq 0x58930
movl %eax, %r15d
movl 0x5e8(%r14), %eax
cmpl %eax, 0x5ec(%r14)
jge 0x98c30
leal -0x1(%rax), %ecx
movq 0x18(%rsp), %rdx
movl %ecx, (%rdx)
movq %r13, %rcx
shrq $0x20, %rcx
movq %rcx, 0x20(%rsp)
cmpl %eax, 0x5f0(%r14)
jge 0x98c4f
leal -0x1(%rax), %ecx
movl %ecx, 0x5f0(%r14)
movl %r13d, %ecx
subl 0x5f4(%r14), %ecx
cmpl %eax, %ecx
jge 0x98c6b
movl %r13d, %ecx
subl %eax, %ecx
incl %ecx
movl %ecx, 0x5f4(%r14)
movq 0x20(%rsp), %rcx
subl 0x5f8(%r14), %ecx
cmpl %eax, %ecx
jge 0x98c8b
movq 0x20(%rsp), %rcx
subl %eax, %ecx
incl %ecx
movl %ecx, 0x5f8(%r14)
callq 0x560d0
cmpl $0x1, %ebp
jne 0x98ce7
movl 0xa8(%r14), %esi
leal -0x2(%rax), %ecx
cmpl %ecx, %esi
jle 0x98ce7
movl 0xac(%r14), %ecx
shrq $0x20, %rax
addl $-0x2, %eax
cmpl %eax, %ecx
jle 0x98ce7
addl 0xb0(%r14), %esi
leal 0x2(%rdx), %eax
cmpl %eax, %esi
jge 0x98ce7
addl 0xb4(%r14), %ecx
shrq $0x20, %rdx
addl $0x2, %edx
cmpl %edx, %ecx
jge 0x98ce7
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x586f0
jmp 0x991fb
leaq 0x44(%rsp), %rdi
callq 0x63288
movq %r12, %rdi
callq 0x57a60
leaq 0x44(%rsp), %rdi
movq %rax, %rsi
callq 0x632fa
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %esi
leaq 0x44(%rsp), %rdi
callq 0x63306
leaq 0x44(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x632ca
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %r12, %rdi
callq 0x55160
movq 0xd325f(%rip), %rax     # 0x16bfa8
movl (%rax), %ecx
leaq 0x8(%rsp), %r8
movq $0x0, (%r8)
movq 0xd2772(%rip), %rdx     # 0x16b4d0
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x57930
leaq 0x20(%r14), %rdi
movq 0xd2f62(%rip), %rax     # 0x16bcd8
movswl (%rax), %esi
callq 0x57520
testb %al, %al
movq %r12, 0x30(%rsp)
jne 0x99122
cmpl $0x0, 0x40(%r14)
jle 0x99122
movq %r13, 0x50(%rsp)
movswl %r15w, %eax
cvtsi2sd %eax, %xmm0
divsd 0x5a90d(%rip), %xmm0    # 0xf36b8
movsd %xmm0, 0x28(%rsp)
movl 0x5e8(%r14), %ebx
leaq 0x38(%r14), %rax
movq %rax, 0x60(%rsp)
xorl %ebp, %ebp
xorl %r15d, %r15d
movq $0x0, 0x38(%rsp)
movq 0x60(%rsp), %rdi
movl %ebp, %esi
callq 0x5b074
movq (%rax), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
movl %eax, %r12d
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x4, %eax
jne 0x98e90
cmpw $0x1, 0x1a0(%r13)
movl 0xb4(%r13), %eax
jne 0x98e87
addl %eax, %ebx
addl $0x3, %ebx
movl 0x5e8(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
addsd 0x5d1d2(%rip), %xmm1    # 0xf6018
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
cvttpd2dq %xmm0, %xmm0
movlpd %xmm0, 0x8(%rsp)
movq 0x50(%rsp), %rcx
subl %eax, %ecx
movl %ecx, (%rsp)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, 0x4(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
movl $0x1, %ecx
callq 0x58fc0
movq %r13, 0x38(%rsp)
jmp 0x98e90
addl %ebx, %eax
movq %r13, 0x38(%rsp)
movl %eax, %ebx
orl %r12d, %r15d
incl %ebp
cmpl 0x40(%r14), %ebp
jl 0x98dcf
testb $0x4, %r15b
movq 0x30(%rsp), %r12
movq 0x50(%rsp), %r13
je 0x98fc3
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
mulsd 0x28(%rsp), %xmm0
addsd 0x5d150(%rip), %xmm0    # 0xf6018
cvttsd2si %xmm0, %eax
movl 0x5e8(%r14), %ecx
movl %ecx, 0x8(%rsp)
movl %eax, 0xc(%rsp)
movl %r13d, %edx
subl %ecx, %edx
movl %edx, (%rsp)
movl %eax, 0x4(%rsp)
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x98f6e
cmpw $0x2, 0x1a0(%rax)
jne 0x98f6e
movq %r12, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x5a7a2(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x5a8c6(%rip), %rbx     # 0xf37f0
addsd (%rbx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addl %eax, 0xc(%rsp)
movq %r12, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x5a765(%rip), %xmm0    # 0xf36b8
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
addsd (%rbx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addl %eax, 0x4(%rsp)
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq 0x58fc0
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
addl $0x2, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
leaq 0x70(%rsp), %rsi
movq %rcx, (%rsi)
movl (%rsp), %eax
movl 0x4(%rsp), %ecx
addl $0x2, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
leaq 0x68(%rsp), %rdx
movq %rcx, (%rdx)
movq %r12, %rdi
movl $0x1, %ecx
callq 0x58fc0
testb $0x8, %r15b
movl $0x0, %ebx
je 0x99068
movl 0x5e8(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sdl 0x20(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x5e4(%r14), %xmm1
mulsd 0x28(%rsp), %xmm1
subsd %xmm1, %xmm0
addsd 0x5a388(%rip), %xmm0    # 0xf3388
cvttsd2si %xmm0, %ecx
leaq 0x8(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movl %r13d, %edi
subl %eax, %edi
movq %rsp, %rdx
movl %edi, (%rdx)
movl %ecx, 0x4(%rdx)
movq %r12, %rdi
movl $0x1, %ecx
callq 0x58fc0
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
addl $0x2, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
leaq 0x70(%rsp), %rsi
movq %rcx, (%rsi)
movl (%rsp), %eax
movl 0x4(%rsp), %ecx
addl $0x2, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
leaq 0x68(%rsp), %rdx
movq %rcx, (%rdx)
movq %r12, %rdi
movl $0x1, %ecx
callq 0x58fc0
testb $0x10, %r15b
je 0x990bf
xorps %xmm0, %xmm0
cvtsi2sdl 0x5d8(%r14), %xmm0
mulsd 0x28(%rsp), %xmm0
addsd 0x5dae0(%rip), %xmm0    # 0xf6b68
cvttsd2si %xmm0, %eax
movl 0x5dc(%r14), %ecx
leaq 0x8(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movl 0x5e4(%r14), %ecx
notl %ecx
addl 0x20(%rsp), %ecx
movq %rsp, %rdx
movl %eax, (%rdx)
movl %ecx, 0x4(%rdx)
movq %r12, %rdi
movl $0x2, %ecx
callq 0x58fc0
testb $0x20, %r15b
je 0x99122
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x5e0(%r14), %xmm1
mulsd 0x28(%rsp), %xmm1
subsd %xmm1, %xmm0
addsd 0x5a29d(%rip), %xmm0    # 0xf3388
cvttsd2si %xmm0, %eax
movl 0x5dc(%r14), %ecx
leaq 0x8(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movl 0x5e4(%r14), %ecx
notl %ecx
addl 0x20(%rsp), %ecx
movq %rsp, %rdx
movl %eax, (%rdx)
movl %ecx, 0x4(%rdx)
movq %r12, %rdi
movl $0x2, %ecx
callq 0x58fc0
cmpl $0x0, 0x40(%r14)
jle 0x991d8
leaq 0x38(%r14), %r15
movq 0xd26c8(%rip), %rax     # 0x16b800
xorl %r12d, %r12d
movswl (%rax), %ebp
movq %r15, %rdi
movl %r12d, %esi
callq 0x5b074
movq (%rax), %r13
leaq 0x20(%r13), %rdi
movl %ebp, %esi
callq 0x57520
testb %al, %al
jne 0x9917d
movq (%r13), %rax
movq %r13, %rdi
movq 0x18(%rsp), %rsi
callq *0x158(%rax)
testb %al, %al
je 0x9917d
movq (%r13), %rax
movq %r13, %rdi
xorl %esi, %esi
callq *0x78(%rax)
incl %r12d
movl 0x40(%r14), %eax
cmpl %eax, %r12d
jl 0x9913e
testl %eax, %eax
jle 0x991d8
xorl %r12d, %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x5b074
movq (%rax), %r13
leaq 0x20(%r13), %rdi
movl %ebp, %esi
callq 0x57520
testb %al, %al
je 0x991cf
movq (%r13), %rax
movq %r13, %rdi
movq 0x18(%rsp), %rsi
callq *0x158(%rax)
testb %al, %al
je 0x991cf
movq (%r13), %rax
movq %r13, %rdi
xorl %esi, %esi
callq *0x78(%rax)
incl %r12d
cmpl 0x40(%r14), %r12d
jl 0x99190
addq $0x648, %r14            # imm = 0x648
movq %r14, %rdi
callq 0x701aa
movq 0x30(%rsp), %rdi
callq 0x58780
leaq 0x44(%rsp), %rdi
callq 0x63294
movq 0x58(%rsp), %rdi
callq 0x55cc0
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
jmp 0x9922e
movq %rax, %rbx
leaq 0x44(%rsp), %rdi
callq 0x63294
movq %rbx, %rdi
callq 0x57090
nop