// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x208(%rbp)
movq %rdi, %rax
movq %rax, -0x200(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x5ca10
leaq 0x117076(%rip), %rsi    # 0x187556
leaq -0x48(%rbp), %rdi
callq 0x5c1f0
jmp 0x704eb
leaq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x591d0
movb %al, -0x209(%rbp)
jmp 0x70500
leaq -0x48(%rbp), %rdi
callq 0x5df00
leaq -0x30(%rbp), %rdi
callq 0x5df00
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x70521
jmp 0x705a3
movl $0x48, %edi
callq 0x59820
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x218(%rbp)
movq -0x10(%rbp), %rsi
callq 0x71810
jmp 0x70543
movq -0x218(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x705a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x70573
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5df00
leaq -0x30(%rbp), %rdi
callq 0x5df00
jmp 0x70b55
movq -0x218(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x48, %esi
callq 0x595b0
jmp 0x70b55
cmpq $0x0, -0x18(%rbp)
jne 0x707fd
leaq -0x70(%rbp), %rdi
movl $0xc, %esi
callq 0x71080
movq -0x10(%rbp), %rdx
leaq -0x178(%rbp), %rdi
movl $0x3, %esi
movl $0x2, %ecx
callq 0x5d200
jmp 0x705d8
leaq -0x70(%rbp), %rdi
callq 0x71100
movq %rax, -0x220(%rbp)
jmp 0x705ea
movq -0x220(%rbp), %rsi
leaq -0x178(%rbp), %rdi
movl $0xc, %edx
callq 0x5b510
jmp 0x70604
leaq -0x70(%rbp), %rdi
callq 0x70b60
movw %ax, -0x222(%rbp)
jmp 0x70616
movw -0x222(%rbp), %ax
movw %ax, -0x17a(%rbp)
movswl -0x17a(%rbp), %eax
cmpl $0x0, %eax
jne 0x706a9
movl $0x48, %edi
callq 0x59820
movq %rax, -0x230(%rbp)
jmp 0x70643
movq -0x230(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x71810
jmp 0x70655
movq -0x230(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x707cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x707ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x707e3
movq -0x230(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x48, %esi
callq 0x595b0
jmp 0x707e3
movswl -0x17a(%rbp), %eax
cmpl $0x1, %eax
jne 0x7070c
movl $0x48, %edi
callq 0x59820
movq %rax, -0x238(%rbp)
jmp 0x706c8
movq -0x238(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x71df0
jmp 0x706da
movq -0x238(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x707ca
movq -0x238(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x48, %esi
callq 0x595b0
jmp 0x707e3
movswl -0x17a(%rbp), %eax
cmpl $0x2, %eax
jne 0x70769
movl $0x48, %edi
callq 0x59820
movq %rax, -0x240(%rbp)
jmp 0x7072b
movq -0x240(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x71250
jmp 0x7073d
movq -0x240(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x707c8
movq -0x240(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x48, %esi
callq 0x595b0
jmp 0x707e3
movswl -0x17a(%rbp), %eax
cmpl $0x3, %eax
jne 0x707c6
movl $0x48, %edi
callq 0x59820
movq %rax, -0x248(%rbp)
jmp 0x70788
movq -0x248(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x728f0
jmp 0x7079a
movq -0x248(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x707c6
movq -0x248(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x48, %esi
callq 0x595b0
jmp 0x707e3
jmp 0x707c8
jmp 0x707ca
jmp 0x707cc
leaq -0x178(%rbp), %rdi
callq 0x59710
leaq -0x70(%rbp), %rdi
callq 0x71000
jmp 0x707fd
leaq -0x178(%rbp), %rdi
callq 0x59710
leaq -0x70(%rbp), %rdi
callq 0x71000
jmp 0x70b55
movq -0x208(%rbp), %rdi
movb $0x0, -0x17b(%rbp)
xorl %esi, %esi
callq 0x5d4a0
cmpq $0x0, -0x18(%rbp)
je 0x70875
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, -0x250(%rbp)
jmp 0x7082f
movq -0x250(%rbp), %rsi
movq -0x208(%rbp), %rdi
callq 0x5cca0
jmp 0x70844
movq -0x18(%rbp), %rax
movq %rax, -0x258(%rbp)
cmpq $0x0, %rax
je 0x70862
movq -0x258(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x70875
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x70b49
movq -0x10(%rbp), %rax
movq %rax, -0x260(%rbp)
movb $0x0, -0x1b1(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x5cfc0
jmp 0x70895
movq -0x260(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x5bf60
movb %al, -0x261(%rbp)
jmp 0x708b0
movb -0x261(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x262(%rbp)
jne 0x7090e
jmp 0x708c5
movq -0x10(%rbp), %rax
movq %rax, -0x270(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x5c270
jmp 0x708de
movq -0x270(%rbp), %rdi
movb $0x1, -0x1b1(%rbp)
leaq -0x1b0(%rbp), %rsi
callq 0x5bf60
movb %al, -0x271(%rbp)
jmp 0x70900
movb -0x271(%rbp), %al
xorb $-0x1, %al
movb %al, -0x262(%rbp)
movb -0x262(%rbp), %al
movb %al, -0x272(%rbp)
testb $0x1, -0x1b1(%rbp)
jne 0x70925
jmp 0x70931
leaq -0x1b0(%rbp), %rdi
callq 0x5df00
leaq -0x198(%rbp), %rdi
callq 0x5df00
movb -0x272(%rbp), %al
testb $0x1, %al
jne 0x7094c
jmp 0x70b1d
movq -0x208(%rbp), %rdi
xorl %esi, %esi
callq 0x5c730
movb %al, -0x273(%rbp)
jmp 0x70962
movb -0x273(%rbp), %al
testb $0x1, %al
jne 0x70971
jmp 0x70a57
leaq -0x1d8(%rbp), %rdi
callq 0x5cfc0
jmp 0x7097f
movq -0x10(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x5a710
movq %rax, -0x280(%rbp)
jmp 0x70998
movq -0x280(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
callq 0x5cba0
jmp 0x709ad
movq -0x208(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x5cca0
jmp 0x709c2
leaq -0x1c0(%rbp), %rdi
callq 0x5de40
leaq -0x1d8(%rbp), %rdi
callq 0x5df00
jmp 0x70a57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x70a0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
testb $0x1, -0x1b1(%rbp)
jne 0x70a01
jmp 0x70a0d
leaq -0x1b0(%rbp), %rdi
callq 0x5df00
jmp 0x70a0f
leaq -0x198(%rbp), %rdi
callq 0x5df00
jmp 0x70b49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x70a46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x5de40
leaq -0x1d8(%rbp), %rdi
callq 0x5df00
jmp 0x70b49
movq -0x208(%rbp), %rdi
xorl %esi, %esi
callq 0x5c730
movb %al, -0x281(%rbp)
jmp 0x70a6d
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0x70a7c
jmp 0x70b1b
leaq -0x1f8(%rbp), %rdi
callq 0x5c270
jmp 0x70a8a
movq -0x10(%rbp), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0x5a710
movq %rax, -0x290(%rbp)
jmp 0x70aa3
movq -0x290(%rbp), %rsi
leaq -0x1e0(%rbp), %rdi
callq 0x5cba0
jmp 0x70ab8
movq -0x208(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x5cca0
jmp 0x70acd
leaq -0x1e0(%rbp), %rdi
callq 0x5de40
leaq -0x1f8(%rbp), %rdi
callq 0x5df00
jmp 0x70b1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x70b0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x5de40
leaq -0x1f8(%rbp), %rdi
callq 0x5df00
jmp 0x70b49
jmp 0x70b1d
movb $0x1, -0x17b(%rbp)
testb $0x1, -0x17b(%rbp)
jne 0x70b39
movq -0x208(%rbp), %rdi
callq 0x5de40
movq -0x200(%rbp), %rax
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
movq -0x208(%rbp), %rdi
callq 0x5de40
movq -0x50(%rbp), %rdi
callq 0x5b6b0
nop