// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0xc0(%rbp)
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movb $0x0, -0x19(%rbp)
movq -0x18(%rbp), %rsi
movsbl 0xa(%rax), %edx
callq 0x59b20
leaq -0x24(%rbp), %rdi
callq 0x5b530
jmp 0x6cf0f
leaq -0x3c(%rbp), %rdi
callq 0x5b530
jmp 0x6cf1a
movq -0xb0(%rbp), %rax
cvtsi2sdl 0x10(%rax), %xmm0
movq -0x18(%rbp), %rcx
cvtsi2sdl (%rcx), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
cvtsi2sdl 0x14(%rax), %xmm0
movq -0x18(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x6d30c
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x6d2fc
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
cvtsi2sdl -0x3c(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
cvtsi2sd %ecx, %xmm0
movsd -0x48(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x11a4c6(%rip), %xmm1   # 0x187490
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jge 0x6d29a
cvtsi2sdl -0x38(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
cvtsi2sd %ecx, %xmm0
movsd -0x50(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x11a487(%rip), %xmm1   # 0x187490
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jge 0x6d28a
movq -0xb0(%rbp), %rsi
movq (%rsi), %rax
movq 0x60(%rax), %rax
leaq -0x88(%rbp), %rdi
leaq -0x24(%rbp), %rdx
callq *%rax
jmp 0x6d036
leaq -0x88(%rbp), %rdi
callq 0x59210
movq %rax, -0xc8(%rbp)
jmp 0x6d04b
movq -0xc8(%rbp), %rax
movl %eax, -0x74(%rbp)
cvtsi2sdl -0x3c(%rbp), %xmm1
movsd -0x48(%rbp), %xmm2
cvtsi2sdl -0x24(%rbp), %xmm0
mulsd %xmm2, %xmm1
subsd %xmm0, %xmm1
xorps %xmm0, %xmm0
callq 0x5d580
movsd %xmm0, -0xd0(%rbp)
jmp 0x6d07e
movsd -0xd0(%rbp), %xmm1
movsd 0x11a2da(%rip), %xmm0   # 0x187368
subsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movl -0x24(%rbp), %eax
incl %eax
cvtsi2sd %eax, %xmm1
movl -0x3c(%rbp), %eax
incl %eax
cvtsi2sd %eax, %xmm0
movsd -0x48(%rbp), %xmm2
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm1
xorps %xmm0, %xmm0
callq 0x5d580
movsd %xmm0, -0xd8(%rbp)
jmp 0x6d0cb
movsd -0xd8(%rbp), %xmm1
movsd -0xe0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd -0x48(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
cvtsi2sdl -0x38(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
cvtsi2sdl -0x20(%rbp), %xmm0
mulsd %xmm2, %xmm1
subsd %xmm0, %xmm1
xorps %xmm0, %xmm0
callq 0x5d580
movsd %xmm0, -0xe8(%rbp)
jmp 0x6d119
movsd -0xe8(%rbp), %xmm1
movsd 0x11a23f(%rip), %xmm0   # 0x187368
subsd %xmm1, %xmm0
movsd %xmm0, -0xf8(%rbp)
movl -0x20(%rbp), %eax
incl %eax
cvtsi2sd %eax, %xmm1
movl -0x38(%rbp), %eax
incl %eax
cvtsi2sd %eax, %xmm0
movsd -0x50(%rbp), %xmm2
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm1
xorps %xmm0, %xmm0
callq 0x5d580
movsd %xmm0, -0xf0(%rbp)
jmp 0x6d166
movq -0xb0(%rbp), %rax
movsd -0xf0(%rbp), %xmm1
movsd -0xf8(%rbp), %xmm0
subsd %xmm1, %xmm0
divsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movl -0x74(%rbp), %ecx
andl $0xff, %ecx
cvtsi2sd %ecx, %xmm0
mulsd -0x90(%rbp), %xmm0
movsd -0x98(%rbp), %xmm2
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x74(%rbp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
cvtsi2sd %ecx, %xmm0
mulsd -0x90(%rbp), %xmm0
movsd -0x98(%rbp), %xmm2
movsd -0x60(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x74(%rbp), %ecx
sarl $0x10, %ecx
andl $0xff, %ecx
cvtsi2sd %ecx, %xmm0
mulsd -0x90(%rbp), %xmm0
movsd -0x98(%rbp), %xmm2
movsd -0x68(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsbl 0xa(%rax), %eax
cmpl $0x20, %eax
jne 0x6d27a
movl -0x74(%rbp), %eax
sarl $0x18, %eax
andl $0xff, %eax
cvtsi2sd %eax, %xmm0
mulsd -0x90(%rbp), %xmm0
movsd -0x98(%rbp), %xmm2
movsd -0x70(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
jmp 0x6d27a
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x5de40
jmp 0x6d332
jmp 0x6d27c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x6cfeb
jmp 0x6d28c
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x6cfac
cvttsd2si -0x58(%rbp), %eax
cvttsd2si -0x60(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
cvttsd2si -0x68(%rbp), %ecx
shll $0x10, %ecx
orl %ecx, %eax
cvttsd2si -0x70(%rbp), %ecx
shll $0x18, %ecx
orl %ecx, %eax
movslq %eax, %rsi
leaq -0xa8(%rbp), %rdi
movl $0x1, %edx
callq 0x59be0
jmp 0x6d2d3
movq -0xc0(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x5a3d0
jmp 0x6d2ec
jmp 0x6d2ee
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6cf6c
jmp 0x6d2fe
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x6cf55
movb $0x1, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x6d322
movq -0xc0(%rbp), %rdi
callq 0x5de40
movq -0xb8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x5b6b0
nopl (%rax,%rax)