// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/lha.c
// Function: do_extract_file
static void do_extract_file(deark *c, lctx *d, struct member_data *md)
{
	de_finfo *fi = NULL;
	dbuf *outf = NULL;
	int tsidx;
	u8 dcmpr_disabled = 0;
	u8 dcmpr_attempted = 0;
	u8 dcmpr_ok = 0;
	struct de_dfilter_in_params dcmpri;
	struct de_dfilter_out_params dcmpro;
	struct de_dfilter_results dres;

	if(!md->cmi) goto done;

	if(md->is_special) {
		de_dbg(c, "[not extracting special file]");
		goto done;
	}
	else if(md->is_dir) {
		;
	}
	else if((!md->cmi->decompressor) || dcmpr_disabled) {
		de_err(c, "%s: Unsupported compression method '%s'",
			ucstring_getpsz_d(md->fullfilename), md->cmi->id_printable_sz);
		goto done;
	}

	if(md->compressed_data_pos+md->compressed_data_len > c->infile->len) {
		de_err(c, "%s: Data goes beyond end of file", ucstring_getpsz_d(md->fullfilename));
		goto done;
	}

	fi = de_finfo_create(c);

	for(tsidx=0; tsidx<DE_TIMESTAMPIDX_COUNT; tsidx++) {
		if(md->tsdata[tsidx].ts.is_valid) {
			fi->timestamp[tsidx] = md->tsdata[tsidx].ts;
		}
	}

	if(md->is_dir) {
		fi->is_directory = 1;
	}
	else if(md->is_executable) {
		fi->mode_flags |= DE_MODEFLAG_EXE;
	}
	else if(md->is_nonexecutable) {
		fi->mode_flags |= DE_MODEFLAG_NONEXE;
	}

	de_finfo_set_name_from_ucstring(c, fi, md->fullfilename, DE_SNFLAG_FULLPATH);
	fi->original_filename_flag = 1;

	outf = dbuf_create_output_file(c, NULL, fi, 0x0);
	dbuf_enable_wbuffer(outf);
	de_crcobj_reset(d->crco);
	dbuf_set_writelistener(outf, de_writelistener_for_crc, (void*)d->crco);

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

	if(md->is_dir) goto done; // For directories, we're done.

	dcmpr_attempted = 1;
	if(md->cmi->decompressor) {
		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->fullfilename),
			de_dfilter_get_errmsg(c, &dres));
		goto done;
	}

	if(md->have_crc_reported) {
		u32 crc_calc;

		crc_calc = de_crcobj_getval(d->crco);
		if(d->basefmt==BASEFMT_PAKLEO) {
			de_dbg(c, "crc (calculated): 0x%08x", (UI)crc_calc);
		}
		else {
			de_dbg(c, "crc (calculated): 0x%04x", (UI)crc_calc);
		}
		if(crc_calc != md->crc_reported) {
			de_err(c, "%s: CRC check failed", ucstring_getpsz_d(md->fullfilename));
			goto done;
		}
	}

	dcmpr_ok = 1;

done:
	if(dcmpr_attempted && md->cmi && md->cmi->uniq_id==CODE_lh7) {
		if(dcmpr_ok)
			d->lh7_success_flag = 1;
		else
			d->lh7_failed_flag = 1;
	}
	dbuf_close(outf);
	de_finfo_destroy(c, fi);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movb $0x0, -0x2d(%rbp)
