// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/graphics/backends/surfacebackend.cpp
// Function: smooth::GUI::SurfaceBackend::Gradient(smooth::GUI::Rect const&, smooth::GUI::Color const&, smooth::GUI::Color const&, int)
S::Int S::GUI::SurfaceBackend::Gradient(const Rect &rect, const Color &color1, const Color &color2, Int style)
{
	Float	 red1	= color1.GetRed();
	Float	 green1	= color1.GetGreen();
	Float	 blue1	= color1.GetBlue();
	Float	 red2	= color2.GetRed();
	Float	 green2	= color2.GetGreen();
	Float	 blue2	= color2.GetBlue();
	Int	 xmax	= rect.GetWidth();
	Int	 ymax	= rect.GetHeight();

	Bitmap	 bmp(Size(xmax, ymax));

	switch (style)
	{
		case OR_HORZ:
		{
			Float	 biasr = (red2 - red1) / xmax;
			Float	 biasg = (green2 - green1) / xmax;
			Float	 biasb = (blue2 - blue1) / xmax;

			if (rightToLeft.GetRightToLeft())
			{
				for (Int x = xmax - 1; x >= 0; x--)
				{
					red1	= red1 + biasr;
					green1	= green1 + biasg;
					blue1	= blue1 + biasb;

					for (Int y = 0; y < ymax; y++) bmp.SetPixel(Point(x, y), Color((Int) red1, (Int) green1, (Int) blue1));
				}
			}
			else
			{
				for (Int x = 0; x < xmax; x++)
				{
					red1	= red1 + biasr;
					green1	= green1 + biasg;
					blue1	= blue1 + biasb;

					for (Int y = 0; y < ymax; y++) bmp.SetPixel(Point(x, y), Color((Int) red1, (Int) green1, (Int) blue1));
				}
			}
		}
		break;

		case OR_VERT:
		{
			Float	 biasr = (red2 - red1) / ymax;
			Float	 biasg = (green2 - green1) / ymax;
			Float	 biasb = (blue2 - blue1) / ymax;

			for (Int y = 0; y < ymax; y++)
			{
				red1	= red1 + biasr;
				green1	= green1 + biasg;
				blue1	= blue1 + biasb;

				for (Int x = 0; x < xmax; x++) bmp.SetPixel(Point(x, y), Color((Int) red1, (Int) green1, (Int) blue1));
			}
		}
		break;
	}

	BlitFromBitmap(bmp, Rect(Point(0, 0), rect.GetSize()), rect);

	return Success();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x18(%rbp), %rdi
callq 0x59f20
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5d920
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5b650
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0x59f20
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5d920
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5b650
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x591a0
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %esi
movl -0x60(%rbp), %edx
leaq -0x70(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x59260
movq -0x150(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x59b20
movl -0x24(%rbp), %eax
movl %eax, -0x144(%rbp)
subl $0x1, %eax
je 0x6f2ad
jmp 0x6f299
movl -0x144(%rbp), %eax
subl $0x2, %eax
je 0x6f502
jmp 0x6f635
movq -0x158(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
subsd %xmm1, %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x50(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
subsd %xmm1, %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x58(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
subsd %xmm1, %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
addq $0x28, %rdi
callq 0x73480
movb %al, -0x159(%rbp)
jmp 0x6f31c
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x6f32b
jmp 0x6f421
movl -0x5c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x98(%rbp)
cmpl $0x0, -0x98(%rbp)
jl 0x6f41c
movsd -0x30(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x38(%rbp), %xmm0
addsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
addsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jge 0x6f406
movl -0x98(%rbp), %esi
movl -0x9c(%rbp), %edx
leaq -0xa4(%rbp), %rdi
callq 0x5c2c0
jmp 0x6f3a3
cvttsd2si -0x30(%rbp), %esi
cvttsd2si -0x38(%rbp), %edx
cvttsd2si -0x40(%rbp), %ecx
leaq -0xb8(%rbp), %rdi
xorl %r8d, %r8d
callq 0x5a6b0
jmp 0x6f3c3
leaq -0x68(%rbp), %rdi
leaq -0xa4(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x5a3d0
jmp 0x6f3dc
jmp 0x6f3de
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x6f37e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x6f70b
jmp 0x6f408
movl -0x98(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x6f337
jmp 0x6f4fd
movl $0x0, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x6f4fb
movsd -0x30(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x38(%rbp), %xmm0
addsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
addsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0x60(%rbp), %eax
jge 0x6f4e5
movl -0xbc(%rbp), %esi
movl -0xc0(%rbp), %edx
leaq -0xc8(%rbp), %rdi
callq 0x5c2c0
jmp 0x6f499
cvttsd2si -0x30(%rbp), %esi
cvttsd2si -0x38(%rbp), %edx
cvttsd2si -0x40(%rbp), %ecx
leaq -0xd8(%rbp), %rdi
xorl %r8d, %r8d
callq 0x5a6b0
jmp 0x6f4b9
leaq -0x68(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x5a3d0
jmp 0x6f4d2
jmp 0x6f4d4
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x6f474
jmp 0x6f4e7
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x6f42b
jmp 0x6f4fd
jmp 0x6f635
movsd -0x48(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x60(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0x50(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x60(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0x58(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
cvtsi2sdl -0x60(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xf0(%rbp)
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0x60(%rbp), %eax
jge 0x6f633
movsd -0x30(%rbp), %xmm0
addsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x38(%rbp), %xmm0
addsd -0xe8(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
addsd -0xf0(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x6f61d
movl -0xf8(%rbp), %esi
movl -0xf4(%rbp), %edx
leaq -0x100(%rbp), %rdi
callq 0x5c2c0
jmp 0x6f5d1
cvttsd2si -0x30(%rbp), %esi
cvttsd2si -0x38(%rbp), %edx
cvttsd2si -0x40(%rbp), %ecx
leaq -0x110(%rbp), %rdi
xorl %r8d, %r8d
callq 0x5a6b0
jmp 0x6f5f1
leaq -0x68(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x5a3d0
jmp 0x6f60a
jmp 0x6f60c
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x6f5ac
jmp 0x6f61f
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x6f55d
jmp 0x6f635
leaq -0x128(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x5c2c0
jmp 0x6f647
movq -0x10(%rbp), %rdi
callq 0x59e00
movq %rax, -0x168(%rbp)
jmp 0x6f659
movq -0x168(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x128(%rbp), %rsi
leaq -0x130(%rbp), %rdx
callq 0x59ff0
jmp 0x6f683
movq -0x158(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq (%rdi), %rax
movq 0x90(%rax), %rax
leaq -0x68(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq *%rax
jmp 0x6f6a7
leaq -0x140(%rbp), %rdi
callq 0x5ca80
jmp 0x6f6b5
leaq -0x140(%rbp), %rdi
callq 0x59680
movl %eax, -0x16c(%rbp)
jmp 0x6f6c9
leaq -0x140(%rbp), %rdi
callq 0x5a410
leaq -0x68(%rbp), %rdi
callq 0x5de40
movl -0x16c(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x5a410
leaq -0x68(%rbp), %rdi
callq 0x5de40
movq -0x90(%rbp), %rdi
callq 0x5b6b0