// File: /workspace/github_c_makefile_star2_O2/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 0x6ec0c
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 0x6ebe9
leaq (%rbx,%r14), %rcx
cmpq 0x10(%r12), %rcx
jle 0x6ea3c
leaq 0xab12d(%rip), %rsi     # 0x119b5a
movl %r15d, %edx
xorl %eax, %eax
callq 0xdf2a5
jmp 0x6ebe9
xorl %edx, %edx
testq %r15, %r15
movl $0x0, %ecx
cmovgq %r15, %rcx
testq %rax, %rax
cmovleq %rdx, %rax
cmpq %rcx, %rax
cmovgeq %rcx, %rax
pushq $0x8
popq %rcx
cmpq %rdx, %rax
je 0x6ea7b
movq 0x20(%r12), %r8
cmpq %r14, -0x8(%r8,%rcx)
jne 0x6ea72
cmpq %rbx, (%r8,%rcx)
je 0x6eaed
incq %rdx
addq $0x10, %rcx
jmp 0x6ea5b
cmpq $0x4, %rbx
jl 0x6ebe9
movq %rsi, 0x20(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x18(%rdi), %rdi
movq 0x8(%r12), %rsi
addq %r14, %rsi
leaq 0x58(%rsp), %rbp
pushq $0x4
popq %rcx
movq %rbp, %rdx
xorl %r8d, %r8d
callq 0xe657c
leaq 0x1166c3(%rip), %rcx    # 0x185178
pushq $0x2f
popq %r13
movl 0x4(%rbp), %eax
leaq 0xb041e(%rip), %rdx     # 0x11eee1
decq %r13
je 0x6eb00
leaq 0x18(%rcx), %rbp
cmpl %eax, 0x18(%rcx)
movq %rbp, %rcx
jne 0x6eac3
movq 0x8(%rbp), %rax
testq %rax, %rax
leaq 0xb03ff(%rip), %rcx     # 0x11eee1
cmovneq %rax, %rcx
movq %rcx, 0x18(%rsp)
jmp 0x6eb07
leaq 0xab086(%rip), %rsi     # 0x119b7a
xorl %eax, %eax
callq 0xde896
jmp 0x6ebe9
xorl %ebp, %ebp
movq %rdx, 0x18(%rsp)
movq 0x20(%rsp), %rax
leaq 0x18(%rax), %rsi
movq %rsi, 0x28(%rsp)
leaq 0x58(%rsp), %rdi
xorl %edx, %edx
callq 0x6e8b1
leaq 0xab073(%rip), %rsi     # 0x119b9b
movq 0x10(%rsp), %rdi
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0xde896
andq $0x0, 0x50(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r12, 0x38(%rsp)
movq 0x8(%r12), %rcx
addq %r14, %rcx
movq %rcx, 0x40(%rsp)
movq %rbx, 0x48(%rsp)
leaq 0x58(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x50(%rsp)
testq %r13, %r13
je 0x6eb8d
movq 0x10(%rbp), %rax
testq %rax, %rax
je 0x6eb8d
leaq 0x30(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq *%rax
jmp 0x6ebe9
cmpq $0x8, %rbx
movq 0x10(%rsp), %r13
jl 0x6ebe9
cmpl $0x2, (%r13)
jl 0x6ebe9
movq 0x18(%r13), %rdi
leaq 0x4(%rcx), %rsi
movq %rcx, %rbp
callq 0xe404f
leaq 0xab2fa(%rip), %rsi     # 0x119eb0
movq %r13, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r13), %rsi
addq $0x8, %rbp
leaq -0x8(%rbx), %rcx
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %r13, %rdi
movq %rbp, %rdx
xorl %r9d, %r9d
callq 0xded3a
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