// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x18(%rbp), %rax
movl 0x20(%rax), %esi
leaq 0x8e855(%rip), %rcx     # 0x19f5ff
leaq 0xbfe1f(%rip), %rax     # 0x1d0bd0
cmpl $0x0, %esi
cmovneq %rax, %rcx
movq -0x20(%rbp), %r8
leaq 0xb2ce6(%rip), %rsi     # 0x1c3aa9
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
addq 0x18(%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x110dfb
movq -0x8(%rbp), %rdi
leaq 0xb2ce0(%rip), %rsi     # 0x1c3acf
movb $0x0, %al
callq 0x15bfb0
jmp 0x110f5d
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0x110e3f
movq -0x30(%rbp), %rax
movb $0x1, 0x9(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rsi
movl $0x1, %edx
callq 0x1729c0
jmp 0x110e63
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x1729c0
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x171460
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x30, %rcx
movq -0x18(%rbp), %rax
movzbl 0x4(%rax), %r8d
xorl %r9d, %r9d
callq 0x175820
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x1, %ecx
callq 0x15d2c0
movq -0x30(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x50(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x58(%rcx), %rcx
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
movb $0x1, 0x10(%rax)
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x18(%rbp), %rax
movl 0x34(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xa4(%rax)
movq -0x18(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xa8(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
xorl %ecx, %ecx
callq 0x166c60
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x20(%rax)
je 0x110f3e
movq -0x28(%rbp), %rdi
callq 0x167b90
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x110f90
jmp 0x110f5b
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x28(%rbp), %rcx
callq 0x166070
jmp 0x110f5d
movq -0x28(%rbp), %rdi
callq 0x1676a0
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15d260
movq -0x38(%rbp), %rdi
callq 0x171750
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)