// File: /workspace/github_c_makefile_star2_O1/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 0xfde72
cmpq $0x0, 0x38(%rbx)
jle 0xfdef5
cmpb $0x0, 0x4c(%rbx)
je 0xfe04e
cmpb $0x0, 0xa1(%rbx)
je 0xfdf0d
movq 0x8(%rbx), %rax
cmpq $0x0, 0x30(%rax)
je 0xfe04e
cmpb $0x0, 0x80(%rbx)
je 0xfdf3b
movq 0x60(%rbx), %rdi
callq 0xf7557
leaq 0x4ca17(%rip), %rsi     # 0x14a93d
xorl %r15d, %r15d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
jmp 0xfe051
movq %rbx, %rdi
callq 0xfde12
testl %eax, %eax
je 0xfe04e
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
jne 0xfdf7d
movq 0x58(%rbx), %rdi
callq 0xf6c00
testl %eax, %eax
je 0xfdf7d
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movl 0x78(%rbx), %ecx
movq %r14, %rdi
callq 0xea9e4
movq 0x50(%rbx), %rax
movb $0x1, 0x8(%rax)
movq 0x50(%rbx), %rdx
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0xf037a
movq %rax, %r15
movq %rax, %rdi
callq 0xf0e3f
cmpb $0x0, 0xa1(%rbx)
je 0xfdfb8
movq 0x8(%rbx), %rax
movq 0x30(%rax), %rdx
leaq -0xc55f(%rip), %rsi     # 0xf1a51
movq %r15, %rdi
callq 0xf1a12
leaq 0x78(%rsp), %r12
movq %rsp, %r13
leaq 0x18(%rsp), %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0xfa6e0
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), %rcx
movq %rcx, 0x10(%r13)
movq %r12, 0xb0(%rbx)
movq %r13, 0xb8(%rbx)
movq %rbp, 0xc0(%rbx)
cmpb $0x0, 0xa1(%rbx)
je 0xfe02e
movq 0x30(%rax), %rdi
callq 0xebdc3
cmpb $0x0, 0x4c(%rbx)
je 0xfe03b
cmpq $0x0, 0x38(%rbx)
je 0xfe08f
movq 0xa8(%rbx), %rax
testq %rax, %rax
je 0xfe080
movq %rbx, %rdi
callq *%rax
jmp 0xfe08f
xorl %r15d, %r15d
movq %r15, %rdi
callq 0xf0b13
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 0xfa815
movq (%rsp), %rdi
callq 0xf0ea4
cmpl $0x0, 0x18(%rsp)
je 0xfe0d1
movq 0x60(%rbx), %rdi
callq 0xf7557
movq %rax, %r12
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0xfa6a8
leaq 0x160ae(%rip), %rsi     # 0x11416d
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9df7
jmp 0xfe051
cmpb $0x0, 0x4c(%rbx)
je 0xfe0e1
movq 0x18(%r15), %rax
cmpq 0x38(%rbx), %rax
jne 0xfe147
cmpb $0x0, 0xa1(%rbx)
je 0xfe13b
movq 0x8(%rbx), %rax
movq 0x30(%rax), %rdi
callq 0xebe2a
movl %eax, %ebp
leaq 0x17133(%rip), %rsi     # 0x115233
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
cmpl 0x48(%rbx), %ebp
je 0xfe13b
movb 0xa2(%rbx), %bpl
movq 0x60(%rbx), %rdi
callq 0xf7557
cmpb $0x1, %bpl
jne 0xfe171
leaq 0x4c835(%rip), %rsi     # 0x14a963
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9b27
movb $0x1, 0xa3(%rbx)
jmp 0xfe051
movq 0x60(%rbx), %rdi
callq 0xf7557
movq 0x38(%rbx), %rcx
movq 0x18(%r15), %r8
leaq 0x39d3f(%rip), %rsi     # 0x137e9e
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
jmp 0xfe051
leaq 0x169f4(%rip), %rsi     # 0x114b6c
jmp 0xfdf29
nopl (%rax)