// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/iccprofile.c
// Function: do_read_main_tags
static void do_read_main_tags(deark *c, lctx *d, i64 pos1)
{
	i64 tagindex;
	struct tagset_type *tgs = NULL;

	de_dbg(c, "tag table at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);

	tgs = de_malloc(c, sizeof(struct tagset_type));
	tgs->data_area_pos = 0;
	if(d->profile_size!=0) {
		tgs->data_area_len = de_min_int(d->profile_size, c->infile->len);
	}
	else {
		tgs->data_area_len = c->infile->len;
	}
	tgs->num_tags = de_getu32be(pos1);
	de_dbg(c, "number of tags: %u", (UI)tgs->num_tags);
	if(tgs->num_tags>MAX_TAGS_PER_TAGSET) {
		de_err(c, "Invalid or excessive number of tags: %u", (UI)tgs->num_tags);
		goto done;
	}
	de_dbg(c, "expected start of data segment: %"I64_FMT, (i64)(pos1+4+12*tgs->num_tags));

	// Make a place to record some information about each tag we encounter in the table.
	tgs->tags_seen = de_mallocarray(c, tgs->num_tags, sizeof(struct tag_seen_type));

	for(tagindex=0; tagindex<tgs->num_tags; tagindex++) {
		do_main_tag(c, d, tgs, tagindex, pos1+4+12*tagindex);
	}

done:
	destroy_tagset(c, tgs);
	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x10c9ca(%rip), %rsi    # 0x1b2165
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movl $0x28, %esi
callq 0x15b780
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xa57ff
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rsi
callq 0x15ccf0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xa5813
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165470
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
leaq 0x10c947(%rip), %rsi    # 0x1b218b
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
cmpq $0x1f4, 0x18(%rax)      # imm = 0x1F4
jle 0xa587a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
leaq 0x10c908(%rip), %rsi    # 0x1b2176
movb $0x0, %al
callq 0x15bfb0
jmp 0xa590c
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x4, %rdx
movq -0x28(%rbp), %rax
imulq $0xc, 0x18(%rax), %rax
addq %rax, %rdx
leaq 0x10c905(%rip), %rsi    # 0x1b219e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rsi
movl $0x10, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0xa590a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %r8
addq $0x4, %r8
imulq $0xc, -0x20(%rbp), %rax
addq %rax, %r8
callq 0xa5ba0
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xa58c9
jmp 0xa590c
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xa5d00
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)