#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct MinHeapNode {
  int dummy;
};

/* Variables and functions */
struct MinHeapNode *buildHuffmanTree(char *, int *, int);
int /*<<< orphan*/ printCodes(struct MinHeapNode *, int *, int);
int /*<<< orphan*/ printf(char *);
void HuffmanCodes(char data[], int freq[], int size) {
  struct MinHeapNode *root = buildHuffmanTree(data, freq, size);
  int arr[100], top = 0;
  printf("\t\t\t\t\t\t\t    USE THE HUFFMAN CODES TO DECODE THE STRING\n\n");
  printf("\t\t\t\t\t\t\t\t\tCHARACTER | CODE \n");
  printf("\t\t\t\t\t\t\t\t\t---------------- \n");
  printCodes(root, arr, top);
  printf("\t\t\t\t\t\t\t\t\t---------------- \n\n");
}


x86 assembly (clang, -O0):
<HuffmanCodes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <buildHuffmanTree@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x1b4(%rbp)
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x1b0(%rbp),%rsi
mov    -0x1b4(%rbp),%edx
call   1040 <printCodes@plt>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HuffmanCodes>:
push   %rbx
sub    $0x190,%rsp
call   1050 <buildHuffmanTree@plt>
mov    %rax,%rbx
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <printCodes@plt>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
add    $0x190,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.MinHeapNode = type { i32 }
@.str = [56 x i8] c"\09\09\09\09\09\09\09 USE THE HUFFMAN CODES TO DECODE THE STRING\0A\0A\00"
@.str.1 = [28 x i8] c"\09\09\09\09\09\09\09\09\09CHARACTER | CODE \0A\00"
@.str.2 = [28 x i8] c"\09\09\09\09\09\09\09\09\09---------------- \0A\00"
@.str.3 = [29 x i8] c"\09\09\09\09\09\09\09\09\09---------------- \0A\0A\00"
define void @HuffmanCodes(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.MinHeapNode*
%8 = alloca [100 x i32]
%9 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = call %struct.MinHeapNode* @buildHuffmanTree(i8* %10, i32* %11, i32 %12)
store %struct.MinHeapNode* %13, %struct.MinHeapNode** %7
store i32 0, i32* %9
%14 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%17 = load %struct.MinHeapNode*, %struct.MinHeapNode** %7
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %8, i64 0, i64 0
%19 = load i32, i32* %9
%20 = call i32 @printCodes(%struct.MinHeapNode* %17, i32* %18, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.MinHeapNode = type { i32 }
@str = [55 x i8] c"\09\09\09\09\09\09\09 USE THE HUFFMAN CODES TO DECODE THE STRING\0A\00"
@str.4 = [27 x i8] c"\09\09\09\09\09\09\09\09\09CHARACTER | CODE \00"
@str.5 = [27 x i8] c"\09\09\09\09\09\09\09\09\09---------------- \00"
@str.6 = [28 x i8] c"\09\09\09\09\09\09\09\09\09---------------- \0A\00"
define void @HuffmanCodes(i8* %0, i32* %1, i32 %2) {
%4 = alloca [100 x i32]
%5 = tail call %struct.MinHeapNode* @buildHuffmanTree(i8* %0, i32* %1, i32 %2)
%6 = bitcast [100 x i32]* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%11 = call i32 @printCodes(%struct.MinHeapNode* %5, i32* %10, i32 0)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
ret void
}