// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/packdir.c
// Function: do_packdir_extract_file
static void do_packdir_extract_file(deark *c, struct pdctx_struct *d,
	struct pdctx_object *md, i64 pos)
{
	dbuf *outf = NULL;
	de_finfo *fi = NULL;
	de_ucstring *fullfn = NULL;

	de_dbg(c, "%"I64_FMT" bytes of %scompressed data at %"I64_FMT,
		md->cmpr_len, (md->is_compressed?"":"un"), pos);

	if(pos + md->cmpr_len > c->infile->len) {
		de_err(c, "Unexpected EOF");
		goto done;
	}

	fi = de_finfo_create(c);

	fullfn = ucstring_create(c);
	if(md->is_dir) {
		fi->is_directory = 1;
		de_strarray_make_path(d->curpath, fullfn, DE_MPFLAG_NOTRAILINGSLASH);
	}
	else {
		de_strarray_make_path(d->curpath, fullfn, 0);
		ucstring_append_ucstring(fullfn, md->name);
	}

	fmtutil_riscos_append_type_to_filename(c, fi, fullfn, &md->rfa, md->is_dir, 0);
	de_finfo_set_name_from_ucstring(c, fi, fullfn, DE_SNFLAG_FULLPATH);
	fi->original_filename_flag = 1;

	fi->timestamp[DE_TIMESTAMPIDX_MODIFY] = md->rfa.mod_time;

	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;

	outf = dbuf_create_output_file(c, NULL, fi, 0);

	if(md->is_compressed) {
		dbuf_enable_wbuffer(outf);
		do_packdir_file_compressed(c, d, md, pos, outf);
	}
	else {
		dbuf_copy(c->infile, pos, md->cmpr_len, outf);
	}

done:
	dbuf_close(outf);
	de_finfo_destroy(c, fi);
	ucstring_destroy(fullfn);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movq 0x18(%rdx), %rdx
cmpl $0x0, 0x20(%r12)
leaq 0x59eec(%rip), %rax     # 0x11361f
leaq 0x8b496(%rip), %rcx     # 0x144bd0
cmoveq %rax, %rcx
leaq 0x7e724(%rip), %rsi     # 0x137e69
movq %rbp, %r8
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r12), %rax
addq %rbp, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xb9780
leaq 0x7e727(%rip), %rsi     # 0x137e8f
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0xb9976
movq %rbx, %rdi
callq 0xea9a9
movq %rax, %r14
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r15
cmpb $0x0, 0x4(%r12)
movq %r13, 0x10(%rsp)
je 0xb97bb
movb $0x1, 0x9(%r14)
movq 0x8(%r13), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xf776e
jmp 0xb97d6
movq 0x8(%r13), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xf776e
movq 0x28(%r12), %rsi
movq %r15, %rdi
callq 0xf6969
leaq 0x30(%r12), %rcx
movzbl 0x4(%r12), %r8d
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %r9d, %r9d
callq 0xf9907
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x1, %ecx
callq 0xea9e4
movb $0x1, %al
movb %al, 0x8(%r14)
movups 0x50(%r12), %xmm0
movups %xmm0, 0x18(%r14)
movb %al, 0x10(%r14)
movl 0x3c(%r12), %eax
movl %eax, 0xa0(%r14)
movl 0x34(%r12), %eax
movl %eax, 0xa4(%r14)
movl 0x38(%r12), %eax
movl %eax, 0xa8(%r14)
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xf037a
movq %rax, %r13
cmpl $0x0, 0x20(%r12)
je 0xb9929
movq %r15, 0x8(%rsp)
movq %r13, %rdi
callq 0xf0e3f
leaq 0xa8(%rsp), %r15
leaq 0x18(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfa6e0
movq 0x18(%rbx), %rax
movq %rax, (%r15)
movq %rbp, 0x8(%r15)
movq 0x18(%r12), %rax
movq %rax, 0x10(%r15)
leaq 0x18(%rsp), %rdx
movq %r13, (%rdx)
movb $0x1, 0x8(%rdx)
movq 0x10(%r12), %rax
movq %rax, 0x10(%rdx)
movq 0x10(%rsp), %rax
movl (%rax), %eax
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %r8
movaps %xmm0, (%r8)
movl $0x0, 0x10(%r8)
movl $0x4, (%r8)
movl %eax, 0xc(%r8)
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x48(%rsp), %r15
movq %r15, %rcx
callq 0x102cf0
movq %r13, %rdi
callq 0xf0ea4
cmpl $0x0, (%r15)
je 0xb993f
movq 0x28(%r12), %rdi
callq 0xf7557
movq %rax, %r15
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0xfa6a8
leaq 0x8f4d3(%rip), %rsi     # 0x148dea
movq %rbx, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9df7
jmp 0xb9971
movq 0x18(%rbx), %rdi
movq 0x18(%r12), %rdx
movq %rbp, %rsi
movq %r13, %rcx
callq 0xefabc
jmp 0xb9976
movq 0x18(%r13), %rax
cmpq 0x10(%r12), %rax
je 0xb9971
movq 0x28(%r12), %rdi
callq 0xf7557
movq 0x10(%r12), %rcx
movq 0x18(%r13), %r8
leaq 0x7e53a(%rip), %rsi     # 0x137e9e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
movq 0x8(%rsp), %r15
movq %r13, %rdi
callq 0xf0b13
movq %rbx, %rdi
movq %r14, %rsi
callq 0xea9b3
movq %r15, %rdi
callq 0xf6bb0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop