// File: /workspace/github_c_makefile_star2_O2/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 $0x88, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movsbl 0xa(%rsi), %edx
movq %r14, %rsi
callq 0x569c0
leaq 0x18(%rsp), %r12
andl $0x0, 0x4(%r12)
cvtdq2pd 0x10(%r15), %xmm2
movq (%r14), %rcx
movq %rcx, %xmm0
cvtdq2pd %xmm0, %xmm1
divpd %xmm1, %xmm2
movapd %xmm2, %xmm1
shufpd $0x1, %xmm2, %xmm1      # xmm1 = xmm1[1],xmm2[0]
movapd %xmm1, 0x70(%rsp)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
movapd %xmm2, 0x20(%rsp)
movapd %xmm2, %xmm4
unpckhpd %xmm2, %xmm4            # xmm4 = xmm4[1],xmm2[1]
xorl %edx, %edx
leaq 0x50(%rsp), %r13
movl $0xff, %ebp
movapd %xmm4, 0x60(%rsp)
movl %edx, 0xc(%rsp)
cmpl %eax, %edx
jge 0x61088
xorl %eax, %eax
movl %eax, 0x8(%rsp)
cmpl %ecx, %eax
jge 0x61079
cvtsi2sd %eax, %xmm0
mulsd 0x20(%rsp), %xmm0
cvttsd2si %xmm0, %ecx
xorpd %xmm6, %xmm6
xorpd %xmm7, %xmm7
xorpd %xmm3, %xmm3
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl %ecx, 0x18(%rsp)
leal 0x1(%rax), %edx
cvtsi2sd %edx, %xmm0
mulsd 0x20(%rsp), %xmm0
addsd 0x82694(%rip), %xmm0    # 0xe34d8
cvttsd2si %xmm0, %edx
cmpl %edx, %ecx
jge 0x61024
movl 0xc(%rsp), %edx
cvtsi2sd %edx, %xmm0
mulsd %xmm4, %xmm0
cvttsd2si %xmm0, %esi
movl %esi, 0x1c(%rsp)
incl %edx
cvtsi2sd %edx, %xmm0
mulsd %xmm4, %xmm0
addsd 0x82662(%rip), %xmm0    # 0xe34d8
cvttsd2si %xmm0, %edx
cmpl %edx, %esi
jge 0x6101d
movsd %xmm7, 0x38(%rsp)
movsd %xmm6, 0x40(%rsp)
movsd %xmm3, 0x48(%rsp)
movq (%r15), %rax
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x60(%rax)
movq 0x8(%rsp), %rax
movq %rax, %xmm1
cvtdq2pd %xmm1, %xmm4
movq 0x18(%rsp), %rcx
movq %rcx, %xmm0
cvtdq2pd %xmm0, %xmm2
pcmpeqd %xmm5, %xmm5
psubd %xmm5, %xmm0
cvtdq2pd %xmm0, %xmm3
psubd %xmm5, %xmm1
cvtdq2pd %xmm1, %xmm1
shufpd $0x1, %xmm1, %xmm1      # xmm1 = xmm1[1,0]
shufpd $0x1, %xmm4, %xmm4      # xmm4 = xmm4[1,0]
shufpd $0x1, %xmm3, %xmm3      # xmm3 = xmm3[1,0]
shufpd $0x1, %xmm2, %xmm2      # xmm2 = xmm2[1,0]
movapd 0x70(%rsp), %xmm5
mulpd %xmm5, %xmm1
subpd %xmm1, %xmm3
mulpd %xmm5, %xmm4
subpd %xmm2, %xmm4
movapd %xmm3, %xmm1
xorpd %xmm5, %xmm5
cmpltpd %xmm5, %xmm1
movapd %xmm4, %xmm2
cmpltpd %xmm5, %xmm2
shufps $0x88, %xmm2, %xmm1     # xmm1 = xmm1[0,2],xmm2[0,2]
movmskps %xmm1, %edx
movsd 0x8244e(%rip), %xmm7    # 0xe3370
movapd %xmm7, %xmm1
testb $0x8, %dl
jne 0x60f3b
movapd %xmm4, %xmm2
unpckhpd %xmm4, %xmm2            # xmm2 = xmm2[1],xmm4[1]
movapd %xmm7, %xmm1
subsd %xmm2, %xmm1
xorpd %xmm6, %xmm6
xorpd %xmm5, %xmm5
testb $0x2, %dl
jne 0x60f50
movapd %xmm3, %xmm5
unpckhpd %xmm3, %xmm5            # xmm5 = xmm5[1],xmm3[1]
movapd %xmm7, %xmm2
testb $0x4, %dl
jne 0x60f61
movapd %xmm7, %xmm2
subsd %xmm4, %xmm2
testb $0x1, %dl
jne 0x60f6a
movapd %xmm3, %xmm6
subsd %xmm6, %xmm2
movl 0x58(%rsp), %edi
subsd %xmm5, %xmm1
divsd 0x20(%rsp), %xmm1
movapd 0x60(%rsp), %xmm4
divsd %xmm4, %xmm2
movl %edi, %edx
andl %ebp, %edx
cvtsi2sd %edx, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
movsd 0x40(%rsp), %xmm6
addsd %xmm3, %xmm6
movl %edi, %edx
shrl $0x8, %edx
andl %ebp, %edx
cvtsi2sd %edx, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
movsd 0x38(%rsp), %xmm7
addsd %xmm3, %xmm7
movl %edi, %edx
shrl $0x10, %edx
andl %ebp, %edx
cvtsi2sd %edx, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
movsd 0x48(%rsp), %xmm5
addsd %xmm3, %xmm5
movapd %xmm5, %xmm3
movq %rax, %rdx
shrq $0x20, %rdx
cmpb $0x20, 0xa(%r15)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %esi
jne 0x60e60
shrl $0x18, %edi
cvtsi2sd %edi, %xmm0
mulsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x60e60
incl %ecx
jmp 0x60e2b
cvttsd2si %xmm6, %eax
cvttsd2si %xmm7, %ecx
shll $0x8, %ecx
orl %eax, %ecx
cvttsd2si %xmm3, %eax
shll $0x10, %eax
cvttsd2si 0x10(%rsp), %edx
shll $0x18, %edx
orl %eax, %edx
orl %ecx, %edx
movslq %edx, %rax
movq %rax, 0x58(%rsp)
movl $0x1, 0x50(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x57160
movl 0x8(%rsp), %eax
incl %eax
movl (%r14), %ecx
movapd 0x60(%rsp), %xmm4
jmp 0x60dfb
movl 0xc(%rsp), %edx
incl %edx
movl 0x4(%r14), %eax
jmp 0x60ded
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6109f
movq %rax, %r14
movq %rbx, %rdi
callq 0x5a4c8
movq %r14, %rdi
callq 0x58260