// File: /workspace/github_c_makefile_star2_O1/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 0x8f570(%rip), %rsi     # 0x132773
callq 0xeb6d6
movl $0x20, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r14
testq %r15, %r15
je 0xa3239
testb $0x8, 0x8(%r15)
je 0xa3239
movq 0x30(%r15), %rdi
callq 0xf6c00
testl %eax, %eax
je 0xa3239
movq 0x30(%r15), %rax
movq %rax, 0x10(%r14)
movq %rbx, %rdi
movq %r15, %rsi
movl $0x4c, %edx
callq 0xea97e
testl %eax, %eax
je 0xa32cb
movl $0x1, 0x4(%r14)
movq %rsp, %r13
movq $0x0, (%r13)
leaq 0x8f539(%rip), %rsi     # 0x1327a0
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
movq %rax, %rbp
leaq 0x8f517(%rip), %rsi     # 0x1327b0
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq (%r13), %rdx
addq $-0x4, %rbp
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rcx
callq 0xa3522
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
jmp 0xa3348
movq %rbx, %rdi
movq %r15, %rsi
movl $0x52, %edx
callq 0xea97e
testl %eax, %eax
je 0xa3301
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 0xa3522
jmp 0xa3348
testq %r15, %r15
je 0xa330d
testb $0x1, 0x8(%r15)
jne 0xa332e
leaq 0x8f47d(%rip), %rsi     # 0x132791
movq %rbx, %rdi
callq 0xea6cb
testq %rax, %rax
je 0xa3345
movq %rax, %rdi
callq 0xea781
movl %eax, %r12d
jmp 0xa3348
movl 0x10(%r15), %r12d
testl %r12d, %r12d
je 0xa349a
movl $0x1, 0x4(%r14)
jmp 0xa3348
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r15, %rsi
movl $0xd, %edx
callq 0xeb7d1
movl %eax, (%r14)
movq $0x200, 0x8(%r14)       # imm = 0x200
testl %r12d, %r12d
je 0xa33b8
movb $0x1, %bpl
cmpl $0x77ff, %r12d          # imm = 0x77FF
ja 0xa33b0
movq 0x18(%rbx), %rdi
movl %r12d, %esi
shrl $0x6, %esi
andl $0x1fe, %esi            # imm = 0x1FE
addl $0x20, %esi
callq 0xef1ca
movq %rax, %r13
movq 0x18(%rbx), %rdi
leal 0x200(,%r12,2), %esi
callq 0xef1ca
movl %eax, %r15d
cmpq $0xffff, %r15           # imm = 0xFFFF
jne 0xa3465
xorl %r15d, %r15d
jmp 0xa3485
movq 0x18(%rbx), %rax
cmpq $0x401, 0x18(%rax)      # imm = 0x401
jl 0xa349a
movl $0x400, %r12d           # imm = 0x400
movq %rsp, %r15
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef169
cmpl $0x4541, %eax           # imm = 0x4541
jne 0xa341c
movq 0x18(%rbx), %rdi
leaq 0x4(%r12), %rsi
callq 0xef32a
testl %eax, %eax
jne 0xa341c
movq 0x18(%rbx), %rdi
leaq 0x8(%r12), %rsi
callq 0xef0d5
cmpb $0x20, %al
jb 0xa341c
movq 0x18(%rbx), %rdi
leaq 0x16(%r12), %rsi
callq 0xef32a
testl %eax, %eax
je 0xa342f
addq $0x200, %r12            # imm = 0x200
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r12
jl 0xa33d3
jmp 0xa349a
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0xa361c
cmpq $0x0, (%rsp)
jg 0xa344f
movq $0x1, (%rsp)
addq (%rsp), %r12
movl $0x200, %esi            # imm = 0x200
movq %r12, %rdi
callq 0xea80b
movq %rax, %r12
jmp 0xa3423
movl %r13d, %eax
addq %rax, %r15
imulq 0x8(%r14), %r15
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef169
cmpl $0x4541, %eax           # imm = 0x4541
setne %bpl
testb %bpl, %bpl
jne 0xa349a
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xa361c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq