// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/os2ea.c
// Function: eadata_do_ea_sector_by_offset
static void eadata_do_ea_sector_by_offset(deark *c, struct eadata_ctx *d, i64 pos1,
	i64 *pbytes_consumed1)
{
	i64 n;
	i64 pos;
	struct easector_ctx *md = NULL;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	if(pbytes_consumed1) {
		*pbytes_consumed1 = 0;
	}
	md = de_malloc(c, sizeof(struct easector_ctx));

	if(!eadata_is_ea_sector_at_offset(c, d, pos1, 0)) {
		de_err(c, "EA sector not found at %"I64_FMT, pos1);
		goto done;
	}

	de_dbg(c, "EA sector at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);
	pos = pos1+2;
	n = de_getu16le_p(&pos);
	de_dbg(c, "sector number (consistency check): %u", (UI)n);

	pos += 4;

	md->fn = ucstring_create(c);
	dbuf_read_to_ucstring(c->infile, pos, 12, md->fn, DE_CONVFLAG_STOP_AT_NUL, d->input_encoding);
	de_dbg(c, "file name: \"%s\"", ucstring_getpsz_d(md->fn));
	pos += 12;

	pos += 2;
	pos += 4;

	eadata_do_ea_data(c, d, md, pos);
	pos += md->ea_data_len;

	if(pbytes_consumed1) {
		*pbytes_consumed1 = pos - pos1;
	}

done:
	if(md) {
		ucstring_destroy(md->fn);
		de_free(c, md);
	}
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x15b580
cmpq $0x0, -0x20(%rbp)
je 0xf064f
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rdi
movl $0x10, %esi
callq 0x15b780
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
xorl %ecx, %ecx
callq 0xf0f50
cmpl $0x0, %eax
jne 0xf0694
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xcdf95(%rip), %rsi     # 0x1be61d
movb $0x0, %al
callq 0x15bfb0
jmp 0xf07c6
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xcdf95(%rip), %rsi     # 0x1be638
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0xcdf5f(%rip), %rsi     # 0x1be649
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movl (%rax), %r9d
movl $0xc, %edx
movl $0x1, %r8d
callq 0x1669f0
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x172650
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0xcf5ae(%rip), %rsi     # 0x1bfd0d
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0xf1010
movq -0x38(%rbp), %rax
movq (%rax), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xf07c4
movq -0x30(%rbp), %rcx
subq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0xf07c6
cmpq $0x0, -0x38(%rbp)
je 0xf07e7
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171750
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x15b5a0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)