// File: /workspace/github_c_makefile_star2_O0/tditlu[P]shadetabler/src/image.c
// Function: image_load_rgba
image_error_t image_load_rgba(image_t *const image, const char *infile) {
	image->buffer = NULL;

	image_error_t error;

	unsigned int status = lodepng_decode32_file(&image->buffer, &image->width, &image->height, infile);
	if (status || image->buffer == NULL) {
		error = IMAGE_ERROR_OPEN;
		goto error;
	}

	for (unsigned int y = 0; y < image->height; y++) {
		for (unsigned int x = 0; x < image->width; x++) {
			if (image->buffer[((y * image->width *4 ) + (x * 4)) + 3] != 255) {
				float a = ((float)image->buffer[((y * image->width * 4) + (x * 4)) + 3]) / 255.0f;
				image->buffer[((y * image->width * 4) + (x * 4)) + 0] = (unsigned char)(((float)image->buffer[((y * image->width * 4) + (x * 4)) + 0]) * a);
				image->buffer[((y * image->width * 4) + (x * 4)) + 1] = (unsigned char)(((float)image->buffer[((y * image->width * 4) + (x * 4)) + 1]) * a);
				image->buffer[((y * image->width * 4) + (x * 4)) + 2] = (unsigned char)(((float)image->buffer[((y * image->width * 4) + (x * 4)) + 2]) * a);
				image->buffer[((y * image->width * 4) + (x * 4)) + 3] = 255;
			}
		}
	}

	return IMAGE_ERROR_NO_ERROR;

error:
	if (image->buffer != NULL) {
		image_free_rgba(image);
	}
	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rdx
addq $0xc, %rdx
movq -0x18(%rbp), %rcx
callq 0xd2e0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x1906b
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x19077
movl $0x1, -0x1c(%rbp)
jmp 0x19222
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x19219
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x19209
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rdx
imull 0x8(%rdx), %ecx
shll $0x2, %ecx
movl -0x28(%rbp), %edx
shll $0x2, %edx
addl %edx, %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x191f9
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movl -0x24(%rbp), %esi
movl 0x8(%rcx), %ecx
imull %ecx, %esi
movl -0x28(%rbp), %edx
shll $0x2, %edx
movl %edx, %ecx
movl %esi, %edx
leal (%rcx,%rdx,4), %ecx
movzbl 0x3(%rax,%rcx), %eax
cvtsi2ss %eax, %xmm0
movss 0x1f04(%rip), %xmm1     # 0x1b008
divss %xmm1, %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movl -0x24(%rbp), %esi
movl 0x8(%rcx), %ecx
imull %ecx, %esi
movl -0x28(%rbp), %edx
shll $0x2, %edx
movl %edx, %ecx
movl %esi, %edx
leal (%rcx,%rdx,4), %ecx
movzbl (%rax,%rcx), %edx
cvtsi2ss %edx, %xmm0
movss -0x2c(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movl -0x24(%rbp), %esi
movl 0x8(%rcx), %ecx
imull %ecx, %esi
movl -0x28(%rbp), %edx
shll $0x2, %edx
movl %edx, %ecx
movl %esi, %edx
leal (%rcx,%rdx,4), %ecx
movzbl 0x1(%rax,%rcx), %edx
cvtsi2ss %edx, %xmm0
movss -0x2c(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
movb %dl, 0x1(%rax,%rcx)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movl -0x24(%rbp), %esi
movl 0x8(%rcx), %ecx
imull %ecx, %esi
movl -0x28(%rbp), %edx
shll $0x2, %edx
movl %edx, %ecx
movl %esi, %edx
leal (%rcx,%rdx,4), %ecx
movzbl 0x2(%rax,%rcx), %eax
cvtsi2ss %eax, %xmm0
movss -0x2c(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rsi
imull 0x8(%rsi), %ecx
shll $0x2, %ecx
movl -0x28(%rbp), %esi
shll $0x2, %esi
addl %esi, %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rdx
imull 0x8(%rdx), %ecx
shll $0x2, %ecx
movl -0x28(%rbp), %edx
shll $0x2, %edx
addl %edx, %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movb $-0x1, (%rax,%rcx)
jmp 0x191fb
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x19095
jmp 0x1920b
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1907e
movl $0x0, -0x4(%rbp)
jmp 0x1923b
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x19235
movq -0x10(%rbp), %rdi
callq 0x18fe0
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)