// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/iccprofile.c
// Function: typedec_tagArray_tagStruct
static void typedec_tagArray_tagStruct(deark *c, struct typedec_params *p)
{
	struct de_fourcc ty4cc;
	struct de_fourcc tmp4cc;
	lctx *d = p->d;
	struct tagset_type *tgs = NULL;
	i64 pos = p->pos1 + 8;
	i64 endpos = p->pos1 + p->len;
	int is_struct = (p->type_id == 0x74737472U);
	i64 array_item_size;
	i64 i;
	const char *struct_name;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	de_zeromem(&tmp4cc, sizeof(struct de_fourcc));

	tgs = de_malloc(c, sizeof(struct tagset_type));
	tgs->data_area_pos = p->pos1;
	tgs->data_area_len = p->len;
	tgs->nesting_level = p->tgs->nesting_level+1;
	if(tgs->nesting_level > MAX_NESTING_LEVEL) goto done;

	if(is_struct) {
		array_item_size = 12;
		struct_name = "struct";
	}
	else {
		array_item_size = 8;
		struct_name = "array";
	}

	dbuf_read_fourcc(c->infile, pos, &ty4cc, 4, 0x0);
	pos += 4;
	de_dbg(c, "%s type: %s", struct_name,
		format_4cc_dbgstr(&ty4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0));
	tgs->num_tags = de_getu32be_p(&pos);
	de_dbg(c, "number of elements: %"I64_FMT, tgs->num_tags);
	if(tgs->num_tags>MAX_TAGS_PER_TAGSET) {
		de_err(c, "Invalid or excessive number of elements: %u", (UI)tgs->num_tags);
		goto done;
	}

	tgs->tags_seen = de_mallocarray(c, tgs->num_tags, sizeof(struct tag_seen_type));

	for(i=0; i<tgs->num_tags; i++) {
		i64 elem_pos_rel, elem_pos_abs;
		i64 elem_dlen;
		i64 tpos = pos;

		if(pos+array_item_size > endpos) break;

		if(is_struct) {
			dbuf_read_fourcc(c->infile, pos, &tmp4cc, 4, 0x0);
			pos += 4;
		}

		elem_pos_rel = de_getu32be_p(&pos);
		elem_dlen = de_getu32be_p(&pos);
		elem_pos_abs = p->pos1 + elem_pos_rel;

		if(is_struct) {
			format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0);
			de_snprintf(d->tmpbuf2, sizeof(d->tmpbuf2), " %s", d->tmpbuf1);
		}
		else {
			d->tmpbuf2[0] = '\0';
		}
		de_dbg(c, "elem #%d%s tpos=%"I64_FMT" dpos=%"I64_FMT" (%"I64_FMT"+%"I64_FMT"), dlen=%"I64_FMT,
			(int)i, d->tmpbuf2, tpos, elem_pos_abs, p->pos1, elem_pos_rel, elem_dlen);

		de_dbg_indent(c, 1);
		do_tag_data(c, d, tgs, i, elem_pos_rel, elem_dlen);
		de_dbg_indent(c, -1);
	}

done:
	destroy_tagset(c, tgs);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsi), %rcx
