// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/fmtutil-arch.c
// Function: de_arch_extract_member_file
void de_arch_extract_member_file(struct de_arch_member_data *md)
{
	deark *c = md->c;
	dbuf *outf = NULL;
	u32 crc_calc;
	struct de_dfilter_in_params dcmpri;
	struct de_dfilter_out_params dcmpro;
	struct de_dfilter_results dres;

	md->extracted_ok = 0;
	ensure_name_for_msgs_is_set(md);
	if(md->orig_len>0 && !md->orig_len_known) goto done; // sanity check
	if(md->validate_crc && !md->d->crco) goto done;
	if(md->is_encrypted) {
		de_err(c, "%s: Encrypted files are not supported", ucstring_getpsz_d(md->name_for_msgs));
		goto done;
	}
	if(!de_arch_good_cmpr_data_pos(md)) {
		goto done;
	}

	if(!md->fi->file_name_internal && ucstring_isnonempty(md->filename)) {
		de_finfo_set_name_from_ucstring(c, md->fi, md->filename, md->set_name_flags);
		md->fi->original_filename_flag = 1;
	}

	outf = dbuf_create_output_file(c, NULL, md->fi, 0);
	dbuf_enable_wbuffer(outf);
	if(md->validate_crc) {
		dbuf_set_writelistener(outf, de_writelistener_for_crc, (void*)md->d->crco);
	}

	de_dfilter_init_objects(c, &dcmpri, &dcmpro, &dres);
	dcmpri.f = md->d->inf;
	dcmpri.pos = md->cmpr_pos;
	dcmpri.len = md->cmpr_len;
	dcmpro.f = outf;
	dcmpro.len_known = md->orig_len_known;
	dcmpro.expected_len = md->orig_len;
	md->dcmpri = &dcmpri;
	md->dcmpro = &dcmpro;
	md->dres = &dres;

	if(md->validate_crc) {
		de_crcobj_reset(md->d->crco);
	}

	if(md->orig_len_known && md->orig_len==0) {
		;
	}
	else if(md->dfn) {
		md->dfn(md);
	}
	else {
		de_dfilter_set_generic_error(c, &dres, NULL);
	}
	dbuf_flush(dcmpro.f);

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

	if(md->orig_len_known && (outf->len != md->orig_len)) {
		de_err(c, "%s: Expected %"I64_FMT" decompressed bytes, got %"I64_FMT,
			ucstring_getpsz_d(md->name_for_msgs), md->orig_len, outf->len);
		goto done;
	}

	if(md->validate_crc) {
		crc_calc = de_crcobj_getval(md->d->crco);
		de_dbg(c, "crc (calculated): 0x%04x", (unsigned int)crc_calc);
		if(crc_calc!=md->crc_reported) {
			if(md->behavior_on_wrong_crc==1) {
				de_warn(c, "%s: CRC check not available", ucstring_getpsz_d(md->name_for_msgs));
			}
			else {
				de_err(c, "%s: CRC check failed", ucstring_getpsz_d(md->name_for_msgs));
				goto done;
			}
		}
	}

	md->extracted_ok = 1;

done:
	dbuf_close(outf);
	md->dcmpri = NULL;
	md->dcmpro = NULL;
	md->dres = NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movq (%rdi), %r14
movb $0x0, 0xa3(%rdi)
callq 0xfd80f
cmpq $0x0, 0x38(%rbx)
jle 0xfd892
cmpb $0x0, 0x4c(%rbx)
je 0xfd9ee
cmpb $0x0, 0xa1(%rbx)
je 0xfd8aa
movq 0x8(%rbx), %rax
cmpq $0x0, 0x30(%rax)
je 0xfd9ee
cmpb $0x0, 0x80(%rbx)
je 0xfd8d8
movq 0x60(%rbx), %rdi
callq 0xf70f6
leaq 0x4d62a(%rip), %rsi     # 0x14aeed
xorl %r15d, %r15d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9295
jmp 0xfd9f1
movq %rbx, %rdi
callq 0xfd7af
testl %eax, %eax
je 0xfd9ee
movq 0x50(%rbx), %rdx
cmpq $0x0, (%rdx)
jne 0xfd920
movq 0x58(%rbx), %rdi
callq 0xf67a3
movq 0x50(%rbx), %rdx
testl %eax, %eax
je 0xfd920
movq 0x58(%rbx), %rax
movl 0x78(%rbx), %ecx
movq %r14, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0xea53f
movq 0x50(%rbx), %rdx
movb $0x1, 0x8(%rdx)
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %r15
movq %rax, %rdi
callq 0xf0855
cmpb $0x0, 0xa1(%rbx)
je 0xfd957
movq 0x8(%rbx), %rax
movq 0x30(%rax), %rdx
leaq -0xc4fe(%rip), %rsi     # 0xf1451
movq %r15, %rdi
callq 0xf1412
leaq 0x78(%rsp), %r12
movq %rsp, %r13
leaq 0x18(%rsp), %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0xfa1dc
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rcx
movq %rcx, (%r12)
movq 0x40(%rbx), %rcx
movq %rcx, 0x8(%r12)
movq 0x30(%rbx), %rcx
movq %rcx, 0x10(%r12)
movq %r15, (%r13)
movb 0x4c(%rbx), %cl
movb %cl, 0x8(%r13)
movq 0x38(%rbx), %rdx
movq %rdx, 0x10(%r13)
movq %r12, 0xb0(%rbx)
movq %r13, 0xb8(%rbx)
movq %rbp, 0xc0(%rbx)
cmpb $0x0, 0xa1(%rbx)
je 0xfd9d0
movq 0x30(%rax), %rdi
callq 0xeb7fe
movb 0x4c(%rbx), %cl
testb %cl, %cl
je 0xfd9db
cmpq $0x0, 0x38(%rbx)
je 0xfda2f
movq 0xa8(%rbx), %rax
testq %rax, %rax
je 0xfda20
movq %rbx, %rdi
callq *%rax
jmp 0xfda2f
xorl %r15d, %r15d
movq %r15, %rdi
callq 0xf052b
xorps %xmm0, %xmm0
movups %xmm0, 0xb0(%rbx)
movq $0x0, 0xc0(%rbx)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0xfa311
movq (%rsp), %rdi
callq 0xf08ba
cmpl $0x0, 0x18(%rsp)
je 0xfda71
movq 0x60(%rbx), %rdi
callq 0xf70f6
movq %rax, %r12
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0xfa1a4
leaq 0x167be(%rip), %rsi     # 0x11421d
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9295
jmp 0xfd9f1
cmpb $0x0, 0x4c(%rbx)
je 0xfda81
movq 0x18(%r15), %rax
cmpq 0x38(%rbx), %rax
jne 0xfdae7
cmpb $0x0, 0xa1(%rbx)
je 0xfdadb
movq 0x8(%rbx), %rax
movq 0x30(%rax), %rdi
callq 0xeb865
movl %eax, %ebp
leaq 0x17843(%rip), %rsi     # 0x1152e3
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
cmpl 0x48(%rbx), %ebp
je 0xfdadb
movb 0xa2(%rbx), %bpl
movq 0x60(%rbx), %rdi
callq 0xf70f6
cmpb $0x1, %bpl
jne 0xfdb11
leaq 0x4d445(%rip), %rsi     # 0x14af13
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8faa
movb $0x1, 0xa3(%rbx)
jmp 0xfd9f1
movq 0x60(%rbx), %rdi
callq 0xf70f6
movq 0x38(%rbx), %rcx
movq 0x18(%r15), %r8
leaq 0x3a72b(%rip), %rsi     # 0x13822a
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9295
jmp 0xfd9f1
leaq 0x1712f(%rip), %rsi     # 0x114c47
jmp 0xfd8c6
nopl (%rax)