// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/stuffit.c
// Function: do_member
static int do_member(deark *c, lctx *d, i64 pos1, i64 *bytes_consumed)
{
	i64 pos = pos1;
	struct member_data *md = NULL;
	int saved_indent_level;
	int retval = 0;
	int curpath_need_pop = 0;

	*bytes_consumed = 0;
	de_dbg_indent_save(c, &saved_indent_level);

	md = de_malloc(c, sizeof(struct member_data));
	md->rfork.is_rsrc_fork = 1;
	md->dfork.forkname = "data";
	md->rfork.forkname = "resource";

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

	md->advf = de_advfile_create(c);
	md->advf->enable_wbuffer = 1;

	if(!do_member_header(c, d, md, pos)) goto done;

	*bytes_consumed = 112;

	if(md->rfork.cmpr_meth_etc==32 || md->dfork.cmpr_meth_etc==32) {
		md->is_folder = 1;
		md->rfork.cmpr_len = 0;
		md->dfork.cmpr_len = 0;
	}
	else if(md->rfork.cmpr_meth_etc==33 || md->dfork.cmpr_meth_etc==33) {
		// end of folder marker
		if(d->subdir_level>0) d->subdir_level--;
		de_strarray_pop(d->curpath);
		retval = 1;
		goto done;
	}
	else if(md->rfork.cmpr_meth_etc>33 || md->dfork.cmpr_meth_etc>33) {
		de_err(c, "Unknown member type. Cannot continue.");
		goto done;
	}

	*bytes_consumed += md->rfork.cmpr_len + md->dfork.cmpr_len;
	retval = 1;

	pos += 112;

	md->full_fname = ucstring_create(c);
	de_strarray_push(d->curpath, md->fname->str);
	curpath_need_pop = 1;
	de_strarray_make_path(d->curpath, md->full_fname, DE_MPFLAG_NOTRAILINGSLASH);
	de_dbg(c, "full name: \"%s\"", ucstring_getpsz_d(md->full_fname));

	if(md->is_folder) {
		if(d->subdir_level >= MAX_NESTING_LEVEL) {
			de_err(c, "Directories nested too deeply");
			retval = 0;
			goto done;
		}
		d->subdir_level++;
		curpath_need_pop = 0;
		do_extract_folder(c, d, md);
		goto done;
	}

	md->rfork.cmpr_pos = pos;
	pos += md->rfork.cmpr_len;
	md->dfork.cmpr_pos = pos;
	//pos += md->dfork.cmpr_len;

	do_extract_member_file(c, d, md);

done:
	if(curpath_need_pop) {
		de_strarray_pop(d->curpath);
	}
	if(md) {
		de_destroy_stringreaderdata(c, md->fname);
		ucstring_destroy(md->full_fname);
		de_advfile_destroy(md->advf);
		de_free(c, md);
	}
	de_dbg_indent_restore(c, saved_indent_level);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %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)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0x140, %esi            # imm = 0x140
callq 0x15b780
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movb $0x1, 0xa0(%rax)
movq -0x30(%rbp), %rax
leaq 0x864b3(%rip), %rcx     # 0x1c5b79
movq %rcx, 0x108(%rax)
movq -0x30(%rbp), %rax
leaq 0x7cd28(%rip), %rcx     # 0x1bc400
movq %rcx, 0xc8(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x87ca4(%rip), %rsi     # 0x1c7392
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
callq 0x17aa20
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x1, 0x78(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x13f9d0
cmpl $0x0, %eax
jne 0x13f742
jmp 0x13f964
movq -0x20(%rbp), %rax
movq $0x70, (%rax)
movq -0x30(%rbp), %rax
movzbl 0xa1(%rax), %eax
cmpl $0x20, %eax
je 0x13f76d
movq -0x30(%rbp), %rax
movzbl 0xe1(%rax), %eax
cmpl $0x20, %eax
jne 0x13f797
movq -0x30(%rbp), %rax
movb $0x1, (%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x100(%rax)
jmp 0x13f822
movq -0x30(%rbp), %rax
movzbl 0xa1(%rax), %eax
cmpl $0x21, %eax
je 0x13f7b7
movq -0x30(%rbp), %rax
movzbl 0xe1(%rax), %eax
cmpl $0x21, %eax
jne 0x13f7e7
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jle 0x13f7ce
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x172850
movl $0x1, -0x38(%rbp)
jmp 0x13f964
movq -0x30(%rbp), %rax
movzbl 0xa1(%rax), %eax
cmpl $0x21, %eax
jg 0x13f807
movq -0x30(%rbp), %rax
movzbl 0xe1(%rax), %eax
cmpl $0x21, %eax
jle 0x13f81e
movq -0x8(%rbp), %rdi
leaq 0x8e550(%rip), %rsi     # 0x1cdd62
movb $0x0, %al
callq 0x15bfb0
jmp 0x13f964
jmp 0x13f820
jmp 0x13f822
movq -0x30(%rbp), %rax
movq 0xc0(%rax), %rcx
movq -0x30(%rbp), %rax
addq 0x100(%rax), %rcx
movq -0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movl $0x1, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rsi
callq 0x1728d0
movl $0x1, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
movl $0x1, %edx
callq 0x1729c0
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x172650
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x7ea39(%rip), %rsi     # 0x1be2ff
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
je 0x13f922
movq -0x10(%rbp), %rax
cmpl $0x20, 0xc(%rax)
jl 0x13f8fb
movq -0x8(%rbp), %rdi
leaq 0x6063d(%rip), %rsi     # 0x19ff28
movb $0x0, %al
callq 0x15bfb0
movl $0x0, -0x38(%rbp)
jmp 0x13f964
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movl $0x0, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x140080
jmp 0x13f964
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x30(%rbp), %rax
movq 0xc0(%rax), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0xf8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x140160
cmpl $0x0, -0x3c(%rbp)
je 0x13f977
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x172850
cmpq $0x0, -0x30(%rbp)
je 0x13f9b6
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x166830
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x171750
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x17aaa0
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x15b5a0
movl -0x38(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)