// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/os2ea.c
// Function: de_run_eadata
static void de_run_eadata(deark *c, de_module_params *mparams)
{
	int ret;
	UI ea_id = 0;
	i64 pos;
	const char *s;
	struct eadata_ctx *d = NULL;

	de_declare_fmt(c, "OS/2 extended attributes data");

	d = de_malloc(c, sizeof(struct eadata_ctx));

	if(mparams && (mparams->in_params.flags & 0x8)!=0) {
		if(ucstring_isnonempty(mparams->in_params.str1)) {
			d->base_filename_ref = mparams->in_params.str1;
		}
	}

	if(de_havemodcode(c, mparams, 'L')) {
		d->createflags_for_icons = DE_CREATEFLAG_IS_AUX;
		eadata_do_FEA2LIST(c, d);
	}
	else if(de_havemodcode(c, mparams, 'R')) {
		d->createflags_for_icons = DE_CREATEFLAG_IS_AUX;
		eadata_do_raw_list(c, d, 0, c->infile->len);
	}
	else if(mparams && (mparams->in_params.flags & 0x1)) {
		// We're being used by another module, to handle a specific ea_id.
		ea_id = (UI)mparams->in_params.uint1;
		if(ea_id==0) goto done;
		d->createflags_for_icons = DE_CREATEFLAG_IS_AUX;
	}
	else {
		s = de_get_ext_option(c, "ea_data:handle");
		if(s) {
			ea_id = (UI)de_atoi(s);
		}
	}

	d->input_encoding = de_get_input_encoding(c, mparams, DE_ENCODING_CP437);
	d->bytes_per_cluster = 512;

	if(ea_id==0) {
		eadata_scan_file(c, d);
	}
	else {
		ret = eadata_id_to_offset(c, d, ea_id, &pos);
		if(!ret) goto done;
		eadata_do_ea_sector_by_offset(c, d, pos, NULL);
	}

done:
	de_free(c, d);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xce4fd(%rip), %rsi     # 0x1be537
callq 0x15e380
movq -0x8(%rbp), %rdi
movl $0x20, %esi
callq 0x15b780
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xf008b
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xf008b
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x1717f0
cmpl $0x0, %eax
je 0xf0089
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xf008b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x4c, %edx
callq 0x15d1d0
cmpl $0x0, %eax
je 0xf00bf
movq -0x30(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xf02b0
jmp 0xf0165
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x52, %edx
callq 0x15d1d0
cmpl $0x0, %eax
je 0xf0100
movq -0x30(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0xf0350
jmp 0xf0163
cmpq $0x0, -0x10(%rbp)
je 0xf0138
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xf0138
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0xf012b
jmp 0xf01d6
movq -0x30(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0xf0161
movq -0x8(%rbp), %rdi
leaq 0xce412(%rip), %rsi     # 0x1be555
callq 0x15cb30
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xf015f
movq -0x28(%rbp), %rdi
callq 0x15cca0
movl %eax, -0x18(%rbp)
jmp 0xf0161
jmp 0xf0163
jmp 0xf0165
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0xd, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movq $0x200, 0x8(%rax)       # imm = 0x200
cmpl $0x0, -0x18(%rbp)
jne 0xf01a0
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xf0490
jmp 0xf01d4
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x18(%rbp), %edx
leaq -0x20(%rbp), %rcx
callq 0xf0530
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xf01bf
jmp 0xf01d6
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0xf0610
jmp 0xf01d6
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15b820
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)