// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/iccprofile.c
// Function: do_tag_data
static void do_tag_data(deark *c, lctx *d, struct tagset_type *tgs, i64 tagindex,
	i64 tagdataoffset, i64 tagdatalen)
{
	struct de_fourcc tagtype4cc;
	struct typedec_params tdp;
	const struct datatypeinfo *dti;
	const char *dtname;
	i64 idx_of_dup;

	if(tagindex >= tgs->num_tags) return;
	if(tagdatalen<1) goto done;
	if(tagdataoffset+tagdatalen > tgs->data_area_len) {
		de_err(c, "Tag #%d data exceeds its bounds", (int)tagindex);
		goto done;
	}
	if(is_duplicate_data(c, d, tgs, tagindex, tagdataoffset, tagdatalen, &idx_of_dup)) {
		de_dbg(c, "[data is a duplicate of tag #%d]", (int)idx_of_dup);
		goto done;
	}

	if(tagdatalen<4) goto done;

	dbuf_read_fourcc(c->infile, tgs->data_area_pos+tagdataoffset, &tagtype4cc, 4, 0x0);
	dti = lookup_datatypeinfo(tagtype4cc.id);
	if(dti && dti->name) dtname=dti->name;
	else dtname="?";
	de_dbg(c, "data type: %s (%s)",
		format_4cc_dbgstr(&tagtype4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0x0), dtname);

	de_zeromem(&tdp, sizeof(struct typedec_params));
	tdp.d = d;
	tdp.tgs = tgs;
	tdp.pos1 = tgs->data_area_pos+tagdataoffset;
	tdp.len = tagdatalen;
	tdp.type_id = tagtype4cc.id;

	if(dti && dti->dtdfn) {
		dti->dtdfn(c, &tdp);
	}
	else if(c->debug_level>=2) {
		typedec_hexdump(c, &tdp);
	}

done:
	tgs->tags_seen[tagindex].offset = tagdataoffset;
	tgs->tags_seen[tagindex].len = tagdatalen;
}

// Assembly:
movq 0x18(%rdx), %rax
cmpq %rcx, %rax
jle 0x72d51
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
testq %r9, %r9
jle 0x72d31
movq %rdi, %r13
leaq (%rbx,%r14), %rcx
cmpq 0x10(%r12), %rcx
jle 0x72c7f
leaq 0xb3ebd(%rip), %rsi     # 0x126b2a
movq %r13, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9df7
jmp 0x72d31
movq %rsi, %rbp
testq %r15, %r15
jle 0x72cc3
xorl %esi, %esi
testq %rax, %rax
cmovleq %rsi, %rax
movl $0x8, %edi
movq $-0x1, %rdx
movb $0x1, %cl
cmpq %rsi, %rax
je 0x72cd1
movq 0x20(%r12), %r8
cmpq %r14, -0x8(%r8,%rdi)
jne 0x72cb5
cmpq %rbx, (%r8,%rdi)
je 0x72ccc
incq %rsi
addq $0x10, %rdi
cmpq %rsi, %r15
jne 0x72c9c
jmp 0x72cd1
movb $0x1, %cl
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
jmp 0x72cd1
xorl %ecx, %ecx
movq %rsi, %rdx
testb %cl, %cl
je 0x72d20
cmpq $0x4, %rbx
jl 0x72d31
movq 0x18(%r13), %rdi
movq 0x8(%r12), %rsi
addq %r14, %rsi
leaq 0x48(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1d74
leaq 0x48(%rsp), %rax
movl 0x4(%rax), %edx
leaq 0x10f3d8(%rip), %rax    # 0x1820e0
xorl %ecx, %ecx
cmpl %edx, (%rcx,%rax)
je 0x72d52
addq $0x18, %rcx
cmpq $0x450, %rcx            # imm = 0x450
jne 0x72d0a
xorl %eax, %eax
jmp 0x72d55
leaq 0xb3e23(%rip), %rsi     # 0x126b4a
movq %r13, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x20(%r12), %rax
shlq $0x4, %r15
movq %r14, (%rax,%r15)
movq %rbx, 0x8(%rax,%r15)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rcx, %rax
testq %rax, %rax
je 0x72d63
movq 0x8(%rax), %rcx
testq %rcx, %rcx
jne 0x72d6a
leaq 0xb90ff(%rip), %rcx     # 0x12be69
movq %rcx, 0x10(%rsp)
leaq 0x18(%rbp), %rcx
movq %rcx, 0x8(%rsp)
leaq 0x58(%rsp), %rcx
leaq 0xc748f(%rip), %rdx     # 0x13a213
leaq 0x20(%rsp), %rdi
movl $0x28, %esi
movq %rax, 0x18(%rsp)
xorl %eax, %eax
callq 0xe8d67
movl $0x50, %edx
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xe8ded
leaq 0xb3db6(%rip), %rsi     # 0x126b6b
movq %r13, %rdi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0xe9226
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rcx
movaps %xmm0, (%rcx)
movaps %xmm0, 0x10(%rcx)
movq $0x0, 0x20(%rcx)
movq %rbp, (%rcx)
movq %r12, 0x8(%rcx)
movq 0x8(%r12), %rax
addq %r14, %rax
movq %rax, 0x10(%rcx)
movq %rbx, 0x18(%rcx)
leaq 0x58(%rsp), %rax
movl -0xc(%rax), %eax
movl %eax, 0x20(%rcx)
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x72e24
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x72e24
leaq 0x20(%rsp), %rsi
movq %r13, %rdi
callq *%rax
jmp 0x72d31
cmpl $0x2, (%r13)
jl 0x72d31
leaq 0x20(%rsp), %rsi
movq %r13, %rdi
callq 0x72e41
jmp 0x72d31