// File: /workspace/github_c_makefile_star2_O3/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 0x632ca
movq %rax, 0x48(%rsp)
movq %rdx, 0x50(%rsp)
movq %rax, 0x40(%rsp)
movl %eax, 0x20(%rsp)
shrq $0x20, %rax
leal -0x1(%rdx), %ecx
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
shrq $0x20, %rdx
decl %edx
movl %edx, 0x24(%rsp)
movl %ecx, 0x18(%rsp)
movl %edx, 0x1c(%rsp)
cmpl $0x1, %ebp
je 0x60dd0
xorl %eax, %eax
movl $0x0, %ecx
testl %ebp, %ebp
jne 0x60e5f
movq 0x10a78e(%rip), %rax    # 0x16b4d0
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
movl $0x40, %edi
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 0x60e5b
movq 0x10a6f9(%rip), %rax    # 0x16b4d0
movl 0x8(%rax), %edx
movl $0xff, %edi
movl %edx, %esi
andl %edi, %esi
cmpl $0x41, %esi
movl $0x40, %r8d
cmovael %esi, %r8d
addl $-0x40, %r8d
movl %edx, %eax
shrl $0x8, %eax
andl %edi, %eax
cmpl $0x41, %eax
movl $0x40, %ecx
cmovael %eax, %ecx
shrl $0x10, %edx
andl %edi, %edx
cmpl $0x41, %edx
movl $0x40, %edi
cmovael %edx, %edi
movl $0x40, %r9d
shll $0x10, %edi
addl $0xffc00000, %edi       # imm = 0xFFC00000
shll $0x8, %ecx
addl $0xffffc000, %ecx       # imm = 0xFFFFC000
orl %r8d, %ecx
orl %edi, %ecx
movl $0xbf, %edi
cmpl %edi, %esi
cmovael %edi, %esi
addl %r9d, %esi
cmpl %edi, %eax
cmovael %edi, %eax
cmpl %edi, %edx
cmovael %edi, %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 0x6330c
movb %al, 0xf(%rsp)
xorl %r13d, %r13d
movq %r15, %rdi
xorl %esi, %esi
callq 0x63306
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)
movl %r13d, (%r15)
movq (%r14), %rax
leaq 0x40(%rsp), %r12
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rcx
callq *0x60(%rax)
movq %rbx, 0x8(%r15)
movl %r13d, (%r15)
movq (%r14), %rax
leaq 0x20(%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)
movl %r13d, (%rbx)
movq (%r14), %rax
leaq 0x18(%rsp), %rbx
leaq 0x28(%rsp), %r12
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq *0x60(%rax)
movq %rbp, 0x8(%r12)
movl %r13d, (%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)
movl %r13d, (%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 0x63306
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop