// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/zip.c
// Function: ef_os2
static void ef_os2(deark *c, lctx *d, struct extra_item_info_struct *eii)
{
	i64 pos = eii->dpos;
	i64 endpos;
	i64 ulen;
	i64 cmpr_attr_size;
	int cmpr_meth;
	u32 crc_reported;
	const struct cmpr_meth_info *cmi = NULL;
	const char *name = "OS/2 ext. attr. data";
	dbuf *attr_data = NULL;
	de_module_params *mparams = NULL;
	int ret;

	endpos = pos+eii->dlen;
	if(pos+4>endpos) goto done;
	ulen = de_getu32le_p(&pos);
	de_dbg(c, "uncmpr ext attr data size: %"I64_FMT, ulen);
	if(eii->is_central) goto done;

	if(pos+2>endpos) goto done;
	cmpr_meth = (int)de_getu16le_p(&pos);
	de_dbg(c, "ext attr cmpr method: %d", cmpr_meth);

	if(pos+4>endpos) goto done;
	crc_reported = (u32)de_getu32le_p(&pos);
	de_dbg(c, "ext attr crc (reported): 0x%08x", (UI)crc_reported);

	cmpr_attr_size = endpos-pos;
	de_dbg(c, "cmpr ext attr data at %"I64_FMT", len=%"I64_FMT, pos, cmpr_attr_size);
	if(pos + cmpr_attr_size > endpos) goto done;

	cmi = get_cmpr_meth_info(cmpr_meth);
	if(cmpr_meth==6 || !is_compression_method_supported(d, cmi)) {
		de_warn(c, "%s: Unsupported compression method: %d (%s)",
			name, cmpr_meth, (cmi ? cmi->name : "?"));
		goto done;
	}

	attr_data = dbuf_create_membuf(c, ulen, 0x1);
	ret = do_decompress_attrib_data(c, d, pos, cmpr_attr_size,
		attr_data, ulen, crc_reported, cmpr_meth, cmi, 0x1, name);
	if(!ret) {
		de_warn(c, "Failed to decompress %s", name);
		goto done;
	}

	// attr_data contains an OS/2 extended attribute structure (FEA2LIST)
	mparams = de_malloc(c, sizeof(de_module_params));
	mparams->in_params.codes = "L";
	if(ucstring_isnonempty(eii->dd->fname)) {
		mparams->in_params.str1 = eii->dd->fname;
		mparams->in_params.flags |= 0x8;
	}
	de_dbg(c, "decoding OS/2 ext. attribs., unc. len=%"I64_FMT, attr_data->len);
	de_dbg_indent(c, 1);
	de_run_module_by_id_on_slice(c, "ea_data", mparams, attr_data, 0, attr_data->len);
	de_dbg_indent(c, -1);

done:
	dbuf_close(attr_data);
	de_free(c, mparams);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x8(%rdx), %r12
movq %r12, (%rsp)
movq 0x10(%rdx), %r13
cmpq $0x4, %r13
jge 0xd5337
xorl %r14d, %r14d
jmp 0xd536c
movq %rdx, %r15
movq %rsi, 0x20(%rsp)
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xe40bf
movq %rax, %rbp
leaq 0x618b3(%rip), %rsi     # 0x136c08
xorl %r14d, %r14d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpl $0x0, 0x30(%r15)
je 0xd5391
xorl %r12d, %r12d
movq %r14, %rdi
callq 0xe5591
movq %rbx, %rdi
movq %r12, %rsi
callq 0xded32
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %r12, %r13
movq (%rsp), %rax
addq $0x2, %rax
cmpq %r13, %rax
jg 0xd5332
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xe3fc4
movq %rax, %r12
leaq 0x61870(%rip), %rsi     # 0x136c27
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movq %rsp, %rax
movq (%rax), %rax
addq $0x4, %rax
cmpq %r13, %rax
jg 0xd536c
movq %r12, 0x18(%rsp)
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
movq %rsi, %r12
callq 0xe40bf
leaq 0x6184f(%rip), %rsi     # 0x136c40
xorl %r14d, %r14d
movq %rbx, %rdi
movq %rax, 0x10(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq (%r12), %rdx
movq %r13, %r12
subq %rdx, %r12
leaq 0x6184a(%rip), %rsi     # 0x136c60
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0xde896
movq %rsp, %rax
movq (%rax), %rax
movq %r12, 0x8(%rsp)
addq %r12, %rax
cmpq %r13, %rax
jg 0xd536c
movq 0x18(%rsp), %r12
movl %r12d, %edi
callq 0xd4ec7
movq %rax, %r13
cmpl $0x6, %r12d
jne 0xd545e
testq %r13, %r13
jne 0xd554a
jmp 0xd5550
testq %r13, %r13
je 0xd5550
cmpq $0x0, 0x10(%r13)
je 0xd554a
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe59cd
movq %rax, %r14
movq (%rsp), %rdx
subq $0x8, %rsp
leaq 0x61761(%rip), %rax     # 0x136bf3
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rcx
movq %r14, %r8
movq %rbp, %r9
pushq %rax
pushq $0x1
pushq %r13
pushq %r12
pushq 0x38(%rsp)
callq 0xd6409
addq $0x30, %rsp
testl %eax, %eax
je 0xd557a
pushq $0x70
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r12
leaq 0x5c7c8(%rip), %rax     # 0x131c9e
movq %rax, (%r12)
movq 0x28(%r15), %rax
movq 0x48(%rax), %rdi
callq 0xeaf8a
testl %eax, %eax
je 0xd54fe
movq 0x28(%r15), %rax
movq 0x48(%rax), %rax
movq %rax, 0x30(%r12)
orb $0x8, 0x8(%r12)
movq 0x18(%r14), %rdx
leaq 0x617be(%rip), %rsi     # 0x136cc7
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%r14), %r9
leaq 0x402bc(%rip), %rsi     # 0x1157e5
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0xdf9b8
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
jmp 0xd536f
movq 0x8(%r13), %r8
jmp 0xd5557
leaq 0x4998a(%rip), %r8      # 0x11eee1
leaq 0x61725(%rip), %rsi     # 0x136c83
leaq 0x6168e(%rip), %rdx     # 0x136bf3
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0xdf05a
jmp 0xd536c
leaq 0x6172e(%rip), %rsi     # 0x136caf
leaq 0x6166b(%rip), %rdx     # 0x136bf3
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
jmp 0xd536f