// File: /workspace/github_c_makefile_star2_O2/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 0x88cbc(%rip), %rsi     # 0x12580b
callq 0xe07f7
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r14
testq %r15, %r15
je 0x9cb83
testb $0x8, 0x8(%r15)
je 0x9cb83
movq 0x30(%r15), %rdi
callq 0xeaf8a
testl %eax, %eax
je 0x9cb83
movq 0x30(%r15), %rax
movq %rax, 0x10(%r14)
pushq $0x4c
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xdfcf4
testl %eax, %eax
je 0x9cc0c
movl $0x1, 0x4(%r14)
movq %rsp, %r13
andq $0x0, (%r13)
leaq 0x88c8c(%rip), %rsi     # 0x125838
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe40bf
movq %rax, %rbp
leaq 0x88c6c(%rip), %rsi     # 0x125848
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq (%r13), %rdx
addq $-0x4, %rbp
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rcx
callq 0x9ce03
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
jmp 0x9cc87
pushq $0x52
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xdfcf4
testl %eax, %eax
je 0x9cc40
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 0x9ce03
jmp 0x9cc87
testq %r15, %r15
je 0x9cc4c
testb $0x1, 0x8(%r15)
jne 0x9cc6d
leaq 0x88bd6(%rip), %rsi     # 0x125829
movq %rbx, %rdi
callq 0xdfa87
testq %rax, %rax
je 0x9cc84
movq %rax, %rdi
callq 0xdfb36
movl %eax, %r12d
jmp 0x9cc87
movl 0x10(%r15), %r12d
testl %r12d, %r12d
je 0x9cd16
movl $0x1, 0x4(%r14)
jmp 0x9cc87
xorl %r12d, %r12d
pushq $0xd
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe08d2
movl %eax, (%r14)
movq $0x200, 0x8(%r14)       # imm = 0x200
testl %r12d, %r12d
je 0x9cd30
cmpl $0x77ff, %r12d          # imm = 0x77FF
ja 0x9cd16
movq 0x18(%rbx), %rdi
movl %r12d, %esi
shrl $0x6, %esi
andl $0x1fe, %esi            # imm = 0x1FE
addl $0x20, %esi
callq 0xe3fa3
movq %rax, %r13
movq 0x18(%rbx), %rdi
leal 0x200(,%r12,2), %esi
callq 0xe3fa3
movl %eax, %r15d
cmpq $0xffff, %r15           # imm = 0xFFFF
je 0x9cd16
movl %r13d, %eax
addq %rax, %r15
imulq 0x8(%r14), %r15
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x9d64c
testl %eax, %eax
je 0x9cd16
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x9cef8
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x400, %r12d           # imm = 0x400
pushq $0x1
popq %rbp
movq %rsp, %r15
pushq $0x1
popq %r13
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r12
jge 0x9cd16
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x9d64c
testl %eax, %eax
je 0x9cd92
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x9cef8
movq (%rsp), %rdi
testq %rdi, %rdi
jg 0x9cd80
movq $0x1, (%rsp)
movq %r13, %rdi
addq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
callq 0xdfbb6
movq %rax, %r12
jmp 0x9cd40
addq $0x200, %r12            # imm = 0x200
jmp 0x9cd40