// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/misc/init.cpp
// Function: smooth::Free()
S::Void S::Free()
{
	/* Delete all remaining callers left
	 * from nonblocking function calls.
	 */
	NonBlocking::CleanUp();

	/* Call ObjectCleanup() to make sure other
	 * DLLs are unloaded before we continue.
	 */
	Object::ObjectCleanup();

	if (--initCount) return;

#ifdef DEBUG
	if (Object::GetNOfObjects() != 0) GUI::Dialogs::QuickMessage(String("Incomplete smooth library shutdown!\n\n").Append(String::FromInt(Object::GetNOfObjects())).Append(" objects are still alive.\n\nPlease make sure to delete any smooth objects\nyou create before exiting the program."), "Error", GUI::Dialogs::Message::Buttons::Ok, GUI::Dialogs::Message::Icon::Error);
#endif

	/* Stop running threads.
	 */
	if (Threads::Thread::GetNOfRunningThreads() > 0)
	{
		for (Int i = 0; i < Object::GetNOfObjects(); i++)
		{
			Object	*object = Object::GetNthObject(i);

			if (object == NIL) continue;

			if (object->GetObjectType() == Threads::Thread::classID &&
			    !(object->GetFlags() & Threads::THREAD_KILLFLAG_WAIT)) ((Threads::Thread *) object)->Stop();
		}
	}

	/* Wait for remaining threads to finish.
	 */
	while (Threads::Thread::GetNOfRunningThreads() > 0) System::System::Sleep(10);

	/* Delete translator object and free iconv library.
	 */
	delete I18n::Translator::defaultTranslator;

#if defined __WIN32__
	if (Setup::useIconv) FreeIconvDLL();
#endif

	/* Call registered free functions.
	 */
	foreach (Int (*freeFunction)(), (*freeFunctions))
	{
		freeFunction();
	}

	initFunctions->RemoveAll();
	freeFunctions->RemoveAll();

	delete initFunctions;
	delete freeFunctions;

	/* Deinit system backends.
	 */
	Backends::Backend::DeinitBackends();

	/* All pending objects should be marked for
	 * deletion now, so let's call ObjectCleanup()
	 * again to actually free them.
	 */
	Object::ObjectCleanup();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
callq 0x5b8e0
callq 0x5de30
movl 0xfafe8(%rip), %eax     # 0x214530
addl $-0x1, %eax
movl %eax, 0xfafdf(%rip)     # 0x214530
cmpl $0x0, %eax
je 0x11955b
jmp 0x1196fb
callq 0x5a4c0
cwtl
cmpl $0x0, %eax
jle 0x1195e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x24(%rbp)
callq 0x5bd10
movl %eax, %ecx
movl -0x24(%rbp), %eax
cmpl %ecx, %eax
jge 0x1195de
movl -0x4(%rbp), %edi
callq 0x5d300
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x119596
jmp 0x1195d3
movq -0x10(%rbp), %rdi
callq 0x5bb10
movq %rax, %rdi
movq 0xef467(%rip), %rax     # 0x208a10
movswl (%rax), %esi
callq 0x5bc10
testb $0x1, %al
jne 0x1195b7
jmp 0x1195d1
movq -0x10(%rbp), %rdi
callq 0x5a120
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x1195d1
movq -0x10(%rbp), %rdi
callq 0x5a660
jmp 0x1195d3
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x11956d
jmp 0x1195e0
jmp 0x1195e2
callq 0x5a4c0
cwtl
cmpl $0x0, %eax
jle 0x1195f9
movl $0xa, %edi
callq 0x5c090
jmp 0x1195e2
movq 0xeedc0(%rip), %rax     # 0x2083c0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x119617
movq -0x30(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movl $0x0, -0x14(%rbp)
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0x31(%rbp)
jne 0x119652
movl -0x18(%rbp), %eax
movl %eax, -0x38(%rbp)
movq 0xfaf03(%rip), %rdi     # 0x214540
callq 0x5c990
movl %eax, %ecx
movl -0x38(%rbp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x11965b
jmp 0x1196a1
movq 0xfaede(%rip), %rdi     # 0x214540
movl -0x18(%rbp), %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
callq 0x1197e0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x119686
jmp 0x119694
callq *-0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x119677
jmp 0x119696
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x119625
movq 0xfae90(%rip), %rdi     # 0x214538
movq (%rdi), %rax
callq *0x20(%rax)
movq 0xfae8b(%rip), %rdi     # 0x214540
movq (%rdi), %rax
callq *0x20(%rax)
movq 0xfae76(%rip), %rax     # 0x214538
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x1196d6
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0xfae63(%rip), %rax     # 0x214540
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0x1196f1
movq -0x48(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
callq 0x61150
callq 0x5de30
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)