// File: /workspace/github_c_makefile_star2_O3/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 0x993bc
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x128(%rax)
cmpl $0x14, %eax
je 0x99388
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x24, %eax
je 0x99388
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x18, %eax
je 0x99388
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x28, %eax
jne 0x993cd
movq 0x620(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x30(%rax)
testl %eax, %eax
jne 0x993bc
movq %rbx, %rdi
callq 0x57e00
xorl %ebp, %ebp
testb %al, %al
je 0x993bc
movq 0x5c0(%rbx), %rdi
movq (%rdi), %rax
movl $0x1, %esi
callq *0x58(%rax)
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 0x993bc
leaq 0x20(%r14), %r15
movq 0xd2461(%rip), %rax     # 0x16b848
movswl (%rax), %esi
movq %r15, %rdi
callq 0x57520
testb %al, %al
je 0x99535
movl 0x30(%r14), %edi
movl $0x2, %esi
callq 0x583f0
testb %al, %al
jne 0x99410
orb $0x4, 0x30(%rbx)
cmpl $0x0, 0xb4(%r14)
jne 0x9956e
movq 0x5c0(%rbx), %r15
movq %r15, %rdi
callq 0x9a4ee
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 0x5a052(%rip), %xmm1    # 0xf34b0
andpd %xmm3, %xmm1
movsd 0x59f2e(%rip), %xmm0    # 0xf3398
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
mulsd 0x5a4cd(%rip), %xmm3    # 0xf3948
xorpd %xmm2, %xmm2
movapd %xmm3, %xmm4
cmpltsd %xmm2, %xmm4
movsd 0x59f00(%rip), %xmm1    # 0xf3390
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 0x5a200(%rip), %xmm4    # 0xf36b8
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 0x9a4f4
movq %rsp, %rdi
callq 0x57b20
jmp 0x9956e
movq 0xd1f54(%rip), %rax     # 0x16b490
movswl (%rax), %esi
movq %r15, %rdi
callq 0x57520
testb %al, %al
je 0x9956e
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 0x9939c
movq %rbx, %rdi
callq 0x55ef0
jmp 0x9939c
movq %rax, %rbx
movq %rsp, %rdi
callq 0x57b20
movq %rbx, %rdi
callq 0x57090
nop