// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
pushq $-0x1
popq %rbp
testq %rsi, %rsi
je 0x95670
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x128(%rax)
cmpl $0x14, %eax
je 0x9563e
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x24, %eax
je 0x9563e
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x18, %eax
je 0x9563e
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x28, %eax
jne 0x95681
movq 0x620(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x30(%rax)
testl %eax, %eax
jne 0x95670
movq %rbx, %rdi
callq 0x59090
xorl %ebp, %ebp
testb %al, %al
je 0x95670
movq 0x5c0(%rbx), %rdi
movq (%rdi), %rax
pushq $0x1
popq %rsi
callq *0x58(%rax)
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r14, %rsi
callq 0x58ed0
testl %eax, %eax
jne 0x95670
leaq 0x20(%r14), %r15
movq 0xcc1ad(%rip), %rax     # 0x161848
movswl (%rax), %esi
movq %r15, %rdi
callq 0x58720
testb %al, %al
je 0x95768
movl 0x30(%r14), %edi
pushq $0x2
popq %rsi
callq 0x596b0
testb %al, %al
jne 0x956c2
orb $0x4, 0x30(%rbx)
cmpl $0x0, 0xb4(%r14)
jne 0x95795
movq 0x5c0(%rbx), %r15
movq %r15, %rdi
callq 0x96558
movq %rax, %r12
movabsq $0x1300000000, %rax     # imm = 0x1300000000
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %rdx
andq $0x0, (%rdx)
movq %rsp, %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0x58340
movq %r13, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
leaq 0x8(%rsp), %rdi
callq 0x57480
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
movsd 0x4dde2(%rip), %xmm0    # 0xe3510
callq 0x59050
movq %rax, %rcx
shrq $0x20, %rcx
movl (%r12), %edx
movl 0x4(%r12), %esi
subl %eax, %edx
subl %ecx, %esi
shlq $0x20, %rsi
orq %rsi, %rdx
leaq 0x18(%rsp), %rsi
movq %rdx, (%rsi)
movq %r15, %rdi
callq 0x9655e
movq %rsp, %rdi
callq 0x58d90
jmp 0x95795
movq 0xcbd21(%rip), %rax     # 0x161490
movswl (%rax), %esi
movq %r15, %rdi
callq 0x58720
testb %al, %al
je 0x95795
movq (%r14), %rax
movq %r14, %rdi
callq *0xa8(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x596d0
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
cmpl $0x80, %eax
je 0x95652
movq %rbx, %rdi
callq 0x56fc0
jmp 0x95652
movq %rax, %rbx
movq %rsp, %rdi
callq 0x58d90
movq %rbx, %rdi
callq 0x58260