// File: /workspace/github_c_makefile_star2_O3/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 0x72b89
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
testq %r9, %r9
jle 0x72b66
leaq (%rbx,%r14), %rcx
cmpq 0x10(%r12), %rcx
jle 0x729cf
leaq 0xb439a(%rip), %rsi     # 0x126d5a
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9295
jmp 0x72b66
testq %r15, %r15
jle 0x72a02
movl $0x8, %ecx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x72a02
movq 0x20(%r12), %r8
cmpq %r14, -0x8(%r8,%rcx)
jne 0x729f6
cmpq %rbx, (%r8,%rcx)
je 0x72b58
incq %rdx
addq $0x10, %rcx
cmpq %rdx, %r15
jne 0x729db
cmpq $0x4, %rbx
jl 0x72b66
movq %rsi, 0x28(%rsp)
movq %rdi, 0x8(%rsp)
movq 0x18(%rdi), %rdi
movq 0x8(%r12), %rsi
addq %r14, %rsi
leaq 0x58(%rsp), %r13
movq $0x0, 0x18(%rsp)
movq %r13, %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1762
movl 0x4(%r13), %r13d
leaq 0x10f735(%rip), %rax    # 0x182180
leaq 0xb96ff(%rip), %rdx     # 0x12c151
xorl %ecx, %ecx
movl (%rcx,%rax), %ebp
cmpl %r13d, %ebp
je 0x72a70
addq $0x18, %rcx
cmpq $0x450, %rcx            # imm = 0x450
jne 0x72a54
movq %rdx, 0x10(%rsp)
jmp 0x72a91
leaq (%rax,%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rcx,%rax), %rax
testq %rax, %rax
leaq 0xb96c9(%rip), %rcx     # 0x12c151
cmovneq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x28(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x20(%rsp)
leaq 0x68(%rsp), %rcx
leaq 0xc7aec(%rip), %rdx     # 0x13a597
leaq 0x30(%rsp), %rdi
movl $0x28, %esi
xorl %eax, %eax
callq 0xe8193
movl $0x50, %edx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe8219
leaq 0xb42c4(%rip), %rsi     # 0x126d9b
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0xe8617
leaq 0x30(%rsp), %rcx
movq $0x0, 0x20(%rcx)
movq 0x28(%rsp), %rax
movq %rax, (%rcx)
movq %r12, 0x8(%rcx)
movq 0x8(%r12), %rax
addq %r14, %rax
movq %rax, 0x10(%rcx)
movq %rbx, 0x18(%rcx)
leaq 0x68(%rsp), %rax
movl -0xc(%rax), %eax
movl %eax, 0x20(%rcx)
cmpl %r13d, %ebp
jne 0x72b42
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x72b42
leaq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq *%rax
jmp 0x72b66
movq 0x8(%rsp), %rdi
cmpl $0x2, (%rdi)
jl 0x72b66
leaq 0x30(%rsp), %rsi
callq 0x72b8a
jmp 0x72b66
leaq 0xb421b(%rip), %rsi     # 0x126d7a
xorl %eax, %eax
callq 0xe8617
movq 0x20(%r12), %rax
shlq $0x4, %r15
movq %r14, (%rax,%r15)
movq %rbx, 0x8(%rax,%r15)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq