// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/amigaicon.c
// Function: do_read_tooltypes_table
static int do_read_tooltypes_table(deark *c, lctx *d,
	i64 pos1, i64 *pbytesused)
{
	i64 num_entries_raw;
	i64 num_entries;
	int retval = 0;
	i64 i;
	i64 pos = pos1;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);

	de_dbg(c, "tool types table at %"I64_FMT, pos);
	de_dbg_indent(c, 1);

	num_entries_raw = de_getu32be_p(&pos);
	num_entries = num_entries_raw/4 - 1;
	de_dbg(c, "number of tool types: %d", (int)num_entries);
	if(num_entries<0 || num_entries>1000) {
		goto done;
	}

	for(i=0; i<num_entries; i++) {
		i64 entry_pos;
		i64 tpos;
		i64 tlen;

		entry_pos = pos;
		tlen = de_getu32be_p(&pos);
		tpos = pos;
		de_dbg(c, "tooltype[%d] at %"I64_FMT", dpos=%"I64_FMT", dlen=%"I64_FMT,
			(int)i, entry_pos, tpos, tlen);
		if(tlen>10000) {
			de_err(c, "Bad ToolTypes data");
			goto done;
		}

		de_dbg_indent(c, 1);
		do_one_tooltype(c, d, tpos, tlen);
		de_dbg_indent(c, -1);

		pos += tlen;
	}

	retval = 1;
done:
	*pbytesused = pos - pos1;
	de_dbg_indent_restore(c, saved_indent_level);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq 0x17e957(%rip), %rsi    # 0x19d6ba
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl $0x4, %ecx
cqto
idivq %rcx
subq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
leaq 0x17e91e(%rip), %rsi    # 0x19d6d2
movb $0x0, %al
callq 0x15b0d0
cmpq $0x0, -0x30(%rbp)
jl 0x1edcc
cmpq $0x3e8, -0x30(%rbp)     # imm = 0x3E8
jle 0x1edd1
jmp 0x1eea3
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x1ee9c
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %r8
movq -0x68(%rbp), %r9
leaq 0x17e8c2(%rip), %rsi    # 0x19d6eb
movb $0x0, %al
callq 0x15b0d0
cmpq $0x2710, -0x68(%rbp)    # imm = 0x2710
jle 0x1ee4e
movq -0x8(%rbp), %rdi
leaq 0x17e8ce(%rip), %rsi    # 0x19d713
movb $0x0, %al
callq 0x15bfb0
jmp 0x1eea3
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
callq 0x1efa0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x68(%rbp), %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1edd9
movl $0x1, -0x34(%rbp)
movq -0x48(%rbp), %rcx
subq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x15b5a0
movl -0x34(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)