// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/huffcode.c
// Function: gt_huffman_new
GtHuffman *gt_huffman_new(const void *distribution,
                          GtDistrFunc distr_func,
                          GtUword num_of_symbols)
{
  GtHuffman *huff;

  gt_assert(distribution && distr_func != NULL);
  gt_assert(num_of_symbols > 0);

  huff = gt_malloc(sizeof (GtHuffman));
  huff->num_of_symbols = num_of_symbols;
  initialise_rbt(huff, distribution, distr_func);
  make_huffman_tree(huff);

  huff->code_tab = gt_calloc((size_t) huff->num_of_symbols,
                             sizeof (GtHuffmanCode));

  huff->num_of_text_symbols = 0;
  huff->num_of_text_bits = 0;
  huffman_tree_set_codes_rec(huff->root_huffman_tree);
  (void) gt_huffman_iterate(huff, calc_size, huff);
  (void) gt_huffman_iterate(huff, store_codes, huff);

  return huff;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x154310
movq %rsi, %r14
testq %rsi, %rsi
je 0x154310
movq %rdx, %r12
testq %rdx, %rdx
je 0x154315
movq %rdi, %r15
leaq 0x2302b9(%rip), %rsi    # 0x3842ea
movl $0x38, %edi
movl $0x15a, %edx            # imm = 0x15A
callq 0x104226
movq %rax, %rbx
movq %r12, 0x30(%rax)
movq $0x0, 0x28(%rax)
leaq 0x1c2c(%rip), %rdi      # 0x155c82
leaq 0x1c61(%rip), %rsi      # 0x155cbe
xorl %edx, %edx
callq 0x165f7c
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x15431a
xorl %r13d, %r13d
cmpq $0x0, 0x30(%rbx)
je 0x154102
xorl %ebp, %ebp
movq %r15, %rdi
movq %rbp, %rsi
callq *%r14
testq %rax, %rax
je 0x1540f4
movq %rax, %r12
movl $0x38, %edi
leaq 0x23024c(%rip), %rsi    # 0x3842ea
movl $0x7a, %edx
callq 0x104226
movq $0x0, (%rax)
movl %r13d, 0x8(%rax)
movq %rbp, 0x18(%rax)
movq %r12, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movl %r13d, 0x30(%rax)
movb $0x0, 0xe(%rsp)
movq 0x18(%rbx), %rdi
movq %rax, %rsi
leaq 0xe(%rsp), %rdx
callq 0x1663b6
cmpb $0x1, 0xe(%rsp)
jne 0x1542f7
testq %rax, %rax
je 0x1542f7
incq 0x28(%rbx)
incq %rbp
movq 0x30(%rbx), %rdx
cmpq %rdx, %rbp
jb 0x154081
jmp 0x154104
xorl %edx, %edx
movq 0x28(%rbx), %rsi
leaq 0x23066a(%rip), %rdi    # 0x384779
xorl %eax, %eax
callq 0x103d72
movb $0x0, 0xf(%rsp)
movq 0x28(%rbx), %rax
cmpq 0x30(%rbx), %rax
ja 0x15431f
testq %rax, %rax
je 0x154154
cmpq $0x1, %rax
jne 0x154161
movq 0x18(%rbx), %rdi
callq 0x166ae4
movq %rax, 0x10(%rbx)
movq $0x0, (%rax)
movl $0x1, 0x8(%rax)
jmp 0x154288
movq $0x0, 0x10(%rbx)
jmp 0x154288
xorl %r14d, %r14d
movq 0x18(%rbx), %rdi
callq 0x166a92
movq %rax, %r12
movq %rax, %rdi
callq 0x155d06
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0x166432
testl %eax, %eax
jne 0x15430b
movq %r14, 0x10(%rsp)
movq 0x18(%rbx), %rdi
callq 0x166a92
movq %rax, %rbp
movq %rax, %rdi
callq 0x155d06
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0x166432
testl %eax, %eax
jne 0x154306
movq %rbx, %r15
movq 0x18(%r12), %rax
movq 0x18(%rbp), %r14
cmpq %r14, %rax
cmovaq %rax, %r14
movq 0x10(%rbp), %rbx
addq 0x10(%r12), %rbx
movl $0x38, %edi
leaq 0x230109(%rip), %rsi    # 0x3842ea
movl $0x7a, %edx
callq 0x104226
movq %rax, %r13
movq $0x0, (%rax)
xorl %eax, %eax
movl %eax, 0x8(%r13)
movq %r14, 0x18(%r13)
movq %rbx, 0x10(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r13)
movl %eax, 0x30(%r13)
movq 0x10(%r12), %rax
cmpq 0x10(%rbp), %rax
movq %r12, %rax
cmovbq %rbp, %rax
cmovbq %r12, %rbp
movq %rax, 0x20(%r13)
movq %rbp, 0x28(%r13)
movq 0x18(%r15), %rdi
testq %rdi, %rdi
je 0x1542fc
movq %r15, %rbx
movq %r13, %rsi
leaq 0xf(%rsp), %rdx
callq 0x1663b6
cmpb $0x1, 0xf(%rsp)
movq 0x10(%rsp), %r14
jne 0x154301
testq %rax, %rax
je 0x154301
incq %r14
movq 0x28(%rbx), %rax
decq %rax
cmpq %rax, %r14
jb 0x154164
movq %r13, 0x10(%rbx)
movq $0x0, (%r13)
movl $0x0, 0x8(%r13)
movq 0x30(%rbx), %rdi
leaq 0x230057(%rip), %rdx    # 0x3842ea
movl $0x10, %esi
movl $0x160, %ecx            # imm = 0x160
callq 0x10436a
movq %rax, 0x20(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq 0x10(%rbx), %rdi
callq 0x154324
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1542e5
leaq 0xd5(%rip), %rdx        # 0x15439a
movq %rbx, %rsi
callq 0x1543f9
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1542e5
leaq 0xcd(%rip), %rdx        # 0x1543aa
movq %rbx, %rsi
callq 0x1543f9
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x48d2b
callq 0x48e0f
callq 0x48dd6
callq 0x48d9d
callq 0x48d64
callq 0x48cf2
callq 0x48eba
callq 0x48e81
callq 0x48e48