// File: akw0088[P]openssl/huffman.c
// Function: huffman_write_tree_and_make_encode_table
static void _huffman_write_tree_and_make_encode_table(unsigned char *out, unsigned long *outbitctr, unsigned long outlen,
 struct _huffman_encode_table *et,unsigned long code,unsigned int bits,struct _huffman_node *t)
{
	struct _huffman_encode_table *eti;
	unsigned int i;
	unsigned long byte_index;

	byte_index = (*outbitctr)++ >> 3;
	byte_index *= (byte_index < outlen);
	if (t->lr[0])
	{
		out[byte_index] <<= 1;
		_huffman_write_tree_and_make_encode_table(out,outbitctr,outlen,et,code,bits + 1,t->lr[0]);
		_huffman_write_tree_and_make_encode_table(out,outbitctr,outlen,et,code | (1 << bits),bits + 1,t->lr[1]);
	}
	else
	{
		out[byte_index] = (out[byte_index] << 1) | 1;
		for(i = 0; i < 9; ++i)
		{
			byte_index = (*outbitctr)++ >> 3;
			if (byte_index >= outlen)
				return;
			out[byte_index] = (out[byte_index] << 1) | ((unsigned char)((t->c >> i) & 1));
		}
		eti = &(et[t->c]);
		eti->code = code;
		eti->bits = bits;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
shrq $0x3, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
imulq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1bec
movq -0x8(%rbp), %rax
movq -0x48(%rbp), %rcx
movzbl (%rax,%rcx), %edx
shll %edx
movb %dl, (%rax,%rcx)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movl -0x2c(%rbp), %r9d
addl $0x1, %r9d
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, (%rsp)
callq 0x1b00
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %r8
movl -0x2c(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movq -0x50(%rbp), %rcx
cltq
orq %rax, %r8
movl -0x2c(%rbp), %r9d
addl $0x1, %r9d
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, (%rsp)
callq 0x1b00
jmp 0x1cab
movq -0x8(%rbp), %rax
movq -0x48(%rbp), %rcx
movzbl (%rax,%rcx), %eax
shll %eax
orl $0x1, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movq -0x48(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl $0x0, -0x3c(%rbp)
cmpl $0x9, -0x3c(%rbp)
jae 0x1c7c
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
shrq $0x3, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0x1c3c
jmp 0x1cab
movq -0x8(%rbp), %rax
movq -0x48(%rbp), %rcx
movzbl (%rax,%rcx), %eax
shll %eax
movq 0x10(%rbp), %rcx
movq 0x28(%rcx), %rdx
movl -0x3c(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq $0x1, %rcx
movzbl %cl, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movq -0x48(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1c11
movq -0x20(%rbp), %rax
movq 0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movl -0x2c(%rbp), %eax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)