// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/arc.c
// Function: do_extract_member_file
static void do_extract_member_file(deark *c, lctx *d, struct member_data *md,
	struct persistent_member_data *pmd, de_finfo *fi, i64 pos)
{
	de_ucstring *fullfn = NULL;
	dbuf *outf = NULL;
	int ignore_failed_crc = 0;
	int saved_indent_level;
	struct de_dfilter_in_params dcmpri;
	struct de_dfilter_out_params dcmpro;
	struct de_dfilter_results dres;

	de_dbg_indent_save(c, &saved_indent_level);
	fullfn = ucstring_create(c);

	if(pmd && ucstring_isnonempty(pmd->path)) {
		// For PAK-style paths.
		// (Pretty useless, until we support cmpr. meth. #11.)
		// Note that PAK-style paths, and directory recursion, are not expected to
		// be possible in the same file.
		ucstring_append_ucstring(fullfn, pmd->path);
		fixup_path(c, d, fullfn);
	}

	de_strarray_make_path(d->curpath, fullfn, DE_MPFLAG_NOTRAILINGSLASH);

	if(md->rfa.file_type_known) {
		fmtutil_riscos_append_type_to_filename(c, fi, fullfn, &md->rfa, md->is_dir, 0);
	}
	de_finfo_set_name_from_ucstring(c, fi, fullfn, DE_SNFLAG_FULLPATH);

	de_dbg_indent(c, 1);

	if(!md->cmi || !md->cmi->decompressor) {
		const char *mname;

		// A quick hack because we don't want the error message claiming that
		// "trimmed or crushed" isn't supported. We do support trimmed, so
		// if we got here, we must have decided it's crushed.
		mname = md->cmpr_meth==10 ? "crushed" : md->cmpr_meth_name;

		de_err(c, "%s: Compression type 0x%02x (%s) is not supported.",
			ucstring_getpsz_d(md->fn), (UI)md->cmpr_meth, mname);
		goto done;
	}

	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);

	de_dfilter_init_objects(c, &dcmpri, &dcmpro, &dres);
	dcmpri.f = c->infile;
	dcmpri.pos = pos;
	dcmpri.len = md->cmpr_size;
	dcmpro.f = outf;
	dcmpro.len_known = 1;
	dcmpro.expected_len = md->orig_size;

	if(dcmpri.pos + dcmpri.len > dcmpri.f->len) {
		de_err(c, "%s: Data goes beyond end of file", ucstring_getpsz_d(md->fn));
		goto done;
	}

	md->cmi->decompressor(c, d, md, &dcmpri, &dcmpro, &dres);
	dbuf_flush(dcmpro.f);
	if(dres.errcode) {
		de_err(c, "%s: Decompression failed: %s", ucstring_getpsz_d(md->fn),
			de_dfilter_get_errmsg(c, &dres));
		goto done;
	}

	md->crc_calc = de_crcobj_getval(d->crco);
	de_dbg(c, "crc (calculated): 0x%04x", (unsigned int)md->crc_calc);
	if(md->crc_reported==0 && !d->recurse_subdirs && md->rfa.file_type_known &&
		md->rfa.file_type==0xddc && md->cmpr_meth==0x82)
	{
		ignore_failed_crc = 1;
	}
	if((md->crc_calc!=md->crc_reported) && !ignore_failed_crc) {
		de_err(c, "%s: CRC check failed", ucstring_getpsz_d(md->fn));
	}

done:
	dbuf_close(outf);
	ucstring_destroy(fullfn);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x3244f
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1717f0
cmpl $0x0, %eax
je 0x3244f
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x171460
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x33020
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x38(%rbp), %rsi
movl $0x1, %edx
callq 0x1729c0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x60(%rax)
je 0x32496
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x60, %rcx
movq -0x18(%rbp), %rax
movl 0x90(%rax), %r8d
xorl %r9d, %r9d
callq 0x175820
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x1, %ecx
callq 0x15d2c0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x324d4
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x32552
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0xa, %eax
jne 0x324f1
leaq 0x16e334(%rip), %rax    # 0x1a081c
movq %rax, -0xf0(%rbp)
jmp 0x32500
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x172650
movq -0xf8(%rbp), %rdi
movq %rax, %rdx
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %ecx
movq -0xe8(%rbp), %r8
leaq 0x16e3f3(%rip), %rsi    # 0x1a0939
movb $0x0, %al
callq 0x15bfb0
jmp 0x32777
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
xorl %ecx, %ecx
callq 0x166c60
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x167b90
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdx
leaq 0x136d4b(%rip), %rsi    # 0x1692d0
callq 0x169280
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x15f250
movq -0x8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x80(%rbp), %rdx
leaq -0xe0(%rbp), %rcx
callq 0x1773f0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x80(%rbp)
movb $0x1, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rax
addq -0x58(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x3262e
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x172650
movq -0x100(%rbp), %rdi
movq %rax, %rdx
leaq 0x16e3a2(%rip), %rsi    # 0x1a09c4
movb $0x0, %al
callq 0x15bfb0
jmp 0x32777
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x68(%rbp), %rcx
leaq -0x80(%rbp), %r8
leaq -0xe0(%rbp), %r9
callq *%rax
movq -0x80(%rbp), %rdi
callq 0x167c30
cmpl $0x0, -0xe0(%rbp)
je 0x326bc
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x172650
movq %rax, -0x108(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x177360
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rdx
movq %rax, %rcx
leaq 0x16d949(%rip), %rsi    # 0x19fff9
movb $0x0, %al
callq 0x15bfb0
jmp 0x32777
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x15f340
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x44(%rax), %edx
leaq 0x16e9a3(%rip), %rsi    # 0x1a1087
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpl $0x0, 0x40(%rax)
jne 0x3272f
movq -0x10(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jne 0x3272f
movq -0x18(%rbp), %rax
movzbl 0x60(%rax), %eax
cmpl $0x0, %eax
je 0x3272f
movq -0x18(%rbp), %rax
cmpl $0xddc, 0x70(%rax)      # imm = 0xDDC
jne 0x3272f
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x82, %eax
jne 0x3272f
movl $0x1, -0x44(%rbp)
movq -0x18(%rbp), %rax
movl 0x44(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x40(%rcx), %eax
je 0x32775
cmpl $0x0, -0x44(%rbp)
jne 0x32775
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x172650
movq -0x118(%rbp), %rdi
movq %rax, %rdx
leaq 0x16e2a5(%rip), %rsi    # 0x1a0a13
movb $0x0, %al
callq 0x15bfb0
jmp 0x32777
movq -0x40(%rbp), %rdi
callq 0x1676a0
movq -0x38(%rbp), %rdi
callq 0x171750
movq -0x8(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x15b5a0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nop