// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/graphics/backends/bitmapbackend.cpp
// Function: smooth::GUI::BitmapBackend::Scale(smooth::GUI::Size const&) const
S::GUI::Bitmap S::GUI::BitmapBackend::Scale(const Size &newSize) const
{
	Bitmap	 bitmap(newSize, depth);

	Point	 srcPoint;
	Point	 destPoint;

	Float	 scaleFactorX = Float(size.cx) / Float(newSize.cx);
	Float	 scaleFactorY = Float(size.cy) / Float(newSize.cy);

	for (destPoint.y = 0; destPoint.y < newSize.cy; destPoint.y++)
	{
		for (destPoint.x = 0; destPoint.x < newSize.cx; destPoint.x++)
		{
			Float	 red = 0, green = 0, blue = 0, alpha = 0;

			for (srcPoint.x = Int(Float(destPoint.x) * scaleFactorX); srcPoint.x < Int(Float(destPoint.x + 1) * scaleFactorX + 0.9999); srcPoint.x++)
			{
				for (srcPoint.y = Int(Float(destPoint.y) * scaleFactorY); srcPoint.y < Int(Float(destPoint.y + 1) * scaleFactorY + 0.9999); srcPoint.y++)
				{
					Int	 color	 = GetPixel(srcPoint);

					Float	 weightX = (1.0 - Math::Max(0.0, Float(destPoint.x) * scaleFactorX - Float(srcPoint.x)) - Math::Max(0.0, Float(srcPoint.x + 1) - Float(destPoint.x + 1) * scaleFactorX)) / scaleFactorX;
					Float	 weightY = (1.0 - Math::Max(0.0, Float(destPoint.y) * scaleFactorY - Float(srcPoint.y)) - Math::Max(0.0, Float(srcPoint.y + 1) - Float(destPoint.y + 1) * scaleFactorY)) / scaleFactorY;

					red   += Float(	color	     & 255) * weightX * weightY;
					green += Float((color >>  8) & 255) * weightX * weightY;
					blue  += Float((color >> 16) & 255) * weightX * weightY;

					if (depth == 32) alpha += Float((color >> 24) & 255) * weightX * weightY;
				}
			}

			bitmap.SetPixel(destPoint, Color(Int(red) | (Int(green) << 8) | (Int(blue) << 16) | (Int(alpha) << 24), Color::RGBA));
		}
	}

	return bitmap;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movsbl 0xa(%rsi), %edx
movq %r14, %rsi
callq 0x55960
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
cvtsi2sdl 0x10(%r15), %xmm0
movsd %xmm0, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl (%r14), %xmm0
cvtsi2sdl 0x14(%r15), %xmm4
movl 0x4(%r14), %eax
movl $0x0, 0xc(%rsp)
testl %eax, %eax
jle 0x60270
cvtsi2sd %eax, %xmm1
movsd 0x18(%rsp), %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, 0x18(%rsp)
divsd %xmm1, %xmm4
movsd 0x94537(%rip), %xmm2    # 0xf44b8
leaq 0x48(%rsp), %r12
leaq 0x10(%rsp), %r13
movl $0xff, %ebp
movsd %xmm4, 0x28(%rsp)
movl $0x0, 0x8(%rsp)
cmpl $0x0, (%r14)
jle 0x6025c
xorl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x18(%rsp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x10(%rsp)
movl 0x8(%rsp), %ecx
incl %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jge 0x6021c
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
xorpd %xmm1, %xmm1
xorpd %xmm3, %xmm3
xorpd %xmm5, %xmm5
movl 0xc(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd %xmm4, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x14(%rsp)
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd %xmm4, %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %eax
cmpl %eax, %ecx
jge 0x601ca
movsd %xmm5, 0x30(%rsp)
movsd %xmm3, 0x38(%rsp)
movsd %xmm1, 0x40(%rsp)
movq (%r15), %rax
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *0x60(%rax)
movl 0x50(%rsp), %ecx
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movl 0x10(%rsp), %edi
movl 0x14(%rsp), %eax
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
movsd 0x18(%rsp), %xmm3
mulsd %xmm3, %xmm0
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
movsd 0x942f9(%rip), %xmm5    # 0xf4388
movapd %xmm5, %xmm0
subsd %xmm1, %xmm0
incl %edi
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
incl %esi
xorps %xmm2, %xmm2
cvtsi2sd %esi, %xmm2
mulsd %xmm3, %xmm2
subsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
maxsd %xmm1, %xmm2
subsd %xmm2, %xmm0
divsd %xmm3, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
movsd 0x28(%rsp), %xmm4
mulsd %xmm4, %xmm1
subsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
maxsd %xmm1, %xmm2
movapd %xmm5, %xmm1
incl %eax
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
subsd %xmm2, %xmm1
incl %edx
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
mulsd %xmm4, %xmm2
subsd %xmm2, %xmm3
xorpd %xmm2, %xmm2
maxsd %xmm3, %xmm2
subsd %xmm2, %xmm1
divsd %xmm4, %xmm1
cmpb $0x20, 0xa(%r15)
jne 0x60142
movl %ecx, %edx
shrl $0x18, %edx
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movsd 0x20(%rsp), %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, 0x20(%rsp)
movsd 0x38(%rsp), %xmm3
movsd 0x30(%rsp), %xmm5
movl %ecx, %edx
andl %ebp, %edx
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm5
movl %ecx, %edx
shrl $0x8, %edx
andl %ebp, %edx
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm3
shrl $0x10, %ecx
andl %ebp, %ecx
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movsd 0x40(%rsp), %xmm1
addsd %xmm2, %xmm1
movl %eax, 0x14(%rsp)
movl 0xc(%rsp), %ecx
incl %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd %xmm4, %xmm0
movsd 0x942fe(%rip), %xmm2    # 0xf44b8
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jl 0x6002e
movl 0x10(%rsp), %eax
incl %eax
movl %eax, 0x10(%rsp)
movl 0x8(%rsp), %ecx
incl %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd 0x18(%rsp), %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jl 0x5fffa
cvttsd2si %xmm5, %eax
cvttsd2si %xmm3, %ecx
shll $0x8, %ecx
cvttsd2si %xmm1, %edx
orl %eax, %ecx
shll $0x10, %edx
cvttsd2si 0x20(%rsp), %eax
shll $0x18, %eax
orl %edx, %eax
orl %ecx, %eax
cltq
jmp 0x6021e
xorl %eax, %eax
movq %rax, 0x50(%rsp)
movl $0x1, 0x48(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x56080
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl (%r14), %eax
movsd 0x28(%rsp), %xmm4
movsd 0x94262(%rip), %xmm2    # 0xf44b8
jl 0x5ffaa
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
cmpl 0x4(%r14), %eax
jl 0x5ff96
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x60284
movq %rax, %r14
movq %rbx, %rdi
callq 0x59148
movq %r14, %rdi
callq 0x57090
nop