// File: /workspace/github_c_makefile_star2_O2/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)
testb %al, %al
je 0x78c87
movq (%r15), %rax
movq %r15, %rdi
callq *0x90(%rax)
xorl %r13d, %r13d
testb %al, %al
je 0x78c8b
movq (%r15), %rax
movq %r15, %rdi
callq *0x40(%rax)
movq %rax, %rbx
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, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
movl %ecx, 0x10(%rsp)
addl %r12d, %eax
movl %eax, 0x14(%rsp)
cmpl $0x1, %ebp
ja 0x78c8b
movabsq $-0x100000000, %r12     # imm = 0xFFFFFFFF00000000
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
movq (%r15), %rax
movq %r15, %rdi
callq *0x130(%rax)
leaq 0x58(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x56160
movq (%r15), %rax
movq %r15, %rdi
callq *0x98(%rax)
movabsq $0x100000001, %rcx      # imm = 0x100000001
testb %al, %al
movq %rbx, %r14
leaq 0x20(%rsp), %rsi
je 0x78ca0
movq %rcx, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x58930
leal (%rdx,%r13), %ecx
andq %r12, %rdx
movabsq $-0x200000000, %rbx     # imm = 0xFFFFFFFE00000000
addq %rbx, %rdx
orq %rdx, %rcx
leaq 0x58(%rsp), %rsi
movq %rax, (%rsi)
movq %rcx, 0x8(%rsi)
movq 0xe9335(%rip), %rax     # 0x161fa8
movl (%rax), %ecx
leaq 0x40(%rsp), %r8
andq $0x0, (%r8)
movq 0xe89eb(%rip), %rdx     # 0x161670
jmp 0x78ce9
pushq $-0x1
popq %r13
movl %r13d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x58930
leal (%rdx,%r13), %ecx
andq %r12, %rdx
movabsq $-0x200000000, %rbx     # imm = 0xFFFFFFFE00000000
addq %rbx, %rdx
orq %rdx, %rcx
leaq 0x58(%rsp), %rsi
movq %rax, (%rsi)
movq %rcx, 0x8(%rsi)
movq 0xe92d1(%rip), %rax     # 0x161fa8
movl (%rax), %ecx
leaq 0x40(%rsp), %r8
andq $0x0, (%r8)
movq 0xe87e7(%rip), %rdx     # 0x1614d0
movq %r14, %rdi
callq 0x58b80
cmpl $0x1, %ebp
je 0x78d06
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x58ad0
cmpl $0x0, 0x5c4(%r15)
movq %r14, 0x18(%rsp)
jle 0x78ed4
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, %r14
movq %rax, %rbp
shrq $0x20, %rbp
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
leal (%rax,%r14), %ecx
shrq $0x20, %rax
leaq 0x20(%rsp), %rdi
movl %r14d, (%rdi)
movl %ebp, 0x4(%rdi)
movl %ecx, 0x8(%rdi)
addl %ebp, %eax
movl %eax, 0xc(%rdi)
leaq 0x40(%rsp), %rsi
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%rsi)
callq 0x58930
addq %rdx, %r13
andq %rdx, %r12
addq %rbx, %r12
movl %r13d, %ecx
orq %r12, %rcx
movq %rax, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
cmpw $0x1, 0x1a0(%r15)
jne 0x78dc8
subl %eax, %r13d
cvtsi2sd %r13d, %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, 0x60(%rsp)
jmp 0x78e0e
shrq $0x20, %rax
shrq $0x20, %r12
movl %r12d, %ecx
subl %eax, %ecx
cvtsi2sd %ecx, %xmm0
movl 0x5cc(%r15), %eax
movl 0x5c4(%r15), %ecx
movl 0x5c8(%r15), %edx
subl %edx, %eax
cvtsi2sd %eax, %xmm1
subl %edx, %ecx
cvtsi2sd %ecx, %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
subl %eax, %r12d
movl %r12d, 0x5c(%rsp)
leaq 0x5b8(%r15), %r12
movq %r12, %rdi
callq 0x596e0
movq %rax, %r14
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
leal -0x2(%rax), %ecx
cmpl %ecx, (%r14)
jne 0x78e56
shrq $0x20, %rax
addl $-0x2, %eax
cmpl %eax, 0x4(%r14)
jne 0x78e56
movb 0x5c0(%r15), %bpl
movq (%r15), %rax
movq %r15, %rdi
callq *0x160(%rax)
cmpb %al, %bpl
je 0x78e6f
movq (%r15), %rax
movq %r15, %rdi
callq *0x50(%rax)
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x56070
movq (%r15), %rax
movq %r15, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x78e97
movq %r12, %rdi
callq 0x596e0
movl (%rax), %edi
movl 0x58(%rsp), %eax
movl 0x60(%rsp), %edx
subl %edx, %edi
addl %eax, %edi
jmp 0x78ea1
movl 0x58(%rsp), %eax
movl 0x60(%rsp), %edx
xorl %edi, %edi
movq 0x18(%rsp), %r14
leaq 0x58(%rsp), %rcx
movl 0xc(%rcx), %r8d
subl 0x4(%rcx), %r8d
leaq 0x20(%rsp), %rsi
movl %edi, (%rsi)
andl $0x0, 0x4(%rsi)
addl %edi, %edx
subl %eax, %edx
movl %edx, 0x8(%rsi)
movl %r8d, 0xc(%rsi)
movq %r12, %rdi
movq %r14, %rdx
callq 0x56c40
cmpw $0x1, 0x1a0(%r15)
movl $0x0, %r13d
jne 0x7926a
movl 0x30(%r15), %eax
cmpl $0x2, %eax
je 0x78f37
cmpl $0x1, %eax
jne 0x790af
movl 0x5c4(%r15), %eax
movl 0x5c8(%r15), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movslq %ecx, %rsi
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x57e80
leaq 0xf0(%r15), %rdi
movq %r14, %rsi
callq 0x56630
leaq 0x58(%rsp), %rdi
jmp 0x790aa
movq 0xe84aa(%rip), %rax     # 0x1613e8
movq (%rax), %r14
cmpl $0x0, 0x5c4(%r15)
jle 0x79012
leaq 0x6d0da(%rip), %rsi     # 0xe6030
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x58c40
movq %r14, %rdi
movq %r12, %rsi
callq 0x59510
movq %rax, %r14
leaq 0x6d0bc(%rip), %rsi     # 0xe6034
leaq 0x40(%rsp), %rdi
callq 0x58c40
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 0x6d079(%rip), %xmm1    # 0xe6028
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x6a9a9(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm1
cvttsd2si %xmm1, %rax
xorl %esi, %esi
testl %eax, %eax
cmovgl %eax, %esi
leaq 0x98(%rsp), %rdi
callq 0x57e80
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x98(%rsp), %rcx
movq %r14, %rsi
callq 0x59350
leaq 0xf0(%r15), %rdi
leaq 0x58(%rsp), %rsi
callq 0x56630
jmp 0x79084
leaq 0x6d017(%rip), %rsi     # 0xe6030
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x58c40
movq %r14, %rdi
movq %r12, %rsi
callq 0x59510
movq %rax, %r14
leaq 0x6cff9(%rip), %rsi     # 0xe6034
leaq 0x40(%rsp), %rdi
callq 0x58c40
leaq 0xa2fde(%rip), %rsi     # 0x11c02a
leaq 0x98(%rsp), %rdi
callq 0x58c40
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x98(%rsp), %rcx
movq %r14, %rsi
callq 0x59350
leaq 0xf0(%r15), %rdi
leaq 0x58(%rsp), %rsi
callq 0x56630
leaq 0x58(%rsp), %rdi
callq 0x5a588
leaq 0x98(%rsp), %rdi
callq 0x5a588
leaq 0x40(%rsp), %rdi
callq 0x5a588
leaq 0x20(%rsp), %rdi
callq 0x5a588
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, %r14
leaq 0x140(%r15), %rbx
leaq 0xf0(%r15), %rsi
movq %rsi, 0xc0(%rsp)
movq %rbx, %rdi
movq %rbx, 0xb8(%rsp)
callq 0x57870
movl %eax, %edx
movl %eax, 0x3c(%rsp)
movl 0xc(%rsp), %ebp
movl 0x10(%rsp), %eax
movl 0x8(%rsp), %ecx
addl %edx, %ecx
subl %ecx, %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, %r12d
addl %r14d, %r12d
movq %r14, 0xb0(%rsp)
shrq $0x20, %r14
movl 0x14(%rsp), %r13d
movq 0xe8c9d(%rip), %rsi     # 0x161db8
movq %rbx, %rdi
callq 0x588a0
addl %ebp, %eax
subl %eax, %r13d
cvtsi2sd %r13d, %xmm0
mulsd 0x6a24b(%rip), %xmm0    # 0xe3380
callq 0x57e30
leal (%rax,%r14), %ebp
leal (%rax,%r14), %r13d
decl %r13d
movl 0x14(%rsp), %r14d
subl 0xc(%rsp), %r14d
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x59c60
cwtl
addl %eax, %eax
cvtsi2sd %eax, %xmm0
divsd 0x6a3a5(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x6a7f1(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
notl %eax
leaq 0x20(%rsp), %rdx
movl %r12d, (%rdx)
movl %r13d, 0x4(%rdx)
addl 0x3c(%rsp), %r12d
movl %r12d, 0x8(%rdx)
movq 0xb8(%rsp), %r12
leal (%r14,%rbp), %ecx
decl %ecx
movq %rbx, %r14
movq 0xc0(%rsp), %rbx
addl %eax, %ecx
movl %ecx, 0xc(%rdx)
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x58df0
movl 0x5c4(%r15), %eax
testl %eax, %eax
movl $0x0, %r13d
jle 0x7926a
movl 0x10(%rsp), %ecx
subl 0x8(%rsp), %ecx
addl $-0x2, %ecx
cvtsi2sd %ecx, %xmm0
movl 0x5c8(%r15), %ecx
movl 0x5cc(%r15), %edx
subl %ecx, %edx
cvtsi2sd %edx, %xmm1
subl %ecx, %eax
cvtsi2sd %eax, %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
addl 0xb0(%rsp), %eax
movl %eax, 0x28(%rsp)
leaq 0x58(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x56bf0
movq 0xe88f5(%rip), %rsi     # 0x161b30
movq %r14, %rdi
movq 0x18(%rsp), %r14
callq 0x59940
leaq 0x20(%rsp), %rdx
leaq 0x58(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0x58df0
leaq 0x58(%rsp), %rdi
callq 0x57860
movq %r14, %rdi
callq 0x59a80
jmp 0x78c8b
jmp 0x79281
jmp 0x79290
jmp 0x792a2
jmp 0x792b3
jmp 0x792b3
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x5a588
jmp 0x79293
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x5a588
jmp 0x792a5
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x5a588
jmp 0x792b6
jmp 0x792b3
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5a588
jmp 0x792d9
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
jmp 0x792bb
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x57860
movq %rbx, %rdi
callq 0x58260
nop