// File: /workspace/github_c_makefile_star2_O3/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 $0xe8, %rsp
movq %rsi, %r15
movq %rdi, %rbp
movq (%rsi), %rax
movq %rax, 0x18(%rsp)
movq 0x10(%rsi), %r12
leaq 0x8(%r12), %r14
movq %r14, 0x8(%rsp)
movq 0x18(%rsi), %rax
addq %r12, %rax
movq %rax, 0x50(%rsp)
movl 0x20(%rsi), %eax
movl %eax, 0x4(%rsp)
leaq 0x2c(%rsp), %rsi
callq 0xe8a1c
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movl $0x28, %esi
movq %rbp, %rdi
callq 0xe8b2b
movups 0x10(%r15), %xmm0
movups %xmm0, 0x8(%rax)
movq %r15, 0x38(%rsp)
movq 0x8(%r15), %rcx
movl (%rcx), %edx
leal 0x1(%rdx), %ecx
movq %rax, 0x20(%rsp)
movl %ecx, (%rax)
cmpl $0xf, %edx
jg 0x73586
xorl %r13d, %r13d
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
sete %bl
leaq 0xb3d30(%rip), %rax     # 0x127028
leaq 0xbd6ae(%rip), %r15     # 0x1309ad
cmoveq %rax, %r15
movq 0x18(%rbp), %rdi
leaq 0xb8(%rsp), %rdx
movq %r14, %rsi
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1762
addq $0xc, %r12
leaq 0x8(%rsp), %r14
movq %r12, (%r14)
movq 0x18(%rsp), %rax
movq %rbp, 0x10(%rsp)
leaq 0x18(%rax), %rbp
leaq 0xc8(%rsp), %rcx
leaq 0xc724f(%rip), %rdx     # 0x13a597
leaq 0x90(%rsp), %r12
movl $0x28, %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0xe8193
movl $0x50, %edx
movq %rbp, %rdi
movq %r12, %rsi
callq 0xe8219
leaq 0xb3cb9(%rip), %rsi     # 0x12702f
movq 0x10(%rsp), %rdi
movq %r15, %rdx
movq %rbp, 0x40(%rsp)
movq %rbp, %rcx
movq 0x10(%rsp), %rbp
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbp), %rdi
movq %r14, %rsi
callq 0xeed31
movq 0x20(%rsp), %r14
movq %rax, 0x18(%r14)
leaq 0xb3c8d(%rip), %rsi     # 0x12703b
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rax
cmpq $0x1f5, %rax            # imm = 0x1F5
jl 0x733df
leaq 0xb3c85(%rip), %rsi     # 0x127053
movq %rbp, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9295
jmp 0x73586
movl $0x10, %edx
movq %rbp, %rdi
movq %rax, %rsi
callq 0xe96f7
movq %rax, 0x20(%r14)
cmpq $0x0, 0x18(%r14)
jle 0x73586
movb %bl, %r13b
leaq 0x8(,%r13,4), %rax
movq %rax, 0x48(%rsp)
movq 0x18(%rsp), %rax
addq $0x68, %rax
movq %rax, 0x30(%rsp)
leaq 0x8(%rsp), %r12
xorl %r15d, %r15d
movq 0x8(%rsp), %r13
movq 0x48(%rsp), %rax
addq %r13, %rax
cmpq 0x50(%rsp), %rax
jg 0x73586
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
jne 0x73465
movq 0x18(%rbp), %rdi
movq %r13, %rsi
leaq 0x60(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1762
addq $0x4, 0x8(%rsp)
movq 0x18(%rbp), %rdi
movq %r12, %rsi
callq 0xeed31
movq %rbp, %rcx
movq %rax, %rbp
movq 0x18(%rcx), %rdi
movq %r12, %rsi
callq 0xeed31
movq %rax, 0x58(%rsp)
movq 0x38(%rsp), %rax
movq 0x10(%rax), %r14
addq %rbp, %r14
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
jne 0x734fe
movl $0x28, %esi
leaq 0x90(%rsp), %r12
movq %r12, %rdi
leaq 0xc70e2(%rip), %rdx     # 0x13a597
leaq 0x70(%rsp), %rcx
xorl %eax, %eax
callq 0xe8193
movl $0x50, %edx
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8219
movl $0x50, %esi
movq 0x30(%rsp), %r12
movq %r12, %rdi
leaq 0xa1874(%rip), %rdx     # 0x114d5e
movq %rbx, %rcx
xorl %eax, %eax
callq 0xe8193
movq %r12, %rcx
leaq 0x8(%rsp), %r12
jmp 0x73506
movq 0x30(%rsp), %rcx
movb $0x0, (%rcx)
subq $0x8, %rsp
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0xb3b66(%rip), %rsi     # 0x12707f
movl %r15d, %edx
movq %r13, %r8
movq %r14, %r9
xorl %eax, %eax
movq 0x60(%rsp), %r13
pushq %r13
pushq %rbp
movq 0x50(%rsp), %r10
pushq 0x10(%r10)
callq 0xe8617
addq $0x20, %rsp
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %r14
movq %r14, %rdx
movq %r15, %rcx
movq %rbp, %r8
movq %rbx, %rbp
movq %r13, %r9
callq 0x7297b
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
incq %r15
cmpq 0x18(%r14), %r15
jl 0x73424
movq 0x20(%rsp), %r14
movq 0x20(%r14), %rsi
movq %rbp, %rdi
callq 0xe8be2
movq %rbp, %rdi
movq %r14, %rsi
callq 0xe8be2
movl 0x2c(%rsp), %esi
movq %rbp, %rdi
callq 0xe8a25
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq