// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/crush.c
// Function: do_member_file
static int do_member_file(deark *c, lctx *d, i64 idx, i64 pos1)
{
	int retval = 0;
	struct de_arch_member_data *md = NULL;
	struct crush_member_data *mdc = NULL;
	de_ucstring *descr = NULL;
	i64 pos;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	md = de_arch_create_md(c, d->da);
	mdc = de_malloc(c, sizeof(struct crush_member_data));
	md->userdata = (void*)mdc;
	md->tmpfn_base = ucstring_create(c);

	de_dbg(c, "member file[%d]", (int)idx);
	de_dbg_indent(c, 1);
	de_dbg(c, "dir entry at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);
	pos = pos1;

	mdc->path_num = (UI)de_getbyte_p(&pos);
	de_dbg(c, "path num: %u", mdc->path_num);

	de_arch_read_field_dos_attr_p(md, &pos);

	de_arch_read_field_dttm_p(d->da, &md->fi->timestamp[DE_TIMESTAMPIDX_MODIFY], "mod",
		DE_ARCH_TSTYPE_DOS_TD, &pos);

	de_arch_read_field_orig_len_p(md, &pos);
	md->cmpr_len = md->orig_len;

	dbuf_read_to_ucstring(c->infile, pos, 12, md->tmpfn_base, DE_CONVFLAG_STOP_AT_NUL,
		d->da->input_encoding);
	de_dbg(c, "filename: \"%s\"", ucstring_getpsz_d(md->tmpfn_base));
	fixup_filename(md->tmpfn_base);
	make_fullfilename(c, d, md);
	md->set_name_flags |= DE_SNFLAG_FULLPATH;
	de_dbg_indent(c, -1);

	// If this is just an index (.CRI) file, there's nothing to extract.
	// We can't tell the difference between an index file, and an archive file
	// containing only zero-length members, so extract zero-length files just
	// in case.
	if(d->is_cri && md->cmpr_len!=0) {
		retval = 1;
		goto done;
	}

	de_dbg(c, "file data at %"I64_FMT, d->da->cmpr_data_curpos);

	if(d->da->cmpr_data_curpos + md->cmpr_len > d->dir_segment_pos) {
		de_err(c, "Malformed CRU archive");
		goto done;
	}

	md->cmpr_pos = d->da->cmpr_data_curpos;
	d->da->cmpr_data_curpos += md->cmpr_len;
	retval = 1;

	if((md->dos_attribs & 0x18) != 0x00) {
		// I don't know if subdirs or volume labels can be in these archives.
		de_warn(c, "%s: Not a regular file", ucstring_getpsz_d(md->filename));
	}

	md->dfn = uncmpr_decompressor_fn;
	de_arch_extract_member_file(md);

done:
	ucstring_destroy(descr);
	if(mdc) {
		de_free(c, mdc);
	}
	de_arch_destroy_md(c, md);
	de_dbg_indent_restore(c, saved_indent_level);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x17c120
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x15b780
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %edx
leaq 0x12707f(%rip), %rsi    # 0x1aeafd
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x147715(%rip), %rsi    # 0x1cf1b7
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x165170
movzbl %al, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl (%rax), %edx
leaq 0x127023(%rip), %rsi    # 0x1aeb0d
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x17c540
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rsi
addq $0x18, %rsi
leaq 0x11c3db(%rip), %rdx    # 0x1a3ef3
movl $0x4, %ecx
leaq -0x48(%rbp), %r8
callq 0x17c580
movq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x17c350
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x48(%rbp), %rsi
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x18(%rax), %r9d
movl $0xc, %edx
movl $0x1, %r8d
callq 0x1669f0
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x172650
movq -0x58(%rbp), %rdi
movq %rax, %rdx
leaq 0x13f9ee(%rip), %rsi    # 0x1c7583
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x87d10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x87d90
movq -0x30(%rbp), %rax
movl 0x78(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x78(%rax)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x87bf6
movq -0x30(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x87bf6
movl $0x1, -0x24(%rbp)
jmp 0x87ccc
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rdx
leaq 0x1259d7(%rip), %rsi    # 0x1ad5e3
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
addq 0x30(%rcx), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jle 0x87c47
movq -0x8(%rbp), %rdi
leaq 0x126edf(%rip), %rsi    # 0x1aeb1a
movb $0x0, %al
callq 0x15bfb0
jmp 0x87ccc
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movl $0x1, -0x24(%rbp)
movq -0x30(%rbp), %rax
movl 0x7c(%rax), %eax
andl $0x18, %eax
cmpl $0x0, %eax
je 0x87cb1
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x172650
movq -0x60(%rbp), %rdi
movq %rax, %rdx
leaq 0x126e86(%rip), %rsi    # 0x1aeb30
movb $0x0, %al
callq 0x15bc10
movq -0x30(%rbp), %rax
leaq 0x184(%rip), %rcx       # 0x87e40
movq %rcx, 0xa8(%rax)
movq -0x30(%rbp), %rdi
callq 0x17c920
movq -0x40(%rbp), %rdi
callq 0x171750
cmpq $0x0, -0x38(%rbp)
je 0x87ce9
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x17c1a0
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x15b5a0
movl -0x24(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)