leaq 0x8(%rcx), %rax
movq %rax, 0x10(%rsp)
addq 0x18(%rsi), %rcx
movq %rcx, 0x40(%rsp)
movl 0x20(%rsi), %eax
movl %eax, 0x4(%rsp)
leaq 0x24(%rsp), %rsi
callq 0xe958c
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movl $0x28, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r12
movq 0x10(%r14), %rax
movq %rax, 0x8(%r12)
movq 0x18(%r14), %rax
movq %rax, 0x10(%r12)
movq 0x8(%r14), %rax
movl (%rax), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r12)
cmpl $0xf, %eax
jg 0x73875
movq %r14, 0x30(%rsp)
xorl %r13d, %r13d
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
leaq 0xb3838(%rip), %rax     # 0x126df8
leaq 0xbd0ab(%rip), %r15     # 0x130672
cmoveq %rax, %r15
sete 0x18(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r14
movq (%r14), %rsi
leaq 0xc8(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1d74
addq $0x4, (%r14)
movq 0x8(%rsp), %rax
leaq 0x18(%rax), %rbp
leaq 0xd8(%rsp), %rcx
leaq 0xc6c06(%rip), %rdx     # 0x13a213
movq %r12, 0x38(%rsp)
leaq 0xa0(%rsp), %r12
movl $0x28, %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0xe8d67
movl $0x50, %edx
movq %rbp, %rdi
movq %r12, %rsi
movq 0x38(%rsp), %r12
callq 0xe8ded
leaq 0xb37ba(%rip), %rsi     # 0x126dff
movq %rbx, %rdi
movq %r15, %rdx
movq %rbp, 0x48(%rsp)
movq %rbp, %rcx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef34e
movq %rax, 0x18(%r12)
leaq 0xb3799(%rip), %rsi     # 0x126e0b
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r12), %rax
cmpq $0x1f5, %rax            # imm = 0x1F5
jl 0x736a4
leaq 0xb3790(%rip), %rsi     # 0x126e23
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9df7
jmp 0x73875
movl $0x10, %edx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xea259
movq %rax, 0x20(%r12)
cmpq $0x0, 0x18(%r12)
movq 0x30(%rsp), %r14
jle 0x73875
movb 0x18(%rsp), %al
movb %al, %r13b
leaq 0x8(,%r13,4), %rax
movq %rax, 0x58(%rsp)
movq 0x8(%rsp), %rax
addq $0x68, %rax
movq %rax, 0x28(%rsp)
xorl %r13d, %r13d
movq %rbx, 0x50(%rsp)
movq 0x10(%rsp), %r15
movq 0x58(%rsp), %rax
addq %r15, %rax
cmpq 0x40(%rsp), %rax
jg 0x73875
movq %rax, 0x18(%rsp)
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
jne 0x7373a
movq 0x18(%rbx), %rdi
movq %r15, %rsi
leaq 0x70(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1d74
addq $0x4, 0x10(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xef34e
movq %rax, %rbp
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef34e
movq %rax, 0x60(%rsp)
movq 0x10(%r14), %r14
movq %rbp, 0x68(%rsp)
addq %rbp, %r14
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
jne 0x737d5
movl $0x28, %esi
leaq 0xa0(%rsp), %r12
movq %r12, %rdi
leaq 0xc6a87(%rip), %rdx     # 0x13a213
leaq 0x80(%rsp), %rcx
xorl %eax, %eax
callq 0xe8d67
movl $0x50, %edx
movq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8ded
movl $0x50, %esi
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
leaq 0xa14ea(%rip), %rdx     # 0x114cae
movq %rbx, %rcx
xorl %eax, %eax
callq 0xe8d67
movq 0x8(%rsp), %r12
jmp 0x737e5
movq 0x8(%rsp), %r12
movb $0x0, 0x68(%r12)
movq 0x28(%rsp), %rbp
subq $0x8, %rsp
movq 0x58(%rsp), %rbx
movq %rbx, %rdi
leaq 0xb3657(%rip), %rsi     # 0x126e4f
movl %r13d, %edx
movq %rbp, %rcx
movq %r15, %r8
movq %r14, %r9
xorl %eax, %eax
movq 0x68(%rsp), %rbp
pushq %rbp
movq 0x78(%rsp), %r15
pushq %r15
movq 0x48(%rsp), %r14
pushq 0x10(%r14)
callq 0xe9226
addq $0x20, %rsp
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq %rbx, %rdi
movq %r12, %rsi
movq 0x38(%rsp), %r12
movq %r12, %rdx
movq %r13, %rcx
movq %r15, %r8
movq %rbp, %r9
callq 0x72c28
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x18(%rsp), %rax
cmpq 0x40(%rsp), %rax
jg 0x73875
incq %r13
cmpq 0x18(%r12), %r13
jl 0x736f4
movq 0x20(%r12), %rsi
movq %rbx, %rdi
callq 0xe9752
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe9752
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq