// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jl 0xa5e36
jmp 0xa6042
cmpq $0x1, -0x30(%rbp)
jge 0xa5e42
jmp 0xa600d
movq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jle 0xa5e71
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq 0x10c745(%rip), %rsi    # 0x1b25aa
movb $0x0, %al
callq 0x15bfb0
jmp 0xa600d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
leaq -0xa0(%rbp), %rax
movq %rax, (%rsp)
callq 0xa6050
cmpl $0x0, %eax
je 0xa5ebe
movq -0x8(%rbp), %rdi
movq -0xa0(%rbp), %rax
movl %eax, %edx
leaq 0x10c718(%rip), %rsi    # 0x1b25ca
movb $0x0, %al
callq 0x15b0d0
jmp 0xa600d
cmpq $0x4, -0x30(%rbp)
jge 0xa5eca
jmp 0xa600d
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
addq -0x28(%rbp), %rsi
leaq -0x60(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movl -0x5c(%rbp), %edi
callq 0xa6120
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0xa5f2a
movq -0x90(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xa5f2a
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0xa5f38
leaq 0x111cfc(%rip), %rax    # 0x1b7c2d
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
leaq -0x60(%rbp), %rdi
movl $0x50, %edx
xorl %ecx, %ecx
callq 0xa5930
movq -0xa8(%rbp), %rdi
movq %rax, %rdx
movq -0x98(%rbp), %rcx
leaq 0x10c678(%rip), %rsi    # 0x1b25eb
movb $0x0, %al
callq 0x15b0d0
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x19140
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x68(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0xa5ff0
movq -0x90(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xa5ff0
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq *%rax
jmp 0xa600b
movq -0x8(%rbp), %rax
cmpl $0x2, (%rax)
jl 0xa6009
movq -0x8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0xa6180
jmp 0xa600b
jmp 0xa600d
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x20(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x20(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)