// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/src/fmtutil-huffman.c
// Function: fmtutil_huffman_dump
void fmtutil_huffman_dump(deark *c, struct fmtutil_huffman_decoder *ht)
{
	NODE_REF_TYPE k;
	de_ucstring *tmps = NULL;

	de_dbg(c, "internal huffman table:");
	de_dbg_indent(c, 1);

	de_dbg(c, "number of codes: %"I64_FMT, fmtutil_huffman_get_num_codes(ht->bk));
	de_dbg(c, "max code size: %u bits", fmtutil_huffman_get_max_bits(ht->bk));
	tmps = ucstring_create(c);
	for(k=0; k<ht->bk->next_avail_node && k<ht->bk->nodes_alloc; k++) {
		UI child_idx;
		struct huffman_node *nd = &ht->bk->nodes[k];

		ucstring_empty(tmps);
		ucstring_printf(tmps, DE_ENCODING_LATIN1, "node[%u]: depth=%u (", (UI)k, (UI)nd->depth);

		for(child_idx=0; child_idx<=1; child_idx++) {
			if(child_idx==1) {
				ucstring_append_sz(tmps, " ", DE_ENCODING_LATIN1);
			}
			if(nd->child_status[child_idx]==CHILDSTATUS_POINTER) {
				ucstring_printf(tmps, DE_ENCODING_LATIN1, "next=%u",
					(UI)nd->child[child_idx].hnpd.noderef);
			}
			else if(nd->child_status[child_idx]==CHILDSTATUS_VALUE) {
				ucstring_printf(tmps, DE_ENCODING_LATIN1, "value=%d",
					(int)nd->child[child_idx].hnvd.value);
			}
			else {
				ucstring_append_sz(tmps, "unused", DE_ENCODING_LATIN1);
			}
		}
		ucstring_printf(tmps, DE_ENCODING_LATIN1, ")");
		de_dbg(c, "%s", ucstring_getpsz_d(tmps));
	}
	ucstring_destroy(tmps);
	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x469af(%rip), %rsi     # 0x13eae6
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movq 0x8(%r15), %rax
movq 0x20(%rax), %rdx
testq %rdx, %rdx
cmovleq %rbx, %rdx
leaq 0x4699d(%rip), %rsi     # 0x13eafe
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
movq %r15, 0x20(%rsp)
movq 0x8(%r15), %rax
movl 0x28(%rax), %edx
leaq 0x46995(%rip), %rsi     # 0x13eb13
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
movq %r14, 0x10(%rsp)
movq %r14, %rdi
callq 0xeac74
movq %rax, %r15
pushq $0x5
popq %rbp
leaq 0x278bb(%rip), %r13     # 0x11fa5d
leaq 0x11430(%rip), %rbx     # 0x1095d9
movq $0x0, 0x18(%rsp)
xorl %r14d, %r14d
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %ecx
cmpq %rcx, %r14
jae 0xf82c6
movl 0xc(%rax), %ecx
cmpq %rcx, %r14
jae 0xf82c6
movq 0x10(%rax), %r12
imulq $0xc, %r14, %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
callq 0xeac85
movq 0x8(%rsp), %rax
movzbl 0x2(%r12,%rax), %r8d
movq %r15, %rdi
movl %ebp, %esi
leaq 0x46928(%rip), %rdx     # 0x13eb2a
movq %r14, 0x8(%rsp)
movl %r14d, %ecx
xorl %eax, %eax
callq 0xeae8b
addq 0x18(%rsp), %r12
xorl %r14d, %r14d
cmpq $0x1, %r14
je 0xf8227
cmpq $0x2, %r14
jne 0xf8234
jmp 0xf8282
movq %r15, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0xeae42
movzbl (%r12,%r14), %eax
cmpl $0x2, %eax
je 0xf8256
cmpl $0x1, %eax
jne 0xf8270
movl 0x4(%r12,%r14,4), %ecx
movq %r15, %rdi
movl %ebp, %esi
leaq 0x468eb(%rip), %rdx     # 0x13eb3f
jmp 0xf8267
movl 0x4(%r12,%r14,4), %ecx
movq %r15, %rdi
movl %ebp, %esi
leaq 0x468e0(%rip), %rdx     # 0x13eb47
xorl %eax, %eax
callq 0xeae8b
jmp 0xf827d
movq %r15, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0xeae42
incq %r14
jmp 0xf8219
movq %r15, %rdi
movl %ebp, %esi
leaq 0x46a2b(%rip), %rdx     # 0x13ecb9
xorl %eax, %eax
callq 0xeae8b
movq %r15, %rdi
callq 0xeb877
movq 0x10(%rsp), %rdi
leaq 0xfa56(%rip), %rsi      # 0x107cff
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x8(%rsp), %r14
incq %r14
addq $0xc, 0x18(%rsp)
jmp 0xf81b5
movq %r15, %rdi
callq 0xeaf3c
pushq $-0x1
popq %rsi
movq 0x10(%rsp), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdeba7