// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/misc2.c
// Function: do_fmtownsicn_table
static void do_fmtownsicn_table(deark *c, struct fmtownsicn_ctx *d, i64 idx,
	i64 pos1)
{
	int saved_indent_level;
	i64 pos = pos1;
	struct fmtownsicn_table_ctx *tbl = NULL;
	i64 i;

	de_dbg_indent_save(c, &saved_indent_level);

	if(pos1+32>c->infile->len) {
		d->fatalerrflag = 1;
		d->need_errmsg = 1;
		goto done;
	}

	tbl = de_malloc(c, sizeof(struct fmtownsicn_table_ctx));
	tbl->idx = idx;

	de_dbg(c, "table #%"I64_FMT" at %"I64_FMT, idx, pos1);
	de_dbg_indent(c, 1);
	pos += 2; // id
	tbl->num_icons = de_getu16le_p(&pos);
	de_dbg(c, "num icons: %u", (UI)tbl->num_icons);
	pos += 2;
	pos += 2;

	tbl->icon_arr_offs = de_getu32le_p(&pos);
	de_dbg(c, "offset of icon array: %"I64_FMT, tbl->icon_arr_offs);
	if(tbl->icon_arr_offs <= pos1) {
		d->fatalerrflag = 1;
		d->need_errmsg = 1;
		goto done;
	}

	for(i=0; i<tbl->num_icons; i++) {
		if(d->fatalerrflag) goto done;
		do_fmtownsicn_icon(c, d, tbl, i, tbl->icon_arr_offs+48*i);
	}

done:
	de_free(c, tbl);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x15b580
movq -0x20(%rbp), %rax
addq $0x20, %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x9ce1f
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1(%rax)
jmp 0x9cf6b
movq -0x8(%rbp), %rdi
movl $0x18, %esi
callq 0x15b780
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x113ef1(%rip), %rsi    # 0x1b0d40
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1652c0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
leaq 0x113eb1(%rip), %rsi    # 0x1b0d52
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x165580
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x113e71(%rip), %rsi    # 0x1b0d60
movb $0x0, %al
callq 0x15b0d0
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x20(%rbp), %rax
jg 0x9cf15
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1(%rax)
jmp 0x9cf6b
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x9cf69
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x9cf36
jmp 0x9cf6b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq 0x10(%rax), %r8
imulq $0x30, -0x40(%rbp), %rax
addq %rax, %r8
callq 0x9cf90
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x9cf1d
jmp 0x9cf6b
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x15b5a0
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)