// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/installshld.c
// Function: isz_do_one_file
static int isz_do_one_file(deark *c, struct isz_ctx *d, i64 pos1, i64 *pbytes_consumed)
{
	i64 pos = pos1;
	i64 name_len;
	i64 segment_size;
	int retval = 0;
	struct de_arch_member_data *md = NULL;
	struct isz_member_data *mdi = NULL;
	struct isz_dir_array_item *di = NULL;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	mdi = de_malloc(c, sizeof(struct isz_member_data));
	md = de_arch_create_md(c, d->da);
	md->userdata = (void*)mdi;

	de_dbg(c, "file entry at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);

	mdi->end_vol = (UI)de_getbyte_p(&pos);
	de_dbg(c, "ending volume: %u", (UI)mdi->end_vol);

	mdi->dir_id = (UI)de_getu16le_p(&pos); // 1
	de_dbg(c, "dir id: %u", mdi->dir_id);
	if(mdi->dir_id >= d->num_dirs) {
		de_err(c, "Invalid directory");
		goto done;
	}
	di = &d->dir_array[mdi->dir_id];

	de_arch_read_field_orig_len_p(md, &pos); // 3
	d->tot_orig_size += md->orig_len;
	de_arch_read_field_cmpr_len_p(md, &pos); // 7
	d->tot_cmpr_size += md->cmpr_len;
	md->cmpr_pos = de_getu32le_p(&pos); // 11
	// printing cmpr_pos is deferred until we read the volume

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

	pos += 4; // ? (maybe a bit-field?)

	segment_size = de_getu16le_p(&pos);
	de_dbg(c, "segment size: %"I64_FMT, segment_size);
	if(segment_size<30) goto done;

	mdi->attribs = (UI)de_getbyte_p(&pos);
	de_dbg(c, "attribs: 0x%02x", (UI)mdi->attribs);

	mdi->is_split = de_getbyte_p(&pos);
	de_dbg(c, "is split: %u", (UI)mdi->is_split);

	pos += 1; // ?

	mdi->start_vol = (UI)de_getbyte_p(&pos);
	de_dbg(c, "cmpr data pos: %"I64_FMT", volume=%u",
		md->cmpr_pos, (UI)mdi->start_vol);

	name_len = (i64)de_getbyte_p(&pos);
	de_dbg(c, "name len: %"I64_FMT, name_len);
	md->tmpfn_base = ucstring_create(c);
	dbuf_read_to_ucstring(c->infile, pos, name_len, md->tmpfn_base, 0, d->da->input_encoding);
	de_dbg(c, "name: \"%s\"", ucstring_getpsz_d(md->tmpfn_base));

	if(ucstring_isempty(md->tmpfn_base)) {
		ucstring_append_char(md->tmpfn_base, '_');
	}
	ucstring_append_ucstring(md->filename, di->dname);
	ucstring_append_ucstring(md->filename, md->tmpfn_base);
	de_dbg(c, "full name: \"%s\"", ucstring_getpsz_d(md->filename));

	*pbytes_consumed = segment_size;
	retval = 1;

	if(mdi->is_split) {
		de_err(c, "%s: Fragmented files aren't supported",
			ucstring_getpsz_d(md->filename));
		goto done;
	}
	if(mdi->start_vol != d->volume_number) {
		de_err(c, "%s: File not on this volume",
			ucstring_getpsz_d(md->filename));
		goto done;
	}

	md->set_name_flags |= DE_SNFLAG_FULLPATH;
	if(mdi->attribs & 0x10) {
		md->dfn = noncompressed_decompressor_fn;
	}
	else {
		md->dfn = dclimplode_decompressor_fn;
	}
	de_arch_extract_member_file(md);

done:
	de_arch_destroy_md(c, md);
	de_free(c, mdi);
	de_dbg_indent_restore(c, saved_indent_level);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0x14, %esi
callq 0x15b780
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x17c120
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xb3190(%rip), %rsi     # 0x1a2473
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0xcef82(%rip), %rsi     # 0x1be2a7
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl (%rax), %edx
leaq 0xcef63(%rip), %rsi     # 0x1be2b9
movb $0x0, %al
callq 0x15b0d0
movq -0x50(%rbp), %rax
movl (%rax), %eax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jl 0xef384
movq -0x8(%rbp), %rdi
leaq 0xb07f9(%rip), %rsi     # 0x19fb71
movb $0x0, %al
callq 0x15bfb0
jmp 0xef6f6
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rcx
movl (%rcx), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x17c350
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movq -0x48(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x17c400
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x10(%rbp), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165580
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rsi
addq $0x18, %rsi
leaq 0xb4ade(%rip), %rdx     # 0x1a3ef3
movl $0x3, %ecx
leaq -0x28(%rbp), %r8
callq 0x17c580
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0xcee30(%rip), %rsi     # 0x1be283
movb $0x0, %al
callq 0x15b0d0
cmpq $0x1e, -0x38(%rbp)
jge 0xef466
jmp 0xef6f6
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl 0xc(%rax), %edx
leaq 0xcee31(%rip), %rsi     # 0x1be2c4
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movb %al, %cl
movq -0x50(%rbp), %rax
movb %cl, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movzbl 0x10(%rax), %edx
leaq 0xcee0d(%rip), %rsi     # 0x1be2d4
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rdx
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
leaq 0xcedd2(%rip), %rsi     # 0x1be2e1
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0xced5c(%rip), %rsi     # 0x1be299
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x18(%rax), %r9d
xorl %r8d, %r8d
callq 0x1669f0
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x172650
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0xbec2a(%rip), %rsi     # 0x1ae1d0
movb $0x0, %al
callq 0x15b0d0
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x1717b0
cmpl $0x0, %eax
je 0xef5d1
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rdi
movl $0x5f, %esi
callq 0x1714c0
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rsi
callq 0x171460
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x171460
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x172650
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0xcece2(%rip), %rsi     # 0x1be2ff
movb $0x0, %al
callq 0x15b0d0
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x3c(%rbp)
movq -0x50(%rbp), %rax
cmpb $0x0, 0x10(%rax)
je 0xef66f
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x172650
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0xcecac(%rip), %rsi     # 0x1be30f
movb $0x0, %al
callq 0x15bfb0
jmp 0xef6f6
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x38(%rcx), %eax
je 0xef6ab
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x172650
movq -0x80(%rbp), %rdi
movq %rax, %rdx
leaq 0xcec93(%rip), %rsi     # 0x1be335
movb $0x0, %al
callq 0x15bfb0
jmp 0xef6f6
movq -0x48(%rbp), %rax
movl 0x78(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x78(%rax)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xef6db
movq -0x48(%rbp), %rax
leaq 0x5e(%rip), %rcx        # 0xef730
movq %rcx, 0xa8(%rax)
jmp 0xef6ed
movq -0x48(%rbp), %rax
leaq 0x9a(%rip), %rcx        # 0xef780
movq %rcx, 0xa8(%rax)
movq -0x48(%rbp), %rdi
callq 0x17c920
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x17c1a0
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x15b5a0
movl -0x3c(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)