// File: /workspace/github_c_makefile_star2_O0/albinoloverats[P]hide/src/jpeg-load.c
// Function: JpegDecode
static int JpegDecode(stJpegData *jdata)
{
	g_reservoir = 0;
	g_nbits_in_reservoir = 0;

	int hFactor = jdata->m_component_info[cY].m_hFactor;
	int vFactor = jdata->m_component_info[cY].m_vFactor;

	// RGB24:
	if (jdata->m_rgb == NULL)
	{
		int h = jdata->m_height * 3;
		int w = jdata->m_width * 3;
		int height = h + (hFactor << 3) - (h % (hFactor << 3));
		int width = w + (vFactor << 3) - (w % (vFactor << 3));
		jdata->m_rgb = calloc(width * height, sizeof (uint8_t));
	}

	jdata->m_component_info[0].m_previousDC = 0;
	jdata->m_component_info[1].m_previousDC = 0;
	jdata->m_component_info[2].m_previousDC = 0;
	jdata->m_component_info[3].m_previousDC = 0;

	int xstride_by_mcu = hFactor << 3;
	int ystride_by_mcu = vFactor << 3;

	// Just the decode the image by 'macroblock' (size is 8x8, 8x16, or 16x16)
	for (int y = 0; y < (int)jdata->m_height; y += ystride_by_mcu)
	{
		for (int x = 0; x < (int)jdata->m_width; x += xstride_by_mcu)
		{
			jdata->m_colourspace = jdata->m_rgb + x * 3 + (y * jdata->m_width * 3);
			// Decode MCU Plane
			DecodeMCU(jdata, hFactor, vFactor);
			YCrCB_to_RGB24_Block8x8(jdata, hFactor, vFactor, x, y, jdata->m_width, jdata->m_height);
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, 0x781a(%rip)      # 0x9520
movl $0x0, 0x7814(%rip)      # 0x9524
movq -0x8(%rbp), %rax
movl 0xc8(%rax), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0xcc(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1dac
movq -0x8(%rbp), %rax
imull $0x3, 0xc(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
imull $0x3, 0x8(%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
movl -0xc(%rbp), %ecx
shll $0x3, %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movl -0x14(%rbp), %eax
movl -0xc(%rbp), %ecx
shll $0x3, %ecx
cltd
idivl %ecx
movl -0x38(%rbp), %eax
subl %edx, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
movl -0x10(%rbp), %ecx
shll $0x3, %ecx
addl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x18(%rbp), %eax
movl -0x10(%rbp), %ecx
shll $0x3, %ecx
cltd
idivl %ecx
movl -0x34(%rbp), %eax
subl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
imull -0x1c(%rbp), %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x10d0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xc4(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x16c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x214(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x2bc(%rax)
movl -0xc(%rbp), %eax
shll $0x3, %eax
movl %eax, -0x24(%rbp)
movl -0x10(%rbp), %eax
shll $0x3, %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x1ea0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x1e90
movq -0x8(%rbp), %rax
movq (%rax), %rcx
imull $0x3, -0x30(%rbp), %eax
cltq
addq %rax, %rcx
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rdx
imull 0x8(%rdx), %eax
imull $0x3, %eax, %eax
movl %eax, %eax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x19500(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
callq 0x28f0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movq -0x8(%rbp), %rax
movl 0x8(%rax), %r9d
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, (%rsp)
callq 0x29f0
movl -0x24(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x1e14
jmp 0x1e92
movl -0x28(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x1dfd
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)