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

	Surface	*surface = GetDrawSurface();
	Rect	 frame	 = Rect(GetRealPosition(), GetRealSize());

	switch (message)
	{
		case SP_PAINT:
		case SP_UPDATE:
			surface->StartPaint(GetVisibleArea());

			if (IsActive())	surface->Box(frame + Point(1, 1) - Size(2, 2), Setup::ClientColor, Rect::Filled);
			else		surface->Box(frame + Point(1, 1) - Size(2, 2), Setup::BackgroundColor, Rect::Filled);

			if (message != SP_UPDATE) surface->Frame(frame, FRAME_DOWN);

			if (value > 0)
			{
				Rect	 frame = Rect(GetRealPosition(), GetRealSize()) + Point(1, 1) - Size(2, 2);

				if (subtype == OR_HORZ)	frame.right = frame.left   + (Int) (frame.GetWidth() / ((Float) (endValue - startValue) / (Float) (value - startValue)));
				else			frame.top   = frame.bottom - (Int) (frame.GetHeight() / ((Float) (endValue - startValue) / (Float) (value - startValue)));

				/* Update gradient bitmap if necessary.
				 */
				if (gradient.GetSize() != GetRealSize() - Size(2, 2) || gradientDirection != IsRightToLeft()) CreateGradient(GetRealSize());

				gradient.BlitToSurface(Rect(Point(0 + (IsRightToLeft() ? gradient.GetSize().cx - frame.GetWidth() : 0), 0), frame.GetSize()), surface, frame);
			}

			if (subtype == OR_HORZ)
			{
				I18n::Translator	*i18n = I18n::Translator::defaultTranslator;

				switch (GetFlags())
				{
					case PB_NOTEXT:
						break;
					case PB_VALUE:
						text = String::FromInt((Int) Math::Max(value, startValue));
						break;
					case PB_PERCENT:
						if (value > 0)	text = i18n->TranslateString("%1%").Replace("%1", String::FromInt((Int) Math::Max(0, (Int) Math::Round(100 / ((Float) (endValue - startValue) / (Float) (value - startValue))))));
						else		text = i18n->TranslateString("%1%").Replace("%1", "0");

						break;
				}

				Point	 realPos  = GetRealPosition();

				Int	 textSize = font.GetScaledTextSizeX(text);
				Rect	 textRect = Rect(Point(realPos.x + (frame.GetWidth() - textSize) / 2, realPos.y + Math::Ceil(Float(frame.GetHeight() - font.GetScaledTextSizeY()) / 2) - 1), Size(textSize, frame.GetHeight() - Math::Round(2 * surface->GetSurfaceDPI() / 96.0) - 1));

				surface->SetText(text, textRect, font);

				if (value > 0)
				{
					textRect.right = realPos.x + (Int) ((frame.GetWidth() - 2) / ((Float) (endValue - startValue) / (Float) (value - startValue)));

					Font	 nFont = font;

					nFont.SetColor(Setup::GradientTextColor);

					surface->SetText(text, textRect, nFont);
				}
			}

			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, %r15
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %al, %al
je 0x7a98e
movq (%r15), %rax
movq %r15, %rdi
callq *0x90(%rax)
xorl %ebx, %ebx
testb %al, %al
je 0x7a98e
movq (%r15), %rax
movq %r15, %rdi
callq *0x40(%rax)
movq %rax, %r13
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, %r14
movq %rax, %r12
shrq $0x20, %r12
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
leal (%rax,%r14), %ecx
shrq $0x20, %rax
movl %r14d, (%rsp)
movl %r12d, 0x4(%rsp)
movl %ecx, 0x8(%rsp)
addl %r12d, %eax
movl %eax, 0xc(%rsp)
cmpl $0x1, %ebp
ja 0x7a98e
movq (%r15), %rax
movq %r15, %rdi
callq *0x130(%rax)
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %r13, %rdi
callq 0x55160
movq (%r15), %rax
movq %r15, %rdi
callq *0x98(%rax)
testb %al, %al
je 0x7a3d2
movl (%rsp), %eax
movl 0x4(%rsp), %ecx
incl %eax
incl %ecx
shlq $0x20, %rcx
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %esi
decl %edx
decl %esi
orq %rcx, %rax
shlq $0x20, %rsi
orq %rsi, %rdx
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq 0xf2bed(%rip), %rax     # 0x16cfa8
movl (%rax), %ecx
leaq 0x10(%rsp), %r8
movq $0x0, (%r8)
movq 0xf22a0(%rip), %rdx     # 0x16c670
jmp 0x7a41f
movl (%rsp), %eax
movl 0x4(%rsp), %ecx
incl %eax
incl %ecx
shlq $0x20, %rcx
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %esi
decl %edx
decl %esi
orq %rcx, %rax
shlq $0x20, %rsi
orq %rsi, %rdx
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq 0xf2b9e(%rip), %rax     # 0x16cfa8
movl (%rax), %ecx
leaq 0x10(%rsp), %r8
movq $0x0, (%r8)
movq 0xf20b1(%rip), %rdx     # 0x16c4d0
movq %r13, %rdi
callq 0x57930
cmpl $0x1, %ebp
je 0x7a43c
movq %rsp, %rsi
movq %r13, %rdi
movl $0x1, %edx
callq 0x57890
cmpl $0x0, 0x5c4(%r15)
jle 0x7a5e3
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, %r14
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movq %rax, %rdx
andq %rcx, %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %r14, %rdi
orq %rsi, %rdi
leal 0x1(%r14), %r8d
addl %r14d, %esi
addl %esi, %eax
leaq (%rdi,%r8), %rsi
incq %rsi
addq %r14, %rdx
andq %rcx, %rdx
orq %rdx, %rax
addq %rcx, %rax
movq %rsi, 0x38(%rsp)
movq %rax, 0x40(%rsp)
cmpw $0x1, 0x1a0(%r15)
jne 0x7a4ee
movl 0x38(%rsp), %eax
movl 0x40(%rsp), %ecx
subl %eax, %ecx
cvtsi2sd %ecx, %xmm0
movl 0x5cc(%r15), %ecx
movl 0x5c4(%r15), %edx
movl 0x5c8(%r15), %esi
subl %esi, %ecx
cvtsi2sd %ecx, %xmm1
subl %esi, %edx
cvtsi2sd %edx, %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
addl %eax, %ecx
movl %ecx, 0x40(%rsp)
jmp 0x7a52f
movl 0x44(%rsp), %eax
movl %eax, %ecx
subl 0x3c(%rsp), %ecx
cvtsi2sd %ecx, %xmm0
movl 0x5cc(%r15), %ecx
movl 0x5c4(%r15), %edx
movl 0x5c8(%r15), %esi
subl %esi, %ecx
cvtsi2sd %ecx, %xmm1
subl %esi, %edx
cvtsi2sd %edx, %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
subl %ecx, %eax
movl %eax, 0x3c(%rsp)
leaq 0x5b8(%r15), %r12
movq %r12, %rdi
callq 0x58410
movq %rax, %r14
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
leal -0x2(%rax), %ecx
cmpl %ecx, (%r14)
jne 0x7a577
shrq $0x20, %rax
addl $-0x2, %eax
cmpl %eax, 0x4(%r14)
jne 0x7a577
movb 0x5c0(%r15), %bpl
movq (%r15), %rax
movq %r15, %rdi
callq *0x160(%rax)
cmpb %al, %bpl
je 0x7a590
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x55070
movq (%r15), %rax
movq %r15, %rdi
callq *0x160(%rax)
xorl %edx, %edx
testb %al, %al
je 0x7a5b4
movq %r12, %rdi
callq 0x58410
movl (%rax), %edx
subl 0x40(%rsp), %edx
addl 0x38(%rsp), %edx
leaq 0x38(%rsp), %rcx
movl 0xc(%rcx), %eax
subl 0x4(%rcx), %eax
leaq 0x10(%rsp), %rsi
movl %edx, (%rsi)
movl $0x0, 0x4(%rsi)
addl 0x8(%rcx), %edx
subl (%rcx), %edx
movl %edx, 0x8(%rsi)
movl %eax, 0xc(%rsi)
movq %r12, %rdi
movq %r13, %rdx
callq 0x55bc0
cmpw $0x1, 0x1a0(%r15)
jne 0x7a986
movl 0x30(%r15), %eax
cmpl $0x2, %eax
movq %r13, 0xc0(%rsp)
je 0x7a648
cmpl $0x1, %eax
jne 0x7a7c0
movl 0x5c4(%r15), %eax
movl 0x5c8(%r15), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movslq %ecx, %rsi
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x56cf0
leaq 0xf0(%r15), %rdi
movq %r14, %rsi
callq 0x555f0
leaq 0x38(%rsp), %rdi
jmp 0x7a7bb
movq 0xf1d99(%rip), %rax     # 0x16c3e8
movq (%rax), %r14
cmpl $0x0, 0x5c4(%r15)
jle 0x7a723
leaq 0x7c971(%rip), %rsi     # 0xf6fd8
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x579f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x58260
movq %rax, %r14
leaq 0x7c953(%rip), %rsi     # 0xf6fdc
leaq 0x90(%rsp), %rdi
callq 0x579f0
movl 0x5cc(%r15), %eax
movl 0x5c8(%r15), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movl 0x5c4(%r15), %eax
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x7c90d(%rip), %xmm1    # 0xf6fd0
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x7a0b5(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm1
cvttsd2si %xmm1, %rax
xorl %esi, %esi
testl %eax, %eax
cmovgl %eax, %esi
leaq 0x78(%rsp), %rdi
callq 0x56cf0
leaq 0x38(%rsp), %rdi
leaq 0x90(%rsp), %rdx
leaq 0x78(%rsp), %rcx
movq %r14, %rsi
callq 0x580c0
leaq 0xf0(%r15), %rdi
leaq 0x38(%rsp), %rsi
callq 0x555f0
jmp 0x7a795
leaq 0x7c8ae(%rip), %rsi     # 0xf6fd8
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x579f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x58260
movq %rax, %r14
leaq 0x7c890(%rip), %rsi     # 0xf6fdc
leaq 0x90(%rsp), %rdi
callq 0x579f0
leaq 0xb299a(%rip), %rsi     # 0x12d0fa
leaq 0x78(%rsp), %rdi
callq 0x579f0
leaq 0x38(%rsp), %rdi
leaq 0x90(%rsp), %rdx
leaq 0x78(%rsp), %rcx
movq %r14, %rsi
callq 0x580c0
leaq 0xf0(%r15), %rdi
leaq 0x38(%rsp), %rsi
callq 0x555f0
leaq 0x38(%rsp), %rdi
callq 0x59200
leaq 0x78(%rsp), %rdi
callq 0x59200
leaq 0x90(%rsp), %rdi
callq 0x59200
leaq 0x10(%rsp), %rdi
callq 0x59200
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, %r14
leaq 0x140(%r15), %rbp
leaq 0xf0(%r15), %rsi
movq %rsi, 0xb8(%rsp)
movq %rbp, %rdi
movq %rbp, 0xb0(%rsp)
callq 0x56730
movl %eax, 0x34(%rsp)
movl 0x4(%rsp), %ecx
movl %ecx, 0x28(%rsp)
movl 0x8(%rsp), %edx
movl (%rsp), %ecx
addl %eax, %ecx
subl %ecx, %edx
movl %edx, %r12d
shrl $0x1f, %r12d
addl %edx, %r12d
sarl %r12d
addl %r14d, %r12d
movq %r14, 0xa8(%rsp)
shrq $0x20, %r14
movl 0xc(%rsp), %r13d
movq 0xf2587(%rip), %rsi     # 0x16cdb8
movq %rbp, %rdi
callq 0x57680
addl 0x28(%rsp), %eax
subl %eax, %r13d
cvtsi2sd %r13d, %xmm0
mulsd 0x79b4b(%rip), %xmm0    # 0xf4398
callq 0x56cb0
leal (%rax,%r14), %ecx
movq %rcx, 0x28(%rsp)
leal (%rax,%r14), %ebp
decl %ebp
movl 0xc(%rsp), %r14d
subl 0x4(%rsp), %r14d
movq 0xc0(%rsp), %r13
movq %r13, %rdi
callq 0x58930
cwtl
addl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x79c63(%rip), %xmm0    # 0xf44f0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x79eef(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
notl %eax
leaq 0x10(%rsp), %rdx
movl %r12d, (%rdx)
movl %ebp, 0x4(%rdx)
movq 0xb0(%rsp), %rbp
addl 0x34(%rsp), %r12d
movl %r12d, 0x8(%rdx)
movq 0xb8(%rsp), %r12
movq 0x28(%rsp), %rcx
addl %r14d, %ecx
decl %ecx
addl %eax, %ecx
movl %ecx, 0xc(%rdx)
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x57b80
movl 0x5c4(%r15), %eax
testl %eax, %eax
jle 0x7a986
movl 0x8(%rsp), %ecx
subl (%rsp), %ecx
addl $-0x2, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movl 0x5c8(%r15), %ecx
movl 0x5cc(%r15), %edx
subl %ecx, %edx
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
subl %ecx, %eax
cvtsi2sd %eax, %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
addl 0xa8(%rsp), %eax
movl %eax, 0x18(%rsp)
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x55b70
movq 0xf21d4(%rip), %rsi     # 0x16cb30
movq %r14, %rdi
callq 0x58650
leaq 0x10(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x57b80
leaq 0x38(%rsp), %rdi
callq 0x56720
movq %r13, %rdi
callq 0x58780
movl %ebx, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7a9ac
jmp 0x7a9bb
jmp 0x7a9ca
jmp 0x7a9de
jmp 0x7a9de
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x59200
jmp 0x7a9be
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x59200
jmp 0x7a9cd
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x59200
jmp 0x7a9e1
jmp 0x7a9de
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x59200
jmp 0x7aa04
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x7a9e6
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x56720
movq %rbx, %rdi
callq 0x57090