// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/graphics/backends/cairo/surfacecairo.cpp
// Function: smooth::GUI::SurfaceCairo::Line(smooth::GUI::Point const&, smooth::GUI::Point const&, smooth::GUI::Color const&)
S::Int S::GUI::SurfaceCairo::Line(const Point &iPos1, const Point &iPos2, const Color &color)
{
	if (window == NIL) return Success();

	Point	 pos1 = rightToLeft.TranslatePoint(iPos1);
	Point	 pos2 = rightToLeft.TranslatePoint(iPos2);

	/* Draw non-straight lines manually to work around bugs in XWayland.
	 */
	if (pos1.x != pos2.x && pos1.y != pos2.y)
	{
		Int	 steps	  = Math::Max(Math::Abs(pos2.x - pos1.x), Math::Abs(pos2.y - pos1.y));
		Float	 xAdvance = steps ? Float(pos2.x - pos1.x) / steps : 0;
		Float	 yAdvance = steps ? Float(pos2.y - pos1.y) / steps : 0;

		if (!painting)
		{
			CreateCairoContext();

			cairo_set_source_rgb(context, color.GetRed() / 255.0, color.GetGreen() / 255.0, color.GetBlue() / 255.0);

			for (Int i = 0; i < steps; i++) cairo_rectangle(context, pos1.x + i * xAdvance, pos1.y + i * yAdvance, 1.0, 1.0);
		
			cairo_fill(context);

			DestroyCairoContext();
		}

		cairo_set_source_rgb(paintContextCairo, color.GetRed() / 255.0, color.GetGreen() / 255.0, color.GetBlue() / 255.0);

		for (Int i = 0; i < steps; i++) cairo_rectangle(paintContextCairo, pos1.x + i * xAdvance, pos1.y + i * yAdvance, 1.0, 1.0);
		
		cairo_fill(paintContextCairo);
	}
	else
	{
		if (!painting)
		{
			CreateCairoContext();

			cairo_set_source_rgb(context, color.GetRed() / 255.0, color.GetGreen() / 255.0, color.GetBlue() / 255.0);
			cairo_set_line_width(context, 1.0);
			cairo_move_to(context, pos1.x + 0.01, pos1.y + 0.01);
			cairo_line_to(context, pos2.x + 0.01, pos2.y + 0.01);
			cairo_stroke(context);

			DestroyCairoContext();
		}

		cairo_set_source_rgb(paintContextCairo, color.GetRed() / 255.0, color.GetGreen() / 255.0, color.GetBlue() / 255.0);
		cairo_set_line_width(paintContextCairo, 1.0);
		cairo_move_to(paintContextCairo, pos1.x + 0.01, pos1.y + 0.01);
		cairo_line_to(paintContextCairo, pos2.x + 0.01, pos2.y + 0.01);
		cairo_stroke(paintContextCairo);
	}

	return Success();
}

