// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/asf.c
// Function: do_ECD_entry
static int do_ECD_entry(deark *c, lctx *d, i64 pos1, i64 len, i64 *bytes_consumed)
{
	i64 pos = pos1;
	struct de_stringreaderdata *name_srd = NULL;
	i64 namelen;
	i64 namelen_to_keep;
	unsigned int val_data_type;
	i64 val_len;
	int retval = 0;
	int saved_indent_level;

	*bytes_consumed = 0;
	de_dbg_indent_save(c, &saved_indent_level);
	de_dbg(c, "ECD object at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);

	if(len<6) goto done;
	namelen = de_getu16le_p(&pos); // # of bytes, including the expected 0x00 0x00 terminator
	namelen_to_keep = namelen-2;
	if(namelen_to_keep<0) namelen_to_keep=0;
	if(namelen_to_keep>256) namelen_to_keep=256;
	name_srd = dbuf_read_string(c->infile, pos, namelen_to_keep, namelen_to_keep,
		DE_CONVFLAG_WANT_UTF8, DE_ENCODING_UTF16LE);
	de_dbg(c, "name: \"%s\"", ucstring_getpsz_d(name_srd->str));
	pos += namelen;

	val_data_type = (unsigned int)de_getu16le_p(&pos);
	de_dbg(c, "value data type: %u (%s)", val_data_type,
		get_metadata_dtype_name(val_data_type));

	val_len = de_getu16le_p(&pos);

	do_metadata_item(c, d, pos, val_len, val_data_type, name_srd, SID_ECD);

	pos += val_len;

	*bytes_consumed = pos-pos1;
	retval = 1;
done:
	de_dbg_indent_restore(c, saved_indent_level);
	de_destroy_stringreaderdata(c, name_srd);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x179ab8(%rip), %rsi    # 0x19e7d5
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
cmpq $0x6, -0x20(%rbp)
jge 0x24d3e
jmp 0x24e7c
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jge 0x24d6e
movq $0x0, -0x48(%rbp)
cmpq $0x100, -0x48(%rbp)     # imm = 0x100
jle 0x24d80
movq $0x100, -0x48(%rbp)     # imm = 0x100
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x10, %r8d
movl $0x3, %r9d
callq 0x1664c0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x172650
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x189404(%rip), %rsi    # 0x1ae1d0
movb $0x0, %al
callq 0x15b0d0
movq -0x40(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1652c0
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x4c(%rbp), %edi
callq 0x25120
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %edx
movq %rax, %rcx
leaq 0x1799cd(%rip), %rsi    # 0x19e7e7
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl -0x4c(%rbp), %r8d
movq -0x38(%rbp), %r9
movl $0xd2, (%rsp)
callq 0x25160
movq -0x58(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rcx
subq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x5c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x15b5a0
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x166830
movl -0x5c(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)