// File: /workspace/github_c_makefile_star2_O3/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 0x7a69b
movq (%r15), %rax
movq %r15, %rdi
callq *0x90(%rax)
xorl %ebx, %ebx
testb %al, %al
je 0x7a69b
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 0x7a69b
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 0x7a0ce
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 0xf1ef1(%rip), %rax     # 0x16bfa8
movl (%rax), %ecx
leaq 0x10(%rsp), %r8
movq $0x0, (%r8)
movq 0xf15a4(%rip), %rdx     # 0x16b670
jmp 0x7a11b
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 0xf1ea2(%rip), %rax     # 0x16bfa8
movl (%rax), %ecx
leaq 0x10(%rsp), %r8
movq $0x0, (%r8)
movq 0xf13b5(%rip), %rdx     # 0x16b4d0
movq %r13, %rdi
callq 0x57930
cmpl $0x1, %ebp
je 0x7a138
movq %rsp, %rsi
movq %r13, %rdi
movl $0x1, %edx
callq 0x57890
cmpl $0x0, 0x5c4(%r15)
jle 0x7a2f0
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, %r14
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r14, %rdx
orq %r8, %rdx
leaq 0x1(%r14), %rcx
leaq (%r14,%rax), %rsi
andq %rdi, %rax
addq %r8, %rsi
movl %ecx, %r8d
addq %rdx, %r8
incq %r8
addq %r14, %rax
andq %rdi, %rax
addq %rdi, %rax
movl %esi, %edi
orq %rax, %rdi
movq %r8, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
cmpw $0x1, 0x1a0(%r15)
jne 0x7a1e6
subl %ecx, %esi
cvtsi2sd %esi, %xmm0
movl 0x5cc(%r15), %eax
movl 0x5c4(%r15), %edx
movl 0x5c8(%r15), %esi
subl %esi, %eax
cvtsi2sd %eax, %xmm1
subl %esi, %edx
cvtsi2sd %edx, %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
addl %ecx, %eax
movl %eax, 0x40(%rsp)
jmp 0x7a22c
incq %rdx
shrq $0x20, %rdx
shrq $0x20, %rax
movl %eax, %ecx
subl %edx, %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 0x7a274
shrq $0x20, %rax
addl $-0x2, %eax
cmpl %eax, 0x4(%r14)
jne 0x7a274
movb 0x5c0(%r15), %bpl
movq (%r15), %rax
movq %r15, %rdi
callq *0x160(%rax)
cmpb %al, %bpl
je 0x7a28d
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)
testb %al, %al
je 0x7a2b5
movq %r12, %rdi
callq 0x58410
movl (%rax), %edi
movl 0x38(%rsp), %eax
movl 0x40(%rsp), %edx
subl %edx, %edi
addl %eax, %edi
jmp 0x7a2bf
movl 0x38(%rsp), %eax
movl 0x40(%rsp), %edx
xorl %edi, %edi
leaq 0x38(%rsp), %rcx
movl 0xc(%rcx), %r8d
subl 0x4(%rcx), %r8d
leaq 0x10(%rsp), %rsi
movl %edi, (%rsi)
movl $0x0, 0x4(%rsi)
addl %edi, %edx
subl %eax, %edx
movl %edx, 0x8(%rsi)
movl %r8d, 0xc(%rsi)
movq %r12, %rdi
movq %r13, %rdx
callq 0x55bc0
cmpw $0x1, 0x1a0(%r15)
jne 0x7a693
movl 0x30(%r15), %eax
cmpl $0x2, %eax
movq %r13, 0xc0(%rsp)
je 0x7a355
cmpl $0x1, %eax
jne 0x7a4cd
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 0x7a4c8
movq 0xf108c(%rip), %rax     # 0x16b3e8
movq (%rax), %r14
cmpl $0x0, 0x5c4(%r15)
jle 0x7a430
leaq 0x7bd1c(%rip), %rsi     # 0xf6090
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x579f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x58260
movq %rax, %r14
leaq 0x7bcfe(%rip), %rsi     # 0xf6094
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 0x7bcb8(%rip), %xmm1    # 0xf6088
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x7b750(%rip), %rcx     # 0xf5b38
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 0x7a4a2
leaq 0x7bc59(%rip), %rsi     # 0xf6090
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x579f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x58260
movq %rax, %r14
leaq 0x7bc3b(%rip), %rsi     # 0xf6094
leaq 0x90(%rsp), %rdi
callq 0x579f0
leaq 0xb1edd(%rip), %rsi     # 0x12c34a
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 0xf187a(%rip), %rsi     # 0x16bdb8
movq %rbp, %rdi
callq 0x57680
addl 0x28(%rsp), %eax
subl %eax, %r13d
cvtsi2sd %r13d, %xmm0
mulsd 0x78e3e(%rip), %xmm0    # 0xf3398
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 0x7911e(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x7b58a(%rip), %rcx     # 0xf5b38
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 0x7a693
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 0xf14c7(%rip), %rsi     # 0x16bb30
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 0x7a6b9
jmp 0x7a6c8
jmp 0x7a6d7
jmp 0x7a6eb
jmp 0x7a6eb
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x59200
jmp 0x7a6cb
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x59200
jmp 0x7a6da
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x59200
jmp 0x7a6ee
jmp 0x7a6eb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x59200
jmp 0x7a711
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x7a6f3
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x56720
movq %rbx, %rdi
callq 0x57090
nop