// Assembly:
cmpq $0x0, 0x50(%rdi)
je 0xbe3fc
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movq %rdi, %rbx
movq %rcx, 0x20(%rsp)
leaq 0x28(%rdi), %r13
movq %r13, %rdi
callq 0x63dec
movq %rax, %r12
movq %rax, %rbp
shrq $0x20, %rbp
movq %r13, %rdi
movq %r15, %rsi
callq 0x63dec
movq %rax, %r15
movq %rax, %r13
shrq $0x20, %r13
movl %r12d, %r14d
subl %r15d, %r14d
sete %al
cmpq %r13, %rbp
sete %cl
orb %al, %cl
je 0xbe049
cmpw $0x0, 0xa(%rbx)
je 0xbe0c8
cvtsi2sd %r12d, %xmm1
movsd 0x4556e(%rip), %xmm0    # 0x103578
cvtsi2sd %ebp, %xmm2
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
addsd %xmm0, %xmm2
movsd %xmm2, 0x18(%rsp)
cvtsi2sd %r15d, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
cvtsi2sd %r13d, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq 0x20(%rsp), %r14
jmp 0xbe1a4
subl %r12d, %r15d
movl %r15d, %eax
negl %eax
cmovsl %r15d, %eax
movq %r13, 0x30(%rsp)
subl %ebp, %r13d
movl %r13d, %ecx
negl %ecx
cmovsl %r13d, %ecx
cmpl %ecx, %eax
cmoval %eax, %ecx
cvtsi2sd %ecx, %xmm0
xorpd %xmm1, %xmm1
movsd %xmm1, 0x18(%rsp)
movsd %xmm1, 0x10(%rsp)
testl %ecx, %ecx
je 0xbe092
cvtsi2sd %r15d, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
je 0xbe0a3
cvtsi2sd %r13d, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
cmpw $0x0, 0xa(%rbx)
je 0xbe23d
cvtsi2sd %r12d, %xmm0
movsd %xmm0, 0x8(%rsp)
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0xbe32d
movq %rbx, %rdi
callq 0xbdda4
movq 0xc0(%rbx), %rdi
movq 0x20(%rsp), %r14
movl 0x8(%r14), %eax
movl $0xff, %ecx
movl %eax, %edx
andl %ecx, %edx
cvtsi2sd %edx, %xmm0
movsd 0x2525b(%rip), %xmm3    # 0xe3350
divsd %xmm3, %xmm0
movl %eax, %edx
shrl $0x8, %edx
andl %ecx, %edx
cvtsi2sd %edx, %xmm1
divsd %xmm3, %xmm1
shrl $0x10, %eax
andl %ecx, %eax
cvtsi2sd %eax, %xmm2
divsd %xmm3, %xmm2
callq 0x592c0
movq 0xc0(%rbx), %rdi
movsd 0x25247(%rip), %xmm0    # 0xe3370
callq 0x57ed0
movq 0xc0(%rbx), %rdi
cvtsi2sd %r12d, %xmm0
movsd 0x45436(%rip), %xmm2    # 0x103578
addsd %xmm2, %xmm0
cvtsi2sd %ebp, %xmm1
addsd %xmm2, %xmm1
movsd %xmm0, (%rsp)
movsd %xmm1, 0x18(%rsp)
callq 0x584d0
movq 0xc0(%rbx), %rdi
cvtsi2sd %r15d, %xmm0
movsd 0x45406(%rip), %xmm2    # 0x103578
addsd %xmm2, %xmm0
cvtsi2sd %r13d, %xmm1
addsd %xmm2, %xmm1
movsd %xmm0, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
callq 0x57580
movq 0xc0(%rbx), %rdi
callq 0x581d0
movq %rbx, %rdi
callq 0xbddf8
movq 0xd0(%rbx), %rdi
movl 0x8(%r14), %eax
movl $0xff, %ecx
movl %eax, %edx
andl %ecx, %edx
cvtsi2sd %edx, %xmm0
movsd 0x2518c(%rip), %xmm3    # 0xe3350
divsd %xmm3, %xmm0
movl %eax, %edx
shrl $0x8, %edx
andl %ecx, %edx
cvtsi2sd %edx, %xmm1
divsd %xmm3, %xmm1
shrl $0x10, %eax
andl %ecx, %eax
cvtsi2sd %eax, %xmm2
divsd %xmm3, %xmm2
callq 0x592c0
movq 0xd0(%rbx), %rdi
movsd 0x25178(%rip), %xmm0    # 0xe3370
callq 0x57ed0
movq 0xd0(%rbx), %rdi
movsd (%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
callq 0x584d0
movq 0xd0(%rbx), %rdi
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x57580
movq 0xd0(%rbx), %rdi
callq 0x581d0
jmp 0xbe3ee
movq %rbx, %rdi
callq 0xbdda4
movq 0xc0(%rbx), %rdi
movq 0x20(%rsp), %rax
movl 0x8(%rax), %eax
movl $0xff, %ecx
movl %eax, %edx
andl %ecx, %edx
cvtsi2sd %edx, %xmm0
movsd 0x250e7(%rip), %xmm3    # 0xe3350
divsd %xmm3, %xmm0
movl %eax, %edx
shrl $0x8, %edx
andl %ecx, %edx
cvtsi2sd %edx, %xmm1
divsd %xmm3, %xmm1
shrl $0x10, %eax
andl %ecx, %eax
cvtsi2sd %eax, %xmm2
divsd %xmm3, %xmm2
callq 0x592c0
cvtsi2sd %r12d, %xmm0
movsd %xmm0, 0x8(%rsp)
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x28(%rsp)
cmpl %r15d, %r14d
movl %r15d, %eax
cmovgl %r14d, %eax
movl %ebp, %r12d
subl 0x30(%rsp), %r12d
cmpl %r13d, %r12d
cmovlel %r13d, %r12d
cmpl %r12d, %eax
cmoval %eax, %r12d
negl %r12d
xorpd %xmm0, %xmm0
movq 0xc0(%rbx), %rdi
testl %r12d, %r12d
je 0xbe320
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
addsd 0x28(%rsp), %xmm1
movsd 0x2506b(%rip), %xmm2    # 0xe3370
movapd %xmm2, %xmm3
callq 0x576b0
movsd (%rsp), %xmm0
addsd 0x25055(%rip), %xmm0    # 0xe3370
incl %r12d
jmp 0xbe2ca
callq 0x58fc0
movq %rbx, %rdi
callq 0xbddf8
movq 0xd0(%rbx), %rdi
movq 0x20(%rsp), %rax
movl 0x8(%rax), %eax
movl $0xff, %ecx
movl %eax, %edx
andl %ecx, %edx
cvtsi2sd %edx, %xmm0
movsd 0x24fff(%rip), %xmm3    # 0xe3350
divsd %xmm3, %xmm0
movl %eax, %edx
shrl $0x8, %edx
andl %ecx, %edx
cvtsi2sd %edx, %xmm1
divsd %xmm3, %xmm1
shrl $0x10, %eax
andl %ecx, %eax
cvtsi2sd %eax, %xmm2
divsd %xmm3, %xmm2
callq 0x592c0
cmpl %r15d, %r14d
cmovgl %r14d, %r15d
subl 0x30(%rsp), %ebp
cmpl %r13d, %ebp
cmovlel %r13d, %ebp
cmpl %ebp, %r15d
cmoval %r15d, %ebp
negl %ebp
xorpd %xmm0, %xmm0
movq 0xd0(%rbx), %rdi
testl %ebp, %ebp
je 0xbe3e9
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
addsd 0x28(%rsp), %xmm1
movsd 0x24fa1(%rip), %xmm2    # 0xe3370
movapd %xmm2, %xmm3
callq 0x576b0
movsd (%rsp), %xmm0
addsd 0x24f8b(%rip), %xmm0    # 0xe3370
incl %ebp
jmp 0xbe395
callq 0x58fc0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq
nop