// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x250(%rbp)
addq $0x40, %rdi
xorl %esi, %esi
callq 0x5ac20
movq -0x250(%rbp), %rax
testb $0x1, 0x38(%rax)
jne 0x72a13
movq -0x250(%rbp), %rax
testb $0x1, 0x39(%rax)
jne 0x72a13
movq -0x250(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x8(%rbp)
jmp 0x72d8e
movq -0x250(%rbp), %rax
testb $0x1, 0x38(%rax)
je 0x72b07
movq -0x250(%rbp), %rdx
addq $0x8, %rdx
leaq -0x118(%rbp), %rdi
movq %rdi, -0x268(%rbp)
movl $0x3, %esi
movl $0x2, %ecx
callq 0x5d200
movq -0x250(%rbp), %rax
movq -0x268(%rbp), %rdi
addq $0x20, %rax
movq %rax, -0x260(%rbp)
callq 0x5a580
movq %rax, -0x258(%rbp)
jmp 0x72a73
movq -0x260(%rbp), %rdi
movq -0x258(%rbp), %rax
movl %eax, %esi
callq 0x72e00
jmp 0x72a8a
movq -0x250(%rbp), %rdi
addq $0x20, %rdi
callq 0x71100
movq %rax, -0x270(%rbp)
jmp 0x72aa3
movq -0x250(%rbp), %rdi
addq $0x20, %rdi
callq 0x71140
movl %eax, -0x274(%rbp)
jmp 0x72abb
movl -0x274(%rbp), %edx
movq -0x270(%rbp), %rsi
leaq -0x118(%rbp), %rdi
callq 0x5b510
jmp 0x72ad6
leaq -0x118(%rbp), %rdi
callq 0x59710
jmp 0x72b07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x59710
jmp 0x72d9b
leaq -0x218(%rbp), %rdi
callq 0x72db0
movq -0x250(%rbp), %rdi
addq $0x20, %rdi
callq 0x71100
movq -0x250(%rbp), %rdi
movq %rax, -0x280(%rbp)
addq $0x20, %rdi
callq 0x71140
movq -0x280(%rbp), %rdi
movslq %eax, %rsi
leaq -0x218(%rbp), %rdx
callq 0x72dd0
cmpl $0x0, %eax
je 0x72b69
movq -0x250(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x8(%rbp)
jmp 0x72d8e
movq -0x250(%rbp), %rdi
movl $0x1, -0x1f0(%rbp)
addq $0x20, %rdi
callq 0x71100
movq -0x250(%rbp), %rdi
movq %rax, -0x288(%rbp)
addq $0x20, %rdi
callq 0x71140
movq -0x288(%rbp), %rdi
movslq %eax, %rsi
leaq -0x218(%rbp), %rdx
callq 0x5b2f0
cmpl $0x0, %eax
je 0x72bc9
movq -0x250(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x8(%rbp)
jmp 0x72d8e
movq -0x250(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x290(%rbp)
movl -0x218(%rbp), %esi
movl -0x214(%rbp), %edx
leaq -0x220(%rbp), %rdi
callq 0x59260
movq -0x290(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5c4d0
movl $0x0, -0x224(%rbp)
movl -0x224(%rbp), %eax
cmpl -0x214(%rbp), %eax
jge 0x72d6f
movl -0x224(%rbp), %eax
shll $0x2, %eax
imull -0x218(%rbp), %eax
movl %eax, -0x228(%rbp)
movl $0x0, -0x22c(%rbp)
movl -0x22c(%rbp), %eax
cmpl -0x218(%rbp), %eax
jge 0x72d59
movq -0x250(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x298(%rbp)
movl -0x22c(%rbp), %esi
movl -0x224(%rbp), %edx
leaq -0x234(%rbp), %rdi
callq 0x5c2c0
movq -0x1e0(%rbp), %rax
movl -0x228(%rbp), %ecx
movl -0x22c(%rbp), %edx
shll $0x2, %edx
addl %edx, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
shll $0x18, %eax
movq -0x1e0(%rbp), %rcx
movl -0x228(%rbp), %edx
movl -0x22c(%rbp), %esi
shll $0x2, %esi
addl %esi, %edx
addl $0x2, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x1e0(%rbp), %rcx
movl -0x228(%rbp), %edx
movl -0x22c(%rbp), %esi
shll $0x2, %esi
addl %esi, %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x1e0(%rbp), %rcx
movl -0x228(%rbp), %edx
movl -0x22c(%rbp), %esi
shll $0x2, %esi
addl %esi, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
orl %ecx, %eax
movslq %eax, %rsi
leaq -0x248(%rbp), %rdi
movl $0x1, %edx
callq 0x59be0
movq -0x298(%rbp), %rdi
leaq -0x234(%rbp), %rsi
leaq -0x248(%rbp), %rdx
callq 0x5a3d0
movl -0x22c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x22c(%rbp)
jmp 0x72c47
jmp 0x72d5b
movl -0x224(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x224(%rbp)
jmp 0x72c15
leaq -0x218(%rbp), %rdi
addq $0x28, %rdi
callq 0x5c520
movq -0x250(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x120(%rbp), %rdi
callq 0x5b6b0
nopw (%rax,%rax)