// File: /workspace/github_c_makefile_star2_O1/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 0x15bbd6
movq %rsi, %r14
testq %rsi, %rsi
je 0x15bbd6
movq %rdx, %r12
testq %rdx, %rdx
je 0x15bbdb
movq %rdi, %r15
leaq 0x231db1(%rip), %rsi    # 0x38d6aa
movl $0x38, %edi
movl $0x15a, %edx            # imm = 0x15A
callq 0x1092b2
movq %rax, %rbx
movq %r12, 0x30(%rax)
movq $0x0, 0x28(%rax)
leaq 0x1f21(%rip), %rdi      # 0x15d83f
leaq 0x1f56(%rip), %rsi      # 0x15d87b
xorl %edx, %edx
callq 0x16dec0
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x15bbe0
movq 0x30(%rbx), %rdx
testq %rdx, %rdx
je 0x15b9ca
xorl %r13d, %r13d
xorl %ebp, %ebp
movq %r15, %rdi
movq %rbp, %rsi
callq *%r14
testq %rax, %rax
je 0x15b9be
movq %rax, %r12
movl $0x38, %edi
leaq 0x231d42(%rip), %rsi    # 0x38d6aa
movl $0x7a, %edx
callq 0x1092b2
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 0x16e310
cmpb $0x1, 0xe(%rsp)
jne 0x15bbbd
testq %rax, %rax
je 0x15bbbd
incq 0x28(%rbx)
incq %rbp
movq 0x30(%rbx), %rdx
cmpq %rdx, %rbp
jb 0x15b94b
movq 0x28(%rbx), %rsi
leaq 0x232177(%rip), %rdi    # 0x38db4c
xorl %eax, %eax
callq 0x108e02
movb $0x0, 0xf(%rsp)
movq 0x28(%rbx), %rax
cmpq 0x30(%rbx), %rax
ja 0x15bbe5
testq %rax, %rax
je 0x15ba1a
cmpq $0x1, %rax
jne 0x15ba27
movq 0x18(%rbx), %rdi
callq 0x16ea68
movq %rax, 0x10(%rbx)
movq $0x0, (%rax)
movl $0x1, 0x8(%rax)
jmp 0x15bb4e
movq $0x0, 0x10(%rbx)
jmp 0x15bb4e
xorl %r14d, %r14d
movq 0x18(%rbx), %rdi
callq 0x16ea16
movq %rax, %r12
movq %rax, %rdi
callq 0x15d8c3
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0x16e38c
testl %eax, %eax
jne 0x15bbd1
movq %r14, 0x10(%rsp)
movq 0x18(%rbx), %rdi
callq 0x16ea16
movq %rax, %rbp
movq %rax, %rdi
callq 0x15d8c3
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0x16e38c
testl %eax, %eax
jne 0x15bbcc
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 0x231c03(%rip), %rsi    # 0x38d6aa
movl $0x7a, %edx
callq 0x1092b2
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 0x15bbc2
movq %r15, %rbx
movq %r13, %rsi
leaq 0xf(%rsp), %rdx
callq 0x16e310
cmpb $0x1, 0xf(%rsp)
movq 0x10(%rsp), %r14
jne 0x15bbc7
testq %rax, %rax
je 0x15bbc7
incq %r14
movq 0x28(%rbx), %rax
decq %rax
cmpq %rax, %r14
jb 0x15ba2a
movq %r13, 0x10(%rbx)
movq $0x0, (%r13)
movl $0x0, 0x8(%r13)
movq 0x30(%rbx), %rdi
leaq 0x231b51(%rip), %rdx    # 0x38d6aa
movl $0x10, %esi
movl $0x160, %ecx            # imm = 0x160
callq 0x1093ef
movq %rax, 0x20(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq 0x10(%rbx), %rdi
callq 0x15bbea
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x15bb93
leaq 0xd2(%rip), %rdx        # 0x15bc5d
movq %rbx, %rsi
callq 0x15bcbc
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x15bbab
leaq 0xca(%rip), %rdx        # 0x15bc6d
movq %rbx, %rsi
callq 0x15bcbc
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x49b9f
callq 0x49c83
callq 0x49c4a
callq 0x49c11
callq 0x49bd8
callq 0x49b66
callq 0x49d2e
callq 0x49cf5
callq 0x49cbc