// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x8, %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
addq 0x18(%rcx), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x74737472, 0x20(%rax) # imm = 0x74737472
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x94(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xb4(%rbp), %rsi
callq 0x15b580
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x19140
movq -0x8(%rbp), %rdi
movl $0x28, %esi
callq 0x15b780
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
movq -0x80(%rbp), %rax
cmpl $0x10, (%rax)
jle 0xa6a1c
jmp 0xa6d33
cmpl $0x0, -0x94(%rbp)
je 0xa6a40
movq $0xc, -0xa0(%rbp)
leaq 0x10be41(%rip), %rax    # 0x1b2878
movq %rax, -0xb0(%rbp)
jmp 0xa6a59
movq $0x8, -0xa0(%rbp)
leaq 0x115a0b(%rip), %rax    # 0x1bc45d
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x88(%rbp), %rsi
leaq -0x40(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movq -0x88(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x78(%rbp), %rsi
addq $0x18, %rsi
leaq -0x40(%rbp), %rdi
movl $0x50, %edx
xorl %ecx, %ecx
callq 0xa5930
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
movq %rax, %rcx
leaq 0x10bdab(%rip), %rsi    # 0x1b287f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1654b0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rdx
leaq 0x10bd7e(%rip), %rsi    # 0x1b288b
movb $0x0, %al
callq 0x15b0d0
movq -0x80(%rbp), %rax
cmpq $0x1f4, 0x18(%rax)      # imm = 0x1F4
jle 0xa6b43
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
leaq 0x10bd6c(%rip), %rsi    # 0x1b28a3
movb $0x0, %al
callq 0x15bfb0
jmp 0xa6d33
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rsi
movl $0x10, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x20(%rax)
movq $0x0, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq -0x80(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0xa6d31
movq -0x88(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x88(%rbp), %rax
addq -0xa0(%rbp), %rax
cmpq -0x90(%rbp), %rax
jle 0xa6bae
jmp 0xa6d31
cmpl $0x0, -0x94(%rbp)
je 0xa6be9
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x88(%rbp), %rsi
leaq -0x70(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movq -0x88(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1654b0
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1654b0
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpl $0x0, -0x94(%rbp)
je 0xa6c7b
movq -0x78(%rbp), %rsi
addq $0x18, %rsi
leaq -0x70(%rbp), %rdi
movl $0x50, %edx
xorl %ecx, %ecx
callq 0xa5930
movq -0x78(%rbp), %rdi
addq $0x68, %rdi
movq -0x78(%rbp), %rcx
addq $0x18, %rcx
movl $0x50, %esi
leaq 0xf9ebc(%rip), %rdx     # 0x1a0b2e
movb $0x0, %al
callq 0x15a980
jmp 0xa6c83
movq -0x78(%rbp), %rax
movb $0x0, 0x68(%rax)
movq -0x8(%rbp), %rdi
movq -0xa8(%rbp), %rax
movl %eax, %edx
movq -0x78(%rbp), %rcx
addq $0x68, %rcx
movq -0xd8(%rbp), %r8
movq -0xc8(%rbp), %r9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r11
movq -0xc0(%rbp), %r10
movq -0xd0(%rbp), %rax
leaq 0x10bc0c(%rip), %rsi    # 0x1b28cf
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq -0xa8(%rbp), %rcx
movq -0xc0(%rbp), %r8
movq -0xd0(%rbp), %r9
callq 0xa5e00
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0xa6b6f
jmp 0xa6d33
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0xa5d00
movq -0x8(%rbp), %rdi
movl -0xb4(%rbp), %esi
callq 0x15b5a0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax,%rax)