// File: /workspace/github_c_makefile_star2_O2/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 0x59320
leaq 0x80d5f(%rip), %rsi     # 0xe35e3
leaq 0x8(%rsp), %rdi
callq 0x58c40
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x56180
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x5a588
leaq 0x20(%rsp), %rdi
callq 0x5a588
testb %bpl, %bpl
je 0x628d3
pushq $0x48
popq %rdi
callq 0x56700
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x630bc
jmp 0x629ab
leaq 0x8(%rsp), %rdi
pushq $0xc
popq %rsi
callq 0x62d56
leaq 0x20(%rsp), %rdi
pushq $0x3
popq %rsi
pushq $0x2
popq %rcx
movq %r14, %rdx
callq 0x59a20
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x62902
movq (%rax), %rsi
jmp 0x62904
xorl %esi, %esi
leaq 0x20(%rsp), %rdi
pushq $0xc
popq %rdx
callq 0x58100
leaq 0x8(%rsp), %rdi
callq 0x62b9e
cmpw $0x3, %ax
ja 0x62994
movzwl %ax, %eax
leaq 0x80c7d(%rip), %rcx     # 0xe35a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x48
popq %rdi
callq 0x56700
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x630bc
jmp 0x62997
pushq $0x48
popq %rdi
callq 0x56700
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x62e00
jmp 0x62997
pushq $0x48
popq %rdi
callq 0x56700
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x63900
jmp 0x62997
pushq $0x48
popq %rdi
callq 0x56700
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x63358
jmp 0x62997
xorl %r15d, %r15d
leaq 0x20(%rsp), %rdi
callq 0x565f0
leaq 0x8(%rsp), %rdi
callq 0x62d46
movq %rbx, %rdi
xorl %esi, %esi
callq 0x59c80
testq %r15, %r15
je 0x629d7
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x59570
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq 0x20(%rsp), %rdi
callq 0x59820
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x58a10
testb %al, %al
je 0x62a01
leaq 0x20(%rsp), %rdi
callq 0x5a588
jmp 0x62ad8
leaq 0x8(%rsp), %rdi
callq 0x58cb0
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x58a10
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x5a588
leaq 0x20(%rsp), %rdi
callq 0x5a588
testb %bpl, %bpl
jne 0x62ad8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x590c0
testb %al, %al
je 0x62a8a
leaq 0x20(%rsp), %rdi
callq 0x59820
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x573e0
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x59490
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x59570
leaq 0x8(%rsp), %rdi
callq 0x5a4c8
leaq 0x20(%rsp), %rdi
callq 0x5a588
movq %rbx, %rdi
xorl %esi, %esi
callq 0x590c0
testb %al, %al
je 0x62ad8
leaq 0x20(%rsp), %rdi
callq 0x58cb0
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x573e0
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x59490
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x59570
leaq 0x8(%rsp), %rdi
callq 0x5a4c8
jmp 0x629f2
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x62aef
jmp 0x62aef
jmp 0x62aef
movq %rax, %r14
pushq $0x48
popq %rsi
movq %r15, %rdi
callq 0x564c0
jmp 0x62b31
jmp 0x62b06
jmp 0x62b8b
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5a4c8
jmp 0x62b5f
jmp 0x62b8b
jmp 0x62b5c
jmp 0x62b5c
jmp 0x62b2e
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5a588
jmp 0x62b5f
jmp 0x62b5c
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x565f0
jmp 0x62b40
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x62d46
jmp 0x62b96
movq %rax, %r14
pushq $0x48
popq %rsi
movq %r15, %rdi
callq 0x564c0
jmp 0x62b96
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x5a588
jmp 0x62b8e
jmp 0x62b8b
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5a588
jmp 0x62b7f
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x5a588
jmp 0x62b96
movq %rax, %r14
movq %rbx, %rdi
callq 0x5a4c8
movq %r14, %rdi
callq 0x58260