// File: /workspace/github_c_makefile_star2_O2/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 0xf1a38
cmpq $0x0, 0x38(%rbx)
jle 0xf1ab9
cmpb $0x0, 0x4c(%rbx)
je 0xf1c15
cmpb $0x0, 0xa1(%rbx)
je 0xf1ad1
movq 0x8(%rbx), %rax
cmpq $0x0, 0x30(%rax)
je 0xf1c15
cmpb $0x0, 0x80(%rbx)
je 0xf1aff
movq 0x60(%rbx), %rdi
callq 0xeb877
leaq 0x4bf33(%rip), %rsi     # 0x13da1d
xorl %r15d, %r15d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf2a5
jmp 0xf1c18
movq %rbx, %rdi
callq 0xf19d5
testl %eax, %eax
je 0xf1c15
movq 0x50(%rbx), %rdx
cmpq $0x0, (%rdx)
jne 0xf1b47
movq 0x58(%rbx), %rdi
callq 0xeaf8a
movq 0x50(%rbx), %rdx
testl %eax, %eax
je 0xf1b47
movq 0x58(%rbx), %rax
movl 0x78(%rbx), %ecx
movq %r14, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0xdfd55
movq 0x50(%rbx), %rdx
movb $0x1, 0x8(%rdx)
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %r15
movq %rax, %rdi
callq 0xe589c
cmpb $0x0, 0xa1(%rbx)
je 0xf1b7e
movq 0x8(%rbx), %rax
movq 0x30(%rax), %rdx
leaq -0xb8b5(%rip), %rsi     # 0xe62c1
movq %r15, %rdi
callq 0xe629a
leaq 0x78(%rsp), %r12
movq %rsp, %r13
leaq 0x18(%rsp), %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0xee7ee
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 0xf1bf7
movq 0x30(%rax), %rdi
callq 0xe0e44
movb 0x4c(%rbx), %cl
testb %cl, %cl
je 0xf1c02
cmpq $0x0, 0x38(%rbx)
je 0xf1c53
movq 0xa8(%rbx), %rax
testq %rax, %rax
je 0xf1c44
movq %rbx, %rdi
callq *%rax
jmp 0xf1c53
xorl %r15d, %r15d
movq %r15, %rdi
callq 0xe5591
xorps %xmm0, %xmm0
movups %xmm0, 0xb0(%rbx)
andq $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 0xee91c
movq (%rsp), %rdi
callq 0xe58e8
cmpl $0x0, 0x18(%rsp)
je 0xf1c95
movq 0x60(%rbx), %rdi
callq 0xeb877
movq %rax, %r12
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0xee7bc
leaq 0x1553a(%rip), %rsi     # 0x1071bd
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xdf2a5
jmp 0xf1c18
cmpb $0x0, 0x4c(%rbx)
je 0xf1ca5
movq 0x18(%r15), %rax
cmpq 0x38(%rbx), %rax
jne 0xf1d0b
cmpb $0x0, 0xa1(%rbx)
je 0xf1cff
movq 0x8(%rbx), %rax
movq 0x30(%rax), %rdi
callq 0xe0e95
movl %eax, %ebp
leaq 0x16593(%rip), %rsi     # 0x108257
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
cmpl 0x48(%rbx), %ebp
je 0xf1cff
movb 0xa2(%rbx), %bpl
movq 0x60(%rbx), %rdi
callq 0xeb877
cmpb $0x1, %bpl
jne 0xf1d35
leaq 0x4bd51(%rip), %rsi     # 0x13da43
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf05a
movb $0x1, 0xa3(%rbx)
jmp 0xf1c18
movq 0x60(%rbx), %rdi
callq 0xeb877
movq 0x38(%rbx), %rcx
movq 0x18(%r15), %r8
leaq 0x39207(%rip), %rsi     # 0x12af2a
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf2a5
jmp 0xf1c18
leaq 0x15e80(%rip), %rsi     # 0x107bbc
jmp 0xf1aed
nopl (%rax)