// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/gui/window/window.cpp
// Function: smooth::GUI::Window::Add(smooth::GUI::Widget*)
S::Int S::GUI::Window::Add(Widget *widget)
{
	if (widget == NIL) return Error();

	if (widget->GetOrientation() == OR_UPPERLEFT || widget->GetOrientation() == OR_UPPERRIGHT || widget->GetOrientation() == OR_LOWERLEFT || widget->GetOrientation() == OR_LOWERRIGHT)
	{
		if (mainLayer->Add(widget) == Success())
		{
			/* Enable drag & drop if the added widget is a target.
			 */
			if (IsDropTarget()) backend->EnableDropFiles(True);

			return Success();
		}

		return Error();
	}

	if (Widget::Add(widget) == Success())
	{
		/* Special handling for title and status bars.
		 */
		if (widget->GetObjectType() == Titlebar::classID)
		{
			if (!Binary::IsFlagSet(widget->GetFlags(), TB_MAXBUTTON)) flags |= WF_NORESIZE;

			if (widget->GetHeight() == 0) backend->SetSizeModifier(backend->GetSizeModifier() - Size(0, 19) * Surface().GetSurfaceDPI() / 96.0);
		}
		else if (widget->GetObjectType() == Statusbar::classID)
		{
			SetDefaultStatusText(widget->GetText());
		}

		/* Recalculate offsets unless the added widget has free orientation.
		 */
		if (widget->GetOrientation() != OR_FREE) CalculateOffsets();

		/* Enable drag & drop if the added widget is a target.
		 */
		if (IsDropTarget()) backend->EnableDropFiles(True);

		return Success();
	}

	return Error();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rsi, %rsi
je 0x99baa
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x128(%rax)
cmpl $0x14, %eax
je 0x99b76
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x24, %eax
je 0x99b76
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x18, %eax
je 0x99b76
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x28, %eax
jne 0x99bbb
movq 0x620(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x30(%rax)
testl %eax, %eax
jne 0x99baa
movq %rbx, %rdi
callq 0x57e00
testb %al, %al
je 0x99ba8
movq 0x5c0(%rbx), %rdi
movq (%rdi), %rax
movl $0x1, %esi
callq *0x58(%rax)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r14, %rsi
callq 0x57c50
testl %eax, %eax
jne 0x99baa
leaq 0x20(%r14), %r15
movq 0xd2c73(%rip), %rax     # 0x16c848
movswl (%rax), %esi
movq %r15, %rdi
callq 0x57520
testb %al, %al
je 0x99d23
movl 0x30(%r14), %edi
movl $0x2, %esi
callq 0x583f0
testb %al, %al
jne 0x99bfe
orb $0x4, 0x30(%rbx)
cmpl $0x0, 0xb4(%r14)
jne 0x99d5c
movq 0x5c0(%rbx), %r15
movq %r15, %rdi
callq 0x9ace0
movq %rax, %r12
leaq 0x10(%rsp), %rdx
movq $0x0, (%rdx)
movq %rsp, %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0x57150
movq %r13, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm3
movapd 0x5d1e4(%rip), %xmm1    # 0xf6e30
andpd %xmm3, %xmm1
movsd 0x5a740(%rip), %xmm0    # 0xf4398
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
mulsd 0x5ac67(%rip), %xmm3    # 0xf48d0
xorpd %xmm2, %xmm2
movapd %xmm3, %xmm4
cmpltsd %xmm2, %xmm4
movsd 0x5a712(%rip), %xmm1    # 0xf4390
movapd %xmm4, %xmm5
andpd %xmm1, %xmm5
andnpd %xmm0, %xmm4
orpd %xmm5, %xmm4
addsd %xmm3, %xmm4
cvttsd2si %xmm4, %rcx
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
movsd 0x5a84a(%rip), %xmm4    # 0xf44f0
divsd %xmm4, %xmm3
movapd %xmm3, %xmm5
cmpltsd %xmm2, %xmm5
movapd %xmm5, %xmm6
andpd %xmm1, %xmm6
andnpd %xmm0, %xmm5
orpd %xmm6, %xmm5
addsd %xmm3, %xmm5
cvttsd2si %xmm5, %rax
xorps %xmm3, %xmm3
cvtsi2sd %ecx, %xmm3
divsd %xmm4, %xmm3
movapd %xmm3, %xmm4
cmpltsd %xmm2, %xmm4
andpd %xmm4, %xmm1
andnpd %xmm0, %xmm4
orpd %xmm1, %xmm4
addsd %xmm3, %xmm4
cvttsd2si %xmm4, %rcx
movl (%r12), %edx
movl 0x4(%r12), %esi
subl %eax, %edx
subl %ecx, %esi
shlq $0x20, %rsi
orq %rsi, %rdx
leaq 0x8(%rsp), %rsi
movq %rdx, (%rsi)
movq %r15, %rdi
callq 0x9ace6
movq %rsp, %rdi
callq 0x57b20
jmp 0x99d5c
movq 0xd2766(%rip), %rax     # 0x16c490
movswl (%rax), %esi
movq %r15, %rdi
callq 0x57520
testb %al, %al
je 0x99d5c
movq (%r14), %rax
movq %r14, %rdi
callq *0xa8(%rax)
leaq 0x600(%rbx), %rdi
movq %rax, %rsi
callq 0x555f0
movq %rbx, %rdi
callq 0x55de0
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x80, %eax
je 0x99b8a
movq %rbx, %rdi
callq 0x55ef0
jmp 0x99b8a
movq %rax, %rbx
movq %rsp, %rdi
callq 0x57b20
movq %rbx, %rdi
callq 0x57090
nop