// File: /workspace/github_c_makefile_star2_O3/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), %rbp
cmpq $0x4, %rbp
jge 0xdea3f
xorl %r14d, %r14d
jmp 0xdea74
movq %rdx, %r15
movq %rsi, 0x20(%rsp)
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xeed83
movq %rax, %r13
leaq 0x655fb(%rip), %rsi     # 0x144058
xorl %r14d, %r14d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
cmpl $0x0, 0x30(%r15)
je 0xdea99
xorl %r12d, %r12d
movq %r14, %rdi
callq 0xf052b
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8be2
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %r12, %rbp
movq (%rsp), %rax
addq $0x2, %rax
cmpq %rbp, %rax
jg 0xdea3a
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xeebeb
movq %rax, %r12
leaq 0x655b8(%rip), %rsi     # 0x144077
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
movq %rsp, %rax
movq (%rax), %rax
addq $0x4, %rax
cmpq %rbp, %rax
jg 0xdea74
movq %r12, 0x18(%rsp)
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
movq %rsi, %r12
callq 0xeed83
leaq 0x65597(%rip), %rsi     # 0x144090
xorl %r14d, %r14d
movq %rbx, %rdi
movq %rax, 0x10(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq (%r12), %rdx
movq %rbp, %r12
subq %rdx, %r12
leaq 0x65592(%rip), %rsi     # 0x1440b0
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0xe8617
movq %rsp, %rax
movq (%rax), %rax
movq %r12, 0x8(%rsp)
addq %r12, %rax
cmpq %rbp, %rax
jg 0xdea74
xorl %eax, %eax
leaq 0xaf445(%rip), %rbp     # 0x18df90
leaq 0x4d5ff(%rip), %r8      # 0x12c151
movq 0x18(%rsp), %r12
cmpl %r12d, (%rax,%rbp)
je 0xdeb6e
addq $0x18, %rax
cmpq $0x210, %rax            # imm = 0x210
jne 0xdeb57
jmp 0xdec6b
cmpl $0x6, %r12d
je 0xdec66
cmpq $0x0, 0x10(%rax,%rbp)
je 0xdec66
addq %rax, %rbp
movq %rbx, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xf09c5
movq %rax, %r14
movq (%rsp), %rdx
subq $0x8, %rsp
leaq 0x6549a(%rip), %rax     # 0x144043
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rcx
movq %r14, %r8
movq %r13, %r9
pushq %rax
pushq $0x1
pushq %rbp
pushq %r12
pushq 0x38(%rsp)
callq 0xdfbd8
addq $0x30, %rsp
testl %eax, %eax
je 0xdec8e
movl $0x70, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r12
leaq 0x603e0(%rip), %rax     # 0x13efce
movq %rax, (%r12)
movq 0x28(%r15), %rax
movq 0x48(%rax), %rdi
callq 0xf67a3
testl %eax, %eax
je 0xdec16
movq 0x28(%r15), %rax
movq 0x48(%rax), %rax
movq %rax, 0x30(%r12)
orb $0x8, 0x8(%r12)
movq 0x18(%r14), %rdx
leaq 0x654f6(%rip), %rsi     # 0x144117
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r14), %r9
leaq 0x43d62(%rip), %rsi     # 0x1229a5
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0xe9aa3
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
jmp 0xdea77
movq 0x8(%rax,%rbp), %r8
leaq 0x65461(%rip), %rsi     # 0x1440d3
leaq 0x653ca(%rip), %rdx     # 0x144043
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe8faa
jmp 0xdea74
leaq 0x6546a(%rip), %rsi     # 0x1440ff
leaq 0x653a7(%rip), %rdx     # 0x144043
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8faa
jmp 0xdea77