// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x477d2(%rip), %rsi     # 0x14bfe2
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x8(%r14), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
movl $0x0, %edx
cmovgq %rax, %rdx
leaq 0x477bb(%rip), %rsi     # 0x14bffa
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x8(%r14), %rax
movl 0x28(%rax), %edx
leaq 0x477b8(%rip), %rsi     # 0x14c00f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r15
movq %r14, 0x10(%rsp)
movq 0x8(%r14), %rax
cmpl $0x0, 0x8(%rax)
je 0x1049a2
xorl %ebx, %ebx
movl 0xc(%rax), %ecx
cmpq %rcx, %rbx
jae 0x1049a2
movq 0x10(%rax), %rax
leaq (%rbx,%rbx,2), %rcx
leaq (%rax,%rcx,4), %rbp
movq %r15, %rdi
callq 0xf6423
movzbl 0x2(%rbp), %r8d
xorl %r13d, %r13d
movq %r15, %rdi
movl $0x5, %esi
leaq 0x47769(%rip), %rdx     # 0x14c026
movl %ebx, %ecx
xorl %eax, %eax
callq 0xf6653
movb $0x1, %r12b
xorl %r14d, %r14d
testb $0x1, %r13b
je 0x1048e6
movq %r15, %rdi
leaq 0x283f1(%rip), %rsi     # 0x12cccd
movl $0x5, %edx
callq 0xf65e3
movzbl (%rbp,%r14), %eax
cmpl $0x2, %eax
je 0x10490c
cmpl $0x1, %eax
jne 0x104929
movl 0x4(%rbp,%r14,4), %ecx
movq %r15, %rdi
movl $0x5, %esi
leaq 0x47731(%rip), %rdx     # 0x14c03b
jmp 0x104920
movl 0x4(%rbp,%r14,4), %ecx
movq %r15, %rdi
movl $0x5, %esi
leaq 0x47723(%rip), %rdx     # 0x14c043
xorl %eax, %eax
callq 0xf6653
jmp 0x10493d
movq %r15, %rdi
leaq 0x11d36(%rip), %rsi     # 0x116669
movl $0x5, %edx
callq 0xf65e3
movl $0x1, %r14d
movb $0x1, %r13b
testb $0x1, %r12b
movl $0x0, %r12d
jne 0x1048cc
movq %r15, %rdi
movl $0x5, %esi
leaq 0x47854(%rip), %rdx     # 0x14c1b9
xorl %eax, %eax
callq 0xf6653
movq %r15, %rdi
callq 0xf70f6
movq 0x8(%rsp), %rdi
leaq 0x103df(%rip), %rsi     # 0x114d5f
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
incq %rbx
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %ecx
cmpq %rcx, %rbx
jb 0x104886
movq %r15, %rdi
callq 0xf6753
movq 0x8(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8a15