// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/misc3.c
// Function: do_dwc_member
static void do_dwc_member(deark *c, de_arch_lctx *d, i64 pos1, i64 fhsize)
{
	i64 pos = pos1;
	struct de_arch_member_data *md = NULL;
	i64 cmt_len = 0;
	i64 path_len = 0;
	UI cdata_crc_reported = 0;
	UI cdata_crc_calc;
	u8 have_cdata_crc = 0;
	u8 b;
	de_ucstring *comment = NULL;

	md = de_arch_create_md(c, d);

	de_dbg(c, "member header at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);
	md->tmpfn_base = ucstring_create(c);
	dbuf_read_to_ucstring(c->infile, pos, 12, md->tmpfn_base, DE_CONVFLAG_STOP_AT_NUL,
		d->input_encoding);
	de_dbg(c, "filename: \"%s\"", ucstring_getpsz_d(md->tmpfn_base));
	// tentative md->filename (could be used by error messages)
	ucstring_append_ucstring(md->filename, md->tmpfn_base);
	pos += 13;

	de_arch_read_field_orig_len_p(md, &pos);
	de_arch_read_field_dttm_p(d, &md->fi->timestamp[DE_TIMESTAMPIDX_MODIFY], "mod",
		DE_ARCH_TSTYPE_UNIX, &pos);
	de_arch_read_field_cmpr_len_p(md, &pos);
	md->cmpr_pos = de_getu32le_p(&pos);
	de_dbg(c, "cmpr. data pos: %"I64_FMT, md->cmpr_pos);

	b = de_getbyte_p(&pos);
	md->cmpr_meth = ((UI)b) & 0x0f;
	de_dbg(c, "cmpr. method: %u", md->cmpr_meth);
	md->file_flags = ((UI)b) >> 4;
	de_dbg(c, "flags: 0x%x", md->file_flags);
	if(md->file_flags & 0x4) {
		md->is_encrypted = 1;
	}

	if(fhsize>=31) {
		cmt_len = (i64)de_getbyte_p(&pos);
		de_dbg(c, "comment len: %d", (int)cmt_len);
	}
	if(fhsize>=32) {
		path_len = (i64)de_getbyte_p(&pos);
		de_dbg(c, "path len: %d", (int)path_len);
	}
	if(fhsize>=34) {
		cdata_crc_reported = (u32)de_getu16le_p(&pos);
		de_dbg(c, "CRC of cmpr. data (reported): 0x%04x", (UI)cdata_crc_reported);
		have_cdata_crc = 1;
	}

	if(!de_arch_good_cmpr_data_pos(md)) {
		goto done;
	}

	if(path_len>1) {
		md->tmpfn_path = ucstring_create(c);
		dbuf_read_to_ucstring(c->infile, md->cmpr_pos+md->cmpr_len,
			path_len-1,
			md->tmpfn_path, DE_CONVFLAG_STOP_AT_NUL, d->input_encoding);
		de_dbg(c, "path: \"%s\"", ucstring_getpsz_d(md->tmpfn_path));
	}
	if(cmt_len>1) {
		comment = ucstring_create(c);
		dbuf_read_to_ucstring(c->infile, md->cmpr_pos+md->cmpr_len+path_len,
			cmt_len-1, comment, DE_CONVFLAG_STOP_AT_NUL, d->input_encoding);
		de_dbg(c, "comment: \"%s\"", ucstring_getpsz_d(comment));
	}

	dwc_process_filename(c, d, md);

	if(have_cdata_crc) {
		if(!d->crco) {
			d->crco = de_crcobj_create(c, DE_CRCOBJ_CRC16_ARC);
		}
		de_crcobj_reset(d->crco);
		de_crcobj_addslice(d->crco, c->infile, md->cmpr_pos, md->cmpr_len);
		cdata_crc_calc = de_crcobj_getval(d->crco);
		de_dbg(c, "CRC of cmpr. data (calculated): 0x%04x", (UI)cdata_crc_calc);
		if(cdata_crc_calc!=cdata_crc_reported) {
			de_err(c, "File data CRC check failed (expected 0x%04x, got 0x%04x). "
				"DWC file may be corrupted.", (UI)cdata_crc_reported,
				(UI)cdata_crc_calc);
		}
	}

	if(d->private1) {
		md->dfn = dwc_decompressor_fn;
		de_arch_extract_member_file(md);
	}

done:
	de_dbg_indent(c, -1);
	de_arch_destroy_md(c, md);
	ucstring_destroy(comment);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %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)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movb $0x0, -0x49(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x17c120
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x12f3b7(%rip), %rsi    # 0x1d0692
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x10(%rbp), %rax
movl 0x18(%rax), %r9d
movl $0xc, %edx
movl $0x1, %r8d
callq 0x1669f0
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0x172650
movq -0x60(%rbp), %rdi
movq %rax, %rdx
leaq 0x126230(%rip), %rsi    # 0x1c7583
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x171460
movq -0x28(%rbp), %rax
addq $0xd, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x17c350
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rsi
addq $0x18, %rsi
leaq 0x102b54(%rip), %rdx    # 0x1a3ef3
movl $0x1, %ecx
leaq -0x28(%rbp), %r8
callq 0x17c580
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x17c400
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165580
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rdx
leaq 0x110483(%rip), %rsi    # 0x1b186c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movb %al, -0x4a(%rbp)
movzbl -0x4a(%rbp), %ecx
andl $0xf, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x90(%rax), %edx
leaq 0x1102bf(%rip), %rsi    # 0x1b16e9
movb $0x0, %al
callq 0x15b0d0
movzbl -0x4a(%rbp), %ecx
shrl $0x4, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x94(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x94(%rax), %edx
leaq 0x12fcb7(%rip), %rsi    # 0x1d110e
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rax
movl 0x94(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xa147b
movq -0x30(%rbp), %rax
movb $0x1, 0x80(%rax)
cmpq $0x1f, -0x20(%rbp)
jl 0xa14b2
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
leaq 0x1103d5(%rip), %rsi    # 0x1b1880
movb $0x0, %al
callq 0x15b0d0
cmpq $0x20, -0x20(%rbp)
jl 0xa14e9
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x1103ae(%rip), %rsi    # 0x1b1890
movb $0x0, %al
callq 0x15b0d0
cmpq $0x22, -0x20(%rbp)
jl 0xa151d
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %edx
leaq 0x11038b(%rip), %rsi    # 0x1b189d
movb $0x0, %al
callq 0x15b0d0
movb $0x1, -0x49(%rbp)
movq -0x30(%rbp), %rdi
callq 0x17c7f0
cmpl $0x0, %eax
jne 0xa1530
jmp 0xa1704
cmpq $0x1, -0x40(%rbp)
jle 0xa15b0
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x30(%rbp), %rax
addq 0x30(%rax), %rsi
movq -0x40(%rbp), %rdx
subq $0x1, %rdx
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rcx
movq -0x10(%rbp), %rax
movl 0x18(%rax), %r9d
movl $0x1, %r8d
callq 0x1669f0
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x172650
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0x12e8b3(%rip), %rsi    # 0x1cfe5c
movb $0x0, %al
callq 0x15b0d0
cmpq $0x1, -0x38(%rbp)
jle 0xa1625
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x30(%rbp), %rax
addq 0x30(%rax), %rsi
addq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
subq $0x1, %rdx
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movl 0x18(%rax), %r9d
movl $0x1, %r8d
callq 0x1669f0
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rdi
callq 0x172650
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0xff02e(%rip), %rsi     # 0x1a064c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xa1730
cmpb $0x0, -0x49(%rbp)
je 0xa16dd
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0xa1664
movq -0x8(%rbp), %rdi
movl $0x21, %esi
callq 0x15eac0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x15f250
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rdx
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rcx
callq 0x15f500
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x15f340
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movl -0x48(%rbp), %edx
leaq 0x11020e(%rip), %rsi    # 0x1b18c2
movb $0x0, %al
callq 0x15b0d0
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0xa16db
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
leaq 0x110215(%rip), %rsi    # 0x1b18e9
movb $0x0, %al
callq 0x15bfb0
jmp 0xa16dd
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0xa1702
movq -0x30(%rbp), %rax
leaq 0x10e(%rip), %rcx       # 0xa1800
movq %rcx, 0xa8(%rax)
movq -0x30(%rbp), %rdi
callq 0x17c920
jmp 0xa1704
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x17c1a0
movq -0x58(%rbp), %rdi
callq 0x171750
addq $0x70, %rsp
popq %rbp
retq
nop