// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/graphics/imageloader/imageloader.cpp
// Function: smooth::GUI::ImageLoader::Load(smooth::String const&)
S::GUI::Bitmap S::GUI::ImageLoader::Load(const String &fileName)
{
	ImageLoader	*loader = NIL;

	if	(fileName.ToLower().Contains(".pci:")) loader = new ImageLoaderPCI(fileName);
#ifdef __WIN32__
	else if (fileName.StartsWith("Icon:"))	       loader = new ImageLoaderIcon(fileName);
#endif

	if (loader == NIL)
	{
		/* Auto-detect image format.
		 */
		Buffer<UnsignedByte>	 buffer(12);
		InStream		 in(STREAM_FILE, fileName, IS_READ);

		in.InputData(buffer, 12);

		Short	 format = DetectImageFormat(buffer);

		if	(format == IMAGE_FORMAT_PCI)  loader = new ImageLoaderPCI(fileName);
		else if (format == IMAGE_FORMAT_PNG)  loader = new ImageLoaderPNG(fileName);
		else if (format == IMAGE_FORMAT_JPEG) loader = new ImageLoaderJPEG(fileName);
		else if (format == IMAGE_FORMAT_WEBP) loader = new ImageLoaderWebP(fileName);
	}

	/* Load image.
	 */
	Bitmap	 bitmap;

	if (loader != NIL)
	{
		bitmap = loader->Load();

		delete loader;
	}

	/* Look in the startup and application folders if no image has been found yet.
	 */
	if (!fileName.StartsWith(Application::GetStartupDirectory()) && !fileName.StartsWith(Application::GetApplicationDirectory()))
	{
		if (bitmap == NIL) bitmap = Load(Application::GetStartupDirectory().Append(fileName));
		if (bitmap == NIL) bitmap = Load(Application::GetApplicationDirectory().Append(fileName));
	}

	return bitmap;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
callq 0x58090
leaq 0x92af9(%rip), %rsi     # 0xf45c3
leaq 0x8(%rsp), %rdi
callq 0x579f0
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x55180
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x20(%rsp), %rdi
callq 0x59200
testb %bpl, %bpl
je 0x61b18
movl $0x48, %edi
callq 0x556b0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x623d4
jmp 0x61b1b
xorl %r15d, %r15d
testq %r15, %r15
jne 0x61c16
leaq 0x8(%rsp), %rdi
movl $0xc, %esi
callq 0x62006
leaq 0x20(%rsp), %rdi
movl $0x3, %esi
movq %r14, %rdx
movl $0x2, %ecx
callq 0x58730
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x61b59
movq (%rax), %rsi
jmp 0x61b5b
xorl %esi, %esi
leaq 0x20(%rsp), %rdi
movl $0xc, %edx
callq 0x56f50
leaq 0x8(%rsp), %rdi
callq 0x61e13
cmpw $0x3, %ax
ja 0x61bf5
movzwl %ax, %eax
leaq 0x92a04(%rip), %rcx     # 0xf4588
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x48, %edi
callq 0x556b0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x623d4
jmp 0x61bf8
movl $0x48, %edi
callq 0x556b0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x620c0
jmp 0x61bf8
movl $0x48, %edi
callq 0x556b0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x62c50
jmp 0x61bf8
movl $0x48, %edi
callq 0x556b0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x6267c
jmp 0x61bf8
xorl %r15d, %r15d
leaq 0x20(%rsp), %rdi
callq 0x555b0
leaq 0xff327(%rip), %rax     # 0x160f30
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
callq 0x6207e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x58950
testq %r15, %r15
je 0x61c42
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x582c0
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq 0x20(%rsp), %rdi
callq 0x58530
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x577d0
movl %eax, %ebp
testb %al, %al
je 0x61c64
xorl %r15d, %r15d
jmp 0x61c82
leaq 0x8(%rsp), %rdi
callq 0x57a50
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x577d0
movl %eax, %r15d
xorb $0x1, %r15b
testb %bpl, %bpl
jne 0x61c91
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x20(%rsp), %rdi
callq 0x59200
testb %r15b, %r15b
je 0x61d3e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x57e30
testb %al, %al
je 0x61cf1
leaq 0x20(%rsp), %rdi
callq 0x58530
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x562f0
movq %rsp, %rdi
movq %rax, %rsi
callq 0x581f0
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x582c0
movq %rsp, %rdi
callq 0x59148
leaq 0x20(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
xorl %esi, %esi
callq 0x57e30
testb %al, %al
je 0x61d3e
leaq 0x20(%rsp), %rdi
callq 0x57a50
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x562f0
movq %rsp, %rdi
movq %rax, %rsi
callq 0x581f0
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x582c0
movq %rsp, %rdi
callq 0x59148
leaq 0x20(%rsp), %rdi
callq 0x59200
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x61d55
jmp 0x61d55
jmp 0x61d55
movq %rax, %r14
movl $0x48, %esi
movq %r15, %rdi
callq 0x55480
jmp 0x61d85
jmp 0x61d6e
jmp 0x61e00
movq %rax, %r14
movq %rsp, %rdi
callq 0x59148
jmp 0x61dd4
jmp 0x61e00
jmp 0x61d82
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x555b0
jmp 0x61d94
movq %rax, %r14
leaq 0xff195(%rip), %rax     # 0x160f30
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
callq 0x6207e
jmp 0x61e0b
jmp 0x61dd1
jmp 0x61dd1
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x59200
jmp 0x61dd4
jmp 0x61dd1
movq %rax, %r14
movl $0x48, %esi
movq %r15, %rdi
callq 0x55480
jmp 0x61e0b
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x59200
jmp 0x61e03
jmp 0x61e00
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x59200
jmp 0x61df4
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x59200
jmp 0x61e0b
movq %rax, %r14
movq %rbx, %rdi
callq 0x59148
movq %r14, %rdi
callq 0x57090