// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/asf.c
// Function: do_metadata_item
static void do_metadata_item(deark *c, lctx *d, i64 pos, i64 val_len,
	unsigned int val_data_type_ori, struct de_stringreaderdata *name_srd,
	u32 object_sid)
{
	de_ucstring *val_str = NULL;
	i64 val_int;
	int handled = 0;
	unsigned int val_data_type; // adjusted type

	de_dbg(c, "value data at %"I64_FMT", len=%d", pos, (int)val_len);

	val_data_type = val_data_type_ori; // default
	if(val_data_type_ori==2) {
		if(object_sid==SID_ECD) {
			val_data_type = 3; // Pretend a 32-bit BOOL is a DWORD
		}
		else {
			val_data_type = 5; // Pretend a 16-bit BOOL is a WORD
		}
	}

	if(val_data_type==0 && val_len>=2) { // Unicode string
		val_str = ucstring_create(c);
		dbuf_read_to_ucstring_n(c->infile, pos, val_len-2, DE_DBG_MAX_STRLEN*2, val_str,
			0, DE_ENCODING_UTF16LE);
		de_dbg(c, "value: \"%s\"", ucstring_getpsz(val_str));
		handled = 1;
	}
	else if(val_data_type==3 && val_len>=4) { // DWORD
		val_int = de_getu32le(pos);
		de_dbg(c, "value: %u", (unsigned int)val_int);
		handled = 1;
	}
	else if(val_data_type==4 && val_len>=8) {
		val_int = de_geti64le(pos);
		if(!de_strcmp(name_srd->sz_utf8, "WM/EncodingTime")) {
			do_WMEncodingTime(c, d, val_int);
		}
		else {
			de_dbg(c, "value: %"I64_FMT, val_int);
		}
		handled = 1;
	}
	else if(val_data_type==5 && val_len>=2) { // WORD
		val_int = de_getu16le(pos);
		de_dbg(c, "value: %u", (unsigned int)val_int);
		handled = 1;
	}
	else if(val_data_type==6 && val_len>=16) { // GUID
		u8 guid_raw[16];
		char guid_string[50];

		read_and_render_guid(c->infile, guid_raw, pos, guid_string, sizeof(guid_string));
		de_dbg(c, "value: {%s}", guid_string);
		handled = 1;
	}
	else if(val_data_type==1) { // binary
		if(!de_strcmp(name_srd->sz_utf8, "ID3")) {
			do_ECD_ID3(c, d, pos, val_len);
			handled = 1;
		}
		else if(!de_strcmp(name_srd->sz_utf8, "WM/Picture")) {
			do_ECD_WMPicture(c, d, pos, val_len);
			handled = 1;
		}
	}

	if(!handled) {
		de_dbg_indent(c, 1);
		de_dbg_hexdump(c, c->infile, pos, val_len, 256, NULL, 0x1);
		de_dbg_indent(c, -1);
	}

	ucstring_destroy(val_str);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
movl %eax, %ecx
leaq 0x179667(%rip), %rsi    # 0x19e811
movb $0x0, %al
callq 0x15b0d0
movl -0x24(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x2, -0x24(%rbp)
jne 0x251d8
cmpl $0xd2, 0x10(%rbp)
jne 0x251cf
movl $0x3, -0x48(%rbp)
jmp 0x251d6
movl $0x5, -0x48(%rbp)
jmp 0x251d8
cmpl $0x0, -0x48(%rbp)
jne 0x25256
cmpq $0x2, -0x20(%rbp)
jl 0x25256
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
subq $0x2, %rdx
movq -0x38(%rbp), %r8
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %r9d, %r9d
movl $0x3, (%rsp)
callq 0x166a40
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x38(%rbp), %rdi
callq 0x172500
movq -0xa8(%rbp), %rdi
movq %rax, %rdx
leaq 0x1795e8(%rip), %rsi    # 0x19e82b
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x44(%rbp)
jmp 0x25423
cmpl $0x3, -0x48(%rbp)
jne 0x2529c
cmpq $0x4, -0x20(%rbp)
jl 0x2529c
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165540
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x19e7bd(%rip), %rsi    # 0x1c3a46
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x44(%rbp)
jmp 0x25421
cmpl $0x4, -0x48(%rbp)
jne 0x2530c
cmpq $0x8, -0x20(%rbp)
jl 0x2530c
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x1657e0
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x17956a(%rip), %rsi    # 0x19e837
callq 0x191a0
cmpl $0x0, %eax
jne 0x252ea
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x25490
jmp 0x25300
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq 0x17954e(%rip), %rsi    # 0x19e847
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x44(%rbp)
jmp 0x2541f
cmpl $0x5, -0x48(%rbp)
jne 0x25352
cmpq $0x2, -0x20(%rbp)
jl 0x25352
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165280
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x19e707(%rip), %rsi    # 0x1c3a46
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x44(%rbp)
jmp 0x2541d
cmpl $0x6, -0x48(%rbp)
jne 0x253a3
cmpq $0x10, -0x20(%rbp)
jl 0x253a3
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x60(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
movl $0x32, %r8d
callq 0x22de0
movq -0x8(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
leaq 0x1794bf(%rip), %rsi    # 0x19e852
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x44(%rbp)
jmp 0x2541b
cmpl $0x1, -0x48(%rbp)
jne 0x25419
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x1794a6(%rip), %rsi    # 0x19e85e
callq 0x191a0
cmpl $0x0, %eax
jne 0x253e0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x254f0
movl $0x1, -0x44(%rbp)
jmp 0x25417
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x179473(%rip), %rsi    # 0x19e862
callq 0x191a0
cmpl $0x0, %eax
jne 0x25415
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x25570
movl $0x1, -0x44(%rbp)
jmp 0x25417
jmp 0x25419
jmp 0x2541b
jmp 0x2541d
jmp 0x2541f
jmp 0x25421
jmp 0x25423
cmpl $0x0, -0x44(%rbp)
jne 0x25470
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl $0x100, %r8d            # imm = 0x100
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, (%rsp)
callq 0x15b840
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x38(%rbp), %rdi
callq 0x171750
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)