// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x4fca3(%rip), %rsi     # 0x1d7986
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1876d0
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0x4fc83(%rip), %rsi     # 0x1d799e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1876b0
movq -0x38(%rbp), %rdi
movl %eax, %edx
leaq 0x4fc6f(%rip), %rsi     # 0x1d79b3
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
xorl %eax, %eax
cmpl 0x8(%rdx), %ecx
movb %al, -0x41(%rbp)
jae 0x187d88
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0xc(%rcx), %eax
setb %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x187d94
jmp 0x187ee0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
callq 0x171210
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %ecx
movq -0x30(%rbp), %rax
movzbl 0x2(%rax), %r8d
movl $0x5, %esi
leaq 0x4fbf7(%rip), %rdx     # 0x1d79ca
movb $0x0, %al
callq 0x171660
movl $0x0, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
ja 0x187e95
cmpl $0x1, -0x24(%rbp)
jne 0x187e06
movq -0x20(%rbp), %rdi
leaq 0x309ad(%rip), %rsi     # 0x1b87a9
movl $0x5, %edx
callq 0x1715e0
movq -0x30(%rbp), %rax
movl -0x24(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x187e3a
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movl -0x24(%rbp), %ecx
movl 0x4(%rax,%rcx,4), %ecx
movl $0x5, %esi
leaq 0x4fbae(%rip), %rdx     # 0x1d79df
movb $0x0, %al
callq 0x171660
jmp 0x187e85
movq -0x30(%rbp), %rax
movl -0x24(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x187e6e
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movl -0x24(%rbp), %ecx
movl 0x4(%rax,%rcx,4), %ecx
movl $0x5, %esi
leaq 0x4fb82(%rip), %rdx     # 0x1d79e7
movb $0x0, %al
callq 0x171660
jmp 0x187e83
movq -0x20(%rbp), %rdi
leaq 0x1a60c(%rip), %rsi     # 0x1a2485
movl $0x5, %edx
callq 0x1715e0
jmp 0x187e85
jmp 0x187e87
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x187de1
movq -0x20(%rbp), %rdi
movl $0x5, %esi
leaq 0x4fca1(%rip), %rdx     # 0x1d7b46
movb $0x0, %al
callq 0x171660
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0x172650
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0x18c64(%rip), %rsi     # 0x1a0b2f
movb $0x0, %al
callq 0x15b0d0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x187d5f
movq -0x20(%rbp), %rdi
callq 0x171750
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)