// File: /workspace/github_c_makefile_star2_O1/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 0x8e42e
movq %rdx, %rbp
movq %rsi, %r13
cmpb $0x0, 0x1(%rdx)
je 0x8e439
movq $0x0, (%rsp)
jmp 0x8e441
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x8e658
movq 0x20(%rbp), %rax
movq %rax, (%rsp)
imulq 0x18(%r13), %r12
movq %rbx, %rdi
callq 0xea9a9
movq %rax, %r14
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r15
cmpb $0x0, 0x4(%rbp)
jne 0x8e470
movq 0x30(%r13), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xf776e
cmpb $0x0, 0x4(%rbp)
je 0x8e47d
movb $0x1, 0xb(%r14)
jmp 0x8e4d1
movq 0x40(%rbp), %rdi
callq 0xf6c00
testl %eax, %eax
je 0x8e4ef
movq 0x40(%rbp), %rsi
movq %r15, %rdi
callq 0xf6969
cmpb $0x0, 0x78(%rbp)
je 0x8e4b9
leaq 0x80(%rbp), %rcx
movzbl 0x1(%rbp), %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, 0x8(%r14)
cmpb $0x0, 0x68(%rbp)
je 0x8e4e0
leaq 0x68(%rbp), %rax
jmp 0x8e56f
cmpb $0x0, 0x58(%rbp)
je 0x8e565
leaq 0x58(%rbp), %rax
jmp 0x8e56f
movq 0x38(%rbp), %rdi
callq 0xf6c00
testl %eax, %eax
je 0x8e4d1
movq 0x38(%rbp), %rsi
movq %r15, %rdi
callq 0xf6969
movq 0x10(%r15), %rsi
cmpq $0x3, %rsi
jl 0x8e496
movq 0x8(%r15), %rax
cmpl $0x3b, -0x8(%rax,%rsi,4)
jne 0x8e496
cmpl $0x31, -0x4(%rax,%rsi,4)
jne 0x8e496
addq $-0x2, %rsi
movq %r15, %rdi
callq 0xf688a
movq 0x10(%r15), %rsi
cmpq $0x2, %rsi
jl 0x8e496
movq 0x8(%r15), %rax
cmpl $0x2e, -0x4(%rax,%rsi,4)
jne 0x8e496
decq %rsi
movq %r15, %rdi
callq 0xf688a
jmp 0x8e496
cmpb $0x0, 0x48(%rbp)
je 0x8e577
leaq 0x48(%rbp), %rax
movups (%rax), %xmm0
movups %xmm0, 0x18(%r14)
cmpb $0x0, 0x1(%rbp)
je 0x8e584
movb $0x1, 0x9(%r14)
jmp 0x8e59c
cmpb $0x0, 0x5(%rbp)
je 0x8e591
orb $0x2, 0x14(%r14)
jmp 0x8e59c
cmpb $0x0, 0x6(%rbp)
je 0x8e59c
orb $0x1, 0x14(%r14)
cmpb $0x0, 0x78(%rbp)
je 0x8e5ce
movb $0x1, 0x10(%r14)
movl 0x8c(%rbp), %eax
movl %eax, 0xa0(%r14)
movl 0x84(%rbp), %eax
movl %eax, 0xa4(%r14)
movl 0x88(%rbp), %eax
movl %eax, 0xa8(%r14)
movq (%rsp), %rax
addq %r12, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x8e5fd
movq %r15, %rdi
callq 0xf74bd
leaq 0x9fcd8(%rip), %rsi     # 0x12e2c6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
jmp 0x8e658
cmpb $0x0, 0x9(%rbp)
je 0x8e60c
leaq 0x9fcd7(%rip), %r13     # 0x12e2e1
jmp 0x8e628
cmpb $0x0, 0x7(%rbp)
je 0x8e61b
leaq 0x9fd11(%rip), %r13     # 0x12e32a
jmp 0x8e628
cmpb $0x0, 0x8(%rbp)
je 0x8e640
leaq 0x9fd35(%rip), %r13     # 0x12e35d
movq %r15, %rdi
callq 0xf74bd
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9b27
movq 0x18(%rbx), %rdi
movq %r12, %rsi
movq (%rsp), %rdx
xorl %ecx, %ecx
movq %r14, %r8
xorl %r9d, %r9d
callq 0xf0321
movq %r15, %rdi
callq 0xf6bb0
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xea9b3