// File: /workspace/github_c_makefile_star2_O1/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 0x46d8f(%rip), %rsi     # 0x14b9c6
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x8(%r14), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
movl $0x0, %edx
cmovgq %rax, %rdx
leaq 0x46d78(%rip), %rsi     # 0x14b9de
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x8(%r14), %rax
movl 0x28(%rax), %edx
leaq 0x46d75(%rip), %rsi     # 0x14b9f3
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r15
movq %r14, 0x10(%rsp)
movq 0x8(%r14), %rax
cmpl $0x0, 0x8(%rax)
je 0x104dbd
leaq 0x27d33(%rip), %r13     # 0x12c9e5
xorl %ebp, %ebp
xorl %ebx, %ebx
movl 0xc(%rax), %ecx
cmpq %rcx, %rbx
jae 0x104dbd
movq 0x10(%rax), %r12
leaq (%rbx,%rbx,2), %r14
movq %r15, %rdi
callq 0xf6883
movzbl 0x2(%r12,%r14,4), %r8d
movq %r15, %rdi
movl $0x5, %esi
leaq 0x46d23(%rip), %rdx     # 0x14ba0a
movl %ebx, %ecx
xorl %eax, %eax
callq 0xf6ab0
addq %rbp, %r12
movl $0x1, %r14d
cmpq $0x2, %r14
jne 0x104d0f
movq %r15, %rdi
movq %r13, %rsi
movl $0x5, %edx
callq 0xf6a40
movzbl -0x1(%r12,%r14), %eax
cmpl $0x2, %eax
je 0x104d34
cmpl $0x1, %eax
jne 0x104d50
movl (%r12,%r14,4), %ecx
movq %r15, %rdi
movl $0x5, %esi
leaq 0x46ced(%rip), %rdx     # 0x14ba1f
jmp 0x104d47
movl (%r12,%r14,4), %ecx
movq %r15, %rdi
movl $0x5, %esi
leaq 0x46ce0(%rip), %rdx     # 0x14ba27
xorl %eax, %eax
callq 0xf6ab0
jmp 0x104d64
movq %r15, %rdi
leaq 0x1185f(%rip), %rsi     # 0x1165b9
movl $0x5, %edx
callq 0xf6a40
incq %r14
cmpq $0x2, %r14
je 0x104cf9
movq %r15, %rdi
movl $0x5, %esi
leaq 0x46e1d(%rip), %rdx     # 0x14bb99
xorl %eax, %eax
callq 0xf6ab0
movq %r15, %rdi
callq 0xf7557
movq 0x8(%rsp), %rdi
leaq 0xff18(%rip), %rsi      # 0x114caf
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
incq %rbx
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %ecx
addq $0xc, %rbp
cmpq %rcx, %rbx
jb 0x104cb6
movq %r15, %rdi
callq 0xf6bb0
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 0xe9585