// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/iso9660.c
// Function: do_extract_file
static void do_extract_file(deark *c, lctx *d, struct dir_record *dr)
{
	i64 dpos, dlen;
	de_finfo *fi = NULL;
	de_ucstring *final_name = NULL;

	if(dr->extent_blk<1) goto done;
	dpos = sector_dpos(d, dr->extent_blk);
	if(dr->is_dir) {
		dlen = 0;
	}
	else {
		dlen = dr->data_len;
	}

	fi = de_finfo_create(c);

	final_name = ucstring_create(c);

	if(!dr->is_root_dot) {
		de_strarray_make_path(d->curpath, final_name, 0);
	}

	if(dr->is_root_dot) {
		fi->is_root_dir = 1;
	}
	else if(ucstring_isnonempty(dr->rr_name)) {
		ucstring_append_ucstring(final_name, dr->rr_name);
		if(dr->has_riscos_data) {
			fmtutil_riscos_append_type_to_filename(c, fi, final_name, &dr->rfa, dr->is_dir, 0);
		}
		de_finfo_set_name_from_ucstring(c, fi, final_name, DE_SNFLAG_FULLPATH);
		fi->original_filename_flag = 1;
	}
	else if(ucstring_isnonempty(dr->fname)) {
		ucstring_append_ucstring(final_name, dr->fname);
		fixup_filename(c, d, final_name);
		if(dr->has_riscos_data) {
			fmtutil_riscos_append_type_to_filename(c, fi, final_name, &dr->rfa, dr->is_dir, 0);
		}
		de_finfo_set_name_from_ucstring(c, fi, final_name, DE_SNFLAG_FULLPATH);
		fi->original_filename_flag = 1;
	}

	if(dr->riscos_timestamp.is_valid) {
		fi->timestamp[DE_TIMESTAMPIDX_MODIFY] = dr->riscos_timestamp;
	}
	else if(dr->rr_modtime.is_valid) {
		fi->timestamp[DE_TIMESTAMPIDX_MODIFY] = dr->rr_modtime;
	}
	else if(dr->recording_time.is_valid) {
		// Apparently, the "recording time" (whatever that is) is
		// sometimes used as the mod time.
		fi->timestamp[DE_TIMESTAMPIDX_MODIFY] = dr->recording_time;
	}

	if(dr->is_dir) {
		fi->is_directory = 1;
	}
	else if(dr->rr_is_executable) {
		fi->mode_flags |= DE_MODEFLAG_EXE;
	}
	else if(dr->rr_is_nonexecutable) {
		fi->mode_flags |= DE_MODEFLAG_NONEXE;
	}

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

	if(dpos+dlen > c->infile->len) {
		de_err(c, "%s goes beyond end of file", ucstring_getpsz(final_name));
		goto done;
	}

	if(dr->is_specialfileformat) {
		de_warn(c, "%s has an advanced file structure, and might not be "
			"extracted correctly.", ucstring_getpsz(final_name));
	}
	else if(dr->is_symlink) {
		de_warn(c, "%s is a symlink. It will not be extracted as such.",
			ucstring_getpsz(final_name));
	}
	else if(dr->is_specialfiletype) { // E.g. FIFO, device, ...
		de_warn(c, "%s is a special file. It will not be extracted as such.",
			ucstring_getpsz(final_name));
	}

	dbuf_create_file_from_slice(c->infile, dpos, dlen, NULL, fi, 0);

done:
	ucstring_destroy(final_name);
	de_finfo_destroy(c, fi);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x30(%rdx), %r12
testq %r12, %r12
jle 0x888e4
movq %rdx, %rbp
movq %rsi, %r13
cmpb $0x0, 0x1(%rdx)
je 0x888ef
movq $0x0, (%rsp)
jmp 0x888f7
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x88a88
movq 0x20(%rbp), %rax
movq %rax, (%rsp)
imulq 0x18(%r13), %r12
movq %rbx, %rdi
callq 0xdfd1a
movq %rax, %r14
movq %rbx, %rdi
callq 0xeac74
movq %rax, %r15
cmpb $0x0, 0x4(%rbp)
jne 0x8892c
movq 0x30(%r13), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xeba55
cmpb $0x0, 0x4(%rbp)
je 0x88949
movb $0x1, 0xb(%r14)
cmpb $0x0, 0x68(%rbp)
je 0x8893d
leaq 0x68(%rbp), %rax
jmp 0x889ab
cmpb $0x0, 0x58(%rbp)
je 0x889a1
leaq 0x58(%rbp), %rax
jmp 0x889ab
movq 0x40(%rbp), %rdi
callq 0xeaf8a
testl %eax, %eax
je 0x88aa9
movq 0x40(%rbp), %rsi
movq %r15, %rdi
callq 0xead71
cmpb $0x0, 0x78(%rbp)
je 0x88989
leaq 0x80(%rbp), %rcx
movzbl 0x1(%rbp), %r8d
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %r9d, %r9d
callq 0xeda93
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xdfd55
movb $0x1, 0x8(%r14)
jmp 0x88931
cmpb $0x0, 0x48(%rbp)
je 0x889b3
leaq 0x48(%rbp), %rax
movups (%rax), %xmm0
movups %xmm0, 0x18(%r14)
cmpb $0x0, 0x1(%rbp)
je 0x889c0
movb $0x1, 0x9(%r14)
jmp 0x889d8
cmpb $0x0, 0x5(%rbp)
je 0x889cd
orb $0x2, 0x14(%r14)
jmp 0x889d8
cmpb $0x0, 0x6(%rbp)
je 0x889d8
orb $0x1, 0x14(%r14)
cmpb $0x0, 0x78(%rbp)
je 0x889fe
movb $0x1, 0x10(%r14)
movl 0x8c(%rbp), %eax
movl %eax, 0xa0(%r14)
movq 0x84(%rbp), %rax
movq %rax, 0xa4(%r14)
movq (%rsp), %rax
addq %r12, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x88a2d
movq %r15, %rdi
callq 0xeb7e4
leaq 0x98930(%rip), %rsi     # 0x12134e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf2a5
jmp 0x88a88
cmpb $0x0, 0x9(%rbp)
je 0x88a3c
leaq 0x9892f(%rip), %r13     # 0x121369
jmp 0x88a58
cmpb $0x0, 0x7(%rbp)
je 0x88a4b
leaq 0x98969(%rip), %r13     # 0x1213b2
jmp 0x88a58
cmpb $0x0, 0x8(%rbp)
je 0x88a70
leaq 0x9898d(%rip), %r13     # 0x1213e5
movq %r15, %rdi
callq 0xeb7e4
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf05a
movq 0x18(%rbx), %rdi
movq %r12, %rsi
movq (%rsp), %rdx
xorl %ecx, %ecx
movq %r14, %r8
xorl %r9d, %r9d
callq 0xe4e0b
movq %r15, %rdi
callq 0xeaf3c
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdfd24
movq 0x38(%rbp), %rdi
callq 0xeaf8a
testl %eax, %eax
je 0x88931
movq 0x38(%rbp), %rsi
movq %r15, %rdi
callq 0xead71
movq 0x10(%r15), %rsi
cmpq $0x3, %rsi
jl 0x88966
movq 0x8(%r15), %rax
cmpl $0x3b, -0x8(%rax,%rsi,4)
jne 0x88966
cmpl $0x31, -0x4(%rax,%rsi,4)
jne 0x88966
addq $-0x2, %rsi
movq %r15, %rdi
callq 0xeac8c
movq 0x10(%r15), %rsi
cmpq $0x2, %rsi
jl 0x88966
movq 0x8(%r15), %rax
cmpl $0x2e, -0x4(%rax,%rsi,4)
jne 0x88966
decq %rsi
movq %r15, %rdi
callq 0xeac8c
jmp 0x88966