// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/zip.c
// Function: do_extract_file
static void do_extract_file(deark *c, lctx *d, struct member_data *md)
{
	dbuf *outf = NULL;
	de_finfo *fi = NULL;
	struct dir_entry_data *ldd = &md->local_dir_entry_data;
	int tsidx;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	de_dbg(c, "file data at %"I64_FMT", len=%"I64_FMT, md->file_data_pos,
		md->cmpr_size);
	de_dbg_indent(c, 1);

	if(ldd->bit_flags & 0x1) {
		de_err(c, "%s: Encryption is not supported", ucstring_getpsz_d(ldd->fname));
		goto done;
	}

	if(!is_compression_method_supported(d, ldd->cmi)) {
		de_err(c, "%s: Unsupported compression method: %d (%s)",
			ucstring_getpsz_d(ldd->fname),
			ldd->cmpr_meth, (ldd->cmi ? ldd->cmi->name : "?"));
		goto done;
	}

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

	if(md->is_symlink) {
		de_warn(c, "\"%s\" is a symbolic link. It will not be extracted as a link.",
			ucstring_getpsz_d(ldd->fname));
	}

	fi = de_finfo_create(c);
	fi->detect_root_dot_dir = 1;

	if(ucstring_isnonempty(ldd->fname)) {
		UI snflags = DE_SNFLAG_FULLPATH;

		if(md->has_riscos_data) {
			fmtutil_riscos_append_type_to_filename(c, fi, ldd->fname, &md->rfa, md->is_dir, 0);
		}
		if(md->is_dir) snflags |= DE_SNFLAG_STRIPTRAILINGSLASH;
		de_finfo_set_name_from_ucstring(c, fi, ldd->fname, snflags);
		fi->original_filename_flag = 1;
	}

	// This is basically a hack to better deal with Deark's ZIP writer's habit of
	// using the NTFS field to store high resolution timestamps. The problem is
	// that there seems to be no standard way to indicate the lack of a particular
	// timestamp.
	// We disregard the NTFS Access or Creation timestamp in some cases, to make it
	// more likely that a ZIP file can be round-tripped through Deark, without
	// spurious timestamps appearing in the 0x5455 (extended timestamp) field.
	if(md->questionable_atime && md->has_extts && !md->has_extts_atime) {
		md->tsdata[DE_TIMESTAMPIDX_ACCESS].ts.is_valid = 0;
	}
	if(md->questionable_crtime && md->has_extts && !md->has_extts_crtime) {
		md->tsdata[DE_TIMESTAMPIDX_CREATE].ts.is_valid = 0;
	}

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

	if(md->has_riscos_data) {
		fi->has_riscos_data = 1;
		fi->riscos_attribs = md->rfa.attribs;
		fi->load_addr = md->rfa.load_addr;
		fi->exec_addr = md->rfa.exec_addr;
	}

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

	outf = dbuf_create_output_file(c, NULL, fi, 0);
	dbuf_enable_wbuffer(outf);
	if(md->is_dir) {
		goto done;
	}

	(void)do_decompress_member(c, d, md, outf);

done:
	dbuf_close(outf);
	de_finfo_destroy(c, fi);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
addq $0x148, %rax            # imm = 0x148
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x198(%rax), %rcx
leaq 0x76773(%rip), %rsi     # 0x1c3363
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x30(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x14cc43
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x172650
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x832ff(%rip), %rsi     # 0x1cff36
movb $0x0, %al
callq 0x15bfb0
jmp 0x14cfa5
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x14c480
cmpl $0x0, %eax
jne 0x14ccc8
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x172650
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x14cc99
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x14cca6
leaq 0x6af8d(%rip), %rax     # 0x1b7c2d
movq %rax, -0x68(%rbp)
jmp 0x14cca6
movl -0x4c(%rbp), %ecx
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %r8
leaq 0x82f4a(%rip), %rsi     # 0x1cfc06
movb $0x0, %al
callq 0x15bfb0
jmp 0x14cfa5
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x198(%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x14cd18
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x172650
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0x53cb8(%rip), %rsi     # 0x1a09c4
movb $0x0, %al
callq 0x15bfb0
jmp 0x14cfa5
movq -0x18(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0x14cd4c
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x172650
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x83211(%rip), %rsi     # 0x1cff56
movb $0x0, %al
callq 0x15bc10
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movb $0x1, 0xc(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x1717f0
cmpl $0x0, %eax
je 0x14cde5
movl $0x1, -0x3c(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0xc0(%rax)
je 0x14cdb2
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdx
movq -0x18(%rbp), %rcx
addq $0xc8, %rcx
movq -0x18(%rbp), %rax
movl 0x38(%rax), %r8d
xorl %r9d, %r9d
callq 0x175820
movq -0x18(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x14cdc5
movl -0x3c(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdx
movl -0x3c(%rbp), %ecx
callq 0x15d2c0
movq -0x28(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x18(%rbp), %rax
movzbl 0x1af(%rax), %eax
cmpl $0x0, %eax
je 0x14ce1a
movq -0x18(%rbp), %rax
movzbl 0x1ac(%rax), %eax
cmpl $0x0, %eax
je 0x14ce1a
movq -0x18(%rbp), %rax
cmpb $0x0, 0x1ad(%rax)
jne 0x14ce1a
movq -0x18(%rbp), %rax
movb $0x0, 0x78(%rax)
movq -0x18(%rbp), %rax
movzbl 0x1b0(%rax), %eax
cmpl $0x0, %eax
je 0x14ce4f
movq -0x18(%rbp), %rax
movzbl 0x1ac(%rax), %eax
cmpl $0x0, %eax
je 0x14ce4f
movq -0x18(%rbp), %rax
cmpb $0x0, 0x1ae(%rax)
jne 0x14ce4f
movq -0x18(%rbp), %rax
movb $0x0, 0x60(%rax)
movl $0x0, -0x34(%rbp)
cmpl $0x5, -0x34(%rbp)
jge 0x14ceb5
movq -0x18(%rbp), %rax
addq $0x48, %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, (%rax)
je 0x14cea8
movq -0x28(%rbp), %rax
addq $0x18, %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
addq $0x48, %rcx
movslq -0x34(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x14ceaa
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x14ce56
movq -0x18(%rbp), %rax
cmpb $0x0, 0xc0(%rax)
je 0x14cf06
movq -0x28(%rbp), %rax
movb $0x1, 0x10(%rax)
movq -0x18(%rbp), %rax
movl 0xd4(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x18(%rbp), %rax
movl 0xcc(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xa4(%rax)
movq -0x18(%rbp), %rax
movl 0xd0(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xa8(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x14cf1a
movq -0x28(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x14cf64
movq -0x18(%rbp), %rax
cmpb $0x0, 0x3c(%rax)
je 0x14cf2e
movq -0x28(%rbp), %rax
movb $0x1, 0xa(%rax)
jmp 0x14cf62
movq -0x18(%rbp), %rax
cmpl $0x0, 0x34(%rax)
je 0x14cf47
movq -0x28(%rbp), %rax
movl 0x14(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x14(%rax)
jmp 0x14cf60
movq -0x18(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x14cf5e
movq -0x28(%rbp), %rax
movl 0x14(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0x14cf60
jmp 0x14cf62
jmp 0x14cf64
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
xorl %ecx, %ecx
callq 0x166c60
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x167b90
movq -0x18(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x14cf90
jmp 0x14cfa5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x14cfd0
movq -0x20(%rbp), %rdi
callq 0x1676a0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x15d260
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x15b5a0
addq $0x80, %rsp
popq %rbp
retq