// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x1, 0x30(%rax)
jge 0xcf1b4
jmp 0xcf534
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0xcd1e0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0xcf1dd
movq $0x0, -0x28(%rbp)
jmp 0xcf1e9
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
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)
jne 0xcf220
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x1729c0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0xcf237
movq -0x30(%rbp), %rax
movb $0x1, 0xb(%rax)
jmp 0xcf337
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x1717f0
cmpl $0x0, %eax
je 0xcf2af
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rsi
callq 0x171460
movq -0x18(%rbp), %rax
cmpb $0x0, 0x78(%rax)
je 0xcf28c
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x80, %rcx
movq -0x18(%rbp), %rax
movzbl 0x1(%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)
jmp 0xcf335
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x1717f0
cmpl $0x0, %eax
je 0xcf333
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x171460
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0xd0420
movq -0x18(%rbp), %rax
cmpb $0x0, 0x78(%rax)
je 0xcf315
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x80, %rcx
movq -0x18(%rbp), %rax
movzbl 0x1(%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)
jmp 0xcf335
jmp 0xcf337
movq -0x18(%rbp), %rax
cmpb $0x0, 0x68(%rax)
je 0xcf35b
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x68(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x70(%rcx), %rcx
movq %rcx, 0x20(%rax)
jmp 0xcf3a5
movq -0x18(%rbp), %rax
cmpb $0x0, 0x58(%rax)
je 0xcf37f
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x58(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x60(%rcx), %rcx
movq %rcx, 0x20(%rax)
jmp 0xcf3a3
movq -0x18(%rbp), %rax
cmpb $0x0, 0x48(%rax)
je 0xcf3a1
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x48(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x50(%rcx), %rcx
movq %rcx, 0x20(%rax)
jmp 0xcf3a3
jmp 0xcf3a5
movq -0x18(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0xcf3b9
movq -0x30(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0xcf3ed
movq -0x18(%rbp), %rax
cmpb $0x0, 0x5(%rax)
je 0xcf3d2
movq -0x30(%rbp), %rax
movl 0x14(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x14(%rax)
jmp 0xcf3eb
movq -0x18(%rbp), %rax
cmpb $0x0, 0x6(%rax)
je 0xcf3e9
movq -0x30(%rbp), %rax
movl 0x14(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0xcf3eb
jmp 0xcf3ed
movq -0x18(%rbp), %rax
cmpb $0x0, 0x78(%rax)
je 0xcf43b
movq -0x30(%rbp), %rax
movb $0x1, 0x10(%rax)
movq -0x18(%rbp), %rax
movl 0x8c(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x18(%rbp), %rax
movl 0x84(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xa4(%rax)
movq -0x18(%rbp), %rax
movl 0x88(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xa8(%rax)
movq -0x20(%rbp), %rax
addq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xcf47c
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x172500
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0xeac6c(%rip), %rsi     # 0x1ba0dc
movb $0x0, %al
callq 0x15bfb0
jmp 0xcf534
movq -0x18(%rbp), %rax
cmpb $0x0, 0x9(%rax)
je 0xcf4ae
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
callq 0x172500
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0xeac52(%rip), %rsi     # 0x1ba0f7
movb $0x0, %al
callq 0x15bc10
jmp 0xcf514
movq -0x18(%rbp), %rax
cmpb $0x0, 0x7(%rax)
je 0xcf4e0
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
callq 0x172500
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0xeac69(%rip), %rsi     # 0x1ba140
movb $0x0, %al
callq 0x15bc10
jmp 0xcf512
movq -0x18(%rbp), %rax
cmpb $0x0, 0x8(%rax)
je 0xcf510
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rdi
callq 0x172500
movq -0x58(%rbp), %rdi
movq %rax, %rdx
leaq 0xeac6a(%rip), %rsi     # 0x1ba173
movb $0x0, %al
callq 0x15bc10
jmp 0xcf512
jmp 0xcf514
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %r8
xorl %eax, %eax
movl %eax, %ecx
xorl %r9d, %r9d
callq 0x166be0
movq -0x38(%rbp), %rdi
callq 0x171750
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15d260
addq $0x60, %rsp
popq %rbp
retq