// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/graphics/backends/cairo/surfacecairo.cpp
// Function: smooth::GUI::SurfaceCairo::Gradient(smooth::GUI::Rect const&, smooth::GUI::Color const&, smooth::GUI::Color const&, int)
S::Int S::GUI::SurfaceCairo::Gradient(const Rect &iRect, const Color &color1, const Color &color2, Int style)
{
	if (window == NIL) return Success();

	Rect	 rect = rightToLeft.TranslateRect(iRect);

	/* Setup colors.
	 */
	Color	 c1   = (style == OR_HORZ && rightToLeft.GetRightToLeft()) ? color2 : color1;
	Color	 c2   = (style == OR_HORZ && rightToLeft.GetRightToLeft()) ? color1 : color2;

	/* Setup Cairo objects and draw gradient.
	 */
	cairo_pattern_t	*pattern = cairo_pattern_create_linear(0, 0, style == OR_HORZ ? rect.GetWidth()	 : 0,
								     style == OR_VERT ? rect.GetHeight() : 0);

	cairo_pattern_add_color_stop_rgb(pattern, 0, c1.GetRed() / 255.0, c1.GetGreen() / 255.0, c1.GetBlue() / 255.0);
	cairo_pattern_add_color_stop_rgb(pattern, 1, c2.GetRed() / 255.0, c2.GetGreen() / 255.0, c2.GetBlue() / 255.0);

	if (!painting)
	{
		CreateCairoContext();

		cairo_set_source(context, pattern);
		cairo_rectangle(context, rect.left, rect.top, rect.GetWidth(), rect.GetHeight());
		cairo_fill(context);

		DestroyCairoContext();
	}

	cairo_set_source(paintContextCairo, pattern);
	cairo_rectangle(paintContextCairo, rect.left, rect.top, rect.GetWidth(), rect.GetHeight());
	cairo_fill(paintContextCairo);

	cairo_pattern_destroy(pattern);

	return Success();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, 0x50(%rax)
jne 0x12e236
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x5ca80
movq -0xb0(%rbp), %rdi
callq 0x59680
movl %eax, -0xa4(%rbp)
jmp 0x12e205
movl -0xa4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5a410
jmp 0x12e643
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5a410
jmp 0x12e64f
movq -0xa0(%rbp), %rdi
addq $0x28, %rdi
movq -0x18(%rbp), %rsi
callq 0x73390
movq %rax, -0x5c(%rbp)
movq %rdx, -0x54(%rbp)
cmpl $0x1, -0x2c(%rbp)
jne 0x12e27b
movq -0xa0(%rbp), %rdi
addq $0x28, %rdi
callq 0x73480
testb $0x1, %al
jne 0x12e26e
jmp 0x12e27b
movq -0x28(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x12e286
movq -0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x5c720
cmpl $0x1, -0x2c(%rbp)
jne 0x12e2bf
movq -0xa0(%rbp), %rdi
addq $0x28, %rdi
callq 0x73480
testb $0x1, %al
jne 0x12e2b2
jmp 0x12e2bf
movq -0x20(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x12e2ca
movq -0x28(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x5c720
cmpl $0x1, -0x2c(%rbp)
jne 0x12e2f1
leaq -0x5c(%rbp), %rdi
callq 0x5a5a0
movl %eax, -0xc4(%rbp)
jmp 0x12e2fb
xorl %eax, %eax
movl %eax, -0xc4(%rbp)
jmp 0x12e2fb
movl -0xc4(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xd0(%rbp)
cmpl $0x2, -0x2c(%rbp)
jne 0x12e324
leaq -0x5c(%rbp), %rdi
callq 0x591a0
movl %eax, -0xd4(%rbp)
jmp 0x12e32e
xorl %eax, %eax
movl %eax, -0xd4(%rbp)
jmp 0x12e32e
movsd -0xd0(%rbp), %xmm2
movl -0xd4(%rbp), %eax
cvtsi2sd %eax, %xmm3
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x5c9f0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x59f20
cvtsi2sd %eax, %xmm0
movsd 0x58fdb(%rip), %xmm1    # 0x187350
divsd %xmm1, %xmm0
movsd %xmm0, -0x100(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5d920
cvtsi2sd %eax, %xmm0
movsd 0x58fba(%rip), %xmm1    # 0x187350
divsd %xmm1, %xmm0
movsd %xmm0, -0xf8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5b650
movq -0x108(%rbp), %rdi
movsd -0x100(%rbp), %xmm1
movsd -0xf8(%rbp), %xmm2
cvtsi2sd %eax, %xmm3
movsd 0x58f82(%rip), %xmm0    # 0x187350
divsd %xmm0, %xmm3
xorps %xmm0, %xmm0
callq 0x5c800
movq -0x88(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x59f20
cvtsi2sd %eax, %xmm0
movsd 0x58f53(%rip), %xmm1    # 0x187350
divsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5d920
cvtsi2sd %eax, %xmm0
movsd 0x58f32(%rip), %xmm1    # 0x187350
divsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5b650
movq -0xf0(%rbp), %rdi
movsd -0xe8(%rbp), %xmm1
movsd -0xe0(%rbp), %xmm2
cvtsi2sd %eax, %xmm3
movsd 0x58efa(%rip), %xmm0    # 0x187350
divsd %xmm0, %xmm3
movsd 0x58f06(%rip), %xmm0    # 0x187368
callq 0x5c800
movq -0xa0(%rbp), %rax
cmpw $0x0, 0xa(%rax)
jne 0x12e533
movq -0xa0(%rbp), %rdi
callq 0x12b760
movq -0xa0(%rbp), %rax
movq 0xc0(%rax), %rdi
movq -0x88(%rbp), %rsi
callq 0x5d1f0
movq -0xa0(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x128(%rbp)
cvtsi2sdl -0x5c(%rbp), %xmm0
movsd %xmm0, -0x120(%rbp)
cvtsi2sdl -0x58(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
leaq -0x5c(%rbp), %rdi
callq 0x5a5a0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x110(%rbp)
leaq -0x5c(%rbp), %rdi
callq 0x591a0
movq -0x128(%rbp), %rdi
movsd -0x120(%rbp), %xmm0
movsd -0x118(%rbp), %xmm1
movsd -0x110(%rbp), %xmm2
cvtsi2sd %eax, %xmm3
callq 0x5aa10
movq -0xa0(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x5c620
movq -0xa0(%rbp), %rdi
callq 0x12b7f0
movq -0xa0(%rbp), %rax
movq 0xd0(%rax), %rdi
movq -0x88(%rbp), %rsi
callq 0x5d1f0
movq -0xa0(%rbp), %rax
movq 0xd0(%rax), %rax
movq %rax, -0x158(%rbp)
cvtsi2sdl -0x5c(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
cvtsi2sdl -0x58(%rbp), %xmm0
movsd %xmm0, -0x148(%rbp)
leaq -0x5c(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x5a5a0
movq -0x160(%rbp), %rdi
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x140(%rbp)
callq 0x591a0
movq -0x158(%rbp), %rdi
movsd -0x150(%rbp), %xmm0
movsd -0x148(%rbp), %xmm1
movsd -0x140(%rbp), %xmm2
cvtsi2sd %eax, %xmm3
callq 0x5aa10
movq -0xa0(%rbp), %rax
movq 0xd0(%rax), %rdi
callq 0x5c620
movq -0x88(%rbp), %rdi
callq 0x5cb10
leaq -0x98(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x5ca80
movq -0x138(%rbp), %rdi
callq 0x59680
movl %eax, -0x12c(%rbp)
jmp 0x12e612
movl -0x12c(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5a410
jmp 0x12e643
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5a410
jmp 0x12e64f
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x5b6b0
nopl (%rax,%rax)