// File: /workspace/github_c_makefile_star2_O3/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 0x8db37
movq %rdx, %rbp
movq %rsi, %r13
cmpb $0x0, 0x1(%rdx)
je 0x8db42
movq $0x0, (%rsp)
jmp 0x8db4a
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x8dcdd
movq 0x20(%rbp), %rax
movq %rax, (%rsp)
imulq 0x18(%r13), %r12
movq %rbx, %rdi
callq 0xea504
movq %rax, %r14
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r15
cmpb $0x0, 0x4(%rbp)
jne 0x8db7f
movq 0x30(%r13), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xf730d
cmpb $0x0, 0x4(%rbp)
je 0x8db9c
movb $0x1, 0xb(%r14)
cmpb $0x0, 0x68(%rbp)
je 0x8db90
leaq 0x68(%rbp), %rax
jmp 0x8dc00
cmpb $0x0, 0x58(%rbp)
je 0x8dbf6
leaq 0x58(%rbp), %rax
jmp 0x8dc00
movq 0x40(%rbp), %rdi
callq 0xf67a3
testl %eax, %eax
je 0x8dcfe
movq 0x40(%rbp), %rsi
movq %r15, %rdi
callq 0xf6509
cmpb $0x0, 0x78(%rbp)
je 0x8dbdc
leaq 0x80(%rbp), %rcx
movzbl 0x1(%rbp), %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, 0x8(%r14)
jmp 0x8db84
cmpb $0x0, 0x48(%rbp)
je 0x8dc08
leaq 0x48(%rbp), %rax
movups (%rax), %xmm0
movups %xmm0, 0x18(%r14)
cmpb $0x0, 0x1(%rbp)
je 0x8dc15
movb $0x1, 0x9(%r14)
jmp 0x8dc2d
cmpb $0x0, 0x5(%rbp)
je 0x8dc22
orb $0x2, 0x14(%r14)
jmp 0x8dc2d
cmpb $0x0, 0x6(%rbp)
je 0x8dc2d
orb $0x1, 0x14(%r14)
cmpb $0x0, 0x78(%rbp)
je 0x8dc53
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 0x8dc82
movq %r15, %rdi
callq 0xf705c
leaq 0xa094b(%rip), %rsi     # 0x12e5be
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9295
jmp 0x8dcdd
cmpb $0x0, 0x9(%rbp)
je 0x8dc91
leaq 0xa094a(%rip), %r13     # 0x12e5d9
jmp 0x8dcad
cmpb $0x0, 0x7(%rbp)
je 0x8dca0
leaq 0xa0984(%rip), %r13     # 0x12e622
jmp 0x8dcad
cmpb $0x0, 0x8(%rbp)
je 0x8dcc5
leaq 0xa09a8(%rip), %r13     # 0x12e655
movq %r15, %rdi
callq 0xf705c
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8faa
movq 0x18(%rbx), %rdi
movq %r12, %rsi
movq (%rsp), %rdx
xorl %ecx, %ecx
movq %r14, %r8
xorl %r9d, %r9d
callq 0xefd48
movq %r15, %rdi
callq 0xf6753
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xea50e
movq 0x38(%rbp), %rdi
callq 0xf67a3
testl %eax, %eax
je 0x8db84
movq 0x38(%rbp), %rsi
movq %r15, %rdi
callq 0xf6509
movq 0x10(%r15), %rsi
cmpq $0x3, %rsi
jl 0x8dbb9
movq 0x8(%r15), %rax
cmpl $0x3b, -0x8(%rax,%rsi,4)
jne 0x8dbb9
cmpl $0x31, -0x4(%rax,%rsi,4)
jne 0x8dbb9
addq $-0x2, %rsi
movq %r15, %rdi
callq 0xf642a
movq 0x10(%r15), %rsi
cmpq $0x2, %rsi
jl 0x8dbb9
movq 0x8(%r15), %rax
cmpl $0x2e, -0x4(%rax,%rsi,4)
jne 0x8dbb9
decq %rsi
movq %r15, %rdi
callq 0xf642a
jmp 0x8dbb9