// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r8d, 0x30(%rsp)
movq %rdi, 0x68(%rsp)
movl 0x8(%rdx), %r15d
movl $0xff, %eax
movl %r15d, %ebx
andl %eax, %ebx
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x20(%rsp)
movl %r15d, %r13d
shrl $0x8, %r13d
andl %eax, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x18(%rsp)
shrl $0x10, %r15d
andl %eax, %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x8(%rcx), %r12d
movl %r12d, %r14d
andl %eax, %r14d
movl %r12d, %ebp
shrl $0x8, %ebp
andl %eax, %ebp
shrl $0x10, %r12d
movl 0x8(%rsi), %edx
movl 0xc(%rsi), %ecx
subl (%rsi), %edx
movq %rsi, 0x70(%rsp)
subl 0x4(%rsi), %ecx
andl %eax, %r12d
leaq 0x48(%rsp), %rsi
movl %edx, 0x38(%rsp)
movl %edx, (%rsi)
movl %ecx, 0xc(%rsp)
movl %ecx, 0x4(%rsi)
leaq 0x40(%rsp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x55960
movl 0x30(%rsp), %eax
cmpl $0x2, %eax
je 0x61275
cmpl $0x1, %eax
jne 0x61424
movq 0x68(%rsp), %rax
leaq 0x28(%rax), %rdi
callq 0x632d8
subl %ebx, %r14d
cvtsi2sd %r14d, %xmm1
movl 0x38(%rsp), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
subl %r13d, %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rsp)
subl %r15d, %r12d
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x58(%rsp)
testb %al, %al
je 0x61372
testl %esi, %esi
jle 0x61424
leaq 0x40(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x48(%rsp), %r13
movl %esi, %ecx
movq %rcx, 0x38(%rsp)
leal -0x1(%rcx), %esi
movsd 0x20(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x61265
cvttsd2si 0x20(%rsp), %eax
cvttsd2si 0x18(%rsp), %ecx
cvttsd2si 0x10(%rsp), %edx
shll $0x10, %edx
orl %eax, %edx
shll $0x8, %ecx
orl %edx, %ecx
movslq %ecx, %r14
xorl %ebx, %ebx
movl %esi, %ebp
movl %esi, 0x28(%rsp)
movl %ebx, 0x2c(%rsp)
movq %r14, 0x50(%rsp)
movl $0x0, 0x48(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x56080
incl %ebx
cmpl %ebx, 0xc(%rsp)
movl %ebp, %esi
jne 0x61236
cmpl $0x1, 0x38(%rsp)
jg 0x611ce
jmp 0x61424
cmpl $0x0, 0xc(%rsp)
movl 0x38(%rsp), %eax
jle 0x61424
subl %ebx, %r14d
cvtsi2sd %r14d, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rsp), %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
subl %r13d, %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rsp)
subl %r15d, %r12d
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x58(%rsp)
xorl %ebp, %ebp
leaq 0x40(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x48(%rsp), %r13
movsd 0x10(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x20(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
testl %eax, %eax
jle 0x61361
cvttsd2si 0x20(%rsp), %eax
cvttsd2si 0x18(%rsp), %ecx
cvttsd2si 0x10(%rsp), %edx
shll $0x10, %edx
orl %eax, %edx
shll $0x8, %ecx
orl %edx, %ecx
movslq %ecx, %r14
xorl %ebx, %ebx
movl %ebx, 0x28(%rsp)
movl %ebp, 0x2c(%rsp)
movq %r14, 0x50(%rsp)
movl $0x0, 0x48(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x56080
incl %ebx
movl 0x38(%rsp), %eax
cmpl %ebx, %eax
jne 0x61334
incl %ebp
cmpl 0xc(%rsp), %ebp
jne 0x612d9
jmp 0x61424
testl %esi, %esi
jle 0x61424
xorl %ebp, %ebp
leaq 0x40(%rsp), %rbx
leaq 0x28(%rsp), %r12
leaq 0x48(%rsp), %r13
movsd 0x20(%rsp), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x61418
cvttsd2si 0x20(%rsp), %eax
cvttsd2si 0x18(%rsp), %ecx
cvttsd2si 0x10(%rsp), %edx
shll $0x10, %edx
orl %eax, %edx
shll $0x8, %ecx
orl %edx, %ecx
movslq %ecx, %r15
xorl %r14d, %r14d
movl %ebp, 0x28(%rsp)
movl %r14d, 0x2c(%rsp)
movq %r15, 0x50(%rsp)
movl $0x0, 0x48(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x56080
incl %r14d
cmpl %r14d, 0xc(%rsp)
jne 0x613ea
incl %ebp
cmpl 0x38(%rsp), %ebp
jne 0x6138b
movq 0x70(%rsp), %rcx
movl 0x8(%rcx), %eax
subl (%rcx), %eax
movl 0xc(%rcx), %esi
subl 0x4(%rcx), %esi
leaq 0x48(%rsp), %rdx
movq $0x0, (%rdx)
movl %eax, 0x8(%rdx)
movl %esi, 0xc(%rdx)
movq 0x68(%rsp), %rdi
movq (%rdi), %rax
leaq 0x40(%rsp), %rsi
callq *0x90(%rax)
leaq 0x40(%rsp), %rdi
callq 0x59148
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6147c
jmp 0x6147c
jmp 0x6147c
jmp 0x6147c
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x59148
movq %rbx, %rdi
callq 0x57090
nop