// File: /workspace/github_c_makefile_star2_O3/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 0x55960
xorl %eax, %eax
movl %eax, 0x14(%rsp)
cvtdq2pd 0x10(%r15), %xmm2
movq (%r14), %xmm0
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movd %xmm1, %ecx
movl %eax, 0xc(%rsp)
testl %ecx, %ecx
jle 0x602fe
cvtdq2pd %xmm0, %xmm1
divpd %xmm1, %xmm2
movapd %xmm2, %xmm1
shufpd $0x1, %xmm2, %xmm1      # xmm1 = xmm1[1],xmm2[0]
movapd %xmm1, 0x70(%rsp)
movd %xmm0, %edx
movapd %xmm2, 0x30(%rsp)
movapd %xmm2, %xmm6
unpckhpd %xmm2, %xmm6            # xmm6 = xmm6[1],xmm2[1]
movsd 0x93513(%rip), %xmm4    # 0xf34e8
leaq 0x50(%rsp), %r12
leaq 0x10(%rsp), %r13
movl $0xff, %ebp
movapd %xmm6, 0x60(%rsp)
movl $0x0, 0x8(%rsp)
testl %edx, %edx
jle 0x602f0
xorl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movapd 0x30(%rsp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x10(%rsp)
leal 0x1(%rax), %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %edx
cmpl %edx, %ecx
jge 0x602a6
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0xc(%rsp), %edx
xorpd %xmm5, %xmm5
xorpd %xmm7, %xmm7
xorpd %xmm8, %xmm8
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
mulsd %xmm6, %xmm0
cvttsd2si %xmm0, %esi
movl %esi, 0x14(%rsp)
leal 0x1(%rdx), %edi
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
mulsd %xmm6, %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %edi
cmpl %edi, %esi
jge 0x6025a
movsd %xmm8, 0x20(%rsp)
movsd %xmm7, 0x28(%rsp)
movsd %xmm5, 0x48(%rsp)
movq (%r15), %rax
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *0x60(%rax)
movq 0x8(%rsp), %xmm1
cvtdq2pd %xmm1, %xmm6
movq 0x10(%rsp), %xmm2
cvtdq2pd %xmm2, %xmm3
pcmpeqd %xmm4, %xmm4
psubd %xmm4, %xmm2
cvtdq2pd %xmm2, %xmm5
movdqa %xmm1, %xmm0
psubd %xmm4, %xmm0
cvtdq2pd %xmm0, %xmm0
movapd %xmm0, %xmm4
shufpd $0x1, %xmm0, %xmm4      # xmm4 = xmm4[1],xmm0[0]
shufpd $0x1, %xmm6, %xmm6      # xmm6 = xmm6[1,0]
shufpd $0x1, %xmm5, %xmm5      # xmm5 = xmm5[1,0]
shufpd $0x1, %xmm3, %xmm3      # xmm3 = xmm3[1,0]
movapd 0x70(%rsp), %xmm7
mulpd %xmm7, %xmm4
subpd %xmm4, %xmm5
mulpd %xmm7, %xmm6
subpd %xmm3, %xmm6
movapd %xmm5, %xmm3
xorpd %xmm7, %xmm7
cmpltpd %xmm7, %xmm3
movapd %xmm6, %xmm4
cmpltpd %xmm7, %xmm4
shufps $0x88, %xmm4, %xmm3     # xmm3 = xmm3[0,2],xmm4[0,2]
movmskps %xmm3, %eax
movsd 0x93267(%rip), %xmm9    # 0xf3388
movapd %xmm9, %xmm3
testb $0x8, %al
jne 0x6013b
movapd %xmm6, %xmm4
unpckhpd %xmm6, %xmm4            # xmm4 = xmm4[1],xmm6[1]
movapd %xmm9, %xmm3
subsd %xmm4, %xmm3
xorpd %xmm8, %xmm8
xorpd %xmm7, %xmm7
testb $0x2, %al
jne 0x60150
movapd %xmm5, %xmm7
unpckhpd %xmm5, %xmm7            # xmm7 = xmm7[1],xmm5[1]
movapd %xmm9, %xmm4
testb $0x4, %al
jne 0x60162
movapd %xmm9, %xmm4
subsd %xmm6, %xmm4
testb $0x1, %al
jne 0x6016b
movapd %xmm5, %xmm8
subsd %xmm8, %xmm4
movl 0x58(%rsp), %eax
subsd %xmm7, %xmm3
divsd 0x30(%rsp), %xmm3
movapd 0x60(%rsp), %xmm6
divsd %xmm6, %xmm4
cmpb $0x20, 0xa(%r15)
jne 0x601b3
movl %eax, %ecx
shrl $0x18, %ecx
xorps %xmm5, %xmm5
cvtsi2sd %ecx, %xmm5
mulsd %xmm3, %xmm5
mulsd %xmm4, %xmm5
movsd 0x18(%rsp), %xmm7
addsd %xmm5, %xmm7
movsd %xmm7, 0x18(%rsp)
movsd 0x28(%rsp), %xmm7
movsd 0x20(%rsp), %xmm8
movl %eax, %ecx
andl %ebp, %ecx
xorps %xmm5, %xmm5
cvtsi2sd %ecx, %xmm5
mulsd %xmm3, %xmm5
mulsd %xmm4, %xmm5
addsd %xmm5, %xmm8
movl %eax, %ecx
shrl $0x8, %ecx
andl %ebp, %ecx
xorps %xmm5, %xmm5
cvtsi2sd %ecx, %xmm5
mulsd %xmm3, %xmm5
mulsd %xmm4, %xmm5
addsd %xmm5, %xmm7
shrl $0x10, %eax
andl %ebp, %eax
xorps %xmm5, %xmm5
cvtsi2sd %eax, %xmm5
mulsd %xmm3, %xmm5
mulsd %xmm4, %xmm5
movsd 0x48(%rsp), %xmm3
addsd %xmm5, %xmm3
movapd %xmm3, %xmm5
pshufd $0x55, %xmm2, %xmm3     # xmm3 = xmm2[1,1,1,1]
movd %xmm3, %eax
movd %xmm3, 0x14(%rsp)
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
mulsd %xmm6, %xmm3
movsd 0x932b1(%rip), %xmm4    # 0xf34e8
addsd %xmm4, %xmm3
cvttsd2si %xmm3, %ecx
cmpl %ecx, %eax
jl 0x6007f
pshufd $0x55, %xmm1, %xmm3     # xmm3 = xmm1[1,1,1,1]
movd %xmm3, %edx
movd %xmm1, %eax
movd %xmm2, %ecx
jmp 0x60266
incl %ecx
leal 0x1(%rax), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movl %ecx, 0x10(%rsp)
mulsd 0x30(%rsp), %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %esi
cmpl %esi, %ecx
jl 0x6004e
cvttsd2si %xmm8, %eax
cvttsd2si %xmm7, %ecx
shll $0x8, %ecx
cvttsd2si %xmm5, %edx
orl %eax, %ecx
shll $0x10, %edx
cvttsd2si 0x18(%rsp), %eax
shll $0x18, %eax
orl %edx, %eax
orl %ecx, %eax
cltq
jmp 0x602a8
xorl %eax, %eax
movq %rax, 0x58(%rsp)
movl $0x1, 0x50(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x56080
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
movl (%r14), %edx
cmpl %edx, %eax
movapd 0x60(%rsp), %xmm6
movsd 0x93206(%rip), %xmm4    # 0xf34e8
jl 0x5fffc
movl 0xc(%rsp), %eax
movl 0x4(%r14), %ecx
incl %eax
movl %eax, 0xc(%rsp)
cmpl %ecx, %eax
jl 0x5ffea
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x60315
movq %rax, %r14
movq %rbx, %rdi
callq 0x59148
movq %r14, %rdi
callq 0x57090