// File: /workspace/github_c_makefile_star2_O0/albinoloverats[P]hide/src/jpeg-load.c
// Function: jpeg_decode_data
extern bool jpeg_decode_data(FILE *file, jpeg_message_t *msg, jpeg_image_t *info, jpeg_load_e a, bool fill)
{
	message = msg;
	action = a;

	fseek(file, 0, SEEK_END);
	int64_t length = ftell(file);
	fseek(file, 0, SEEK_SET);
	uint8_t *buf = malloc(length);
	fread(buf, length, 1, file);

	// Allocate memory for our decoded jpg structure, all our data will be
	// decompressed and stored in here for the various stages of our jpeg decoding
	stJpegData jdec;
	memset(&jdec, 0x00, sizeof jdec);

	// Start Parsing.....reading & storing data
	if (JpegParseHeader(&jdec, buf) < 0)
	{
		free(buf);
		return false;
	}

	if (fill)
		fill_size = jdec.m_width * jdec.m_height * 3;

	// We've read it all in, now start using it, to decompress and create rgb values
	JpegDecode(&jdec);

	// Get the size of the image
	info->width = jdec.m_width;
	info->height = jdec.m_height;

	info->rgb = calloc(info->height, sizeof (uint8_t *));
	for (uint32_t i = 0; i < info->height; i++)
	{
		info->rgb[i] = calloc(info->width, 3);
		memcpy(info->rgb[i], jdec.m_rgb + i * info->width * 3, info->width * 3);
	}

	// Release the memory for our jpeg decoder structure jdec
	free(jdec.m_rgb);
	free(buf);

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x19550, %rsp          # imm = 0x19550
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
andb $0x1, %al
movb %al, -0x25(%rbp)
movq -0x18(%rbp), %rax
movq %rax, 0x7a4b(%rip)      # 0x9508
movl -0x24(%rbp), %eax
movl %eax, 0x7a4a(%rip)      # 0x9510
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x1140
movq -0x10(%rbp), %rdi
callq 0x10f0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x1140
movq -0x30(%rbp), %rdi
callq 0x1120
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rcx
movl $0x1, %edx
callq 0x1060
leaq -0x19540(%rbp), %rdi
xorl %esi, %esi
movl $0x19508, %edx          # imm = 0x19508
callq 0x1090
movq -0x38(%rbp), %rsi
leaq -0x19540(%rbp), %rdi
callq 0x1c70
cmpl $0x0, %eax
jge 0x1b51
movq -0x38(%rbp), %rdi
callq 0x1040
movb $0x0, -0x1(%rbp)
jmp 0x1c5f
testb $0x1, -0x25(%rbp)
je 0x1b70
movl -0x19538(%rbp), %eax
imull -0x19534(%rbp), %eax
imull $0x3, %eax, %eax
movl %eax, %eax
movq %rax, 0x79a8(%rip)      # 0x9518
leaq -0x19540(%rbp), %rdi
callq 0x1cf0
movl -0x19538(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x19534(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, %edi
movl $0x8, %esi
callq 0x10d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x19544(%rbp)
movl -0x19544(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x1c46
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %edi
movl $0x3, %esi
callq 0x10d0
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x19544(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x19544(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movq -0x19540(%rbp), %rsi
movl -0x19544(%rbp), %eax
movq -0x20(%rbp), %rcx
imull 0x8(%rcx), %eax
imull $0x3, %eax, %eax
movl %eax, %eax
addq %rax, %rsi
movq -0x20(%rbp), %rax
imull $0x3, 0x8(%rax), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1110
movl -0x19544(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x19544(%rbp)
jmp 0x1bbd
movq -0x19540(%rbp), %rdi
callq 0x1040
movq -0x38(%rbp), %rdi
callq 0x1040
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x19550, %rsp          # imm = 0x19550
popq %rbp
retq
nopl (%rax)