// File: /workspace/github_c_makefile_star2_O3/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 0x5ab77(%rip), %rax     # 0x1136cf
leaq 0x8c551(%rip), %rcx     # 0x1450b0
cmoveq %rax, %rcx
leaq 0x7f68b(%rip), %rsi     # 0x1381f5
movq %rbp, %r8
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r12), %rax
addq %rbp, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xb8ba5
leaq 0x7f68e(%rip), %rsi     # 0x13821b
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0xb8d88
movq %rbx, %rdi
callq 0xea504
movq %rax, %r14
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r15
cmpb $0x0, 0x4(%r12)
movq %r13, 0x10(%rsp)
je 0xb8be0
movb $0x1, 0x9(%r14)
movq 0x8(%r13), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xf730d
jmp 0xb8bfb
movq 0x8(%r13), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xf730d
movq 0x28(%r12), %rsi
movq %r15, %rdi
callq 0xf6509
leaq 0x30(%r12), %rcx
movzbl 0x4(%r12), %r8d
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %r9d, %r9d
callq 0xf93ff
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x1, %ecx
callq 0xea53f
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)
movq 0x34(%r12), %rax
movq %rax, 0xa4(%r14)
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %r13
cmpl $0x0, 0x20(%r12)
je 0xb8d3b
movq %r15, 0x8(%rsp)
movq %r13, %rdi
callq 0xf0855
leaq 0xa8(%rsp), %r15
leaq 0x18(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfa1dc
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 0x34(%rsp), %r8
movups %xmm0, 0x4(%r8)
movl $0x4, (%r8)
movl %eax, 0xc(%r8)
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x48(%rsp), %r15
movq %r15, %rcx
callq 0x102400
movq %r13, %rdi
callq 0xf08ba
cmpl $0x0, (%r15)
je 0xb8d51
movq 0x28(%r12), %rdi
callq 0xf70f6
movq %rax, %r15
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0xfa1a4
leaq 0x90659(%rip), %rsi     # 0x149382
movq %rbx, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9295
jmp 0xb8d83
movq 0x18(%rbx), %rdi
movq 0x18(%r12), %rdx
movq %rbp, %rsi
movq %r13, %rcx
callq 0xef481
jmp 0xb8d88
movq 0x18(%r13), %rax
cmpq 0x10(%r12), %rax
je 0xb8d83
movq 0x28(%r12), %rdi
callq 0xf70f6
movq 0x10(%r12), %rcx
movq 0x18(%r13), %r8
leaq 0x7f4b4(%rip), %rsi     # 0x13822a
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9295
movq 0x8(%rsp), %r15
movq %r13, %rdi
callq 0xf052b
movq %rbx, %rdi
movq %r14, %rsi
callq 0xea50e
movq %r15, %rdi
callq 0xf6753
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)