// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/shg.c
// Function: do_uncompress_picture_data
static int do_uncompress_picture_data(deark *c, lctx *d,
	struct picture_ctx *pctx,
	i64 compressed_offset, i64 compressed_size,
	dbuf *pixels_final, i64 final_image_size)
{
	int retval = 0;
	struct de_dfilter_in_params dcmpri;
	struct de_dfilter_out_params dcmpro;
	struct de_dfilter_results dres;

	if(pctx->packing_method>3) {
		de_err(c, "Unsupported compression type: %d", (int)pctx->packing_method);
		goto done;
	}

	de_dfilter_init_objects(c, &dcmpri, &dcmpro, &dres);
	dcmpri.f = c->infile;
	dcmpri.pos = compressed_offset;
	dcmpri.len = compressed_size;
	dcmpro.f = pixels_final;
	dcmpro.len_known = 1;
	dcmpro.expected_len = final_image_size;

	switch(pctx->packing_method) {
	case 1:
		do_decompress_type_1(c, d, &dcmpri, &dcmpro, &dres);
		break;
	case 2:
		do_decompress_type_2(c, d, &dcmpri, &dcmpro, &dres);
		break;
	case 3:
		do_decompress_type_3(c, d, &dcmpri, &dcmpro, &dres);
		break;
	default: // 0, uncompressed
		fmtutil_decompress_uncompressed(c, &dcmpri, &dcmpro, &dres, 0);
	}
	dbuf_flush(dcmpro.f);

	if(dres.errcode) {
		de_err(c, "%s", de_dfilter_get_errmsg(c, &dres));
		goto done;
	}

	if(pixels_final->len < final_image_size) {
		de_warn(c, "Expected %"I64_FMT" bytes after decompression, only got %"I64_FMT,
			final_image_size, pixels_final->len);
	}

	retval = 1;

done:
	return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdx, %r15
movzbl 0x1(%rsi), %edx
cmpl $0x4, %edx
jb 0xc660d
leaq 0x55dcc(%rip), %rsi     # 0x11c3cb
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xe9295
jmp 0xc67bd
movq %r9, %r14
movq %r8, %r13
movq %rsi, %rbp
movq %rdi, %r12
leaq 0x28(%rsp), %rbx
leaq 0x10(%rsp), %rdx
movq %rcx, 0x8(%rsp)
leaq 0x48(%rsp), %rcx
movq %rbx, %rsi
callq 0xfa1dc
movq %r12, %rcx
movq 0x18(%r12), %rax
leaq 0x10(%rsp), %r12
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rbx)
movq %r13, (%r12)
movb $0x1, 0x8(%r12)
movq %r14, 0x10(%r12)
movzbl 0x1(%rbp), %eax
cmpl $0x3, %eax
je 0xc66e4
cmpl $0x2, %eax
je 0xc66b1
cmpl $0x1, %eax
movq %rcx, %r15
jne 0xc674b
leaq 0x5bcc4(%rip), %rsi     # 0x122346
movq %r15, %rdi
xorl %eax, %eax
callq 0xe8617
leaq 0x13e(%rip), %rsi       # 0xc67d1
leaq 0x28(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x48(%rsp), %r9
movq %r15, %rdi
xorl %edx, %edx
callq 0xfa46f
jmp 0xc6765
leaq 0x74e70(%rip), %rsi     # 0x13b528
movq %rcx, %r15
movq %rcx, %rdi
xorl %eax, %eax
callq 0xe8617
leaq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r15, %rdi
xorl %r8d, %r8d
callq 0xfaf12
jmp 0xc6765
leaq 0x74e56(%rip), %rsi     # 0x13b541
movq %rcx, %r15
movq %rcx, %rdi
xorl %eax, %eax
callq 0xe8617
xorps %xmm0, %xmm0
leaq 0xa8(%rsp), %rsi
movups %xmm0, 0x18(%rsi)
movups %xmm0, 0x28(%rsi)
movups %xmm0, 0x38(%rsi)
movups %xmm0, 0x8(%rsi)
movq $0x0, 0x48(%rsi)
leaq 0x347f0(%rip), %rax     # 0xfaf12
movq %rax, (%rsi)
leaq 0xa5(%rip), %rax        # 0xc67d1
movq %rax, 0x18(%rsi)
movq %rbx, 0x28(%rsi)
movq %r12, 0x30(%rsi)
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsi)
movq %r15, %rdi
callq 0xfb10b
jmp 0xc6765
leaq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r15, %rdi
xorl %r8d, %r8d
callq 0xfa510
movq 0x10(%rsp), %rdi
callq 0xf08ba
cmpl $0x0, 0x48(%rsp)
je 0xc679b
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0xfa1a4
leaq 0x4e5d5(%rip), %rsi     # 0x114d5f
xorl %ebp, %ebp
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9295
jmp 0xc67bd
movq 0x18(%r13), %rcx
movl $0x1, %ebp
cmpq %r14, %rcx
jge 0xc67bd
leaq 0x74d43(%rip), %rsi     # 0x13b4f3
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xe8faa
movl %ebp, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq