// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/arcfs.c
// Function: do_arcfs_extract_member_file
static void do_arcfs_extract_member_file(deark *c, lctx *d, struct arcfs_member_data *md,
	de_finfo *fi)
{
	dbuf *outf = NULL;
	u32 crc_calc;
	de_ucstring *fullfn = NULL;
	struct de_dfilter_in_params dcmpri;
	struct de_dfilter_out_params dcmpro;
	struct de_dfilter_results dres;
	int have_dres = 0;

	de_dfilter_init_objects(c, &dcmpri, &dcmpro, &dres);
	if(md->file_data_offs_abs + md->cmpr_len > c->infile->len) goto done;

	de_dbg(c, "file data at %"I64_FMT", len=%"I64_FMT,
		md->file_data_offs_abs, md->cmpr_len);

	fullfn = ucstring_create(c);
	de_strarray_make_path(d->curpath, fullfn, 0);
	ucstring_append_ucstring(fullfn, md->fn);
	fmtutil_riscos_append_type_to_filename(c, fi, fullfn, &md->rfa, md->is_dir, 0);

	if(md->cmpr_method!=0x82 && md->cmpr_method!=0x83 && md->cmpr_method!=0x88 &&
		md->cmpr_method!=0xff)
	{
		de_err(c, "Compression type 0x%02x (%s) is not supported.",
			(unsigned int)md->cmpr_method, md->cmpr_meth_name);
		goto done;
	}

	de_finfo_set_name_from_ucstring(c, fi, fullfn, DE_SNFLAG_FULLPATH);

	outf = dbuf_create_output_file(c, NULL, fi, 0x0);
	dbuf_enable_wbuffer(outf);

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

	dcmpri.f = c->infile;
	dcmpri.pos = md->file_data_offs_abs;
	dcmpri.len = md->cmpr_len;
	dcmpro.f = outf;
	dcmpro.len_known = 1;
	dcmpro.expected_len = md->orig_len;

	if(md->cmpr_method==0x82) { // stored
		fmtutil_decompress_uncompressed(c, &dcmpri, &dcmpro, &dres, 0);
	}
	else if(md->cmpr_method==0x83) {
		fmtutil_decompress_rle90_ex(c, &dcmpri, &dcmpro, &dres, 0);
		have_dres = 1;
	}
	else if(md->cmpr_method==0xff) {
		do_arcfs_compressed(c, d, md, &dcmpri, &dcmpro, &dres);
		have_dres = 1;
	}
	else if(md->cmpr_method==0x88) {
		do_arcfs_crunched(c, d, md, &dcmpri, &dcmpro, &dres);
		have_dres = 1;
	}
	dbuf_flush(dcmpro.f);

	if(have_dres && dres.errcode!=0) {
		de_err(c, "%s: Decompression failed: %s",
			ucstring_getpsz_d(md->fn), de_dfilter_get_errmsg(c, &dres));
		goto done;
	}

	if(outf->len != md->orig_len) {
		de_err(c, "%s: Decompression failed: Expected size %"I64_FMT
			", got %"I64_FMT, ucstring_getpsz_d(md->fn), md->orig_len, outf->len);
		goto done;
	}

	crc_calc = de_crcobj_getval(d->crco);
	de_dbg(c, "crc (calculated): 0x%04x", (unsigned int)crc_calc);
	if(crc_calc != md->rfa.crc_from_attribs) {
		if(md->rfa.crc_from_attribs==0) {
			de_warn(c, "CRC check not available for file %s", ucstring_getpsz_d(md->fn));
		}
		else {
			de_err(c, "CRC check failed for file %s", ucstring_getpsz_d(md->fn));
		}
	}

done:
	dbuf_close(outf);
	ucstring_destroy(fullfn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0xd4(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x70(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
callq 0x1773f0
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x58(%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x2da60
jmp 0x2de12
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rcx
leaq 0x1958e8(%rip), %rsi    # 0x1c3363
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x1729c0
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x171460
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x18(%rbp), %rax
movl 0x30(%rax), %r8d
xorl %r9d, %r9d
callq 0x175820
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %eax
cmpl $0x82, %eax
je 0x2db36
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %eax
cmpl $0x83, %eax
je 0x2db36
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %eax
cmpl $0x88, %eax
je 0x2db36
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %eax
cmpl $0xff, %eax
je 0x2db36
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %edx
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rcx
leaq 0x172e13(%rip), %rsi    # 0x1a093d
movb $0x0, %al
callq 0x15bfb0
jmp 0x2de12
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x1, %ecx
callq 0x15d2c0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
xorl %ecx, %ecx
callq 0x166c60
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x167b90
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
leaq 0x13b751(%rip), %rsi    # 0x1692d0
callq 0x169280
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x15f250
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
movb $0x1, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %eax
cmpl $0x82, %eax
jne 0x2dbfc
movq -0x8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x70(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
xorl %r8d, %r8d
callq 0x1778b0
jmp 0x2dcac
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %eax
cmpl $0x83, %eax
jne 0x2dc32
movq -0x8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x70(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
xorl %r8d, %r8d
callq 0x177f90
movl $0x1, -0xd4(%rbp)
jmp 0x2dcaa
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %eax
cmpl $0xff, %eax
jne 0x2dc6d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rcx
leaq -0x70(%rbp), %r8
leaq -0xd0(%rbp), %r9
callq 0x2ded0
movl $0x1, -0xd4(%rbp)
jmp 0x2dca8
movq -0x18(%rbp), %rax
movzbl 0x38(%rax), %eax
cmpl $0x88, %eax
jne 0x2dca6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rcx
leaq -0x70(%rbp), %r8
leaq -0xd0(%rbp), %r9
callq 0x2df50
movl $0x1, -0xd4(%rbp)
jmp 0x2dca8
jmp 0x2dcaa
jmp 0x2dcac
movq -0x70(%rbp), %rdi
callq 0x167c30
cmpl $0x0, -0xd4(%rbp)
je 0x2dd1a
cmpl $0x0, -0xd0(%rbp)
je 0x2dd1a
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x172650
movq %rax, -0xe0(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x177360
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
movq %rax, %rcx
leaq 0x1722eb(%rip), %rsi    # 0x19fff9
movb $0x0, %al
callq 0x15bfb0
jmp 0x2de12
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x50(%rcx), %rax
je 0x2dd71
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x172650
movq -0xf0(%rbp), %rdi
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x18(%rax), %r8
leaq 0x1722b1(%rip), %rsi    # 0x1a0016
movb $0x0, %al
callq 0x15bfb0
jmp 0x2de12
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x15f340
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %edx
leaq 0x1732f8(%rip), %rsi    # 0x1a1087
movb $0x0, %al
callq 0x15b0d0
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x18(%rcx), %eax
je 0x2de10
movq -0x18(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x2ddde
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x172650
movq -0xf8(%rbp), %rdi
movq %rax, %rdx
leaq 0x172276(%rip), %rsi    # 0x1a004b
movb $0x0, %al
callq 0x15bc10
jmp 0x2de0e
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x172650
movq -0x100(%rbp), %rdi
movq %rax, %rdx
leaq 0x172268(%rip), %rsi    # 0x1a006f
movb $0x0, %al
callq 0x15bfb0
jmp 0x2de10
jmp 0x2de12
movq -0x28(%rbp), %rdi
callq 0x1676a0
movq -0x38(%rbp), %rdi
callq 0x171750
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax)