// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/fat.c
// Function: loaddskf_decompress
static void loaddskf_decompress(deark *c, struct skf_ctx *d)
{
	struct de_dfilter_in_params dcmpri;
	struct de_dfilter_out_params dcmpro;
	struct de_dfilter_results dres;
	dbuf *outf = NULL;

	if(d->to_raw) {
		outf = dbuf_create_output_file(c, "ima", NULL, 0);
		dbuf_enable_wbuffer(outf);
	}
	else {
		outf = dbuf_create_output_file(c, "unc.dsk", NULL, 0);
		dbuf_enable_wbuffer(outf);
		dbuf_write(outf, (const u8*)"\xaa\x59", 2);
		dbuf_copy(c->infile, 2, d->hdr_size-2, outf);
	}

	de_dfilter_init_objects(c, &dcmpri, &dcmpro, &dres);
	dcmpri.f = c->infile;
	dcmpri.pos = d->hdr_size;
	dcmpri.len = c->infile->len - dcmpri.pos;
	dcmpro.f = outf;

	dbuf_set_writelistener(outf, de_writelistener_for_crc, (void*)d->crco);

	de_dbg(c, "[decompressing]");
	fmtutil_ibmlzw_codectype1(c, &dcmpri, &dcmpro, &dres, NULL);
	dbuf_flush(dcmpro.f);
	if(dres.errcode) {
		de_err(c, "Decompression failed: %s", de_dfilter_get_errmsg(c, &dres));
		goto done;
	}

	d->checksum_calc = de_crcobj_getval(d->crco);
	loaddskf_finish_checksum(c, d);

	if(d->to_raw) {
		loaddskf_pad_ima_file(c, d, outf);
	}
	// TODO: If !d->to_raw, maybe we should still ensure it decompressed to
	// the expected size.

done:
	dbuf_close(outf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0xb0(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x85732
movq -0x8(%rbp), %rdi
leaq 0x128d67(%rip), %rsi    # 0x1ae479
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x166c60
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x167b90
jmp 0x85798
movq -0x8(%rbp), %rdi
leaq 0x128f1f(%rip), %rsi    # 0x1ae65c
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x166c60
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x167b90
movq -0xb0(%rbp), %rdi
leaq 0x128efb(%rip), %rsi    # 0x1ae664
movl $0x2, %edx
callq 0x166170
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
subq $0x2, %rdx
movq -0xb0(%rbp), %rcx
movl $0x2, %esi
callq 0x166070
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x48(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
callq 0x1773f0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
subq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0xb0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdx
leaq 0xe3ad3(%rip), %rsi     # 0x1692d0
callq 0x169280
movq -0x8(%rbp), %rdi
leaq 0x128e5a(%rip), %rsi    # 0x1ae667
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x48(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x184720
movq -0x48(%rbp), %rdi
callq 0x167c30
cmpl $0x0, -0xa8(%rbp)
je 0x85878
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x177360
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
leaq 0x11a78e(%rip), %rsi    # 0x19fffd
movb $0x0, %al
callq 0x15bfb0
jmp 0x858ba
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x15f340
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x85950
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x858b8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0xb0(%rbp), %rdx
callq 0x85b20
jmp 0x858ba
movq -0xb0(%rbp), %rdi
callq 0x1676a0
addq $0xc0, %rsp
popq %rbp
retq
nop