// File: /workspace/github_c_makefile_star2_O1/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 0x999f3
xorl %ebx, %ebx
cmpb $0x1, 0x5ca(%r14)
jne 0x999f3
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
testb %al, %al
je 0x999f3
movl 0x5f4(%r14), %eax
cmpl 0x5ec(%r14), %eax
je 0x999f3
movl 0x5f8(%r14), %eax
cmpl 0x5f0(%r14), %eax
je 0x999f3
leaq 0x5ec(%r14), %rax
movq %rax, 0x20(%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, 0x8(%rsp)
movq %r12, %rdi
callq 0x58930
movl %eax, %r15d
movl 0x5e8(%r14), %eax
cmpl %eax, 0x5ec(%r14)
jge 0x99408
leal -0x1(%rax), %ecx
movq 0x20(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x8(%rsp), %r13
shrq $0x20, %r13
cmpl %eax, 0x5f0(%r14)
jge 0x99424
leal -0x1(%rax), %ecx
movl %ecx, 0x5f0(%r14)
movq 0x8(%rsp), %rcx
subl 0x5f4(%r14), %ecx
cmpl %eax, %ecx
jge 0x99444
movq 0x8(%rsp), %rcx
subl %eax, %ecx
incl %ecx
movl %ecx, 0x5f4(%r14)
movl %r13d, %ecx
subl 0x5f8(%r14), %ecx
cmpl %eax, %ecx
jge 0x99460
movl %r13d, %ecx
subl %eax, %ecx
incl %ecx
movl %ecx, 0x5f8(%r14)
callq 0x560d0
cmpl $0x1, %ebp
jne 0x994bc
movl 0xa8(%r14), %esi
leal -0x2(%rax), %ecx
cmpl %ecx, %esi
jle 0x994bc
movl 0xac(%r14), %ecx
shrq $0x20, %rax
addl $-0x2, %eax
cmpl %eax, %ecx
jle 0x994bc
addl 0xb0(%r14), %esi
leal 0x2(%rdx), %eax
cmpl %eax, %esi
jge 0x994bc
addl 0xb4(%r14), %ecx
shrq $0x20, %rdx
addl $0x2, %edx
cmpl %edx, %ecx
jge 0x994bc
movq %r12, %rdi
movq 0x20(%rsp), %rsi
callq 0x586f0
jmp 0x999e9
leaq 0x44(%rsp), %rdi
callq 0x63254
movq %r12, %rdi
callq 0x57a60
leaq 0x44(%rsp), %rdi
movq %rax, %rsi
callq 0x632c6
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %esi
leaq 0x44(%rsp), %rdi
callq 0x632d2
leaq 0x44(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x63296
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %r12, %rdi
callq 0x55160
movq 0xd3a8a(%rip), %rax     # 0x16cfa8
movl (%rax), %ecx
leaq 0x10(%rsp), %r8
movq $0x0, (%r8)
movq 0xd2f9d(%rip), %rdx     # 0x16c4d0
movq %r12, %rdi
movq 0x20(%rsp), %rsi
callq 0x57930
leaq 0x20(%r14), %rdi
movq 0xd378d(%rip), %rax     # 0x16ccd8
movswl (%rax), %esi
callq 0x57520
testb %al, %al
movq %r12, 0x38(%rsp)
jne 0x99908
movq %r13, 0x50(%rsp)
movswl %r15w, %eax
cvtsi2sd %eax, %xmm0
divsd 0x5af7b(%rip), %xmm0    # 0xf44f0
movsd %xmm0, 0x28(%rsp)
movl 0x5e8(%r14), %eax
cmpl $0x0, 0x40(%r14)
movq %rax, 0x30(%rsp)
jle 0x9967c
leaq 0x38(%r14), %rax
movq %rax, 0x60(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %ebx, %ebx
movq 0x60(%rsp), %rdi
movl %r12d, %esi
callq 0x5b0a4
movq (%rax), %r15
movq (%r15), %rax
movq %r15, %rdi
callq *0x128(%rax)
movl %eax, %r13d
movq (%r15), %rax
movq %r15, %rdi
callq *0x128(%rax)
cmpl $0x4, %eax
jne 0x99659
cmpw $0x1, 0x1a0(%r15)
movl 0xb4(%r15), %eax
jne 0x9965e
movl 0x5e8(%r14), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movq 0x30(%rsp), %rdx
addl %eax, %edx
addl $0x3, %edx
movsd 0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movq %rdx, 0x30(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
mulsd %xmm1, %xmm0
addsd 0x5d952(%rip), %xmm0    # 0xf6f78
cvttsd2si %xmm0, %edx
movl %eax, 0x10(%rsp)
movl %edx, 0x14(%rsp)
movq 0x8(%rsp), %rax
subl %ecx, %eax
movl %eax, (%rsp)
movl %edx, 0x4(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rsp, %rdx
movl $0x1, %ecx
callq 0x58fc0
jmp 0x99667
movq %rbx, %r15
jmp 0x99667
addl 0x30(%rsp), %eax
movq %rax, 0x30(%rsp)
orl %r13d, %ebp
incl %r12d
movq %r15, %rbx
cmpl 0x40(%r14), %r12d
jl 0x995a2
jmp 0x99681
xorl %r15d, %r15d
xorl %ebp, %ebp
testb $0x4, %bpl
movl $0x0, %ebx
movq 0x38(%rsp), %r12
movq 0x50(%rsp), %r13
je 0x997ac
xorps %xmm0, %xmm0
cvtsi2sdl 0x30(%rsp), %xmm0
mulsd 0x28(%rsp), %xmm0
addsd 0x5d8c7(%rip), %xmm0    # 0xf6f78
cvttsd2si %xmm0, %eax
movl 0x5e8(%r14), %ecx
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq 0x8(%rsp), %rdx
subl %ecx, %edx
movl %edx, (%rsp)
movl %eax, 0x4(%rsp)
testq %r15, %r15
je 0x99755
cmpw $0x2, 0x1a0(%r15)
jne 0x99755
movq %r12, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x5adf3(%rip), %xmm0    # 0xf44f0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x5b1af(%rip), %rbx     # 0xf48c0
addsd (%rbx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addl %eax, 0x14(%rsp)
movq %r12, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x5adb6(%rip), %xmm0    # 0xf44f0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
addsd (%rbx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addl %eax, 0x4(%rsp)
leaq 0x10(%rsp), %rsi
movq %rsp, %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq 0x58fc0
movl 0x10(%rsp), %eax
movl 0x14(%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
xorl %ebx, %ebx
testb $0x8, %bpl
je 0x9984f
movl 0x5e8(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x5e4(%r14), %xmm1
mulsd 0x28(%rsp), %xmm1
subsd %xmm1, %xmm0
addsd 0x5aba5(%rip), %xmm0    # 0xf4388
cvttsd2si %xmm0, %ecx
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movq 0x8(%rsp), %rdx
movl %edx, %edi
subl %eax, %edi
movq %rsp, %rdx
movl %edi, (%rdx)
movl %ecx, 0x4(%rdx)
movq %r12, %rdi
movl $0x1, %ecx
callq 0x58fc0
movl 0x10(%rsp), %eax
movl 0x14(%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, %bpl
je 0x998a5
xorps %xmm0, %xmm0
cvtsi2sdl 0x5d8(%r14), %xmm0
mulsd 0x28(%rsp), %xmm0
addsd 0x5e179(%rip), %xmm0    # 0xf79e8
cvttsd2si %xmm0, %eax
movl 0x5dc(%r14), %ecx
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movl 0x5e4(%r14), %ecx
notl %ecx
addl %r13d, %ecx
movq %rsp, %rdx
movl %eax, (%rdx)
movl %ecx, 0x4(%rdx)
movq %r12, %rdi
movl $0x2, %ecx
callq 0x58fc0
testb $0x20, %bpl
je 0x99908
xorps %xmm0, %xmm0
cvtsi2sdl 0x8(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x5e0(%r14), %xmm1
mulsd 0x28(%rsp), %xmm1
subsd %xmm1, %xmm0
addsd 0x5aab6(%rip), %xmm0    # 0xf4388
cvttsd2si %xmm0, %eax
movl 0x5dc(%r14), %ecx
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movl 0x5e4(%r14), %ecx
notl %ecx
addl %r13d, %ecx
movq %rsp, %rdx
movl %eax, (%rdx)
movl %ecx, 0x4(%rdx)
movq %r12, %rdi
movl $0x2, %ecx
callq 0x58fc0
cmpl $0x0, 0x40(%r14)
jle 0x99967
leaq 0x38(%r14), %r15
movq 0xd2ee6(%rip), %rax     # 0x16c800
xorl %ebp, %ebp
movswl (%rax), %r12d
movq %r15, %rdi
movl %ebp, %esi
callq 0x5b0a4
movq (%rax), %r13
leaq 0x20(%r13), %rdi
movl %r12d, %esi
callq 0x57520
testb %al, %al
jne 0x9995f
movq (%r13), %rax
movq %r13, %rdi
movq 0x20(%rsp), %rsi
callq *0x158(%rax)
testb %al, %al
je 0x9995f
movq (%r13), %rax
movq %r13, %rdi
xorl %esi, %esi
callq *0x78(%rax)
incl %ebp
cmpl 0x40(%r14), %ebp
jl 0x99920
cmpl $0x0, 0x40(%r14)
jle 0x999c6
leaq 0x38(%r14), %r15
movq 0xd2e87(%rip), %rax     # 0x16c800
xorl %ebp, %ebp
movswl (%rax), %r12d
movq %r15, %rdi
movl %ebp, %esi
callq 0x5b0a4
movq (%rax), %r13
leaq 0x20(%r13), %rdi
movl %r12d, %esi
callq 0x57520
testb %al, %al
je 0x999be
movq (%r13), %rax
movq %r13, %rdi
movq 0x20(%rsp), %rsi
callq *0x158(%rax)
testb %al, %al
je 0x999be
movq (%r13), %rax
movq %r13, %rdi
xorl %esi, %esi
callq *0x78(%rax)
incl %ebp
cmpl 0x40(%r14), %ebp
jl 0x9997f
addq $0x648, %r14            # imm = 0x648
movq %r14, %rdi
callq 0x70488
movq 0x38(%rsp), %rdi
callq 0x58780
leaq 0x44(%rsp), %rdi
callq 0x63260
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 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
jmp 0x99a1c
movq %rax, %rbx
leaq 0x44(%rsp), %rdi
callq 0x63260
movq %rbx, %rdi
callq 0x57090
nop