// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/fnt.c
// Function: do_read_char_table
static int do_read_char_table(deark *c, lctx *d)
{
	int retval = 0;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	if(d->is_vector) return 0;

	// There is an extra character at the end of the table that is an
	// "absolute-space" character, and is guaranteed to be blank.
	d->has_abs_space_char = (d->fnt_version>=0x200);

	d->num_chars_stored = (i64)d->last_char - d->first_char + 1;
	if(d->has_abs_space_char) d->num_chars_stored++;
	de_dbg(c, "number of characters: %d", (int)d->num_chars_stored);

	if(d->fnt_version==0x100) {
		d->char_table_pos = 117;
		if(d->dfPixWidth==0) { // proportional raster font
			d->char_entry_size = 2;
		}
		else { // fixed-width raster font
			d->char_entry_size = 0;
		}
	}
	else if(d->fnt_version==0x200) {
		d->char_table_pos = 118;
		d->char_entry_size = 4;
	}
	else { // version 0x300
		d->char_table_pos = 148;
		d->char_entry_size = 6;
	}

	d->char_table_size = d->char_entry_size * d->num_chars_stored;
	de_dbg(c, "character table at %d, size %d, %d bytes/entry",
		(int)d->char_table_pos, (int)d->char_table_size, (int)d->char_entry_size);
	de_dbg_indent(c, 1);

	d->char_table = de_mallocarray(c, d->num_chars_stored, sizeof(struct char_table_entry));

	if(d->char_table_size==0) {
		do_create_char_table_v1(c, d);
	}
	else if(d->fnt_version==0x100) {
		do_read_char_table_v1(c, d);
	}
	else {
		do_read_char_table_v23(c, d);
	}

	if(!do_postprocess_char_table(c, d)) goto done;

	de_dbg_indent(c, -1);

	retval = 1;
done:
	de_dbg_indent_restore(c, saved_indent_level);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x15b580
movq -0x18(%rbp), %rax
cmpl $0x0, 0x7c(%rax)
je 0x6ecfa
movl $0x0, -0x4(%rbp)
jmp 0x6eee7
movq -0x18(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
setae %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x18(%rbp), %rax
movzbl 0x41(%rax), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movzbl 0x40(%rax), %eax
subq %rax, %rcx
addq $0x1, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x80(%rax)
je 0x6ed54
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movl %eax, %edx
leaq 0x13bdb0(%rip), %rsi    # 0x1aab19
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpl $0x100, (%rax)          # imm = 0x100
jne 0x6edaf
movq -0x18(%rbp), %rax
movq $0x75, 0x18(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0x6eda1
movq -0x18(%rbp), %rax
movq $0x2, 0x20(%rax)
jmp 0x6edad
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
jmp 0x6edef
movq -0x18(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x6edd5
movq -0x18(%rbp), %rax
movq $0x76, 0x18(%rax)
movq -0x18(%rbp), %rax
movq $0x4, 0x20(%rax)
jmp 0x6eded
movq -0x18(%rbp), %rax
movq $0x94, 0x18(%rax)
movq -0x18(%rbp), %rax
movq $0x6, 0x20(%rax)
jmp 0x6edef
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x18(%rbp), %rax
imulq 0x48(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl %eax, %r8d
leaq 0x13bd00(%rip), %rsi    # 0x1aab32
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rsi
movl $0x18, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x6ee82
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6f200
jmp 0x6eeac
movq -0x18(%rbp), %rax
cmpl $0x100, (%rax)          # imm = 0x100
jne 0x6ee9d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6f270
jmp 0x6eeaa
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6f370
jmp 0x6eeac
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6f460
cmpl $0x0, %eax
jne 0x6eec0
jmp 0x6eed5
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movl $0x1, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x15b5a0
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq