// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x901cc(%rip), %rsi     # 0x132b0b
callq 0xeb125
movl $0x20, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r14
testq %r15, %r15
je 0xa2975
testb $0x8, 0x8(%r15)
je 0xa2975
movq 0x30(%r15), %rdi
callq 0xf67a3
testl %eax, %eax
je 0xa2975
movq 0x30(%r15), %rax
movq %rax, 0x10(%r14)
movq %rbx, %rdi
movq %r15, %rsi
movl $0x4c, %edx
callq 0xea4d9
testl %eax, %eax
je 0xa2a07
movl $0x1, 0x4(%r14)
movq %rsp, %r13
movq $0x0, (%r13)
leaq 0x90195(%rip), %rsi     # 0x132b38
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
movq %rax, %rbp
leaq 0x90173(%rip), %rsi     # 0x132b48
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq (%r13), %rdx
addq $-0x4, %rbp
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rcx
callq 0xa2c5c
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
jmp 0xa2a84
movq %rbx, %rdi
movq %r15, %rsi
movl $0x52, %edx
callq 0xea4d9
testl %eax, %eax
je 0xa2a3d
movl $0x1, 0x4(%r14)
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rcx
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xa2c5c
jmp 0xa2a84
testq %r15, %r15
je 0xa2a49
testb $0x1, 0x8(%r15)
jne 0xa2a6a
leaq 0x900d9(%rip), %rsi     # 0x132b29
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0xa2a81
movq %rax, %rdi
callq 0xe9c2a
movl %eax, %r12d
jmp 0xa2a84
movl 0x10(%r15), %r12d
testl %r12d, %r12d
je 0xa2bd4
movl $0x1, 0x4(%r14)
jmp 0xa2a84
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r15, %rsi
movl $0xd, %edx
callq 0xeb220
movl %eax, (%r14)
movq $0x200, 0x8(%r14)       # imm = 0x200
testl %r12d, %r12d
je 0xa2b28
cmpl $0x77ff, %r12d          # imm = 0x77FF
ja 0xa2bd4
movq 0x18(%rbx), %rdi
movl %r12d, %esi
shrl $0x6, %esi
andl $0x1fe, %esi            # imm = 0x1FE
addl $0x20, %esi
callq 0xeebc8
movq %rax, %r13
movq 0x18(%rbx), %rdi
leal 0x200(,%r12,2), %esi
callq 0xeebc8
movl %eax, %r15d
cmpq $0xffff, %r15           # imm = 0xFFFF
je 0xa2bd4
movl %r13d, %eax
addq %rax, %r15
imulq 0x8(%r14), %r15
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeeb67
cmpl $0x4541, %eax           # imm = 0x4541
jne 0xa2bd4
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xa2d63
jmp 0xa2bd4
movq 0x18(%rbx), %rdi
cmpq $0x401, 0x18(%rdi)      # imm = 0x401
jl 0xa2bd4
movl $0x400, %r12d           # imm = 0x400
movq %rsp, %r15
movq %r12, %rsi
callq 0xeeb67
cmpl $0x4541, %eax           # imm = 0x4541
jne 0xa2b88
movq 0x18(%rbx), %rdi
leaq 0x4(%r12), %rsi
callq 0xeed0d
testl %eax, %eax
jne 0xa2b88
movq 0x18(%rbx), %rdi
leaq 0x8(%r12), %rsi
callq 0xeead3
cmpb $0x20, %al
jb 0xa2b88
movq 0x18(%rbx), %rdi
leaq 0x16(%r12), %rsi
callq 0xeed0d
testl %eax, %eax
je 0xa2b9b
addq $0x200, %r12            # imm = 0x200
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %r12
jl 0xa2b43
jmp 0xa2bd4
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0xa2d63
movq (%rsp), %rdi
testq %rdi, %rdi
jg 0xa2bc2
movq $0x1, (%rsp)
movl $0x1, %edi
addq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
callq 0xe9cb4
movq %rax, %r12
jmp 0xa2b8f
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq