// File: /workspace/github_c_makefile_star2_O2/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 0xbe6a7
leaq 0x50c42(%rip), %rsi     # 0x10f2db
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xdf2a5
jmp 0xbe84f
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 0xee7ee
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 0xbe77b
cmpl $0x2, %eax
je 0xbe74b
cmpl $0x1, %eax
movq %rcx, %r15
jne 0xbe7df
leaq 0x56a6a(%rip), %rsi     # 0x115186
movq %r15, %rdi
xorl %eax, %eax
callq 0xde896
leaq 0x136(%rip), %rsi       # 0xbe863
leaq 0x28(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x48(%rsp), %r9
movq %r15, %rdi
xorl %edx, %edx
callq 0xeea46
jmp 0xbe7f9
leaq 0x6fae6(%rip), %rsi     # 0x12e238
movq %rcx, %r15
movq %rcx, %rdi
xorl %eax, %eax
callq 0xde896
leaq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r15, %rdi
xorl %r8d, %r8d
callq 0xef3d3
jmp 0xbe7f9
leaq 0x6facf(%rip), %rsi     # 0x12e251
movq %rcx, %r15
movq %rcx, %rdi
xorl %eax, %eax
callq 0xde896
xorps %xmm0, %xmm0
leaq 0xa8(%rsp), %rsi
movups %xmm0, 0x18(%rsi)
movups %xmm0, 0x28(%rsi)
movups %xmm0, 0x38(%rsi)
andq $0x0, 0x48(%rsi)
movups %xmm0, 0x8(%rsi)
leaq 0x30c1d(%rip), %rax     # 0xef3d3
movq %rax, (%rsi)
leaq 0xa3(%rip), %rax        # 0xbe863
movq %rax, 0x18(%rsi)
movq %rbx, 0x28(%rsi)
movq %r12, 0x30(%rsi)
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsi)
movq %r15, %rdi
callq 0xef577
jmp 0xbe7f9
leaq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r15, %rdi
xorl %r8d, %r8d
callq 0xeea8f
movq 0x10(%rsp), %rdi
callq 0xe58e8
cmpl $0x0, 0x48(%rsp)
je 0xbe82f
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0xee7bc
leaq 0x494e1(%rip), %rsi     # 0x107cff
xorl %ebp, %ebp
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf2a5
jmp 0xbe84f
movq 0x18(%r13), %rcx
pushq $0x1
popq %rbp
cmpq %r14, %rcx
jge 0xbe84f
leaq 0x6f9c1(%rip), %rsi     # 0x12e203
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xdf05a
movl %ebp, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq