// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/colorix.c
// Function: rixdecomp_read_nodetable
static int rixdecomp_read_nodetable(deark *c, struct rixdecomp_ctx *rhctx)
{
	i64 pos1;
	i64 pos;
	i64 nodetable_dlen_raw;
	int retval = 0;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	pos1 = rhctx->nodetable_pos;
	pos = pos1;
	de_dbg(c, "huffman node table segment at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);
	nodetable_dlen_raw = dbuf_getu16le_p(rhctx->dcmpri->f, &pos);
	rhctx->nodetable_dlen = nodetable_dlen_raw*2;
	de_dbg(c, "node table dlen: %"I64_FMT, rhctx->nodetable_dlen);
	rhctx->nodetable_dpos = pos;
	rhctx->first_cmpr_segment_pos = rhctx->nodetable_dpos + rhctx->nodetable_dlen;

	rhctx->ht = fmtutil_huffman_create_decoder(c, 256, 256);

	// We expect a maximum of 513: 256 leaf entries, + 255 pointer entries,
	// + up to 2 extra zero-valued entries at the end.
	if(nodetable_dlen_raw < 1) {
		de_dfilter_set_generic_error(c, rhctx->dres, rhctx->modname);
		goto done;
	}

	de_dbg2(c, "node table nodes at %"I64_FMT, rhctx->nodetable_dpos);
	de_dbg_indent(c, 1);
	rixdecomp_interpret_nodetable_item(rhctx, rhctx->nodetable_dpos, 0, 0);
	de_dbg_indent(c, -1);

	if(c->debug_level>=4) {
		fmtutil_huffman_dump(c, rhctx->ht);
	}

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x15b580
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x14118d(%rip), %rsi    # 0x1a9fb4
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
shlq %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdx
leaq 0x14115a(%rip), %rsi    # 0x1a9fd6
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rcx
movq -0x10(%rbp), %rax
addq 0x90(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rdi
movl $0x100, %edx            # imm = 0x100
movq %rdx, %rsi
callq 0x188560
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
cmpq $0x1, -0x28(%rbp)
jge 0x68eee
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdx
callq 0x177560
jmp 0x68f62
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdx
leaq 0x1410e7(%rip), %rsi    # 0x1a9feb
movb $0x0, %al
callq 0x15b350
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x69080
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rax
cmpl $0x4, (%rax)
jl 0x68f5b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rsi
callq 0x187cc0
movl $0x1, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x15b5a0
movl -0x2c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)