movb $0x0, -0x2e(%rbp)
movb $0x0, -0x2f(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0xc4903
jmp 0xc4caf
movq -0x18(%rbp), %rax
cmpb $0x0, 0x21(%rax)
je 0xc4924
movq -0x8(%rbp), %rdi
leaq 0xf3642(%rip), %rsi     # 0x1b7f5a
movb $0x0, %al
callq 0x15b0d0
jmp 0xc4caf
movq -0x18(%rbp), %rax
cmpb $0x0, 0x20(%rax)
je 0xc4930
jmp 0xc498b
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0xc4948
movzbl -0x2d(%rbp), %eax
cmpl $0x0, %eax
je 0xc4989
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x172650
movq -0xd8(%rbp), %rdi
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
addq $0x15, %rcx
leaq 0xf35fb(%rip), %rsi     # 0x1b7f78
movb $0x0, %al
callq 0x15bfb0
jmp 0xc4caf
jmp 0xc498b
jmp 0xc498d
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x60(%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xc49e0
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x172650
movq -0xe0(%rbp), %rdi
movq %rax, %rdx
leaq 0xdbff0(%rip), %rsi     # 0x1a09c4
movb $0x0, %al
callq 0x15bfb0
jmp 0xc4caf
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x5, -0x2c(%rbp)
jge 0xc4a58
movq -0x18(%rbp), %rax
addq $0x80, %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, (%rax)
je 0xc4a4b
movq -0x20(%rbp), %rax
addq $0x18, %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
addq $0x80, %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0xc4a4d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xc49f4
movq -0x18(%rbp), %rax
cmpb $0x0, 0x20(%rax)
je 0xc4a6c
movq -0x20(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0xc4aa0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x23(%rax)
je 0xc4a85
movq -0x20(%rbp), %rax
movl 0x14(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x14(%rax)
jmp 0xc4a9e
movq -0x18(%rbp), %rax
cmpb $0x0, 0x22(%rax)
je 0xc4a9c
movq -0x20(%rbp), %rax
movl 0x14(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0xc4a9e
jmp 0xc4aa0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rdx
movl $0x1, %ecx
callq 0x15d2c0
movq -0x20(%rbp), %rax
movb $0x1, 0x8(%rax)
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 -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x15f250
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdx
leaq 0xa47ce(%rip), %rsi     # 0x1692d0
callq 0x169280
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x1773f0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x58(%rbp)
movb $0x1, -0x60(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x20(%rax)
je 0xc4b6a
jmp 0xc4caf
movb $0x1, -0x2e(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0xc4ba6
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq -0xc8(%rbp), %r9
callq *%rax
movq -0x68(%rbp), %rdi
callq 0x167c30
cmpl $0x0, -0xc8(%rbp)
je 0xc4c0b
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x172650
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x177360
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rdx
movq %rax, %rcx
leaq 0xdb3fa(%rip), %rsi     # 0x19fff9
movb $0x0, %al
callq 0x15bfb0
jmp 0xc4caf
movq -0x18(%rbp), %rax
cmpb $0x0, 0x48(%rax)
je 0xc4cab
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x15f340
movl %eax, -0xcc(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3, 0xc(%rax)
jne 0xc4c50
movq -0x8(%rbp), %rdi
movl -0xcc(%rbp), %edx
leaq 0xdf460(%rip), %rsi     # 0x1a40a7
movb $0x0, %al
callq 0x15b0d0
jmp 0xc4c68
movq -0x8(%rbp), %rdi
movl -0xcc(%rbp), %edx
leaq 0xdc426(%rip), %rsi     # 0x1a1087
movb $0x0, %al
callq 0x15b0d0
movl -0xcc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4c(%rcx), %eax
je 0xc4ca9
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x172650
movq -0xf8(%rbp), %rdi
movq %rax, %rdx
leaq 0xdbd73(%rip), %rsi     # 0x1a0a13
movb $0x0, %al
callq 0x15bfb0
jmp 0xc4caf
jmp 0xc4cab
movb $0x1, -0x2f(%rbp)
movzbl -0x2e(%rbp), %eax
cmpl $0x0, %eax
je 0xc4cee
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xc4cee
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x2d6c6837, 0x4(%rax)  # imm = 0x2D6C6837
jne 0xc4cee
cmpb $0x0, -0x2f(%rbp)
je 0xc4ce4
movq -0x10(%rbp), %rax
movb $0x1, 0x19(%rax)
jmp 0xc4cec
movq -0x10(%rbp), %rax
movb $0x1, 0x1a(%rax)
jmp 0xc4cee
movq -0x28(%rbp), %rdi
callq 0x1676a0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x15d260
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax)