// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/graphics/imageloader/webp.cpp
// Function: smooth::GUI::ImageLoaderWebP::Load()
const S::GUI::Bitmap &S::GUI::ImageLoaderWebP::Load()
{
	/* Make sure bitmap is initialized.
	 */
	bitmap = NIL;

	/* Check if we either have a file or a buffer to load.
	 */
	if (!gotFileName && !gotBuffer) return bitmap;

	/* Load file into buffer.
	 */
	if (gotFileName)
	{
		InStream	 in(STREAM_FILE, fileName, IS_READ);

		buffer.Resize(in.Size());
		in.InputData(buffer, buffer.Size());
	}

	/* Init WebP decoder.
	 */
	WebPDecoderConfig config;
	WebPInitDecoderConfig(&config);

	if (WebPGetFeatures(buffer, buffer.Size(), &config.input) != VP8_STATUS_OK) return bitmap;

	/* Decode image in RGBA format.
	 */
	config.output.colorspace = MODE_RGBA;

	if (WebPDecode(buffer, buffer.Size(), &config) != VP8_STATUS_OK) return bitmap;

	/* Copy decoded image to bitmap.
	 */
	bitmap.CreateBitmap(Size(config.input.width, config.input.height));

	for (Int y = 0; y < config.input.height; y++)
	{
		Int	 lineOffset = 4 * y * config.input.width;

		for (Int x = 0; x < config.input.width; x++)
		{
			bitmap.SetPixel(Point(x, y), Color(config.output.u.RGBA.rgba[lineOffset + 4 * x + 3] << 24 | config.output.u.RGBA.rgba[lineOffset + 4 * x + 2] << 16 | config.output.u.RGBA.rgba[lineOffset + 4 * x + 1] << 8 | config.output.u.RGBA.rgba[lineOffset + 4 * x], Color::RGBA));
		}
	}

	WebPFreeDecBuffer(&config.output);

	return bitmap;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %r14
leaq 0x40(%rdi), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x57880
cmpb $0x0, 0x38(%r14)
je 0x6399a
leaq 0x8(%r14), %rdx
leaq 0x20(%rsp), %r15
pushq $0x3
popq %rsi
pushq $0x2
popq %rcx
movq %r15, %rdi
callq 0x59a20
leaq 0x20(%r14), %rdi
cmpw $0x0, 0x8(%r15)
je 0x639a6
movl 0x30(%rsp), %esi
jmp 0x639b3
cmpb $0x0, 0x39(%r14)
jne 0x639e0
jmp 0x63b10
pushq $-0x1
popq %rsi
movw $0x5, 0x118(%rsp)
callq 0x63b3a
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x639c6
movq (%rax), %rsi
jmp 0x639c8
xorl %esi, %esi
movl 0x30(%r14), %edx
leaq 0x20(%rsp), %rdi
callq 0x58100
leaq 0x20(%rsp), %rdi
callq 0x565f0
leaq 0x20(%rsp), %rdi
movl $0x209, %esi            # imm = 0x209
callq 0x59740
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x639fd
movq (%rax), %rdi
jmp 0x639ff
xorl %edi, %edi
movslq 0x30(%r14), %rsi
leaq 0x20(%rsp), %rdx
movl $0x209, %ecx            # imm = 0x209
callq 0x59e60
testl %eax, %eax
jne 0x63b10
movl $0x1, 0x48(%rsp)
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x63a30
movq (%rax), %rdi
jmp 0x63a32
xorl %edi, %edi
movslq 0x30(%r14), %rsi
leaq 0x20(%rsp), %rdx
callq 0x57ee0
testl %eax, %eax
jne 0x63b10
leaq 0x48(%rsp), %rax
movq -0x28(%rax), %rax
leaq 0x10(%rsp), %r15
movq %rax, (%r15)
pushq $-0x1
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x58ea0
xorl %edx, %edx
movq %rsp, %r12
xorl %ebp, %ebp
cmpl 0x24(%rsp), %ebp
jge 0x63b06
movl 0x20(%rsp), %eax
movl %eax, %ecx
movq %rdx, 0x8(%rsp)
imull %edx, %ecx
movslq %ecx, %r14
addq $0x3, %r14
xorl %r13d, %r13d
cltq
cmpq %rax, %r13
jge 0x63af7
movl %r13d, (%rsp)
movl %ebp, 0x4(%rsp)
movq 0x58(%rsp), %rax
addq %r14, %rax
movzbl (%rax,%r13,4), %ecx
shll $0x18, %ecx
movzbl -0x1(%rax,%r13,4), %edx
shll $0x10, %edx
movslq %ecx, %rcx
orq %rdx, %rcx
movzbl -0x2(%rax,%r13,4), %edx
shll $0x8, %edx
orq %rcx, %rdx
movzbl -0x3(%rax,%r13,4), %eax
orq %rdx, %rax
movq %rax, 0x18(%rsp)
movl $0x1, 0x10(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x57160
incq %r13
movl 0x20(%rsp), %eax
jmp 0x63a90
incl %ebp
movq 0x8(%rsp), %rdx
addl $0x4, %edx
jmp 0x63a6e
leaq 0x48(%rsp), %rdi
callq 0x58ee0
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x565f0
movq %rbx, %rdi
callq 0x58260