// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/graphics/backends/surfacebackend.cpp
// Function: smooth::GUI::SurfaceBackend::Frame(smooth::GUI::Rect const&, short)
S::Int S::GUI::SurfaceBackend::Frame(const Rect &iRect, Short style)
{
	Rect	 rect = rightToLeft.TranslateRect(iRect);

	Point	 p1 = Point(rect.left,	    rect.top);
	Point	 p2 = Point(rect.right - 1, rect.top);
	Point	 p3 = Point(rect.left,	    rect.bottom - 1);
	Point	 p4 = Point(rect.right - 1, rect.bottom - 1);

	Long	 color1 = 0;
	Long	 color2 = 0;

	switch (style)
	{
		case FRAME_UP:
			color1 = Color(Math::Min(Setup::BackgroundColor.GetRed() + 64, 255), Math::Min(Setup::BackgroundColor.GetGreen() + 64, 255), Math::Min(Setup::BackgroundColor.GetBlue() + 64, 255));
			color2 = Color(Math::Max(Setup::BackgroundColor.GetRed() - 64, 0), Math::Max(Setup::BackgroundColor.GetGreen() - 64, 0), Math::Max(Setup::BackgroundColor.GetBlue() - 64, 0));

			break;
		case FRAME_DOWN:
			color1 = Color(Math::Max(Setup::BackgroundColor.GetRed() - 64, 0), Math::Max(Setup::BackgroundColor.GetGreen() - 64, 0), Math::Max(Setup::BackgroundColor.GetBlue() - 64, 0));
			color2 = Color(Math::Min(Setup::BackgroundColor.GetRed() + 64, 255), Math::Min(Setup::BackgroundColor.GetGreen() + 64, 255), Math::Min(Setup::BackgroundColor.GetBlue() + 64, 255));

			break;
	}

	Bool	 preRTL = rightToLeft.GetRightToLeft();

	rightToLeft.SetRightToLeft(False);

	StartPaint(rect);

	Line(p1, p2, color1);
	Line(p1, p3, color1);
	Line(p2, p4, color2);
	Line(p3, p4, color2);

	SetPixel(p4, color2);

	EndPaint();

	rightToLeft.SetRightToLeft(preRTL);

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, %ebp
movq %rdi, %r14
leaq 0x28(%rdi), %r15
movq %r15, %rdi
callq 0x63e10
movq %rax, 0x48(%rsp)
movq %rdx, 0x50(%rsp)
movq %rax, 0x40(%rsp)
movl %eax, 0x18(%rsp)
shrq $0x20, %rax
leal -0x1(%rdx), %ecx
movl %ecx, 0x20(%rsp)
movl %eax, 0x24(%rsp)
shrq $0x20, %rdx
decl %edx
movl %edx, 0x1c(%rsp)
movl %ecx, 0x10(%rsp)
movl %edx, 0x14(%rsp)
cmpl $0x1, %ebp
je 0x61b04
xorl %eax, %eax
movl $0x0, %ecx
testl %ebp, %ebp
jne 0x61b96
movq 0xffa58(%rip), %rax     # 0x1614d0
movl 0x8(%rax), %edx
movl $0xff, %r9d
movl %edx, %esi
andl %r9d, %esi
movl $0xbf, %r8d
cmpl %r8d, %esi
movl $0xbf, %r10d
cmovbl %esi, %r10d
pushq $0x40
popq %rdi
addl %edi, %r10d
movl %edx, %eax
shrl $0x8, %eax
andl %r9d, %eax
cmpl %r8d, %eax
movl $0xbf, %ecx
cmovbl %eax, %ecx
shrl $0x10, %edx
andl %r9d, %edx
cmpl %r8d, %edx
cmovbl %edx, %r8d
shll $0x10, %r8d
addl $0x400000, %r8d         # imm = 0x400000
shll $0x8, %ecx
addl $0x4000, %ecx           # imm = 0x4000
orl %r10d, %ecx
orl %r8d, %ecx
cmpl $0x41, %esi
cmovbl %edi, %esi
addl $-0x40, %esi
cmpl $0x41, %eax
cmovbl %edi, %eax
cmpl $0x41, %edx
cmovbl %edi, %edx
shll $0x10, %edx
addl $0xffc00000, %edx       # imm = 0xFFC00000
shll $0x8, %eax
addl $0xffffc000, %eax       # imm = 0xFFFFC000
jmp 0x61b92
movq 0xff9c5(%rip), %rax     # 0x1614d0
movl 0x8(%rax), %edx
movl $0xff, %r8d
movl %edx, %esi
andl %r8d, %esi
cmpl $0x41, %esi
pushq $0x40
popq %rdi
movl %edi, %r9d
cmovael %esi, %r9d
addl $-0x40, %r9d
movl %edx, %eax
shrl $0x8, %eax
andl %r8d, %eax
cmpl $0x41, %eax
movl %edi, %ecx
cmovael %eax, %ecx
shrl $0x10, %edx
andl %r8d, %edx
cmpl $0x41, %edx
movl %edi, %r8d
cmovael %edx, %r8d
shll $0x10, %r8d
addl $0xffc00000, %r8d       # imm = 0xFFC00000
shll $0x8, %ecx
addl $0xffffc000, %ecx       # imm = 0xFFFFC000
orl %r9d, %ecx
orl %r8d, %ecx
movl $0xbf, %r8d
cmpl %r8d, %esi
cmovael %r8d, %esi
addl %edi, %esi
cmpl %r8d, %eax
cmovael %r8d, %eax
cmpl %r8d, %edx
cmovael %r8d, %edx
shll $0x10, %edx
addl $0x400000, %edx         # imm = 0x400000
shll $0x8, %eax
addl $0x4000, %eax           # imm = 0x4000
orl %esi, %eax
orl %edx, %eax
movl %ecx, %ebx
movl %eax, %ebp
movq %r15, %rdi
callq 0x63e62
movb %al, 0xf(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x63e5c
movq (%r14), %rax
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq *0x38(%rax)
movq %r15, 0x38(%rsp)
leaq 0x28(%rsp), %r15
movq %rbx, 0x8(%r15)
andl $0x0, (%r15)
movq (%r14), %rax
leaq 0x40(%rsp), %r12
leaq 0x20(%rsp), %r13
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq *0x60(%rax)
movq %rbx, 0x8(%r15)
andl $0x0, (%r15)
movq (%r14), %rax
leaq 0x18(%rsp), %r15
leaq 0x28(%rsp), %rbx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq *0x60(%rax)
movq %rbp, 0x8(%rbx)
andl $0x0, (%rbx)
movq (%r14), %rax
leaq 0x10(%rsp), %rbx
leaq 0x28(%rsp), %r12
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq *0x60(%rax)
movq %rbp, 0x8(%r12)
andl $0x0, (%r12)
movq (%r14), %rax
leaq 0x28(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq *0x60(%rax)
movq %rbp, 0x8(%r12)
andl $0x0, (%r12)
movq (%r14), %rax
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x58(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movzbl 0xf(%rsp), %esi
movq 0x38(%rsp), %rdi
callq 0x63e5c
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq