// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/gui/widgets/multi/list/listbox.cpp
// Function: smooth::GUI::ListBox::DragSelectedEntry(bool)
S::Int S::GUI::ListBox::DragSelectedEntry(Bool upDown)
{
	if (!(flags & LF_ALLOWREORDER)) return Error();

	/* Get entry numbers to switch and check.
	 */
	Int	 selectedEntryNumber = GetSelectedEntryNumber();
	Int	 newEntryNumber	     = selectedEntryNumber;
	Int	 checkEntryNumber    = selectedEntryNumber;

	if (upDown)
	{
		newEntryNumber	 = Math::Max(0, selectedEntryNumber - 1);
		checkEntryNumber = Math::Max(0, newEntryNumber	    - 1);
	}
	else
	{
		newEntryNumber	 = Math::Min(selectedEntryNumber + 1, Length() - 1);
		checkEntryNumber = Math::Min(newEntryNumber	 + 1, Length() - 1);
	}

	/* Check whether entry should be moved.
	 */
	if (selectedEntryNumber != newEntryNumber)
	{
		Int	 oldScrollbarPos = scrollbarPos;

		/* Check whether to scroll the whole list.
		 */
		ListEntry	*checkEntry = GetNthEntry(checkEntryNumber);

		if (!checkEntry->IsVisible() || checkEntry->GetVisibleArea().GetHeight() <= 2)
		{
			if (upDown) scrollbarPos -= scrollbar->GetStepSize();
			else	    scrollbarPos += scrollbar->GetStepSize();
		}

		/* Move entry to new position.
		 */
		MoveEntry(selectedEntryNumber, newEntryNumber);

		/* Redraw the list.
		 */
		Surface		*surface  = GetDrawSurface();
		ListEntry	*oldEntry = GetNthEntry(selectedEntryNumber);

		surface->StartPaint(Rect(GetRealPosition(), GetRealSize()));

		Paint(SP_PAINT);

		oldEntry->Process(SM_MOUSEMOVE, 0, 0);

		surface->EndPaint();

		/* If list was scrolled, delay next action by 100ms.
		 */
		if (scrollbarPos != oldScrollbarPos) System::System::Sleep(100);
	}
	else
	{
		if (upDown) ScrollUp(ScrollToTop);
		else	    ScrollDown(ScrollToBottom);
	}

	return Success();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl 0x30(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0xb2ca7
leaq -0x28(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5a9c0
movq -0xb8(%rbp), %rdi
callq 0x59680
movl %eax, -0xac(%rbp)
jmp 0xb2c76
movl -0xac(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5b5b0
jmp 0xb2f8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5b5b0
jmp 0xb2f98
movq -0xa8(%rbp), %rdi
callq 0x5d620
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x40(%rbp)
testb $0x1, -0x11(%rbp)
je 0xb2cea
movl -0x38(%rbp), %esi
subl $0x1, %esi
xorl %edi, %edi
callq 0x5aae0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %esi
subl $0x1, %esi
xorl %edi, %edi
callq 0x5aae0
movl %eax, -0x40(%rbp)
jmp 0xb2d48
movq -0xa8(%rbp), %rdi
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
movq (%rdi), %rax
callq *0x178(%rax)
movl -0xc0(%rbp), %edi
movl %eax, %esi
subl $0x1, %esi
callq 0x5ce90
movq -0xa8(%rbp), %rdi
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
movq (%rdi), %rax
callq *0x178(%rax)
movl -0xbc(%rbp), %edi
movl %eax, %esi
subl $0x1, %esi
callq 0x5ce90
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0xb2f08
movq -0xa8(%rbp), %rdi
movl 0x6d0(%rdi), %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %esi
movq (%rdi), %rax
callq *0x180(%rax)
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xc1(%rbp)
jne 0xb2d92
jmp 0xb2dbc
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
callq *0x130(%rax)
movq %rax, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x591a0
cmpl $0x2, %eax
setle %al
movb %al, -0xc1(%rbp)
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0xb2dc8
jmp 0xb2e24
testb $0x1, -0x11(%rbp)
je 0xb2dfa
movq -0xa8(%rbp), %rax
movq 0x6c8(%rax), %rdi
callq 0x5cd00
movl %eax, %edx
movq -0xa8(%rbp), %rax
movl 0x6d0(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x6d0(%rax)
jmp 0xb2e22
movq -0xa8(%rbp), %rax
movq 0x6c8(%rax), %rdi
callq 0x5cd00
movl %eax, %ecx
movq -0xa8(%rbp), %rax
addl 0x6d0(%rax), %ecx
movl %ecx, 0x6d0(%rax)
jmp 0xb2e24
movq -0xa8(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movq (%rdi), %rax
callq *0x170(%rax)
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0xa8(%rbp), %rdi
movq %rax, -0x68(%rbp)
movl -0x38(%rbp), %esi
movq (%rdi), %rax
callq *0x180(%rax)
movq -0xa8(%rbp), %rdi
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq (%rdi), %rax
callq *0x48(%rax)
movq -0xa8(%rbp), %rdi
movq %rax, -0x88(%rbp)
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0x90(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x59ff0
movq -0xd0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x591b0
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
xorl %esi, %esi
callq *0x78(%rax)
movq -0x70(%rbp), %rdi
movq (%rdi), %rax
movl $0x7800, %esi           # imm = 0x7800
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x80(%rax)
movq -0x68(%rbp), %rdi
callq 0x5d270
movq -0xa8(%rbp), %rax
movl 0x6d0(%rax), %eax
cmpl -0x44(%rbp), %eax
je 0xb2f06
movl $0x64, %edi
callq 0x5c090
jmp 0xb2f34
testb $0x1, -0x11(%rbp)
je 0xb2f21
movq -0xa8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x59c70
jmp 0xb2f32
movq -0xa8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5b260
jmp 0xb2f34
leaq -0xa0(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x5ca80
movq -0xe0(%rbp), %rdi
callq 0x59680
movl %eax, -0xd4(%rbp)
jmp 0xb2f5b
movl -0xd4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x5a410
jmp 0xb2f8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x5a410
jmp 0xb2f98
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x5b6b0
nopw %cs:(%rax,%rax)