// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/dms.c
// Function: dmsheavy_read_tree
static int dmsheavy_read_tree(struct lzh_ctx *cctx, struct lzh_tree_wrapper *htw,
	UI ncodes_nbits, UI symlen_nbits)
{
	deark *c = cctx->c;
	UI ncodes;
	UI curr_idx;
	int retval = 0;

	if(htw->ht) goto done;

	ncodes = (UI)de_bitreader_getbits(&cctx->bitrd, ncodes_nbits);
	de_dbg2(c, "num codes: %u", ncodes);

	htw->ht = fmtutil_huffman_create_decoder(c, (i64)ncodes, (i64)ncodes);

	if(ncodes==0) {
		UI null_val;

		null_val = (UI)de_bitreader_getbits(&cctx->bitrd, ncodes_nbits);
		fmtutil_huffman_add_code(c, htw->ht->bk, 0, 0, (fmtutil_huffman_valtype)null_val);
		de_dbg3(c, "val0: %u", null_val);
		retval = 1;
		goto done;
	}

	curr_idx = 0;
	while(curr_idx < ncodes) {
		UI symlen;

		symlen = (UI)de_bitreader_getbits(&cctx->bitrd, symlen_nbits);
		de_dbg3(c, "len[%u] = %u", curr_idx, symlen);
		fmtutil_huffman_record_a_code_length(c, htw->ht->builder, (fmtutil_huffman_valtype)curr_idx, symlen);
		curr_idx++;
	}
	if(cctx->bitrd.eof_flag) goto done;

	if(!fmtutil_huffman_make_canonical_code(c, htw->ht->bk, htw->ht->builder, 0, NULL)) goto done;

	retval = 1;
done:
	if(!retval) {
		lzh_set_err_flag(cctx);
	}
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x67817
jmp 0x67953
movq -0x8(%rbp), %rdi
addq $0x38, %rdi
movl -0x14(%rbp), %esi
callq 0x16a390
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0x14258e(%rip), %rsi    # 0x1a9dc6
movb $0x0, %al
callq 0x15b350
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
movl -0x24(%rbp), %eax
movl %eax, %edx
callq 0x188560
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x0, -0x24(%rbp)
jne 0x678b4
movq -0x8(%rbp), %rdi
addq $0x38, %rdi
movl -0x14(%rbp), %esi
callq 0x16a390
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movl -0x30(%rbp), %r8d
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x187720
movq -0x20(%rbp), %rdi
movl -0x30(%rbp), %edx
leaq 0x142533(%rip), %rsi    # 0x1a9dd4
movb $0x0, %al
callq 0x15b400
movl $0x1, -0x2c(%rbp)
jmp 0x67953
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x67913
movq -0x8(%rbp), %rdi
addq $0x38, %rdi
movl -0x18(%rbp), %esi
callq 0x16a390
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rdi
movl -0x28(%rbp), %edx
movl -0x34(%rbp), %ecx
leaq 0x1424f6(%rip), %rsi    # 0x1a9ddd
movb $0x0, %al
callq 0x15b400
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rsi
movl -0x28(%rbp), %edx
movl -0x34(%rbp), %ecx
callq 0x187f20
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x678bb
movq -0x8(%rbp), %rax
cmpb $0x0, 0x50(%rax)
je 0x6791f
jmp 0x67953
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rdx
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x188020
cmpl $0x0, %eax
jne 0x6794c
jmp 0x67953
movl $0x1, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x67962
movq -0x8(%rbp), %rdi
callq 0x67aa0
movl -0x2c(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)