// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/classes/gui/widgets/multi/menu/popupmenuentry.cpp
// Function: smooth::GUI::PopupMenuEntry::OpenPopupMenu()
S::Void S::GUI::PopupMenuEntry::OpenPopupMenu()
{
	if (popup == NIL) return;

	if (S::System::System::Clock() - popupMenuClosed < 100) return;

	Widget	*window	     = container->GetContainerWindow();
	Surface	*surface     = GetDrawSurface();

	if (window == NIL) return;

	if (timer != NIL)
	{
		DeleteObject(timer);

		timer = NIL;
	}

	hotspot->Deactivate();

	Rect	 monitor     = System::Screen::GetActiveScreenWorkArea();
	Float	 scaleFactor = surface->GetSurfaceDPI() / 96.0;

	popup->CalculateSize();

	Point	 realPos     = GetRealPosition();
	Size	 realSize    = GetRealSize();

	Point	 popupPos    = realPos + Point(realSize.cx, Math::Round(-3 * scaleFactor));
	Size	 popupSize   = popup->GetSize();

	if (!IsRightToLeft()) { if (window->GetX() + popupPos.x			       + Math::Round(popupSize.cx * scaleFactor) >= monitor.right) popupPos.x = realPos.x - Math::Round(popupSize.cx * scaleFactor); }
	else		      { if (window->GetX() + (window->GetWidth() - popupPos.x) - Math::Round(popupSize.cx * scaleFactor) <  monitor.left)  popupPos.x = realPos.x - Math::Round(popupSize.cx * scaleFactor); }

	if (window->GetY() + popupPos.y + Math::Round(popupSize.cy * scaleFactor) >= monitor.bottom) popupPos.y = realPos.y - Math::Round(popupSize.cy * scaleFactor) + realSize.cy + Math::Round(3 * scaleFactor);

	popup->SetPosition(popupPos);
	popup->internalRequestClose.Connect(&PopupMenuEntry::ClosePopupMenu, this);

	owner->SetFlags(owner->GetFlags() | MB_POPUPOPEN);

	Add(popup);

	/* Set the MB_POPUPOPEN flag again as it may have been unset by a
	 * closing sibling popup during PopupMenu::Show in the above Add call.
	 */
	owner->SetFlags(owner->GetFlags() | MB_POPUPOPEN);
}

// Assembly:
cmpq $0x0, 0x5b8(%rdi)
je 0x8c941
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
callq 0x570e0
subq 0x5f0(%rbx), %rax
cmpq $0x64, %rax
jb 0x8c933
movq 0x190(%rbx), %rdi
callq 0x559e0
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %r14, 0x10(%rsp)
testq %r14, %r14
je 0x8c933
movq %rax, %r12
movq 0x608(%rbx), %rdi
testq %rdi, %rdi
je 0x8c72e
callq 0x58cc0
movq $0x0, 0x608(%rbx)
movq 0x5f8(%rbx), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
callq 0x57e90
movq %rax, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movq %r12, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x66f59(%rip), %xmm0    # 0xf36b8
movsd %xmm0, 0x8(%rsp)
movq 0x5b8(%rbx), %rdi
callq 0x58ee0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
movq %rax, %rbp
movq %rax, %r14
shrq $0x20, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x50(%rax)
movsd 0x6a3d3(%rip), %xmm0    # 0xf6b68
mulsd 0x8(%rsp), %xmm0
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
movq %rax, %r12
seta %cl
leaq 0x6703e(%rip), %rax     # 0xf37f0
addsd (%rax,%rcx,8), %xmm0
cvttsd2si %xmm0, %r15
movq %rbp, %r13
addq %r12, %r13
movq %r14, 0x30(%rsp)
addq %r14, %r15
movq %r15, %rax
shlq $0x20, %rax
movl %r13d, %ecx
orq %rax, %rcx
movq %rcx, (%rsp)
movq 0x5b8(%rbx), %rax
movl 0xb0(%rax), %r14d
movl 0xb4(%rax), %eax
movl %eax, 0x1c(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x8c942
movq 0x10(%rsp), %rax
movl 0xb0(%rax), %ecx
addl 0xa8(%rax), %ecx
subl %r13d, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x66faf(%rip), %rdi     # 0xf37f0
addsd (%rdi,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
movslq %ecx, %rcx
subq %rax, %rcx
movslq 0x28(%rsp), %rdx
cmpq %rdx, %rcx
movq 0x20(%rsp), %rsi
jge 0x8c865
subl %eax, %ebp
movl %ebp, (%rsp)
movq 0x10(%rsp), %rax
movslq 0xac(%rax), %rcx
xorps %xmm1, %xmm1
cvtsi2sdl 0x1c(%rsp), %xmm1
movslq %r15d, %rdx
mulsd %xmm2, %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
addsd (%rdi,%rax,8), %xmm1
cvttsd2si %xmm1, %rax
addq %rax, %rcx
addq %rdx, %rcx
sarq $0x20, %rsi
cmpq %rsi, %rcx
jl 0x8c8d6
shrq $0x20, %r12
mulsd 0x66d05(%rip), %xmm2    # 0xf35b8
xorl %ecx, %ecx
ucomisd %xmm2, %xmm0
seta %cl
addsd (%rdi,%rcx,8), %xmm2
cvttsd2si %xmm2, %rcx
addl 0x30(%rsp), %r12d
addl %ecx, %r12d
subl %eax, %r12d
movl %r12d, 0x4(%rsp)
movq 0x5b8(%rbx), %rdi
leaq 0xb0(%rdi), %rdx
movq (%rdi), %rax
movq %rsp, %rsi
callq *0x150(%rax)
movl $0x698, %edi            # imm = 0x698
addq 0x5b8(%rbx), %rdi
movq 0xdf155(%rip), %rsi     # 0x16ba58
xorl %edx, %edx
movq %rbx, %rcx
callq 0x8d7c6
movq 0x600(%rbx), %rax
orl $0x2, 0x30(%rax)
movq 0x5b8(%rbx), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x30(%rax)
movq 0x600(%rbx), %rax
orl $0x2, 0x30(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rax
movslq 0xa8(%rax), %rax
movslq %r13d, %rcx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x66e76(%rip), %rdi     # 0xf37f0
addsd (%rdi,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addq %rax, %rcx
movq 0x20(%rsp), %rsi
movslq %esi, %rdx
cmpq %rdx, %rcx
jge 0x8c860
jmp 0x8c865
nop