// File: /workspace/github_c_makefile_star2_O2/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 $0xc8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rax, 0x38(%rsp)
movq 0x10(%rsi), %rbp
leaq 0x8(%rbp), %r15
movq %r15, 0x8(%rsp)
movq 0x18(%rsi), %rax
addq %rbp, %rax
movq %rax, 0x58(%rsp)
movl 0x20(%rsi), %eax
movl %eax, 0x4(%rsp)
leaq 0x24(%rsp), %rsi
callq 0xdebae
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
pushq $0x28
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movups 0x10(%r14), %xmm0
movups %xmm0, 0x8(%rax)
movq 0x8(%r14), %rcx
movl (%rcx), %edx
leal 0x1(%rdx), %ecx
movq %rax, 0x18(%rsp)
movl %ecx, (%rax)
cmpl $0xf, %edx
jg 0x6f352
movq %r14, 0x30(%rsp)
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
sete 0x10(%rsp)
leaq 0xaab83(%rip), %rax     # 0x119e28
leaq 0xb441e(%rip), %r14     # 0x1236ca
cmoveq %rax, %r14
movq 0x18(%rbx), %rdi
leaq 0x98(%rsp), %r12
pushq $0x4
popq %rcx
movq %r15, %rsi
movq %r12, %rdx
xorl %r8d, %r8d
callq 0xe657c
addq $0xc, %rbp
leaq 0x8(%rsp), %r15
movq %rbp, (%r15)
movq 0x38(%rsp), %rbp
leaq 0x18(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x6e8b1
leaq 0xaab39(%rip), %rsi     # 0x119e2f
movq %rbx, %rdi
movq %r14, %rdx
movq %r13, 0x48(%rsp)
movq %r13, %rcx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe4071
movq 0x18(%rsp), %r15
movq %rax, 0x18(%r15)
leaq 0xaab14(%rip), %rsi     # 0x119e3b
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdx
cmpq $0x1f5, %rdx            # imm = 0x1F5
jl 0x6f37d
leaq 0xaab0b(%rip), %rsi     # 0x119e53
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x6e9bd
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
movb 0x10(%rsp), %cl
movb %cl, %al
leaq 0x8(,%rax,4), %rax
movq %rax, 0x10(%rsp)
pushq $0x10
popq %rax
movq %rbx, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0xdf66f
movq %rax, 0x20(%r15)
leaq 0x68(%rbp), %rax
movq %rax, 0x28(%rsp)
xorl %r13d, %r13d
movq 0x30(%rsp), %r14
movq %rbx, 0x40(%rsp)
cmpq 0x18(%r15), %r13
jge 0x6f352
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %rax
addq %r15, %rax
cmpq 0x58(%rsp), %rax
jg 0x6f352
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
jne 0x6f402
movq 0x18(%rbx), %rdi
movq %r15, %rsi
leaq 0x60(%rsp), %rdx
pushq $0x4
popq %rcx
xorl %r8d, %r8d
callq 0xe657c
addq $0x4, 0x8(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rbp
movq %rbp, %rsi
callq 0xe4071
movq %rax, %r12
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe4071
movq %rax, %rbp
movq 0x10(%r14), %r14
addq %r12, %r14
cmpl $0x74737472, 0x4(%rsp)  # imm = 0x74737472
jne 0x6f47a
leaq 0x60(%rsp), %rdi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
xorl %edx, %edx
callq 0x6e8b1
movq %rbp, 0x50(%rsp)
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
pushq $0x50
popq %rsi
leaq 0x9889d(%rip), %rdx     # 0x107cfe
movq %rbx, %rcx
movq 0x40(%rsp), %rbx
xorl %eax, %eax
callq 0xde40c
movq %rbp, %rcx
movq 0x50(%rsp), %rbp
jmp 0x6f482
movq 0x28(%rsp), %rcx
movb $0x0, (%rcx)
subq $0x8, %rsp
movq %rbx, %rdi
leaq 0xaa9ef(%rip), %rsi     # 0x119e7f
movl %r13d, %edx
movq %r15, %r8
movq %r14, %r9
xorl %eax, %eax
pushq %rbp
pushq %r12
movq 0x48(%rsp), %r14
pushq 0x10(%r14)
callq 0xde896
addq $0x20, %rsp
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
movq 0x18(%rsp), %r15
movq %r15, %rdx
movq %r13, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0x6e9e8
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
incq %r13
jmp 0x6f3bd