#include <stdlib.h>
#include <stdio.h>
#include <time.h>
//#include "cutil.h"

void checkCUDAError(const char *msg)
{
    cudaError_t err = cudaGetLastError();
    if (cudaSuccess != err)
    {
        printf("Cuda error: %s: %s.\n", msg, cudaGetErrorString(err));
        printf("\nPress ENTER to exit...\n");
        getchar();
        exit(-1);
    }
}
//name of the input file
#define INPUT_FILE_NAME "input.txt"
//name of the compressed file
#define COMPRESSED_FILE_NAME "compressed.txt"
#define COMPRESSED_FILE_NAME_GPU "compressed_gpu.txt"

//name of the uncompressed file
#define DECOMPRESSED_FILE_NAME "decompressed.txt"
//name of the config file
#define  CONFIG_FILE_NAME "config.txt"
//max number of characters
#define MAX_CHAR 256

//#define MAX_CHAR 30
//max lenght of the number which can occur in char_frequency or char_huffman_table)
#define MAX_LENGTH_OF_NUMBER 10
//lenght of the array in shared memory on device
#define SHARED_MEMORY_SIZE 256
//lenght of the array in const memory on device
#define CONST_MEMORY_SIZE 15000 //(MAX_CHAR*(MAX_CHAR-1))

//To fill and pass the file as an array to GPU
#define MAX_FILE_CHARS 50000
#define BLOCK_SIZE 256


struct node {
   int val;
   int weight;
   struct node * right, * left;
};

//keeps frequency of particular characters (index - symbof of the character, value - frequency of the character)
int char_frequency[MAX_CHAR];
//keeps huffman table
int char_huffman_table[MAX_CHAR][MAX_CHAR-1];
//keeps number which tells how many bits were unused in last byte (variable is set after call compress_file())
int last_byte_padding=0;

//for writing gpu output
int last_byte_padding_gpu = 0;


//keeps number of characters in current input file - file has to have less than 2,147,483,647 characters (variable is set after call read_file())
int number_of_char=0 ;

//To fill and pass the file as an array to GPU
unsigned char *h_input=0,*d_input=0;

// To read char_huffman_table at the GPU
int *d_char_huffman_table=0;

int copiedarray2[MAX_CHAR][MAX_CHAR-1];


__device__ int char_huffman_table_gpu[MAX_CHAR][MAX_CHAR-1];

//To write the output from compression in GPU

 //char *compressedfile_array=0;

 bool *compressedfile_array=0;

 bool *finalcompressed_array=0;

 // To keep track of how many characters each block wrote

 int *block_cntr_array=0;
 int *block_cntr_array_check=0;
 int *d_last_byte_padding=0;

 int *finalsize=0;
 int *orig_number_of_char=0;
 int *huffman_check = (int *)malloc((MAX_CHAR)*(MAX_CHAR-1) *sizeof(int));

 bool *d_bool = 0;

 bool *h_bool = 0;



 __global__ void final_compression(int *block_cntr_array,bool *compressedfile_array,bool *finalcompressed_array,int number_of_char)
 //__device__ void final_compression(int *block_cntr_array,bool *compressedfile_array,bool *finalcompressed_array)
{
int index_blocks=blockIdx.x*blockDim.x+threadIdx.x;
int index_file=(blockIdx.x*blockDim.x+threadIdx.x)*255;
int final_index=0;

if(index_blocks < number_of_char)
{
for(int i=0;i<index_blocks;i++)
{
final_index = final_index+ block_cntr_array[i];
}
for(int i=0;i<block_cntr_array[index_blocks];i++)
{
finalcompressed_array[final_index+i]=compressedfile_array[index_file+i];
}

}
}


//__global__ void computearray_size(int* block_cntr_array,int *finalsize,int *orig_number_of_char)
__device__ void computearray_size(int* block_cntr_array,int *finalsize,int *orig_number_of_char)
{
*finalsize = 0;
for(int i=0;i<*orig_number_of_char;i++)
{
(*finalsize)=(*finalsize) + block_cntr_array[i];
}

}



/*__global__ void compress_file_gpu(unsigned char *d_input,char *compressedfile_array,int *char_huffman_table2,int *block_cntr_array,int* d_last_byte_padding)
{
	int write_counter=0,block_counter=0;	//how many bits have been written in specific byte
	 unsigned char input_char;
	unsigned char output_char = 0x0;
	 unsigned char end_of_file = 255;
	unsigned char mask = 0x01; //00000001;
	int index_file=(blockIdx.x*blockDim.x+threadIdx.x)*255;
	int index_blocks=blockIdx.x*blockDim.x+threadIdx.x;
	

	//for(int i=0;i<MAX_CHAR;i++)
	//{
		//int *row = (int*)((char*)char_huffman_table2 + i * pitch);
		//for (int c = 0; c < MAX_CHAR-1; ++c) {
          //   char_huffman_table_gpu[i][c] = row[c];
        //}
	//}

  			input_char = d_input[index_blocks];			
			for(int i = 0 ; i < (MAX_CHAR - 1) ; i++)				
			{
				if(char_huffman_table2[input_char*255+i] == 0)			//detect if current character on particular position has 0 or 1
				{
					output_char = output_char << 1;					//if 0 then shift bits one position to left (last bit after shifting is 0)
					write_counter++;
					block_counter++;
				}
				else if(char_huffman_table2[input_char*255+i] == 1)
				{
					output_char = output_char << 1;					//if 1 then shift bits one position to left...
					output_char = output_char | mask;				//...and last bit change to: 1
					write_counter++;
					block_counter++;
				}
				else //-1
				{
					//if(input_char == end_of_file)					//if EOF is detected then write current result to file
					//{													
						if(write_counter != 0)
						{
							output_char = output_char << (8-write_counter);
							compressedfile_array[index_file]=output_char;
							output_char = 0x0;
						}
						else	//write_counter == 0
						{
							compressedfile_array[index_file]=output_char;
						}
					//}

					break;
				}

				if(write_counter == 8)								//if result achieved 8 (size of char) then write it to compressed_file
				{
					compressedfile_array[index_file]=output_char;
					output_char = 0x0;
					write_counter = 0;
				}
			}
		
		block_cntr_array[index_blocks]=block_counter;
		*d_last_byte_padding = write_counter;							//to decompress file we have to know how many bits in last byte have been written
		//update_config(write_counter); //TODO to zakomentowac przy ostatecznych pomiarach
	
}*/

//__global__ void compress_file_gpu(unsigned char *d_input,bool *compressedfile_array,int *char_huffman_table2,int *block_cntr_array,int* d_last_byte_padding)
__global__ void compress_file_gpu(unsigned char *d_input,bool *compressedfile_array,int *char_huffman_table2,int *block_cntr_array,int* d_last_byte_padding,int *finalsize,int *orig_number_of_char,int number_of_char)
{
	//int write_counter=0,
	int block_counter=0;	//how many bits have been written in specific byte
	 unsigned char input_char;
	//unsigned char output_char = 0x0;
	 //unsigned char end_of_file = 255;
	//unsigned char mask = 0x01; //00000001;
	int index_file=(blockIdx.x*blockDim.x+threadIdx.x)*255;
	int index_blocks=blockIdx.x*blockDim.x+threadIdx.x;
	
	if(index_blocks < number_of_char) 
	{
	//for(int i=0;i<MAX_CHAR;i++)
	//{
		//int *row = (int*)((char*)char_huffman_table2 + i * pitch);
		//for (int c = 0; c < MAX_CHAR-1; ++c) {
          //   char_huffman_table_gpu[i][c] = row[c];
        //}
	//}

  			input_char = d_input[index_blocks];			
			for(int i = 0 ; i < (MAX_CHAR - 1) ; i++)				
			{
				if(char_huffman_table2[input_char*255+i] == 0)			//detect if current character on particular position has 0 or 1
				{
					//output_char = output_char << 1;					//if 0 then shift bits one position to left (last bit after shifting is 0)
					compressedfile_array[index_file+i] = false;
					//write_counter++;
					block_counter++;
				}
				else if(char_huffman_table2[input_char*255+i] == 1)
				{
					//output_char = output_char << 1;					//if 1 then shift bits one position to left...
					//output_char = output_char | mask;				//...and last bit change to: 1
					//write_counter++;
					compressedfile_array[index_file+i] = true;
					block_counter++;
				}
				else //-1
				{
					/*if(input_char == end_of_file)					//if EOF is detected then write current result to file
					{													
						if(write_counter != 0)
						{
							output_char = output_char << (8-write_counter);
							compressedfile_array[index_file]=output_char;
							output_char = 0x0;
						}
						else	//write_counter == 0
						{
							compressedfile_array[index_file]=output_char;
						}
					}*/

					break;
				}

				/*if(write_counter == 8)								//if result achieved 8 (size of char) then write it to compressed_file
				{
					compressedfile_array[index_file]=output_char;
					output_char = 0x0;
					write_counter = 0;
				}*/
			}
		
		block_cntr_array[index_blocks]=block_counter;
		//*d_last_byte_padding = write_counter;							//to decompress file we have to know how many bits in last byte have been written
		//update_config(write_counter); //TODO to zakomentowac przy ostatecznych pomiarach

		computearray_size(block_cntr_array,finalsize,orig_number_of_char);
		//final_compression(block_cntr_array,compressedfile_array,finalcompressed_array);

	}
	
}


void write_GPU_compressed(bool *final_compressed_cpu,int *finalsize_cpu)
{
FILE *compressed_file;
int write_counter=0;	//how many bits have been written in specific byte
//unsigned char input_char;
unsigned char output_char = 0x0;
//unsigned char end_of_file = 255;
unsigned char mask = 0x01; //00000001;

compressed_file = fopen(COMPRESSED_FILE_NAME_GPU, "wb");	

if ((compressed_file==NULL))
	{
		perror ("Error reading file");		
	}
else
	{
	for(int i = 0 ; i <  (*finalsize_cpu) ; i++)				
			{
			
			if(int(final_compressed_cpu[i]) == 0)
			{
				output_char = output_char << 1;					//if 0 then shift bits one position to left (last bit after shifting is 0)
					write_counter++;
			}
			else if (int(final_compressed_cpu[i]) == 1)
				{
					output_char = output_char << 1;					//if 1 then shift bits one position to left...
					output_char = output_char | mask;				//...and last bit change to: 1
					write_counter++;
				}
			if(write_counter == 8)								//if result achieved 8 (size of char) then write it to compressed_file
				{
					printf("Compressed char in decimal is %d \n", output_char);
					putc(output_char, compressed_file);				
					output_char = 0x0;
					write_counter = 0;
				}	
				
			}
		
		if(write_counter != 0)
						{
							output_char = output_char << (8-write_counter);
							printf("Compressed char in decimal is %d \n", output_char);
							putc(output_char, compressed_file);
							output_char = 0x0;
						}
	
	}
	fclose(compressed_file);
	last_byte_padding_gpu = write_counter;	
}

























void print_dchar_huffman_table()
{

		printf("\n dchar huffman table ");
		getchar();
		bool flag = false;

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printf("Huffman table:\n");
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	
	for(int i = 0 ; i < MAX_CHAR ; i++)
	{		
		flag = false;
		for(int j = 0 ; j < (MAX_CHAR -1) ; j++)
		{		
			if(copiedarray2[i][j] != -1)
			{				
				if(!flag)
				{
					if(i == 10)//new line
					{
						printf("\\n:\t");
					}
					else
					{
						printf("%c:\t",i);
					}
				}
				flag = true;
				printf("%d ", copiedarray2[i][j]);
			}
		}
		if(flag) printf("\n");
	}

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	getchar();
}

//Huffman table construction+++++++++++++++++++++++++++++++++++++++++++++++++++

void insertion_sort(node **forest, int length)
{	
	for(int i = 1; i < length ; i++)
	{	
		node *tmp = forest[i];
		int j = i - 1;
		bool done = false;

		do
		{
			if(forest[j]->weight < tmp->weight)		//> ascending order; < descending order
			{
				forest[j+1] = forest[j];
				j = j-1;
				if(j < 0)
				{
					done = true;
				}
			}
			else
			{
				done = true;
			}
		}while(!done);
		forest[j+1] = tmp;
	}
}

void print_char_frequency()
{
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printf("character frequency:\n");
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");

	for(int i = 0 ; i < MAX_CHAR ; i++)
	{
		if(char_frequency[i] != 0)
		{
			if(i == 10)//new line
			{
				printf("%d)\tval: \\n\tfreq: %d\n",i, char_frequency[i]);
			}
			else
			{
				printf("%d)\tval: %c\tfreq: %d\n",i, i, char_frequency[i]);
			}
		}
	}

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
}


void print_char_huffman_table()
{
	bool flag = false;

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printf("Huffman table:\n");
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	
	for(int i = 0 ; i < MAX_CHAR ; i++)
	{		
		flag = false;
		for(int j = 0 ; j < (MAX_CHAR -1) ; j++)
		{		
			if(char_huffman_table[i][j] != -1)
			{				
				if(!flag)
				{
					if(i == 10)//new line
					{
						printf("\\n:\t");
					}
					else
					{
						printf("%c:\t",i);
					}
				}
				flag = true;
				printf("%d ", char_huffman_table[i][j]);
			}
		}
		if(flag) printf("\n");
	}

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
}

void printout_inorder(node * tree) 
{	

	if(tree->left) printout_inorder(tree->left);

	if(tree->val != NULL)
	{
		if(tree->val == '\n')
		{
			printf("weight: %d\tvalue: \\n\n",tree->weight);
		}
		else
		{
			printf("weight: %d\tvalue: %c\n",tree->weight, tree->val);
		}
	}
	else
	{
		printf("weight: %d\tvalue: NULL\n",tree->weight);
	}

	if(tree->right) printout_inorder(tree->right);
}

void read_file()
{
	FILE *file;
	unsigned char end_of_file = 255;
	 unsigned char c;

	file = fopen(INPUT_FILE_NAME, "r");
  
	if (file==NULL)
	{
		perror ("Error reading file");		
	}
	else
	{
	//storing the file contents into h_input
		h_input = (unsigned char *)malloc(MAX_FILE_CHARS*sizeof(char));
		do
			{
			c = getc (file);
			//if(c == end_of_file) printf("\n Found EOF \n");
			//printf("c before putting into array is %c\n",c);
			h_input[number_of_char]=c;
			number_of_char++;
			char_frequency[c]++;			
		} while (c != end_of_file);

		fclose (file);		
	}
//	h_input[number_of_char] = end_of_file;
	char_frequency[end_of_file] = 0;				//to avoid problems with several EOF in one file
	//EOF is not needed ; so going to decrement
	number_of_char--;
}

void traverse_preorder(node *root, int *path)
{
	if(root->val != NULL)
	{
		for(int i = 0 ; i < MAX_CHAR -1 ; i++)
		{
			char_huffman_table[root->val][i] = path[i];
		}
	}

	if(root->left)//left 1
	{
		int counter = 0;

		for(int i = 0 ; i < MAX_CHAR - 1 ; i++)
		{			
			if(path[i] == -1)
			{
				break;
			}

			counter++;
		}

		path[counter] = 1;

		traverse_preorder(root->left, path);

		path[counter] = -1;
	}
	
	if(root->right)//right 0
	{
		int counter = 0;

		for(int i = 0 ; i < MAX_CHAR - 1 ; i++)
		{			
			if(path[i] == -1)
			{
				break;
			}

			counter++;
		}

		path[counter] = 0;

		traverse_preorder(root->right, path);

		path[counter] = -1;		
	}
}

void construct_huffman_table(node *root)
{		
	int path[MAX_CHAR - 1];
	for(int i = 0 ; i < MAX_CHAR - 1 ; i++)
	{
		path[i] = -1;
	}

	traverse_preorder(root, path);		
}


void build_binary_tree()
{
	int forest_counter = 0;
	node *forest[MAX_CHAR];
	node *curr;

	for(int i = 0 ; i < MAX_CHAR ; i++)		//initial forest
	{
		if(char_frequency[i] != 0)
		{
			curr = (node *)malloc(sizeof(node));
			curr->left = curr->right = NULL;
			curr->val = i;
			curr->weight = char_frequency[i];

			forest[forest_counter] = curr;
			forest_counter++;
		}
	}

	insertion_sort(forest, forest_counter);//sorted initial forest
		
	while(forest_counter > 1)//build final tree
	{
		node *parent;
		parent = (node *)malloc(sizeof(node));
		parent->right = forest[forest_counter-1];
		parent->left = forest[forest_counter-2];
		parent->weight = forest[forest_counter-1]->weight + forest[forest_counter-2]->weight;
		parent->val = NULL;

		forest[forest_counter-1] = NULL;
		forest[forest_counter-2] = parent;
	
		forest_counter--;

		insertion_sort(forest, forest_counter);
	}

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printf("Huffman tree (inorder traversal sequence):\n");
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printout_inorder(forest[0]);
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");

	construct_huffman_table(forest[0]);

	//delete_binary_tree_postorder(forest[0]);	//after building Huffman table we do not need Huffman tree anymore
}

void array_initializer()
{
	for(int i = 0 ; i < MAX_CHAR ; i++)
	{
		char_frequency[i] = 0;
	}

	for(int i = 0 ; i < MAX_CHAR ; i++)
	{
		for(int j = 0 ; j < (MAX_CHAR-1) ; j++)
		{
			char_huffman_table[i][j] = -1;
		}
	}
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//Calculation on CPU+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

void compress_file()
{
	FILE *input_file;
	FILE *compressed_file;
	unsigned char output_char;
	int write_counter;	//how many bits have been written in specific byte
	
	unsigned char input_char;
	unsigned char end_of_file ;
	unsigned char mask ; //00000001;
	
	

	input_file = fopen(INPUT_FILE_NAME, "rb");
	compressed_file = fopen(COMPRESSED_FILE_NAME, "wb");			// apend file (add text to a file or create a file if it does not exist)
	output_char= 0x0;
	write_counter = 0;
	end_of_file = 255;
	mask = 0x01;

  
	if ((input_file==NULL)||(compressed_file==NULL))
	{
		perror ("Error reading file");		
	}
	else
	{
		do
		{
			input_char = getc (input_file);							//read one character from input file
			
			for(int i = 0 ; i < (MAX_CHAR - 1) ; i++)				
			{
				if(char_huffman_table[input_char][i] == 0)			//detect if current character on particular position has 0 or 1
				{
					output_char = output_char << 1;					//if 0 then shift bits one position to left (last bit after shifting is 0)
					write_counter++;
				}
				else if(char_huffman_table[input_char][i] == 1)
				{
					output_char = output_char << 1;					//if 1 then shift bits one position to left...
					output_char = output_char | mask;				//...and last bit change to: 1
					write_counter++;
				}
				else //-1
				{
					if(input_char == end_of_file)					//if EOF is detected then write current result to file
					{													
						if(write_counter != 0)
						{
							output_char = output_char << (8-write_counter);
							printf("Compressed char in decimal is %d \n", output_char);
							putc(output_char, compressed_file);
							output_char = 0x0;
						}
						else	//write_counter == 0
						{
							printf("Compressed char in decimal is %d \n", output_char);
							putc(output_char, compressed_file);				
						}
					}

					break;
				}

				if(write_counter == 8)								//if result achieved 8 (size of char) then write it to compressed_file
				{
					printf("Compressed char in decimal is %d \n", output_char);
					putc(output_char, compressed_file);				
					output_char = 0x0;
					write_counter = 0;
				}
			}

		} while (input_char != end_of_file);

		fclose (input_file);
		fclose(compressed_file);

		last_byte_padding = write_counter;							//to decompress file we have to know how many bits in last byte have been written
		
		//update_config(write_counter); //TODO to zakomentowac przy ostatecznych pomiarach
	}
}


void print_gpu_compressed_file(char *final_compressed_cpu,int finalsize_cpu)
{
FILE *compressed_file;

compressed_file = fopen(COMPRESSED_FILE_NAME_GPU, "wb");	
for(int i=0;i<finalsize_cpu;i++)
{

char c=final_compressed_cpu[i];
printf("i is %d and c is %c",i,c);
putc(c,compressed_file);

}

fclose(compressed_file);

}


void decompress_file()
{
	FILE *compressed_file;
	FILE *decompressed_file;
	unsigned char end_of_file = 255;
	unsigned char mask = 0x7F; //01111111;	
	unsigned char curr;
	unsigned char next;
	int written_char_counter=0;
	int pattern[MAX_CHAR - 1];

	for(int i = 0 ; i < (MAX_CHAR - 1); i++)
	{
		pattern[i] = -1;
	}

	compressed_file = fopen(COMPRESSED_FILE_NAME, "rb");
	decompressed_file = fopen(DECOMPRESSED_FILE_NAME, "wb");

	if ((compressed_file==NULL)||(decompressed_file==NULL))
	{
		perror ("Error reading file");		
	}
	else
	{
		int bit_counter=0;		
		unsigned char first_bit;
		bool read_next = true;

		curr = getc (compressed_file);
		next = getc (compressed_file);					//we have to read one byte in advance due to padding

//		for(int i = 0 ; i < (MAX_CHAR - 1) ; i++)		//builds a pattern and chcecks if it matches to char_huffman_table
		int pattern_counter=-1;
		while(pattern_counter < (MAX_CHAR - 1))
		{ 
			pattern_counter++;

			first_bit = curr | mask;							//check if first bit is 0 or 1

			curr = curr << 1;

			if(bit_counter == 7)
			{
				bit_counter = 0;				

				curr = next;

				if(read_next)
				{
					next = getc (compressed_file);

					if(next == end_of_file)
					{
						if((number_of_char - written_char_counter) < 8)
						{
							read_next = false;
							bit_counter = 7 - last_byte_padding;					
						}
					}
				}											

				if((curr == end_of_file) && ((number_of_char - written_char_counter) < 8))
				{
					break;
				}					
			}
			else
			{
				bit_counter++;
			}

			if(first_bit == 255)
			{
				pattern[pattern_counter] = 1;
			}
			else
			{
				pattern[pattern_counter] = 0;
			}

			bool flag = true;
			for(int j = 0 ; j < MAX_CHAR ; j++)
			{
				flag = true;

				for(int k = 0 ; k < (MAX_CHAR - 1) ; k++)
				{
					if(char_huffman_table[j][k] != pattern[k])
					{
						flag = false;
						break;
					}
				}

				if(flag == true)
				{	
					written_char_counter++;					
					putc(j, decompressed_file);
					
					for(int i = 0 ; i < (MAX_CHAR - 1); i++)
					{
						pattern[i] = -1;
					}

					pattern_counter = -1;

					break;
				}
			}
				
		}

		fclose (compressed_file);		
		fclose (decompressed_file);		
	}
}


void initialize()
{	
	array_initializer();	
	read_file();	
	print_char_frequency();
	build_binary_tree();
	print_char_huffman_table();
}


/*__global__ void compress(int *d_input,int number_of_char,int *d_char_huffman_table,int MAX_CHAR)
{
	int i=0;

	 extern __shared__ int my2DArray[32][32]; //size need to be coded a development time though  
	 my2DArray[threadIdx.x][threadIdx.y] = flatArray[blockDim.x * threadIdx.y + threadIdx.x];
	
}*/


__global__ void read2darray(int *devPtr,int pitch)
{
	int elements[2][2];
	 for (int r = 0; r < 2; ++r) {
        int* row = (int*)((char*)devPtr + r * pitch);
        for (int c = 0; c < 2; ++c) {
             elements[r][c] = row[c];
        }
    }
}


__global__ void check_bool(bool *d_bool)
{
	d_bool[0]=false;
	d_bool[1]=false;
}


void print_huffman()
{

printf(" \n Huffman after copying back \n " );
unsigned char input_char1;
unsigned char input_char2;

unsigned char input_char3;
unsigned char input_char4;

input_char1 = h_input[0];
input_char2 = h_input[1];
input_char3 = h_input[2];
input_char4 = h_input[3];
for (int i=0;i < MAX_CHAR-1;i++)
{
if(huffman_check[ input_char1*255+i]!= -1 )  printf ("\t%c code is  %d  \n", input_char1,huffman_check[ input_char1*255+i]);
}


for (int i=0;i < MAX_CHAR-1;i++)
{
if(huffman_check[ input_char2*255+i]!= -1) printf ("\t%c code is  %d  \n",input_char2, huffman_check[ input_char2*255+i]);
}

for (int i=0;i < MAX_CHAR-1;i++)
{
if(huffman_check[ input_char3*255+i]!= -1 )  printf ("\t%c code is  %d  \n", input_char3,huffman_check[ input_char3*255+i]);
}

for (int i=0;i < MAX_CHAR-1;i++)
{
if(huffman_check[ input_char4*255+i]!= -1 )  printf ("\t%c code is  %d  \n", input_char4,huffman_check[ input_char4*255+i]);
}




}

int main(int argc, char* argv[])
{
	
	int *finalsize_cpu=0;
	unsigned char end_of_file = 255;
	printf("start\n");
	initialize();

	cudaEvent_t start, stop;   	 	// cuda events to measure time
	float elapsed_time,elapsed_time_Cont; 

	cudaEventCreate(&start);     	// timing objects
	cudaEventCreate(&stop);

	unsigned int timer2=0;
	time_t seconds;


// In initialize in cpu,we put the file chars into array, fill huffman table and char_freq_arrays
//copy the input contents into an array
	cudaMalloc((void **)&d_input,number_of_char*sizeof(char));
	checkCUDAError("Error in allocating d_input");	
	cudaMemcpy(d_input,h_input,number_of_char*sizeof(char),cudaMemcpyHostToDevice);
	checkCUDAError("Error in copying d_input");	

	// Allocate space for the compressed file to be used in GPU
	cudaMalloc((void **)&compressedfile_array,number_of_char*(MAX_CHAR -1)*sizeof(bool));
	checkCUDAError("Error in allocating compressedfile_array");	
	//
	cudaMalloc((void **)&d_char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1) * sizeof(int));
	checkCUDAError("Error in allocating d_char_huffman_table");	
	cudaMemcpy(d_char_huffman_table,char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1) * sizeof(int),cudaMemcpyHostToDevice);
	checkCUDAError("Error in copying d_char_huffman_table");	
	cudaMemcpy(huffman_check,d_char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1) * sizeof(int),cudaMemcpyDeviceToHost);
	checkCUDAError("Error in copying back");	

	cudaMalloc((void **)&block_cntr_array,number_of_char*sizeof(int));
	checkCUDAError("Error in allocating block_cntr_array");	

	cudaMalloc((void **)&d_last_byte_padding,sizeof(int));
	checkCUDAError("Error in allocating d_last_byte_padding");	
	cudaMalloc((void **)&finalsize,sizeof(int));
	checkCUDAError("Error in allocating finalsize");	
	cudaMalloc((void **)&orig_number_of_char,sizeof(int));
	checkCUDAError("Error in allocating orig_number_of_char");	
	cudaMemcpy(orig_number_of_char,&number_of_char,sizeof(int),cudaMemcpyHostToDevice);
	checkCUDAError("Error in copying orig_number_of_char");	

	
	
	// check if i can make a boolean array
	h_bool=(bool *) malloc(2*sizeof(bool));
	h_bool[0]=true;
	h_bool[1]=true;
	printf("bool1 is %d and bool2 is %d \n",h_bool[0],h_bool[1]);
	cudaMalloc((void **)&d_bool,2*sizeof(bool));
	checkCUDAError("Error in d_bool");	
	cudaMemcpy(d_bool,h_bool,2*sizeof(bool),cudaMemcpyHostToDevice);
	checkCUDAError("Error in copying d_bool");
	//check_bool<<<1,1>>>(d_bool);
	checkCUDAError("Error in kernel changing d_bool");
	cudaThreadSynchronize();
	checkCUDAError("Error in cudaThreadSynchronize");
	cudaMemcpy(h_bool,d_bool,2*sizeof(bool),cudaMemcpyDeviceToHost);
	checkCUDAError("Error in copying d_bool back");
	printf("Now bool1 is %d and bool2 is %d \n",h_bool[0],h_bool[1]);

	int checkhuff[2][3]= { {0, 0, 0},
							{1, 1, 1} };
	bool flag = true;
	for(int j=0;j<2;j++)
	{	
		flag = true;
			for(int k=0;k<2;k++)
			{
				printf("h_bool is %d \t checkhuff is %d \n",int(h_bool[k]),checkhuff[j][k]);
				if(checkhuff[j][k] != int(h_bool[k]))
				{
					flag = false;
					break;
				}
			}
			if(flag == true)
			{
				printf("pattern for %d is found\n",checkhuff[j][0]);
			}

	}
	


	//copy and send the huffman table as a 2d array to GPU Device
	//int *darray=0;
	//size_t pitch;   
	//cudaMallocPitch( (void**)&darray, &pitch, 2 * sizeof(int), 2); 
	//cudaMemcpy2D(darray,pitch,harray,2*sizeof(int),2*sizeof(int),2,cudaMemcpyHostToDevice);
	//cudaMalloc((void **)&darray,4*sizeof(int));
	//cudaMemcpy(darray,harray,4*sizeof(int),cudaMemcpyHostToDevice);
	//cudaMemcpy2D(copiedarray,2*sizeof(int),darray,pitch,pitch,2,cudaMemcpyDeviceToHost);
//	cudaMemcpy2D(copiedarray,2*sizeof(int),darray,pitch,2*sizeof(int),2,cudaMemcpyDeviceToHost);
	//printf("After copying back %d, \t %d, \t %d,  \t %d \n",copiedarray[0][0],copiedarray[0][1],copiedarray[1][0],copiedarray[1][1]);
	//int *darray_2d=0;
	//cudaMalloc((void **)&darray_2d,4*sizeof(int));
	//cudaMemcpy(darray,harray,4*sizeof(int),cudaMemcpyHostToDevice);
//	read2darray<<<1,1>>>(darray, pitch); 
	
	//size_t pitch2;   
	//cudaMallocPitch( (void**)&d_char_huffman_table, &pitch2, (MAX_CHAR-1) * sizeof(int), MAX_CHAR); 
	
	
	//cudaMemcpy2D(d_char_huffman_table,pitch2,char_huffman_table,(MAX_CHAR-1) * sizeof(int),(MAX_CHAR-1) * sizeof(int),MAX_CHAR,cudaMemcpyHostToDevice);
	
	//cudaMemcpy2D(char_huffman_table_gpu,(MAX_CHAR-1) * sizeof(int),char_huffman_table,(MAX_CHAR-1) * sizeof(int),(MAX_CHAR-1) * sizeof(int),MAX_CHAR,cudaMemcpyHostToDevice);
	//checkCUDAError("Error in char_huffman_table_gpu");	
	//cudaMemcpy2D(copiedarray2,(MAX_CHAR-1)*sizeof(int),d_char_huffman_table,pitch2,(MAX_CHAR-1)*sizeof(int),MAX_CHAR,cudaMemcpyDeviceToHost);
	
	//cudaMemcpy2D(copiedarray2,(MAX_CHAR-1)*sizeof(int),char_huffman_table_gpu,(MAX_CHAR-1) * sizeof(int),(MAX_CHAR-1) * sizeof(int),MAX_CHAR,cudaMemcpyDeviceToHost);
//cudaMemcpy(orig_number_of_char,&number_of_char,sizeof(int),cudaMemcpyHostToDevice);
//	checkCUDAError("Error in copiedarray2");	
//	print_dchar_huffman_table();
	printf("\n the number of characters in the input file is %d \n",number_of_char);
	getchar();
	/*for(int i=0;i<number_of_char;i++)
	{
		if( h_input[i] == end_of_file ) printf(" EOF \n");
		printf(" Copying into array: i is %d  and c is %c \n",i,h_input[i]);
	}*/
	


	getchar();
	print_huffman();
	
	int no_of_blocks = (number_of_char + BLOCK_SIZE -1)/BLOCK_SIZE;
		printf("no_of_blocksis %d \n", no_of_blocks);
	if(no_of_blocks == 0) no_of_blocks =1;

	//compress_file_gpu<<<number_of_char,1>>>(d_input,compressedfile_array,d_char_huffman_table,block_cntr_array,d_last_byte_padding);
	cudaEventRecord(start, 0);		// start time
	checkCUDAError("Error in cudaEventRecord start \n");	
	compress_file_gpu<<<no_of_blocks,BLOCK_SIZE>>>(d_input,compressedfile_array,d_char_huffman_table,block_cntr_array,d_last_byte_padding,finalsize,orig_number_of_char,number_of_char);
	checkCUDAError("Error in compress_file_gpu \n");	
	cudaThreadSynchronize();

	//cudaMalloc((void **)&block_cntr_array_check,number_of_char*sizeof(int));
	//checkCUDAError("Error in allocating block_cntr_array_check");	
	block_cntr_array_check = (int *) malloc(number_of_char*sizeof(int));
	
	cudaMemcpy(block_cntr_array_check,block_cntr_array,number_of_char*sizeof(int),cudaMemcpyDeviceToHost);
	checkCUDAError("Error in copying back block_cntr_array_check");

	for(int i=0; i < number_of_char; i++)
	{
		printf(" block size for i = %d is %d \n",i, block_cntr_array_check[i]);
	}


//	computearray_size<<<1,1>>>(block_cntr_array,finalsize,orig_number_of_char);
	checkCUDAError("Error in Compute array \n");
		finalsize_cpu = (int *)malloc(sizeof(int));
	cudaMemcpy(finalsize_cpu,finalsize,sizeof(int),cudaMemcpyDeviceToHost);
	printf("The final compressed array size is %d \n ", *finalsize_cpu);
	checkCUDAError("Error in finalsize_cpu");
	int block = *finalsize_cpu;
	//allocate space for the final compressed array

	cudaMalloc((void **)&finalcompressed_array,((*finalsize_cpu)*sizeof(bool)));
	checkCUDAError("cudaMemcpyHostToDevice");
	
	final_compression<<<no_of_blocks,BLOCK_SIZE>>>(block_cntr_array,compressedfile_array,finalcompressed_array,number_of_char);
	checkCUDAError("Error in final_compression call \n");

	cudaThreadSynchronize();
	checkCUDAError("Error in cudaThreadSynchronize \n");
	cudaEventRecord(stop, 0); 
	checkCUDAError("Error in cudaEventRecord stop \n");

	cudaEventSynchronize(stop);
	cudaEventElapsedTime(&elapsed_time, start, stop);
	printf("Time to calculate results: %f ms.\n", elapsed_time);  // print out execution time

	bool *final_compressed_cpu=0;
	final_compressed_cpu = (bool *)malloc((*finalsize_cpu)*sizeof(bool));
	cudaMemcpy(final_compressed_cpu,finalcompressed_array,((*finalsize_cpu)*sizeof(bool)),cudaMemcpyDeviceToHost);
	checkCUDAError("Error in copying final_compressed_cpu\n");
	//print_gpu_compressed_file(final_compressed_cpu,*finalsize_cpu);
	printf("The compressed value in binary is ");

	write_GPU_compressed(final_compressed_cpu,finalsize_cpu);
	for(int i=0;i<*finalsize_cpu;i++)
	//	sprintf(compress_file+i,final_compressed_cpu[i]);

	//printf("i is %d and val is %d \n",i,final_compressed_cpu[i]);
	printf("\n");




//	cudaMalloc((void **)&d_char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1)*sizeof(int));
//	cudaMemcpy(d_char_huffman_table,char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1)*sizeof(int),cudaMemcpyHostToDevice);
//	printf("\n Going to compress on the GPU ");
//	compress<<<number_of_char,1>>>(d_input,number_of_char,d_char_huffman_table,MAX_CHAR);

//test ends
	
	printf("compressing on CPU...\n");
	  //timer2=0;
	// CUT_SAFE_CALL(cutCreateTimer(&timer2));
	 //CUT_SAFE_CALL(cutStartTimer(timer2));

	/*clock_t Linuxclock_start,Linuxclock_end;		// clock return type
	cudaEvent_t CUDAevent_start, CUDAevent_end;
	float CUDAEvents_time; 
	cudaEventRecord(CUDAevent_start, 0 );
	cudaEventSynchronize(CUDAevent_start);  
	Linuxclock_start = clock();*/
	/*time_t before,after;

	before = time (NULL);*/
clock_t start1, stop1;
	start1 = clock();
	compress_file();
	stop1 = clock();
float elapsedTime = (float)(stop1 - start1) /
(float)CLOCKS_PER_SEC * 1000.0f;
printf( "Time in cpu : %3.1f ms\n", elapsedTime );
printf("Time to calculate results: %f ms.\n", elapsed_time);  // print out execution time

printf("Speedup achieved is %lf \n", elapsedTime/elapsed_time );
	/*after = time (NULL);
	double dif;
	dif = difftime (after,before);
	printf ("It took you %.9lf seconds to type your name.\n", dif );*/



	/*Linuxclock_end = clock();
	cudaEventRecord(CUDAevent_end, 0 );    	 // instrument code to measure end time
	cudaEventSynchronize(CUDAevent_end);
	cudaEventElapsedTime(&CUDAEvents_time, CUDAevent_start, CUDAevent_end);
	printf("CPU Time using CUDA events: %f ms\n", CUDAEvents_time);  // time_CUDAEvents is in ms
	printf("CPU Time using Linux clock: %f ms\n", ((double) (Linuxclock_end - Linuxclock_start) * 1000)/CLOCKS_PER_SEC);  //Linuxclock in sec
	cudaEventDestroy(CUDAevent_start);
	cudaEventDestroy(CUDAevent_end);*/

	//CUT_SAFE_CALL(cutStopTimer(timer2));
	//float time2=cutGetAverageTimerValue(timer2); 
	//printf("  Time on Host %f\n", time2);

	printf("decompressing on CPU...\n");
	decompress_file();

	getchar();
	return 0;
}

	.file	"tmpxft_0024e64e_00000000-6_gpulab1_1.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2048:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2048:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Cuda error: %s: %s.\n"
.LC1:
	.string	"\nPress ENTER to exit...\n"
	.text
	.globl	_Z14checkCUDAErrorPKc
	.type	_Z14checkCUDAErrorPKc, @function
_Z14checkCUDAErrorPKc:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	cudaGetLastError@PLT
	testl	%eax, %eax
	je	.L2
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	getchar@PLT
	orl	$-1, %edi
	call	exit@PLT
.L2:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z14checkCUDAErrorPKc, .-_Z14checkCUDAErrorPKc
	.globl	_Z17computearray_sizePiS_S_
	.type	_Z17computearray_sizePiS_S_, @function
_Z17computearray_sizePiS_S_:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z17computearray_sizePiS_S_, .-_Z17computearray_sizePiS_S_
	.section	.rodata.str1.1
.LC2:
	.string	"wb"
.LC3:
	.string	"compressed_gpu.txt"
.LC4:
	.string	"Error reading file"
.LC5:
	.string	"Compressed char in decimal is %d \n"
	.text
	.globl	_Z20write_GPU_compressedPbPi
	.type	_Z20write_GPU_compressedPbPi, @function
_Z20write_GPU_compressedPbPi:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	leaq	.LC3(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	leaq	.LC2(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	pushq	%rdx
	.cfi_def_cfa_offset 64
	call	fopen@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	jne	.L15
	leaq	.LC4(%rip), %rdi
	xorl	%r15d, %r15d
	call	perror@PLT
	jmp	.L10
.L15:
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	leaq	.LC5(%rip), %r14
	xorl	%r15d, %r15d
.L9:
	cmpl	%ebx, (%r12)
	jle	.L17
	incl	%r15d
	addl	%eax, %eax
	orb	0(%r13,%rbx), %al
	cmpl	$8, %r15d
	jne	.L11
	movzbl	%al, %r15d
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movl	%r15d, %edx
	call	__printf_chk@PLT
	movl	%r15d, %edi
	movq	%rbp, %rsi
	xorl	%r15d, %r15d
	call	putc@PLT
	xorl	%eax, %eax
.L11:
	incq	%rbx
	jmp	.L9
.L17:
	testl	%r15d, %r15d
	je	.L10
	movl	$8, %ecx
	movzbl	%al, %ebx
	movl	$2, %edi
	xorl	%eax, %eax
	subl	%r15d, %ecx
	leaq	.LC5(%rip), %rsi
	sall	%cl, %ebx
	movzbl	%bl, %ebx
	movl	%ebx, %edx
	call	__printf_chk@PLT
	movq	%rbp, %rsi
	movl	%ebx, %edi
	call	putc@PLT
.L10:
	movq	%rbp, %rdi
	call	fclose@PLT
	movl	%r15d, last_byte_padding_gpu(%rip)
	popq	%rax
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z20write_GPU_compressedPbPi, .-_Z20write_GPU_compressedPbPi
	.section	.rodata.str1.1
.LC6:
	.string	"\n dchar huffman table "
.LC7:
	.string	"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
.LC8:
	.string	"Huffman table:\n"
.LC9:
	.string	"\\n:\t"
.LC10:
	.string	"%c:\t"
.LC11:
	.string	"%d "
.LC12:
	.string	"\n"
	.text
	.globl	_Z25print_dchar_huffman_tablev
	.type	_Z25print_dchar_huffman_tablev, @function
_Z25print_dchar_huffman_tablev:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC11(%rip), %r15
	leaq	copiedarray2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC7(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 64
	call	__printf_chk@PLT
	call	getchar@PLT
	movq	%r12, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r12, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L19:
	movq	%r14, %rbp
	movl	$255, %r13d
	xorl	%eax, %eax
.L23:
	cmpl	$-1, 0(%rbp)
	je	.L20
	testb	%al, %al
	jne	.L21
	cmpl	$10, %ebx
	jne	.L22
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L21
.L22:
	movl	%ebx, %edx
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L21:
	movl	0(%rbp), %edx
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movb	$1, %al
.L20:
	addq	$4, %rbp
	decl	%r13d
	jne	.L23
	testb	%al, %al
	je	.L24
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L24:
	incl	%ebx
	addq	$1020, %r14
	cmpl	$256, %ebx
	jne	.L19
	movq	%r12, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rax
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	getchar@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z25print_dchar_huffman_tablev, .-_Z25print_dchar_huffman_tablev
	.globl	_Z14insertion_sortPP4nodei
	.type	_Z14insertion_sortPP4nodei, @function
_Z14insertion_sortPP4nodei:
.LFB2031:
	.cfi_startproc
	endbr64
	movl	$1, %ecx
.L32:
	cmpl	%ecx, %esi
	jle	.L37
	movq	(%rdi,%rcx,8), %r8
	leaq	-1(%rcx), %rax
	movl	4(%r8), %r9d
.L35:
	movq	(%rdi,%rax,8), %rdx
	cmpl	%r9d, 4(%rdx)
	jge	.L33
	movq	%rdx, 8(%rdi,%rax,8)
	decq	%rax
	movl	%eax, %edx
	cmpl	$-1, %eax
	jne	.L35
	jmp	.L34
.L33:
	movl	%eax, %edx
.L34:
	incl	%edx
	incq	%rcx
	movslq	%edx, %rdx
	movq	%r8, (%rdi,%rdx,8)
	jmp	.L32
.L37:
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z14insertion_sortPP4nodei, .-_Z14insertion_sortPP4nodei
	.section	.rodata.str1.1
.LC13:
	.string	"character frequency:\n"
.LC14:
	.string	"%d)\tval: \\n\tfreq: %d\n"
.LC15:
	.string	"%d)\tval: %c\tfreq: %d\n"
	.text
	.globl	_Z20print_char_frequencyv
	.type	_Z20print_char_frequencyv, @function
_Z20print_char_frequencyv:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	char_frequency(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC7(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rbp, %rsi
	xorl	%ebx, %ebx
	call	__printf_chk@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L43:
	movl	(%r12,%rbx,4), %r8d
	testl	%r8d, %r8d
	je	.L39
	cmpq	$10, %rbx
	jne	.L40
	movl	%r8d, %ecx
	movl	$10, %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC14(%rip), %rsi
	movl	$11, %ebx
	call	__printf_chk@PLT
	jmp	.L43
.L40:
	movl	%ebx, %edx
	movl	%ebx, %ecx
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L39:
	incq	%rbx
	cmpq	$256, %rbx
	jne	.L43
	popq	%rbx
	.cfi_def_cfa_offset 24
	movq	%rbp, %rsi
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z20print_char_frequencyv, .-_Z20print_char_frequencyv
	.globl	_Z24print_char_huffman_tablev
	.type	_Z24print_char_huffman_tablev, @function
_Z24print_char_huffman_tablev:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC11(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	char_huffman_table(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC7(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 64
	call	__printf_chk@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r12, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L49:
	movq	%r14, %rbp
	movl	$255, %r13d
	xorl	%eax, %eax
.L53:
	cmpl	$-1, 0(%rbp)
	je	.L50
	testb	%al, %al
	jne	.L51
	cmpl	$10, %ebx
	jne	.L52
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L51
.L52:
	movl	%ebx, %edx
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L51:
	movl	0(%rbp), %edx
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movb	$1, %al
.L50:
	addq	$4, %rbp
	decl	%r13d
	jne	.L53
	testb	%al, %al
	je	.L54
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L54:
	incl	%ebx
	addq	$1020, %r14
	cmpl	$256, %ebx
	jne	.L49
	popq	%rdx
	.cfi_def_cfa_offset 56
	movq	%r12, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2033:
	.size	_Z24print_char_huffman_tablev, .-_Z24print_char_huffman_tablev
	.section	.rodata.str1.1
.LC16:
	.string	"weight: %d\tvalue: \\n\n"
.LC17:
	.string	"weight: %d\tvalue: %c\n"
.LC18:
	.string	"weight: %d\tvalue: NULL\n"
	.text
	.globl	_Z16printout_inorderP4node
	.type	_Z16printout_inorderP4node, @function
_Z16printout_inorderP4node:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC18(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 32
.L66:
	movq	16(%rbx), %rdi
	testq	%rdi, %rdi
	je	.L62
	call	_Z16printout_inorderP4node
.L62:
	movl	(%rbx), %ecx
	movl	4(%rbx), %edx
	testl	%ecx, %ecx
	je	.L63
	leaq	.LC16(%rip), %rsi
	cmpl	$10, %ecx
	je	.L72
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L65
.L63:
	movq	%rbp, %rsi
.L72:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L65:
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L66
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z16printout_inorderP4node, .-_Z16printout_inorderP4node
	.section	.rodata.str1.1
.LC19:
	.string	"r"
.LC20:
	.string	"input.txt"
	.text
	.globl	_Z9read_filev
	.type	_Z9read_filev, @function
_Z9read_filev:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC19(%rip), %rsi
	leaq	.LC20(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rcx
	.cfi_def_cfa_offset 32
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L74
	leaq	.LC4(%rip), %rdi
	call	perror@PLT
	jmp	.L75
.L74:
	movl	$50000, %edi
	movq	%rax, %rbx
	leaq	char_frequency(%rip), %rbp
	call	malloc@PLT
	movq	%rax, h_input(%rip)
.L76:
	movq	%rbx, %rdi
	call	getc@PLT
	movslq	number_of_char(%rip), %rdx
	movq	h_input(%rip), %rcx
	movb	%al, (%rcx,%rdx)
	movzbl	%al, %edx
	incl	number_of_char(%rip)
	incl	0(%rbp,%rdx,4)
	incb	%al
	jne	.L76
	movq	%rbx, %rdi
	call	fclose@PLT
.L75:
	xorl	%eax, %eax
	decl	number_of_char(%rip)
	movl	%eax, 1020+char_frequency(%rip)
	popq	%rdx
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	_Z9read_filev, .-_Z9read_filev
	.globl	_Z17traverse_preorderP4nodePi
	.type	_Z17traverse_preorderP4nodePi, @function
_Z17traverse_preorderP4nodePi:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	cmpl	$0, (%rdi)
	je	.L80
	xorl	%eax, %eax
	leaq	char_huffman_table(%rip), %rcx
.L81:
	movslq	0(%rbp), %rdx
	movl	(%rsi,%rax,4), %r8d
	movslq	%eax, %rdi
	incq	%rax
	imulq	$255, %rdx, %rdx
	addq	%rdi, %rdx
	movl	%r8d, (%rcx,%rdx,4)
	cmpq	$255, %rax
	jne	.L81
.L80:
	movq	16(%rbp), %rdi
	testq	%rdi, %rdi
	je	.L82
	xorl	%eax, %eax
.L84:
	cmpl	$-1, (%rsi,%rax,4)
	je	.L85
	incq	%rax
	cmpq	$255, %rax
	jne	.L84
.L85:
	cltq
	movq	%rsi, 8(%rsp)
	leaq	(%rsi,%rax,4), %r12
	movl	$1, (%r12)
	call	_Z17traverse_preorderP4nodePi
	movl	$-1, (%r12)
	movq	8(%rsp), %rsi
.L82:
	movq	8(%rbp), %rdi
	testq	%rdi, %rdi
	je	.L79
	xorl	%eax, %eax
.L88:
	cmpl	$-1, (%rsi,%rax,4)
	je	.L89
	incq	%rax
	cmpq	$255, %rax
	jne	.L88
.L89:
	cltq
	leaq	(%rsi,%rax,4), %rbp
	xorl	%eax, %eax
	movl	%eax, 0(%rbp)
	call	_Z17traverse_preorderP4nodePi
	movl	$-1, 0(%rbp)
.L79:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z17traverse_preorderP4nodePi, .-_Z17traverse_preorderP4nodePi
	.globl	_Z23construct_huffman_tableP4node
	.type	_Z23construct_huffman_tableP4node, @function
_Z23construct_huffman_tableP4node:
.LFB2037:
	.cfi_startproc
	endbr64
	subq	$1048, %rsp
	.cfi_def_cfa_offset 1056
	movq	%rdi, %rdx
	movl	$1020, %ecx
	movq	%fs:40, %rax
	movq	%rax, 1032(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	movb	$-1, %al
	movq	%rsi, %rdi
	rep stosb
	movq	%rdx, %rdi
	call	_Z17traverse_preorderP4nodePi
	movq	1032(%rsp), %rax
	subq	%fs:40, %rax
	je	.L101
	call	__stack_chk_fail@PLT
.L101:
	addq	$1048, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2037:
	.size	_Z23construct_huffman_tableP4node, .-_Z23construct_huffman_tableP4node
	.section	.rodata.str1.1
.LC21:
	.string	"Huffman tree (inorder traversal sequence):\n"
	.text
	.globl	_Z17build_binary_treev
	.type	_Z17build_binary_treev, @function
_Z17build_binary_treev:
.LFB2038:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	char_frequency(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	subq	$2072, %rsp
	.cfi_def_cfa_offset 2112
	movq	%fs:40, %rax
	movq	%rax, 2056(%rsp)
	xorl	%eax, %eax
.L105:
	movl	0(%r13,%rbp,4), %r12d
	testl	%r12d, %r12d
	je	.L104
	movl	$24, %edi
	call	malloc@PLT
	xorl	%esi, %esi
	movslq	%ebx, %rdx
	incl	%ebx
	movq	%rsi, 8(%rax)
	movq	%rsi, 16(%rax)
	movl	%ebp, (%rax)
	movl	%r12d, 4(%rax)
	movq	%rax, 8(%rsp,%rdx,8)
.L104:
	incq	%rbp
	cmpq	$256, %rbp
	jne	.L105
	leaq	8(%rsp), %rbp
	movl	%ebx, %esi
	movslq	%ebx, %rbx
	movq	%rbp, %rdi
	call	_Z14insertion_sortPP4nodei
.L106:
	decq	%rbx
	leal	1(%rbx), %eax
	decl	%eax
	jle	.L115
	movl	$24, %edi
	call	malloc@PLT
	movq	0(%rbp,%rbx,8), %rcx
	movl	%ebx, %esi
	movq	%rbp, %rdi
	movq	-8(%rbp,%rbx,8), %rdx
	movq	%rax, -8(%rbp,%rbx,8)
	movq	%rcx, 8(%rax)
	movq	%rdx, 16(%rax)
	movl	4(%rdx), %edx
	addl	4(%rcx), %edx
	xorl	%ecx, %ecx
	movl	%edx, 4(%rax)
	xorl	%edx, %edx
	movl	%edx, (%rax)
	movq	%rcx, 0(%rbp,%rbx,8)
	call	_Z14insertion_sortPP4nodei
	jmp	.L106
.L115:
	leaq	.LC7(%rip), %rbx
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%rbx, %rsi
	call	__printf_chk@PLT
	leaq	.LC21(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rbp
	movq	%rbp, %rdi
	call	_Z16printout_inorderP4node
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	2056(%rsp), %rax
	subq	%fs:40, %rax
	je	.L108
	call	__stack_chk_fail@PLT
.L108:
	addq	$2072, %rsp
	.cfi_def_cfa_offset 40
	movq	%rbp, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	_Z23construct_huffman_tableP4node
	.cfi_endproc
.LFE2038:
	.size	_Z17build_binary_treev, .-_Z17build_binary_treev
	.globl	_Z17array_initializerv
	.type	_Z17array_initializerv, @function
_Z17array_initializerv:
.LFB2039:
	.cfi_startproc
	endbr64
	leaq	char_frequency(%rip), %rdx
	xorl	%eax, %eax
	movl	$256, %ecx
	movq	%rdx, %rdi
	leaq	char_huffman_table(%rip), %rdx
	rep stosl
	movl	$261120, %ecx
	movb	$-1, %al
	movq	%rdx, %rdi
	rep stosb
	ret
	.cfi_endproc
.LFE2039:
	.size	_Z17array_initializerv, .-_Z17array_initializerv
	.section	.rodata.str1.1
.LC22:
	.string	"rb"
.LC23:
	.string	"compressed.txt"
	.text
	.globl	_Z13compress_filev
	.type	_Z13compress_filev, @function
_Z13compress_filev:
.LFB2040:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC22(%rip), %rsi
	leaq	.LC20(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	leaq	.LC2(%rip), %rsi
	leaq	.LC23(%rip), %rdi
	movq	%rax, %r12
	call	fopen@PLT
	testq	%r12, %r12
	je	.L130
	movq	%rax, %rbp
	xorl	%ebx, %ebx
	leaq	char_huffman_table(%rip), %r14
	xorl	%edx, %edx
	testq	%rax, %rax
	jne	.L118
.L130:
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	leaq	.LC4(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	perror@PLT
.L122:
	.cfi_restore_state
	incb	%r15b
	je	.L135
.L118:
	movq	%r12, %rdi
	movb	%dl, 15(%rsp)
	call	getc@PLT
	movb	15(%rsp), %dl
	movzbl	%al, %r13d
	movl	%eax, %r15d
	imulq	$1020, %r13, %r13
	leaq	0(%r13,%r14), %rax
	xorl	%r13d, %r13d
	movq	%rax, (%rsp)
.L127:
	movq	(%rsp), %rax
	movl	(%rax,%r13,4), %eax
	testl	%eax, %eax
	jne	.L120
	addl	%edx, %edx
	jmp	.L134
.L120:
	decl	%eax
	jne	.L122
	leal	1(%rdx,%rdx), %edx
.L134:
	incl	%ebx
	cmpl	$8, %ebx
	jne	.L126
	movzbl	%dl, %ebx
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movl	%ebx, %edx
	call	__printf_chk@PLT
	movl	%ebx, %edi
	movq	%rbp, %rsi
	xorl	%ebx, %ebx
	call	putc@PLT
	xorl	%edx, %edx
	jmp	.L126
.L135:
	testl	%ebx, %ebx
	movzbl	%dl, %r13d
	leaq	.LC5(%rip), %rsi
	je	.L124
	movl	$8, %ecx
	movl	%r13d, %edx
	subl	%ebx, %ecx
	sall	%cl, %edx
	movzbl	%dl, %r13d
.L124:
	movl	%r13d, %edx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rsi
	movl	%r13d, %edi
	call	putc@PLT
	jmp	.L128
.L126:
	incq	%r13
	cmpq	$255, %r13
	jne	.L127
	incb	%r15b
	jne	.L118
.L128:
	movq	%r12, %rdi
	call	fclose@PLT
	movq	%rbp, %rdi
	call	fclose@PLT
	movl	%ebx, last_byte_padding(%rip)
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2040:
	.size	_Z13compress_filev, .-_Z13compress_filev
	.section	.rodata.str1.1
.LC24:
	.string	"i is %d and c is %c"
	.text
	.globl	_Z25print_gpu_compressed_filePci
	.type	_Z25print_gpu_compressed_filePci, @function
_Z25print_gpu_compressed_filePci:
.LFB2041:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC24(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	leaq	.LC3(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%esi, %r12d
	leaq	.LC2(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 64
	call	fopen@PLT
	movq	%rax, %rbp
.L137:
	movl	%ebx, %edx
	cmpl	%ebx, %r12d
	jle	.L140
	movsbl	0(%r13,%rbx), %r14d
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	movl	%r14d, %ecx
	call	__printf_chk@PLT
	movq	%rbp, %rsi
	movl	%r14d, %edi
	call	putc@PLT
	jmp	.L137
.L140:
	popq	%rax
	.cfi_def_cfa_offset 56
	movq	%rbp, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2041:
	.size	_Z25print_gpu_compressed_filePci, .-_Z25print_gpu_compressed_filePci
	.section	.rodata.str1.1
.LC25:
	.string	"decompressed.txt"
	.text
	.globl	_Z15decompress_filev
	.type	_Z15decompress_filev, @function
_Z15decompress_filev:
.LFB2042:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1020, %ecx
	leaq	.LC22(%rip), %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1080, %rsp
	.cfi_def_cfa_offset 1136
	movq	%fs:40, %rax
	movq	%rax, 1064(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %r12
	movb	$-1, %al
	movq	%r12, %rdi
	rep stosb
	leaq	.LC23(%rip), %rdi
	call	fopen@PLT
	leaq	.LC2(%rip), %rsi
	leaq	.LC25(%rip), %rdi
	movq	%rax, 8(%rsp)
	call	fopen@PLT
	cmpq	$0, 8(%rsp)
	movq	%rax, 16(%rsp)
	sete	%al
	cmpq	$0, 16(%rsp)
	sete	%dl
	orb	%dl, %al
	je	.L142
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L167
	addq	$1080, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	leaq	.LC4(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	perror@PLT
.L142:
	.cfi_restore_state
	movq	8(%rsp), %rdi
	movb	$1, %r13b
	xorl	%ebp, %ebp
	xorl	%ebx, %ebx
	call	getc@PLT
	movq	8(%rsp), %rdi
	movl	%eax, %r15d
	call	getc@PLT
	orl	$-1, %esi
	movl	%eax, %r14d
.L153:
	movl	%r15d, %eax
	incl	%esi
	orl	$127, %eax
	movb	%al, 27(%rsp)
	cmpl	$7, %ebp
	jne	.L144
	movl	%r14d, %r10d
	testb	%r13b, %r13b
	je	.L145
	movq	8(%rsp), %rdi
	movl	%esi, 28(%rsp)
	call	getc@PLT
	movl	28(%rsp), %esi
	movl	%eax, %r10d
	incb	%al
	jne	.L145
	movl	number_of_char(%rip), %eax
	subl	%ebx, %eax
	cmpl	$7, %eax
	jg	.L145
	cmpb	$-1, %r14b
	je	.L146
	subl	last_byte_padding(%rip), %ebp
	xorl	%r13d, %r13d
	jmp	.L147
.L145:
	xorl	%ebp, %ebp
	cmpb	$-1, %r14b
	jne	.L147
	movl	number_of_char(%rip), %eax
	subl	%ebx, %eax
	cmpl	$7, %eax
	jg	.L147
	jmp	.L146
.L144:
	movl	%r14d, %r10d
	incl	%ebp
	leal	(%r15,%r15), %r14d
.L147:
	xorl	%ecx, %ecx
	cmpb	$-1, 27(%rsp)
	movslq	%esi, %rax
	sete	%cl
	xorl	%edi, %edi
	movl	%ecx, 44(%rsp,%rax,4)
	leaq	char_huffman_table(%rip), %rax
.L148:
	xorl	%r15d, %r15d
.L150:
	movl	(%r12,%r15), %edx
	cmpl	%edx, (%rax,%r15)
	jne	.L149
	addq	$4, %r15
	cmpq	$1020, %r15
	jne	.L150
	movq	16(%rsp), %rsi
	movb	%r10b, 27(%rsp)
	incl	%ebx
	call	putc@PLT
	movq	%r12, %rdi
	movq	%r15, %rcx
	movb	$-1, %al
	rep stosb
	movb	27(%rsp), %r10b
	orl	$-1, %esi
	jmp	.L151
.L149:
	incl	%edi
	addq	$1020, %rax
	cmpl	$256, %edi
	jne	.L148
	cmpl	$255, %esi
	je	.L146
.L151:
	movl	%r14d, %r15d
	movl	%r10d, %r14d
	jmp	.L153
.L146:
	movq	8(%rsp), %rdi
	call	fclose@PLT
	movq	1064(%rsp), %rax
	subq	%fs:40, %rax
	je	.L154
.L167:
	call	__stack_chk_fail@PLT
.L154:
	movq	16(%rsp), %rdi
	addq	$1080, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2042:
	.size	_Z15decompress_filev, .-_Z15decompress_filev
	.globl	_Z10initializev
	.type	_Z10initializev, @function
_Z10initializev:
.LFB2043:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z17array_initializerv
	call	_Z9read_filev
	call	_Z20print_char_frequencyv
	call	_Z17build_binary_treev
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	_Z24print_char_huffman_tablev
	.cfi_endproc
.LFE2043:
	.size	_Z10initializev, .-_Z10initializev
	.section	.rodata.str1.1
.LC26:
	.string	" \n Huffman after copying back \n "
.LC27:
	.string	"\t%c code is  %d  \n"
	.text
	.globl	_Z13print_huffmanv
	.type	_Z13print_huffmanv, @function
_Z13print_huffmanv:
.LFB2044:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$2, %edi
	leaq	.LC26(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC27(%rip), %r15
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	__printf_chk@PLT
	movq	h_input(%rip), %rdx
	movzbl	(%rdx), %edi
	movzbl	1(%rdx), %r12d
	movzbl	2(%rdx), %ebp
	movzbl	3(%rdx), %ebx
	movl	%edi, 12(%rsp)
	imulq	$1020, %rdi, %r13
.L172:
	leaq	0(,%r14,4), %rax
	addq	huffman_check(%rip), %rax
	movl	(%rax,%r13), %ecx
	cmpl	$-1, %ecx
	je	.L171
	movl	12(%rsp), %edx
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L171:
	incq	%r14
	cmpq	$255, %r14
	jne	.L172
	movzbl	%r12b, %r13d
	imulq	$1020, %r12, %r12
	xorl	%r14d, %r14d
	leaq	.LC27(%rip), %r15
.L174:
	leaq	0(,%r14,4), %rax
	addq	huffman_check(%rip), %rax
	movl	(%rax,%r12), %ecx
	cmpl	$-1, %ecx
	je	.L173
	movl	%r13d, %edx
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L173:
	incq	%r14
	cmpq	$255, %r14
	jne	.L174
	movzbl	%bpl, %r13d
	imulq	$1020, %rbp, %rbp
	xorl	%r12d, %r12d
	leaq	.LC27(%rip), %r14
.L176:
	leaq	0(,%r12,4), %rax
	addq	huffman_check(%rip), %rax
	movl	(%rax,%rbp), %ecx
	cmpl	$-1, %ecx
	je	.L175
	movl	%r13d, %edx
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L175:
	incq	%r12
	cmpq	$255, %r12
	jne	.L176
	movzbl	%bl, %r12d
	imulq	$1020, %rbx, %rbx
	xorl	%ebp, %ebp
	leaq	.LC27(%rip), %r13
.L178:
	leaq	0(,%rbp,4), %rax
	addq	huffman_check(%rip), %rax
	movl	(%rax,%rbx), %ecx
	cmpl	$-1, %ecx
	je	.L177
	movl	%r12d, %edx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L177:
	incq	%rbp
	cmpq	$255, %rbp
	jne	.L178
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2044:
	.size	_Z13print_huffmanv, .-_Z13print_huffmanv
	.globl	_Z43__device_stub__Z17final_compressionPiPbS0_iPiPbS0_i
	.type	_Z43__device_stub__Z17final_compressionPiPbS0_iPiPbS0_i, @function
_Z43__device_stub__Z17final_compressionPiPbS0_iPiPbS0_i:
.LFB2070:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L196
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z17final_compressionPiPbS0_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L196:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L198
	call	__stack_chk_fail@PLT
.L198:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2070:
	.size	_Z43__device_stub__Z17final_compressionPiPbS0_iPiPbS0_i, .-_Z43__device_stub__Z17final_compressionPiPbS0_iPiPbS0_i
	.globl	_Z17final_compressionPiPbS0_i
	.type	_Z17final_compressionPiPbS0_i, @function
_Z17final_compressionPiPbS0_i:
.LFB2071:
	.cfi_startproc
	endbr64
	jmp	_Z43__device_stub__Z17final_compressionPiPbS0_iPiPbS0_i
	.cfi_endproc
.LFE2071:
	.size	_Z17final_compressionPiPbS0_i, .-_Z17final_compressionPiPbS0_i
	.globl	_Z54__device_stub__Z17compress_file_gpuPhPbPiS1_S1_S1_S1_iPhPbPiS1_S1_S1_S1_i
	.type	_Z54__device_stub__Z17compress_file_gpuPhPbPiS1_S1_S1_S1_iPhPbPiS1_S1_S1_S1_i, @function
_Z54__device_stub__Z17compress_file_gpuPhPbPiS1_S1_S1_S1_iPhPbPiS1_S1_S1_S1_i:
.LFB2072:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	224(%rsp), %rax
	movq	%rdi, 56(%rsp)
	leaq	88(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	100(%rsp), %rsi
	movq	%rdx, 40(%rsp)
	leaq	72(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	80(%rsp), %rcx
	movq	%r8, 24(%rsp)
	movq	%r9, 16(%rsp)
	movq	%rax, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 96(%rsp)
	movq	%rax, 136(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	232(%rsp), %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L201
	pushq	80(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i(%rip), %rdi
	pushq	80(%rsp)
	.cfi_def_cfa_offset 240
	movq	116(%rsp), %rcx
	movl	124(%rsp), %r8d
	movq	104(%rsp), %rsi
	movl	112(%rsp), %edx
	leaq	152(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L201:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L203
	call	__stack_chk_fail@PLT
.L203:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2072:
	.size	_Z54__device_stub__Z17compress_file_gpuPhPbPiS1_S1_S1_S1_iPhPbPiS1_S1_S1_S1_i, .-_Z54__device_stub__Z17compress_file_gpuPhPbPiS1_S1_S1_S1_iPhPbPiS1_S1_S1_S1_i
	.globl	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.type	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i, @function
_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i:
.LFB2073:
	.cfi_startproc
	endbr64
	jmp	_Z54__device_stub__Z17compress_file_gpuPhPbPiS1_S1_S1_S1_iPhPbPiS1_S1_S1_S1_i
	.cfi_endproc
.LFE2073:
	.size	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i, .-_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.section	.rodata.str1.1
.LC28:
	.string	"start\n"
.LC29:
	.string	"Error in allocating d_input"
.LC30:
	.string	"Error in copying d_input"
.LC31:
	.string	"Error in allocating compressedfile_array"
.LC32:
	.string	"Error in allocating d_char_huffman_table"
.LC33:
	.string	"Error in copying d_char_huffman_table"
.LC34:
	.string	"Error in copying back"
.LC35:
	.string	"Error in allocating block_cntr_array"
.LC36:
	.string	"Error in allocating d_last_byte_padding"
.LC37:
	.string	"Error in allocating finalsize"
.LC38:
	.string	"Error in allocating orig_number_of_char"
.LC39:
	.string	"Error in copying orig_number_of_char"
.LC40:
	.string	"bool1 is %d and bool2 is %d \n"
.LC41:
	.string	"Error in d_bool"
.LC42:
	.string	"Error in copying d_bool"
.LC43:
	.string	"Error in kernel changing d_bool"
.LC44:
	.string	"Error in cudaThreadSynchronize"
.LC45:
	.string	"Error in copying d_bool back"
.LC46:
	.string	"Now bool1 is %d and bool2 is %d \n"
.LC47:
	.string	"h_bool is %d \t checkhuff is %d \n"
.LC48:
	.string	"pattern for %d is found\n"
.LC49:
	.string	"\n the number of characters in the input file is %d \n"
.LC50:
	.string	"no_of_blocksis %d \n"
.LC51:
	.string	"Error in cudaEventRecord start \n"
.LC52:
	.string	"Error in compress_file_gpu \n"
.LC53:
	.string	"Error in copying back block_cntr_array_check"
.LC54:
	.string	" block size for i = %d is %d \n"
.LC55:
	.string	"Error in Compute array \n"
.LC56:
	.string	"The final compressed array size is %d \n "
.LC57:
	.string	"Error in finalsize_cpu"
.LC58:
	.string	"cudaMemcpyHostToDevice"
.LC59:
	.string	"Error in final_compression call \n"
.LC60:
	.string	"Error in cudaThreadSynchronize \n"
.LC61:
	.string	"Error in cudaEventRecord stop \n"
.LC62:
	.string	"Time to calculate results: %f ms.\n"
.LC63:
	.string	"Error in copying final_compressed_cpu\n"
.LC64:
	.string	"The compressed value in binary is "
.LC65:
	.string	"compressing on CPU...\n"
.LC68:
	.string	"Time in cpu : %3.1f ms\n"
.LC69:
	.string	"Speedup achieved is %lf \n"
.LC70:
	.string	"decompressing on CPU...\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2045:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC28(%rip), %rsi
	movl	$2, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC47(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	64(%rsp), %rbx
	leaq	88(%rsp), %r14
	call	__printf_chk@PLT
	call	_Z10initializev
	leaq	24(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	movslq	number_of_char(%rip), %rsi
	leaq	d_input(%rip), %rdi
	call	cudaMalloc@PLT
	leaq	.LC29(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movslq	number_of_char(%rip), %rdx
	movl	$1, %ecx
	movq	h_input(%rip), %rsi
	movq	d_input(%rip), %rdi
	call	cudaMemcpy@PLT
	leaq	.LC30(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	leaq	compressedfile_array(%rip), %rdi
	imull	$255, number_of_char(%rip), %esi
	movslq	%esi, %rsi
	call	cudaMalloc@PLT
	leaq	.LC31(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$261120, %esi
	leaq	d_char_huffman_table(%rip), %rdi
	call	cudaMalloc@PLT
	leaq	.LC32(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$1, %ecx
	movq	d_char_huffman_table(%rip), %rdi
	movl	$261120, %edx
	leaq	char_huffman_table(%rip), %rsi
	call	cudaMemcpy@PLT
	leaq	.LC33(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$2, %ecx
	movl	$261120, %edx
	movq	d_char_huffman_table(%rip), %rsi
	movq	huffman_check(%rip), %rdi
	call	cudaMemcpy@PLT
	leaq	.LC34(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movslq	number_of_char(%rip), %rsi
	leaq	block_cntr_array(%rip), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	.LC35(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$4, %esi
	leaq	d_last_byte_padding(%rip), %rdi
	call	cudaMalloc@PLT
	leaq	.LC36(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$4, %esi
	leaq	finalsize(%rip), %rdi
	call	cudaMalloc@PLT
	leaq	.LC37(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$4, %esi
	leaq	orig_number_of_char(%rip), %rdi
	call	cudaMalloc@PLT
	leaq	.LC38(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$1, %ecx
	movq	orig_number_of_char(%rip), %rdi
	movl	$4, %edx
	leaq	number_of_char(%rip), %rsi
	call	cudaMemcpy@PLT
	leaq	.LC39(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$2, %edi
	call	malloc@PLT
	movl	$1, %ecx
	movl	$1, %edx
	leaq	.LC40(%rip), %rsi
	movw	$257, (%rax)
	movl	$2, %edi
	movq	%rax, h_bool(%rip)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %esi
	leaq	d_bool(%rip), %rdi
	call	cudaMalloc@PLT
	leaq	.LC41(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$1, %ecx
	movl	$2, %edx
	movq	h_bool(%rip), %rsi
	movq	d_bool(%rip), %rdi
	call	cudaMemcpy@PLT
	leaq	.LC42(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	leaq	.LC43(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	call	cudaThreadSynchronize@PLT
	leaq	.LC44(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$2, %ecx
	movl	$2, %edx
	movq	d_bool(%rip), %rsi
	movq	h_bool(%rip), %rdi
	call	cudaMemcpy@PLT
	leaq	.LC45(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movq	h_bool(%rip), %rax
	movl	$2, %edi
	leaq	.LC46(%rip), %rsi
	movzbl	1(%rax), %ecx
	movzbl	(%rax), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %eax
	xorl	%ecx, %ecx
	salq	$32, %rax
	movq	%rcx, 64(%rsp)
	movq	%rax, 72(%rsp)
	incq	%rax
	movq	%rax, 80(%rsp)
.L207:
	movq	h_bool(%rip), %rax
	movl	(%rbx), %ebp
	movq	%r12, %rsi
	movl	$2, %edi
	movzbl	(%rax), %edx
	movl	%ebp, %ecx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	h_bool(%rip), %rax
	movzbl	(%rax), %edx
	cmpl	%edx, %ebp
	jne	.L209
	movl	4(%rbx), %r13d
	movzbl	1(%rax), %edx
	movq	%r12, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movl	%r13d, %ecx
	call	__printf_chk@PLT
	movq	h_bool(%rip), %rax
	movzbl	1(%rax), %eax
	cmpl	%eax, %r13d
	jne	.L209
	movl	%ebp, %edx
	leaq	.LC48(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L209:
	addq	$12, %rbx
	cmpq	%rbx, %r14
	jne	.L207
	movl	number_of_char(%rip), %edx
	leaq	.LC49(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	getchar@PLT
	call	getchar@PLT
	call	_Z13print_huffmanv
	movl	number_of_char(%rip), %eax
	movl	$256, %ecx
	leaq	.LC50(%rip), %rsi
	movl	$2, %edi
	addl	$255, %eax
	cltd
	idivl	%ecx
	movl	%eax, %ebx
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	testl	%ebx, %ebx
	jne	.L213
	movl	$1, %ebx
.L213:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	leaq	.LC51(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	%ebx, 40(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	$16777217, %edx
	movl	$1, %ecx
	movl	$1, 60(%rsp)
	movq	%rax, 44(%rsp)
	movq	40(%rsp), %rdi
	salq	$8, %rdx
	movl	48(%rsp), %esi
	movq	%rdx, 52(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L214
	movl	number_of_char(%rip), %eax
	movq	d_char_huffman_table(%rip), %rdx
	movq	finalsize(%rip), %r9
	movq	d_last_byte_padding(%rip), %r8
	movq	block_cntr_array(%rip), %rcx
	movq	compressedfile_array(%rip), %rsi
	pushq	%rax
	.cfi_def_cfa_offset 152
	pushq	orig_number_of_char(%rip)
	.cfi_def_cfa_offset 160
	movq	d_input(%rip), %rdi
	call	_Z54__device_stub__Z17compress_file_gpuPhPbPiS1_S1_S1_S1_iPhPbPiS1_S1_S1_S1_i
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L214:
	leaq	.LC52(%rip), %rdi
	leaq	.LC54(%rip), %r12
	call	_Z14checkCUDAErrorPKc
	call	cudaThreadSynchronize@PLT
	movslq	number_of_char(%rip), %rbp
	salq	$2, %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	movq	block_cntr_array(%rip), %rsi
	movq	%rbp, %rdx
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, block_cntr_array_check(%rip)
	xorl	%ebp, %ebp
	call	cudaMemcpy@PLT
	leaq	.LC53(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
.L215:
	cmpl	%ebp, number_of_char(%rip)
	movl	%ebp, %edx
	jle	.L224
	movq	block_cntr_array_check(%rip), %rax
	movq	%r12, %rsi
	movl	$2, %edi
	movl	(%rax,%rbp,4), %ecx
	xorl	%eax, %eax
	incq	%rbp
	call	__printf_chk@PLT
	jmp	.L215
.L224:
	leaq	.LC55(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	$4, %edi
	call	malloc@PLT
	movl	$2, %ecx
	movl	$4, %edx
	movq	finalsize(%rip), %rsi
	movq	%rax, %rbp
	movq	%rax, %rdi
	call	cudaMemcpy@PLT
	movl	0(%rbp), %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC56(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC57(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movslq	0(%rbp), %rsi
	leaq	finalcompressed_array(%rip), %rdi
	call	cudaMalloc@PLT
	leaq	.LC58(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movl	%ebx, 40(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	$16777217, %edx
	movl	$1, %ecx
	movl	$1, 60(%rsp)
	movq	%rax, 44(%rsp)
	movq	40(%rsp), %rdi
	salq	$8, %rdx
	movl	48(%rsp), %esi
	movq	%rdx, 52(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L217
	movl	number_of_char(%rip), %ecx
	movq	finalcompressed_array(%rip), %rdx
	movq	compressedfile_array(%rip), %rsi
	movq	block_cntr_array(%rip), %rdi
	call	_Z43__device_stub__Z17final_compressionPiPbS0_iPiPbS0_i
.L217:
	leaq	.LC59(%rip), %rdi
	leaq	.LC62(%rip), %r12
	call	_Z14checkCUDAErrorPKc
	call	cudaThreadSynchronize@PLT
	leaq	.LC60(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	leaq	.LC61(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	leaq	52(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	%r12, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	52(%rsp), %xmm0
	call	__printf_chk@PLT
	movslq	0(%rbp), %r13
	movq	%r13, %rdi
	call	malloc@PLT
	movq	finalcompressed_array(%rip), %rsi
	movq	%r13, %rdx
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %rbx
	leaq	.LC12(%rip), %r13
	call	cudaMemcpy@PLT
	leaq	.LC63(%rip), %rdi
	call	_Z14checkCUDAErrorPKc
	leaq	.LC64(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	xorl	%ebx, %ebx
	call	_Z20write_GPU_compressedPbPi
.L218:
	cmpl	%ebx, 0(%rbp)
	jle	.L225
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%ebx
	call	__printf_chk@PLT
	jmp	.L218
.L225:
	leaq	.LC65(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movq	%rax, %rbx
	call	_Z13compress_filev
	call	clock@PLT
	leaq	.LC68(%rip), %rsi
	movl	$2, %edi
	subq	%rbx, %rax
	cvtsi2ssq	%rax, %xmm1
	divss	.LC66(%rip), %xmm1
	movb	$1, %al
	mulss	.LC67(%rip), %xmm1
	cvtss2sd	%xmm1, %xmm0
	movss	%xmm1, 12(%rsp)
	call	__printf_chk@PLT
	movq	%r12, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	52(%rsp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	leaq	.LC69(%rip), %rsi
	movss	12(%rsp), %xmm1
	divss	52(%rsp), %xmm1
	cvtss2sd	%xmm1, %xmm0
	call	__printf_chk@PLT
	leaq	.LC70(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z15decompress_filev
	call	getchar@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L220
	call	__stack_chk_fail@PLT
.L220:
	addq	$96, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2045:
	.size	main, .-main
	.text
	.globl	_Z32__device_stub__Z11read2darrayPiiPii
	.type	_Z32__device_stub__Z11read2darrayPiiPii, @function
_Z32__device_stub__Z11read2darrayPiiPii:
.LFB2074:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L226
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z11read2darrayPii(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L226:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L228
	call	__stack_chk_fail@PLT
.L228:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2074:
	.size	_Z32__device_stub__Z11read2darrayPiiPii, .-_Z32__device_stub__Z11read2darrayPiiPii
	.globl	_Z11read2darrayPii
	.type	_Z11read2darrayPii, @function
_Z11read2darrayPii:
.LFB2075:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z11read2darrayPiiPii
	.cfi_endproc
.LFE2075:
	.size	_Z11read2darrayPii, .-_Z11read2darrayPii
	.globl	_Z30__device_stub__Z10check_boolPbPb
	.type	_Z30__device_stub__Z10check_boolPbPb, @function
_Z30__device_stub__Z10check_boolPbPb:
.LFB2076:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L231
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z10check_boolPb(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L231:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L233
	call	__stack_chk_fail@PLT
.L233:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2076:
	.size	_Z30__device_stub__Z10check_boolPbPb, .-_Z30__device_stub__Z10check_boolPbPb
	.globl	_Z10check_boolPb
	.type	_Z10check_boolPb, @function
_Z10check_boolPb:
.LFB2077:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z10check_boolPbPb
	.cfi_endproc
.LFE2077:
	.size	_Z10check_boolPb, .-_Z10check_boolPb
	.section	.rodata.str1.1
.LC71:
	.string	"_Z10check_boolPb"
.LC72:
	.string	"_Z11read2darrayPii"
.LC73:
	.string	"_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i"
.LC74:
	.string	"_Z17final_compressionPiPbS0_i"
.LC75:
	.string	"char_huffman_table_gpu"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2079:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC71(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z10check_boolPb(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC72(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z11read2darrayPii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC73(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC74(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z17final_compressionPiPbS0_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC75(%rip), %rdx
	movl	$261120, %r9d
	leaq	_ZL22char_huffman_table_gpu(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2079:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text.startup
	.type	_GLOBAL__sub_I__Z14checkCUDAErrorPKc, @function
_GLOBAL__sub_I__Z14checkCUDAErrorPKc:
.LFB2196:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$261120, %edi
	call	malloc@PLT
	movq	%rax, huffman_check(%rip)
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2196:
	.size	_GLOBAL__sub_I__Z14checkCUDAErrorPKc, .-_GLOBAL__sub_I__Z14checkCUDAErrorPKc
	.section	.init_array
	.align 8
	.quad	_GLOBAL__sub_I__Z14checkCUDAErrorPKc
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	h_bool
	.bss
	.align 8
	.type	h_bool, @object
	.size	h_bool, 8
h_bool:
	.zero	8
	.globl	d_bool
	.align 8
	.type	d_bool, @object
	.size	d_bool, 8
d_bool:
	.zero	8
	.globl	huffman_check
	.align 8
	.type	huffman_check, @object
	.size	huffman_check, 8
huffman_check:
	.zero	8
	.globl	orig_number_of_char
	.align 8
	.type	orig_number_of_char, @object
	.size	orig_number_of_char, 8
orig_number_of_char:
	.zero	8
	.globl	finalsize
	.align 8
	.type	finalsize, @object
	.size	finalsize, 8
finalsize:
	.zero	8
	.globl	d_last_byte_padding
	.align 8
	.type	d_last_byte_padding, @object
	.size	d_last_byte_padding, 8
d_last_byte_padding:
	.zero	8
	.globl	block_cntr_array_check
	.align 8
	.type	block_cntr_array_check, @object
	.size	block_cntr_array_check, 8
block_cntr_array_check:
	.zero	8
	.globl	block_cntr_array
	.align 8
	.type	block_cntr_array, @object
	.size	block_cntr_array, 8
block_cntr_array:
	.zero	8
	.globl	finalcompressed_array
	.align 8
	.type	finalcompressed_array, @object
	.size	finalcompressed_array, 8
finalcompressed_array:
	.zero	8
	.globl	compressedfile_array
	.align 8
	.type	compressedfile_array, @object
	.size	compressedfile_array, 8
compressedfile_array:
	.zero	8
	.local	_ZL22char_huffman_table_gpu
	.comm	_ZL22char_huffman_table_gpu,261120,32
	.globl	copiedarray2
	.align 32
	.type	copiedarray2, @object
	.size	copiedarray2, 261120
copiedarray2:
	.zero	261120
	.globl	d_char_huffman_table
	.align 8
	.type	d_char_huffman_table, @object
	.size	d_char_huffman_table, 8
d_char_huffman_table:
	.zero	8
	.globl	d_input
	.align 8
	.type	d_input, @object
	.size	d_input, 8
d_input:
	.zero	8
	.globl	h_input
	.align 8
	.type	h_input, @object
	.size	h_input, 8
h_input:
	.zero	8
	.globl	number_of_char
	.align 4
	.type	number_of_char, @object
	.size	number_of_char, 4
number_of_char:
	.zero	4
	.globl	last_byte_padding_gpu
	.align 4
	.type	last_byte_padding_gpu, @object
	.size	last_byte_padding_gpu, 4
last_byte_padding_gpu:
	.zero	4
	.globl	last_byte_padding
	.align 4
	.type	last_byte_padding, @object
	.size	last_byte_padding, 4
last_byte_padding:
	.zero	4
	.globl	char_huffman_table
	.align 32
	.type	char_huffman_table, @object
	.size	char_huffman_table, 261120
char_huffman_table:
	.zero	261120
	.globl	char_frequency
	.align 32
	.type	char_frequency, @object
	.size	char_frequency, 1024
char_frequency:
	.zero	1024
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC66:
	.long	1232348160
	.align 4
.LC67:
	.long	1148846080
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
//#include "cutil.h"

void checkCUDAError(const char *msg)
{
    hipError_t err = hipGetLastError();
    if (hipSuccess != err)
    {
        printf("Cuda error: %s: %s.\n", msg, hipGetErrorString(err));
        printf("\nPress ENTER to exit...\n");
        getchar();
        exit(-1);
    }
}
//name of the input file
#define INPUT_FILE_NAME "input.txt"
//name of the compressed file
#define COMPRESSED_FILE_NAME "compressed.txt"
#define COMPRESSED_FILE_NAME_GPU "compressed_gpu.txt"

//name of the uncompressed file
#define DECOMPRESSED_FILE_NAME "decompressed.txt"
//name of the config file
#define  CONFIG_FILE_NAME "config.txt"
//max number of characters
#define MAX_CHAR 256

//#define MAX_CHAR 30
//max lenght of the number which can occur in char_frequency or char_huffman_table)
#define MAX_LENGTH_OF_NUMBER 10
//lenght of the array in shared memory on device
#define SHARED_MEMORY_SIZE 256
//lenght of the array in const memory on device
#define CONST_MEMORY_SIZE 15000 //(MAX_CHAR*(MAX_CHAR-1))

//To fill and pass the file as an array to GPU
#define MAX_FILE_CHARS 50000
#define BLOCK_SIZE 256


struct node {
   int val;
   int weight;
   struct node * right, * left;
};

//keeps frequency of particular characters (index - symbof of the character, value - frequency of the character)
int char_frequency[MAX_CHAR];
//keeps huffman table
int char_huffman_table[MAX_CHAR][MAX_CHAR-1];
//keeps number which tells how many bits were unused in last byte (variable is set after call compress_file())
int last_byte_padding=0;

//for writing gpu output
int last_byte_padding_gpu = 0;


//keeps number of characters in current input file - file has to have less than 2,147,483,647 characters (variable is set after call read_file())
int number_of_char=0 ;

//To fill and pass the file as an array to GPU
unsigned char *h_input=0,*d_input=0;

// To read char_huffman_table at the GPU
int *d_char_huffman_table=0;

int copiedarray2[MAX_CHAR][MAX_CHAR-1];


__device__ int char_huffman_table_gpu[MAX_CHAR][MAX_CHAR-1];

//To write the output from compression in GPU

 //char *compressedfile_array=0;

 bool *compressedfile_array=0;

 bool *finalcompressed_array=0;

 // To keep track of how many characters each block wrote

 int *block_cntr_array=0;
 int *block_cntr_array_check=0;
 int *d_last_byte_padding=0;

 int *finalsize=0;
 int *orig_number_of_char=0;
 int *huffman_check = (int *)malloc((MAX_CHAR)*(MAX_CHAR-1) *sizeof(int));

 bool *d_bool = 0;

 bool *h_bool = 0;



 __global__ void final_compression(int *block_cntr_array,bool *compressedfile_array,bool *finalcompressed_array,int number_of_char)
 //__device__ void final_compression(int *block_cntr_array,bool *compressedfile_array,bool *finalcompressed_array)
{
int index_blocks=blockIdx.x*blockDim.x+threadIdx.x;
int index_file=(blockIdx.x*blockDim.x+threadIdx.x)*255;
int final_index=0;

if(index_blocks < number_of_char)
{
for(int i=0;i<index_blocks;i++)
{
final_index = final_index+ block_cntr_array[i];
}
for(int i=0;i<block_cntr_array[index_blocks];i++)
{
finalcompressed_array[final_index+i]=compressedfile_array[index_file+i];
}

}
}


//__global__ void computearray_size(int* block_cntr_array,int *finalsize,int *orig_number_of_char)
__device__ void computearray_size(int* block_cntr_array,int *finalsize,int *orig_number_of_char)
{
*finalsize = 0;
for(int i=0;i<*orig_number_of_char;i++)
{
(*finalsize)=(*finalsize) + block_cntr_array[i];
}

}



/*__global__ void compress_file_gpu(unsigned char *d_input,char *compressedfile_array,int *char_huffman_table2,int *block_cntr_array,int* d_last_byte_padding)
{
	int write_counter=0,block_counter=0;	//how many bits have been written in specific byte
	 unsigned char input_char;
	unsigned char output_char = 0x0;
	 unsigned char end_of_file = 255;
	unsigned char mask = 0x01; //00000001;
	int index_file=(blockIdx.x*blockDim.x+threadIdx.x)*255;
	int index_blocks=blockIdx.x*blockDim.x+threadIdx.x;
	

	//for(int i=0;i<MAX_CHAR;i++)
	//{
		//int *row = (int*)((char*)char_huffman_table2 + i * pitch);
		//for (int c = 0; c < MAX_CHAR-1; ++c) {
          //   char_huffman_table_gpu[i][c] = row[c];
        //}
	//}

  			input_char = d_input[index_blocks];			
			for(int i = 0 ; i < (MAX_CHAR - 1) ; i++)				
			{
				if(char_huffman_table2[input_char*255+i] == 0)			//detect if current character on particular position has 0 or 1
				{
					output_char = output_char << 1;					//if 0 then shift bits one position to left (last bit after shifting is 0)
					write_counter++;
					block_counter++;
				}
				else if(char_huffman_table2[input_char*255+i] == 1)
				{
					output_char = output_char << 1;					//if 1 then shift bits one position to left...
					output_char = output_char | mask;				//...and last bit change to: 1
					write_counter++;
					block_counter++;
				}
				else //-1
				{
					//if(input_char == end_of_file)					//if EOF is detected then write current result to file
					//{													
						if(write_counter != 0)
						{
							output_char = output_char << (8-write_counter);
							compressedfile_array[index_file]=output_char;
							output_char = 0x0;
						}
						else	//write_counter == 0
						{
							compressedfile_array[index_file]=output_char;
						}
					//}

					break;
				}

				if(write_counter == 8)								//if result achieved 8 (size of char) then write it to compressed_file
				{
					compressedfile_array[index_file]=output_char;
					output_char = 0x0;
					write_counter = 0;
				}
			}
		
		block_cntr_array[index_blocks]=block_counter;
		*d_last_byte_padding = write_counter;							//to decompress file we have to know how many bits in last byte have been written
		//update_config(write_counter); //TODO to zakomentowac przy ostatecznych pomiarach
	
}*/

//__global__ void compress_file_gpu(unsigned char *d_input,bool *compressedfile_array,int *char_huffman_table2,int *block_cntr_array,int* d_last_byte_padding)
__global__ void compress_file_gpu(unsigned char *d_input,bool *compressedfile_array,int *char_huffman_table2,int *block_cntr_array,int* d_last_byte_padding,int *finalsize,int *orig_number_of_char,int number_of_char)
{
	//int write_counter=0,
	int block_counter=0;	//how many bits have been written in specific byte
	 unsigned char input_char;
	//unsigned char output_char = 0x0;
	 //unsigned char end_of_file = 255;
	//unsigned char mask = 0x01; //00000001;
	int index_file=(blockIdx.x*blockDim.x+threadIdx.x)*255;
	int index_blocks=blockIdx.x*blockDim.x+threadIdx.x;
	
	if(index_blocks < number_of_char) 
	{
	//for(int i=0;i<MAX_CHAR;i++)
	//{
		//int *row = (int*)((char*)char_huffman_table2 + i * pitch);
		//for (int c = 0; c < MAX_CHAR-1; ++c) {
          //   char_huffman_table_gpu[i][c] = row[c];
        //}
	//}

  			input_char = d_input[index_blocks];			
			for(int i = 0 ; i < (MAX_CHAR - 1) ; i++)				
			{
				if(char_huffman_table2[input_char*255+i] == 0)			//detect if current character on particular position has 0 or 1
				{
					//output_char = output_char << 1;					//if 0 then shift bits one position to left (last bit after shifting is 0)
					compressedfile_array[index_file+i] = false;
					//write_counter++;
					block_counter++;
				}
				else if(char_huffman_table2[input_char*255+i] == 1)
				{
					//output_char = output_char << 1;					//if 1 then shift bits one position to left...
					//output_char = output_char | mask;				//...and last bit change to: 1
					//write_counter++;
					compressedfile_array[index_file+i] = true;
					block_counter++;
				}
				else //-1
				{
					/*if(input_char == end_of_file)					//if EOF is detected then write current result to file
					{													
						if(write_counter != 0)
						{
							output_char = output_char << (8-write_counter);
							compressedfile_array[index_file]=output_char;
							output_char = 0x0;
						}
						else	//write_counter == 0
						{
							compressedfile_array[index_file]=output_char;
						}
					}*/

					break;
				}

				/*if(write_counter == 8)								//if result achieved 8 (size of char) then write it to compressed_file
				{
					compressedfile_array[index_file]=output_char;
					output_char = 0x0;
					write_counter = 0;
				}*/
			}
		
		block_cntr_array[index_blocks]=block_counter;
		//*d_last_byte_padding = write_counter;							//to decompress file we have to know how many bits in last byte have been written
		//update_config(write_counter); //TODO to zakomentowac przy ostatecznych pomiarach

		computearray_size(block_cntr_array,finalsize,orig_number_of_char);
		//final_compression(block_cntr_array,compressedfile_array,finalcompressed_array);

	}
	
}


void write_GPU_compressed(bool *final_compressed_cpu,int *finalsize_cpu)
{
FILE *compressed_file;
int write_counter=0;	//how many bits have been written in specific byte
//unsigned char input_char;
unsigned char output_char = 0x0;
//unsigned char end_of_file = 255;
unsigned char mask = 0x01; //00000001;

compressed_file = fopen(COMPRESSED_FILE_NAME_GPU, "wb");	

if ((compressed_file==NULL))
	{
		perror ("Error reading file");		
	}
else
	{
	for(int i = 0 ; i <  (*finalsize_cpu) ; i++)				
			{
			
			if(int(final_compressed_cpu[i]) == 0)
			{
				output_char = output_char << 1;					//if 0 then shift bits one position to left (last bit after shifting is 0)
					write_counter++;
			}
			else if (int(final_compressed_cpu[i]) == 1)
				{
					output_char = output_char << 1;					//if 1 then shift bits one position to left...
					output_char = output_char | mask;				//...and last bit change to: 1
					write_counter++;
				}
			if(write_counter == 8)								//if result achieved 8 (size of char) then write it to compressed_file
				{
					printf("Compressed char in decimal is %d \n", output_char);
					putc(output_char, compressed_file);				
					output_char = 0x0;
					write_counter = 0;
				}	
				
			}
		
		if(write_counter != 0)
						{
							output_char = output_char << (8-write_counter);
							printf("Compressed char in decimal is %d \n", output_char);
							putc(output_char, compressed_file);
							output_char = 0x0;
						}
	
	}
	fclose(compressed_file);
	last_byte_padding_gpu = write_counter;	
}

























void print_dchar_huffman_table()
{

		printf("\n dchar huffman table ");
		getchar();
		bool flag = false;

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printf("Huffman table:\n");
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	
	for(int i = 0 ; i < MAX_CHAR ; i++)
	{		
		flag = false;
		for(int j = 0 ; j < (MAX_CHAR -1) ; j++)
		{		
			if(copiedarray2[i][j] != -1)
			{				
				if(!flag)
				{
					if(i == 10)//new line
					{
						printf("\\n:\t");
					}
					else
					{
						printf("%c:\t",i);
					}
				}
				flag = true;
				printf("%d ", copiedarray2[i][j]);
			}
		}
		if(flag) printf("\n");
	}

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	getchar();
}

//Huffman table construction+++++++++++++++++++++++++++++++++++++++++++++++++++

void insertion_sort(node **forest, int length)
{	
	for(int i = 1; i < length ; i++)
	{	
		node *tmp = forest[i];
		int j = i - 1;
		bool done = false;

		do
		{
			if(forest[j]->weight < tmp->weight)		//> ascending order; < descending order
			{
				forest[j+1] = forest[j];
				j = j-1;
				if(j < 0)
				{
					done = true;
				}
			}
			else
			{
				done = true;
			}
		}while(!done);
		forest[j+1] = tmp;
	}
}

void print_char_frequency()
{
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printf("character frequency:\n");
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");

	for(int i = 0 ; i < MAX_CHAR ; i++)
	{
		if(char_frequency[i] != 0)
		{
			if(i == 10)//new line
			{
				printf("%d)\tval: \\n\tfreq: %d\n",i, char_frequency[i]);
			}
			else
			{
				printf("%d)\tval: %c\tfreq: %d\n",i, i, char_frequency[i]);
			}
		}
	}

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
}


void print_char_huffman_table()
{
	bool flag = false;

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printf("Huffman table:\n");
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	
	for(int i = 0 ; i < MAX_CHAR ; i++)
	{		
		flag = false;
		for(int j = 0 ; j < (MAX_CHAR -1) ; j++)
		{		
			if(char_huffman_table[i][j] != -1)
			{				
				if(!flag)
				{
					if(i == 10)//new line
					{
						printf("\\n:\t");
					}
					else
					{
						printf("%c:\t",i);
					}
				}
				flag = true;
				printf("%d ", char_huffman_table[i][j]);
			}
		}
		if(flag) printf("\n");
	}

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
}

void printout_inorder(node * tree) 
{	

	if(tree->left) printout_inorder(tree->left);

	if(tree->val != NULL)
	{
		if(tree->val == '\n')
		{
			printf("weight: %d\tvalue: \\n\n",tree->weight);
		}
		else
		{
			printf("weight: %d\tvalue: %c\n",tree->weight, tree->val);
		}
	}
	else
	{
		printf("weight: %d\tvalue: NULL\n",tree->weight);
	}

	if(tree->right) printout_inorder(tree->right);
}

void read_file()
{
	FILE *file;
	unsigned char end_of_file = 255;
	 unsigned char c;

	file = fopen(INPUT_FILE_NAME, "r");
  
	if (file==NULL)
	{
		perror ("Error reading file");		
	}
	else
	{
	//storing the file contents into h_input
		h_input = (unsigned char *)malloc(MAX_FILE_CHARS*sizeof(char));
		do
			{
			c = getc (file);
			//if(c == end_of_file) printf("\n Found EOF \n");
			//printf("c before putting into array is %c\n",c);
			h_input[number_of_char]=c;
			number_of_char++;
			char_frequency[c]++;			
		} while (c != end_of_file);

		fclose (file);		
	}
//	h_input[number_of_char] = end_of_file;
	char_frequency[end_of_file] = 0;				//to avoid problems with several EOF in one file
	//EOF is not needed ; so going to decrement
	number_of_char--;
}

void traverse_preorder(node *root, int *path)
{
	if(root->val != NULL)
	{
		for(int i = 0 ; i < MAX_CHAR -1 ; i++)
		{
			char_huffman_table[root->val][i] = path[i];
		}
	}

	if(root->left)//left 1
	{
		int counter = 0;

		for(int i = 0 ; i < MAX_CHAR - 1 ; i++)
		{			
			if(path[i] == -1)
			{
				break;
			}

			counter++;
		}

		path[counter] = 1;

		traverse_preorder(root->left, path);

		path[counter] = -1;
	}
	
	if(root->right)//right 0
	{
		int counter = 0;

		for(int i = 0 ; i < MAX_CHAR - 1 ; i++)
		{			
			if(path[i] == -1)
			{
				break;
			}

			counter++;
		}

		path[counter] = 0;

		traverse_preorder(root->right, path);

		path[counter] = -1;		
	}
}

void construct_huffman_table(node *root)
{		
	int path[MAX_CHAR - 1];
	for(int i = 0 ; i < MAX_CHAR - 1 ; i++)
	{
		path[i] = -1;
	}

	traverse_preorder(root, path);		
}


void build_binary_tree()
{
	int forest_counter = 0;
	node *forest[MAX_CHAR];
	node *curr;

	for(int i = 0 ; i < MAX_CHAR ; i++)		//initial forest
	{
		if(char_frequency[i] != 0)
		{
			curr = (node *)malloc(sizeof(node));
			curr->left = curr->right = NULL;
			curr->val = i;
			curr->weight = char_frequency[i];

			forest[forest_counter] = curr;
			forest_counter++;
		}
	}

	insertion_sort(forest, forest_counter);//sorted initial forest
		
	while(forest_counter > 1)//build final tree
	{
		node *parent;
		parent = (node *)malloc(sizeof(node));
		parent->right = forest[forest_counter-1];
		parent->left = forest[forest_counter-2];
		parent->weight = forest[forest_counter-1]->weight + forest[forest_counter-2]->weight;
		parent->val = NULL;

		forest[forest_counter-1] = NULL;
		forest[forest_counter-2] = parent;
	
		forest_counter--;

		insertion_sort(forest, forest_counter);
	}

	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printf("Huffman tree (inorder traversal sequence):\n");
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
	printout_inorder(forest[0]);
	printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");

	construct_huffman_table(forest[0]);

	//delete_binary_tree_postorder(forest[0]);	//after building Huffman table we do not need Huffman tree anymore
}

void array_initializer()
{
	for(int i = 0 ; i < MAX_CHAR ; i++)
	{
		char_frequency[i] = 0;
	}

	for(int i = 0 ; i < MAX_CHAR ; i++)
	{
		for(int j = 0 ; j < (MAX_CHAR-1) ; j++)
		{
			char_huffman_table[i][j] = -1;
		}
	}
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//Calculation on CPU+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

void compress_file()
{
	FILE *input_file;
	FILE *compressed_file;
	unsigned char output_char;
	int write_counter;	//how many bits have been written in specific byte
	
	unsigned char input_char;
	unsigned char end_of_file ;
	unsigned char mask ; //00000001;
	
	

	input_file = fopen(INPUT_FILE_NAME, "rb");
	compressed_file = fopen(COMPRESSED_FILE_NAME, "wb");			// apend file (add text to a file or create a file if it does not exist)
	output_char= 0x0;
	write_counter = 0;
	end_of_file = 255;
	mask = 0x01;

  
	if ((input_file==NULL)||(compressed_file==NULL))
	{
		perror ("Error reading file");		
	}
	else
	{
		do
		{
			input_char = getc (input_file);							//read one character from input file
			
			for(int i = 0 ; i < (MAX_CHAR - 1) ; i++)				
			{
				if(char_huffman_table[input_char][i] == 0)			//detect if current character on particular position has 0 or 1
				{
					output_char = output_char << 1;					//if 0 then shift bits one position to left (last bit after shifting is 0)
					write_counter++;
				}
				else if(char_huffman_table[input_char][i] == 1)
				{
					output_char = output_char << 1;					//if 1 then shift bits one position to left...
					output_char = output_char | mask;				//...and last bit change to: 1
					write_counter++;
				}
				else //-1
				{
					if(input_char == end_of_file)					//if EOF is detected then write current result to file
					{													
						if(write_counter != 0)
						{
							output_char = output_char << (8-write_counter);
							printf("Compressed char in decimal is %d \n", output_char);
							putc(output_char, compressed_file);
							output_char = 0x0;
						}
						else	//write_counter == 0
						{
							printf("Compressed char in decimal is %d \n", output_char);
							putc(output_char, compressed_file);				
						}
					}

					break;
				}

				if(write_counter == 8)								//if result achieved 8 (size of char) then write it to compressed_file
				{
					printf("Compressed char in decimal is %d \n", output_char);
					putc(output_char, compressed_file);				
					output_char = 0x0;
					write_counter = 0;
				}
			}

		} while (input_char != end_of_file);

		fclose (input_file);
		fclose(compressed_file);

		last_byte_padding = write_counter;							//to decompress file we have to know how many bits in last byte have been written
		
		//update_config(write_counter); //TODO to zakomentowac przy ostatecznych pomiarach
	}
}


void print_gpu_compressed_file(char *final_compressed_cpu,int finalsize_cpu)
{
FILE *compressed_file;

compressed_file = fopen(COMPRESSED_FILE_NAME_GPU, "wb");	
for(int i=0;i<finalsize_cpu;i++)
{

char c=final_compressed_cpu[i];
printf("i is %d and c is %c",i,c);
putc(c,compressed_file);

}

fclose(compressed_file);

}


void decompress_file()
{
	FILE *compressed_file;
	FILE *decompressed_file;
	unsigned char end_of_file = 255;
	unsigned char mask = 0x7F; //01111111;	
	unsigned char curr;
	unsigned char next;
	int written_char_counter=0;
	int pattern[MAX_CHAR - 1];

	for(int i = 0 ; i < (MAX_CHAR - 1); i++)
	{
		pattern[i] = -1;
	}

	compressed_file = fopen(COMPRESSED_FILE_NAME, "rb");
	decompressed_file = fopen(DECOMPRESSED_FILE_NAME, "wb");

	if ((compressed_file==NULL)||(decompressed_file==NULL))
	{
		perror ("Error reading file");		
	}
	else
	{
		int bit_counter=0;		
		unsigned char first_bit;
		bool read_next = true;

		curr = getc (compressed_file);
		next = getc (compressed_file);					//we have to read one byte in advance due to padding

//		for(int i = 0 ; i < (MAX_CHAR - 1) ; i++)		//builds a pattern and chcecks if it matches to char_huffman_table
		int pattern_counter=-1;
		while(pattern_counter < (MAX_CHAR - 1))
		{ 
			pattern_counter++;

			first_bit = curr | mask;							//check if first bit is 0 or 1

			curr = curr << 1;

			if(bit_counter == 7)
			{
				bit_counter = 0;				

				curr = next;

				if(read_next)
				{
					next = getc (compressed_file);

					if(next == end_of_file)
					{
						if((number_of_char - written_char_counter) < 8)
						{
							read_next = false;
							bit_counter = 7 - last_byte_padding;					
						}
					}
				}											

				if((curr == end_of_file) && ((number_of_char - written_char_counter) < 8))
				{
					break;
				}					
			}
			else
			{
				bit_counter++;
			}

			if(first_bit == 255)
			{
				pattern[pattern_counter] = 1;
			}
			else
			{
				pattern[pattern_counter] = 0;
			}

			bool flag = true;
			for(int j = 0 ; j < MAX_CHAR ; j++)
			{
				flag = true;

				for(int k = 0 ; k < (MAX_CHAR - 1) ; k++)
				{
					if(char_huffman_table[j][k] != pattern[k])
					{
						flag = false;
						break;
					}
				}

				if(flag == true)
				{	
					written_char_counter++;					
					putc(j, decompressed_file);
					
					for(int i = 0 ; i < (MAX_CHAR - 1); i++)
					{
						pattern[i] = -1;
					}

					pattern_counter = -1;

					break;
				}
			}
				
		}

		fclose (compressed_file);		
		fclose (decompressed_file);		
	}
}


void initialize()
{	
	array_initializer();	
	read_file();	
	print_char_frequency();
	build_binary_tree();
	print_char_huffman_table();
}


/*__global__ void compress(int *d_input,int number_of_char,int *d_char_huffman_table,int MAX_CHAR)
{
	int i=0;

	 extern __shared__ int my2DArray[32][32]; //size need to be coded a development time though  
	 my2DArray[threadIdx.x][threadIdx.y] = flatArray[blockDim.x * threadIdx.y + threadIdx.x];
	
}*/


__global__ void read2darray(int *devPtr,int pitch)
{
	int elements[2][2];
	 for (int r = 0; r < 2; ++r) {
        int* row = (int*)((char*)devPtr + r * pitch);
        for (int c = 0; c < 2; ++c) {
             elements[r][c] = row[c];
        }
    }
}


__global__ void check_bool(bool *d_bool)
{
	d_bool[0]=false;
	d_bool[1]=false;
}


void print_huffman()
{

printf(" \n Huffman after copying back \n " );
unsigned char input_char1;
unsigned char input_char2;

unsigned char input_char3;
unsigned char input_char4;

input_char1 = h_input[0];
input_char2 = h_input[1];
input_char3 = h_input[2];
input_char4 = h_input[3];
for (int i=0;i < MAX_CHAR-1;i++)
{
if(huffman_check[ input_char1*255+i]!= -1 )  printf ("\t%c code is  %d  \n", input_char1,huffman_check[ input_char1*255+i]);
}


for (int i=0;i < MAX_CHAR-1;i++)
{
if(huffman_check[ input_char2*255+i]!= -1) printf ("\t%c code is  %d  \n",input_char2, huffman_check[ input_char2*255+i]);
}

for (int i=0;i < MAX_CHAR-1;i++)
{
if(huffman_check[ input_char3*255+i]!= -1 )  printf ("\t%c code is  %d  \n", input_char3,huffman_check[ input_char3*255+i]);
}

for (int i=0;i < MAX_CHAR-1;i++)
{
if(huffman_check[ input_char4*255+i]!= -1 )  printf ("\t%c code is  %d  \n", input_char4,huffman_check[ input_char4*255+i]);
}




}

int main(int argc, char* argv[])
{
	
	int *finalsize_cpu=0;
	unsigned char end_of_file = 255;
	printf("start\n");
	initialize();

	hipEvent_t start, stop;   	 	// cuda events to measure time
	float elapsed_time,elapsed_time_Cont; 

	hipEventCreate(&start);     	// timing objects
	hipEventCreate(&stop);

	unsigned int timer2=0;
	time_t seconds;


// In initialize in cpu,we put the file chars into array, fill huffman table and char_freq_arrays
//copy the input contents into an array
	hipMalloc((void **)&d_input,number_of_char*sizeof(char));
	checkCUDAError("Error in allocating d_input");	
	hipMemcpy(d_input,h_input,number_of_char*sizeof(char),hipMemcpyHostToDevice);
	checkCUDAError("Error in copying d_input");	

	// Allocate space for the compressed file to be used in GPU
	hipMalloc((void **)&compressedfile_array,number_of_char*(MAX_CHAR -1)*sizeof(bool));
	checkCUDAError("Error in allocating compressedfile_array");	
	//
	hipMalloc((void **)&d_char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1) * sizeof(int));
	checkCUDAError("Error in allocating d_char_huffman_table");	
	hipMemcpy(d_char_huffman_table,char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1) * sizeof(int),hipMemcpyHostToDevice);
	checkCUDAError("Error in copying d_char_huffman_table");	
	hipMemcpy(huffman_check,d_char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1) * sizeof(int),hipMemcpyDeviceToHost);
	checkCUDAError("Error in copying back");	

	hipMalloc((void **)&block_cntr_array,number_of_char*sizeof(int));
	checkCUDAError("Error in allocating block_cntr_array");	

	hipMalloc((void **)&d_last_byte_padding,sizeof(int));
	checkCUDAError("Error in allocating d_last_byte_padding");	
	hipMalloc((void **)&finalsize,sizeof(int));
	checkCUDAError("Error in allocating finalsize");	
	hipMalloc((void **)&orig_number_of_char,sizeof(int));
	checkCUDAError("Error in allocating orig_number_of_char");	
	hipMemcpy(orig_number_of_char,&number_of_char,sizeof(int),hipMemcpyHostToDevice);
	checkCUDAError("Error in copying orig_number_of_char");	

	
	
	// check if i can make a boolean array
	h_bool=(bool *) malloc(2*sizeof(bool));
	h_bool[0]=true;
	h_bool[1]=true;
	printf("bool1 is %d and bool2 is %d \n",h_bool[0],h_bool[1]);
	hipMalloc((void **)&d_bool,2*sizeof(bool));
	checkCUDAError("Error in d_bool");	
	hipMemcpy(d_bool,h_bool,2*sizeof(bool),hipMemcpyHostToDevice);
	checkCUDAError("Error in copying d_bool");
	//check_bool<<<1,1>>>(d_bool);
	checkCUDAError("Error in kernel changing d_bool");
	hipDeviceSynchronize();
	checkCUDAError("Error in hipDeviceSynchronize");
	hipMemcpy(h_bool,d_bool,2*sizeof(bool),hipMemcpyDeviceToHost);
	checkCUDAError("Error in copying d_bool back");
	printf("Now bool1 is %d and bool2 is %d \n",h_bool[0],h_bool[1]);

	int checkhuff[2][3]= { {0, 0, 0},
							{1, 1, 1} };
	bool flag = true;
	for(int j=0;j<2;j++)
	{	
		flag = true;
			for(int k=0;k<2;k++)
			{
				printf("h_bool is %d \t checkhuff is %d \n",int(h_bool[k]),checkhuff[j][k]);
				if(checkhuff[j][k] != int(h_bool[k]))
				{
					flag = false;
					break;
				}
			}
			if(flag == true)
			{
				printf("pattern for %d is found\n",checkhuff[j][0]);
			}

	}
	


	//copy and send the huffman table as a 2d array to GPU Device
	//int *darray=0;
	//size_t pitch;   
	//cudaMallocPitch( (void**)&darray, &pitch, 2 * sizeof(int), 2); 
	//cudaMemcpy2D(darray,pitch,harray,2*sizeof(int),2*sizeof(int),2,cudaMemcpyHostToDevice);
	//cudaMalloc((void **)&darray,4*sizeof(int));
	//cudaMemcpy(darray,harray,4*sizeof(int),cudaMemcpyHostToDevice);
	//cudaMemcpy2D(copiedarray,2*sizeof(int),darray,pitch,pitch,2,cudaMemcpyDeviceToHost);
//	cudaMemcpy2D(copiedarray,2*sizeof(int),darray,pitch,2*sizeof(int),2,cudaMemcpyDeviceToHost);
	//printf("After copying back %d, \t %d, \t %d,  \t %d \n",copiedarray[0][0],copiedarray[0][1],copiedarray[1][0],copiedarray[1][1]);
	//int *darray_2d=0;
	//cudaMalloc((void **)&darray_2d,4*sizeof(int));
	//cudaMemcpy(darray,harray,4*sizeof(int),cudaMemcpyHostToDevice);
//	read2darray<<<1,1>>>(darray, pitch); 
	
	//size_t pitch2;   
	//cudaMallocPitch( (void**)&d_char_huffman_table, &pitch2, (MAX_CHAR-1) * sizeof(int), MAX_CHAR); 
	
	
	//cudaMemcpy2D(d_char_huffman_table,pitch2,char_huffman_table,(MAX_CHAR-1) * sizeof(int),(MAX_CHAR-1) * sizeof(int),MAX_CHAR,cudaMemcpyHostToDevice);
	
	//cudaMemcpy2D(char_huffman_table_gpu,(MAX_CHAR-1) * sizeof(int),char_huffman_table,(MAX_CHAR-1) * sizeof(int),(MAX_CHAR-1) * sizeof(int),MAX_CHAR,cudaMemcpyHostToDevice);
	//checkCUDAError("Error in char_huffman_table_gpu");	
	//cudaMemcpy2D(copiedarray2,(MAX_CHAR-1)*sizeof(int),d_char_huffman_table,pitch2,(MAX_CHAR-1)*sizeof(int),MAX_CHAR,cudaMemcpyDeviceToHost);
	
	//cudaMemcpy2D(copiedarray2,(MAX_CHAR-1)*sizeof(int),char_huffman_table_gpu,(MAX_CHAR-1) * sizeof(int),(MAX_CHAR-1) * sizeof(int),MAX_CHAR,cudaMemcpyDeviceToHost);
//cudaMemcpy(orig_number_of_char,&number_of_char,sizeof(int),cudaMemcpyHostToDevice);
//	checkCUDAError("Error in copiedarray2");	
//	print_dchar_huffman_table();
	printf("\n the number of characters in the input file is %d \n",number_of_char);
	getchar();
	/*for(int i=0;i<number_of_char;i++)
	{
		if( h_input[i] == end_of_file ) printf(" EOF \n");
		printf(" Copying into array: i is %d  and c is %c \n",i,h_input[i]);
	}*/
	


	getchar();
	print_huffman();
	
	int no_of_blocks = (number_of_char + BLOCK_SIZE -1)/BLOCK_SIZE;
		printf("no_of_blocksis %d \n", no_of_blocks);
	if(no_of_blocks == 0) no_of_blocks =1;

	//compress_file_gpu<<<number_of_char,1>>>(d_input,compressedfile_array,d_char_huffman_table,block_cntr_array,d_last_byte_padding);
	hipEventRecord(start, 0);		// start time
	checkCUDAError("Error in hipEventRecord start \n");	
	compress_file_gpu<<<no_of_blocks,BLOCK_SIZE>>>(d_input,compressedfile_array,d_char_huffman_table,block_cntr_array,d_last_byte_padding,finalsize,orig_number_of_char,number_of_char);
	checkCUDAError("Error in compress_file_gpu \n");	
	hipDeviceSynchronize();

	//cudaMalloc((void **)&block_cntr_array_check,number_of_char*sizeof(int));
	//checkCUDAError("Error in allocating block_cntr_array_check");	
	block_cntr_array_check = (int *) malloc(number_of_char*sizeof(int));
	
	hipMemcpy(block_cntr_array_check,block_cntr_array,number_of_char*sizeof(int),hipMemcpyDeviceToHost);
	checkCUDAError("Error in copying back block_cntr_array_check");

	for(int i=0; i < number_of_char; i++)
	{
		printf(" block size for i = %d is %d \n",i, block_cntr_array_check[i]);
	}


//	computearray_size<<<1,1>>>(block_cntr_array,finalsize,orig_number_of_char);
	checkCUDAError("Error in Compute array \n");
		finalsize_cpu = (int *)malloc(sizeof(int));
	hipMemcpy(finalsize_cpu,finalsize,sizeof(int),hipMemcpyDeviceToHost);
	printf("The final compressed array size is %d \n ", *finalsize_cpu);
	checkCUDAError("Error in finalsize_cpu");
	int block = *finalsize_cpu;
	//allocate space for the final compressed array

	hipMalloc((void **)&finalcompressed_array,((*finalsize_cpu)*sizeof(bool)));
	checkCUDAError("hipMemcpyHostToDevice");
	
	final_compression<<<no_of_blocks,BLOCK_SIZE>>>(block_cntr_array,compressedfile_array,finalcompressed_array,number_of_char);
	checkCUDAError("Error in final_compression call \n");

	hipDeviceSynchronize();
	checkCUDAError("Error in hipDeviceSynchronize \n");
	hipEventRecord(stop, 0); 
	checkCUDAError("Error in hipEventRecord stop \n");

	hipEventSynchronize(stop);
	hipEventElapsedTime(&elapsed_time, start, stop);
	printf("Time to calculate results: %f ms.\n", elapsed_time);  // print out execution time

	bool *final_compressed_cpu=0;
	final_compressed_cpu = (bool *)malloc((*finalsize_cpu)*sizeof(bool));
	hipMemcpy(final_compressed_cpu,finalcompressed_array,((*finalsize_cpu)*sizeof(bool)),hipMemcpyDeviceToHost);
	checkCUDAError("Error in copying final_compressed_cpu\n");
	//print_gpu_compressed_file(final_compressed_cpu,*finalsize_cpu);
	printf("The compressed value in binary is ");

	write_GPU_compressed(final_compressed_cpu,finalsize_cpu);
	for(int i=0;i<*finalsize_cpu;i++)
	//	sprintf(compress_file+i,final_compressed_cpu[i]);

	//printf("i is %d and val is %d \n",i,final_compressed_cpu[i]);
	printf("\n");




//	cudaMalloc((void **)&d_char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1)*sizeof(int));
//	cudaMemcpy(d_char_huffman_table,char_huffman_table,(MAX_CHAR)*(MAX_CHAR-1)*sizeof(int),cudaMemcpyHostToDevice);
//	printf("\n Going to compress on the GPU ");
//	compress<<<number_of_char,1>>>(d_input,number_of_char,d_char_huffman_table,MAX_CHAR);

//test ends
	
	printf("compressing on CPU...\n");
	  //timer2=0;
	// CUT_SAFE_CALL(cutCreateTimer(&timer2));
	 //CUT_SAFE_CALL(cutStartTimer(timer2));

	/*clock_t Linuxclock_start,Linuxclock_end;		// clock return type
	cudaEvent_t CUDAevent_start, CUDAevent_end;
	float CUDAEvents_time; 
	cudaEventRecord(CUDAevent_start, 0 );
	cudaEventSynchronize(CUDAevent_start);  
	Linuxclock_start = clock();*/
	/*time_t before,after;

	before = time (NULL);*/
clock_t start1, stop1;
	start1 = clock();
	compress_file();
	stop1 = clock();
float elapsedTime = (float)(stop1 - start1) /
(float)CLOCKS_PER_SEC * 1000.0f;
printf( "Time in cpu : %3.1f ms\n", elapsedTime );
printf("Time to calculate results: %f ms.\n", elapsed_time);  // print out execution time

printf("Speedup achieved is %lf \n", elapsedTime/elapsed_time );
	/*after = time (NULL);
	double dif;
	dif = difftime (after,before);
	printf ("It took you %.9lf seconds to type your name.\n", dif );*/



	/*Linuxclock_end = clock();
	cudaEventRecord(CUDAevent_end, 0 );    	 // instrument code to measure end time
	cudaEventSynchronize(CUDAevent_end);
	cudaEventElapsedTime(&CUDAEvents_time, CUDAevent_start, CUDAevent_end);
	printf("CPU Time using CUDA events: %f ms\n", CUDAEvents_time);  // time_CUDAEvents is in ms
	printf("CPU Time using Linux clock: %f ms\n", ((double) (Linuxclock_end - Linuxclock_start) * 1000)/CLOCKS_PER_SEC);  //Linuxclock in sec
	cudaEventDestroy(CUDAevent_start);
	cudaEventDestroy(CUDAevent_end);*/

	//CUT_SAFE_CALL(cutStopTimer(timer2));
	//float time2=cutGetAverageTimerValue(timer2); 
	//printf("  Time on Host %f\n", time2);

	printf("decompressing on CPU...\n");
	decompress_file();

	getchar();
	return 0;
}

	.text
	.file	"gpulab1_1.hip"
	.globl	_Z14checkCUDAErrorPKc           # -- Begin function _Z14checkCUDAErrorPKc
	.type	_Z14checkCUDAErrorPKc,@function
_Z14checkCUDAErrorPKc:                  # @_Z14checkCUDAErrorPKc
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB0_2
# %bb.1:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB0_2:
	.cfi_def_cfa_offset 16
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	callq	getchar
	movl	$-1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z14checkCUDAErrorPKc, .Lfunc_end0-_Z14checkCUDAErrorPKc
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__final_compressionPiPbS0_i # -- Begin function _Z32__device_stub__final_compressionPiPbS0_i
	.type	_Z32__device_stub__final_compressionPiPbS0_i,@function
_Z32__device_stub__final_compressionPiPbS0_i: # @_Z32__device_stub__final_compressionPiPbS0_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z17final_compressionPiPbS0_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z32__device_stub__final_compressionPiPbS0_i, .Lfunc_end1-_Z32__device_stub__final_compressionPiPbS0_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i # -- Begin function _Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.type	_Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i,@function
_Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i: # @_Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	216(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i, .Lfunc_end2-_Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z20write_GPU_compressedPbPi    # -- Begin function _Z20write_GPU_compressedPbPi
	.type	_Z20write_GPU_compressedPbPi,@function
_Z20write_GPU_compressedPbPi:           # @_Z20write_GPU_compressedPbPi
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	movq	%rdi, %r15
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	callq	fopen
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.LBB3_9
# %bb.1:                                # %.preheader
	movl	(%r14), %eax
	testl	%eax, %eax
	jle	.LBB3_2
# %bb.3:                                # %.lr.ph.outer.preheader
	xorl	%r13d, %r13d
.LBB3_4:                                # %.lr.ph.outer
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_5 Depth 2
	cltq
	movl	$-8, %r12d
	xorl	%ecx, %ecx
.LBB3_5:                                # %.lr.ph
                                        #   Parent Loop BB3_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addb	%cl, %cl
	orb	(%r15,%r13), %cl
	movzbl	%cl, %ebp
	cmpl	$-1, %r12d
	je	.LBB3_10
# %bb.6:                                #   in Loop: Header=BB3_5 Depth=2
	incq	%r13
	incl	%r12d
	cmpq	%rax, %r13
	jl	.LBB3_5
	jmp	.LBB3_7
.LBB3_10:                               # %.thread
                                        #   in Loop: Header=BB3_4 Depth=1
	xorl	%r12d, %r12d
	movl	$.L.str.5, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %edi
	movq	%rbx, %rsi
	callq	putc
	movslq	(%r14), %rax
	incq	%r13
	cmpq	%rax, %r13
	jl	.LBB3_4
	jmp	.LBB3_8
.LBB3_7:                                # %._crit_edge
	movl	%r12d, %ecx
	negb	%cl
	shll	%cl, %ebp
	movzbl	%bpl, %ebp
	movl	$.L.str.5, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %edi
	movq	%rbx, %rsi
	callq	putc
	addl	$8, %r12d
	jmp	.LBB3_8
.LBB3_9:
	movl	$.L.str.4, %edi
	callq	perror
.LBB3_2:
	xorl	%r12d, %r12d
.LBB3_8:                                # %._crit_edge.thread43
	movq	%rbx, %rdi
	callq	fclose
	movl	%r12d, last_byte_padding_gpu(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z20write_GPU_compressedPbPi, .Lfunc_end3-_Z20write_GPU_compressedPbPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z25print_dchar_huffman_tablev  # -- Begin function _Z25print_dchar_huffman_tablev
	.type	_Z25print_dchar_huffman_tablev,@function
_Z25print_dchar_huffman_tablev:         # @_Z25print_dchar_huffman_tablev
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	callq	getchar
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	movl	$.Lstr.10, %edi
	callq	puts@PLT
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	movl	$copiedarray2, %r14d
	xorl	%ebx, %ebx
.LBB4_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_2 Depth 2
	xorl	%r15d, %r15d
	xorl	%eax, %eax
.LBB4_2:                                #   Parent Loop BB4_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpl	$-1, (%r14,%r15,4)
	je	.LBB4_8
# %bb.3:                                #   in Loop: Header=BB4_2 Depth=2
	testb	$1, %al
	jne	.LBB4_7
# %bb.4:                                #   in Loop: Header=BB4_2 Depth=2
	cmpq	$10, %rbx
	jne	.LBB4_6
# %bb.5:                                #   in Loop: Header=BB4_2 Depth=2
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB4_7
.LBB4_6:                                #   in Loop: Header=BB4_2 Depth=2
	movl	$.L.str.10, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
.LBB4_7:                                #   in Loop: Header=BB4_2 Depth=2
	movl	(%r14,%r15,4), %esi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movb	$1, %al
.LBB4_8:                                #   in Loop: Header=BB4_2 Depth=2
	incq	%r15
	cmpq	$255, %r15
	jne	.LBB4_2
# %bb.9:                                #   in Loop: Header=BB4_1 Depth=1
	testb	$1, %al
	je	.LBB4_11
# %bb.10:                               #   in Loop: Header=BB4_1 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
.LBB4_11:                               #   in Loop: Header=BB4_1 Depth=1
	incq	%rbx
	addq	$1020, %r14                     # imm = 0x3FC
	cmpq	$256, %rbx                      # imm = 0x100
	jne	.LBB4_1
# %bb.12:
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	getchar                         # TAILCALL
.Lfunc_end4:
	.size	_Z25print_dchar_huffman_tablev, .Lfunc_end4-_Z25print_dchar_huffman_tablev
	.cfi_endproc
                                        # -- End function
	.globl	_Z14insertion_sortPP4nodei      # -- Begin function _Z14insertion_sortPP4nodei
	.type	_Z14insertion_sortPP4nodei,@function
_Z14insertion_sortPP4nodei:             # @_Z14insertion_sortPP4nodei
	.cfi_startproc
# %bb.0:
                                        # kill: def $esi killed $esi def $rsi
	cmpl	$2, %esi
	jl	.LBB5_8
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	decl	%esi
	movl	$1, %eax
	xorl	%ecx, %ecx
	movl	$1, %edx
.LBB5_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_3 Depth 2
	movq	(%rdi,%rax,8), %r8
	movl	4(%r8), %r9d
	xorl	%r10d, %r10d
	movq	%rcx, %r11
.LBB5_3:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rdi,%r11,8), %rbx
	cmpl	%r9d, 4(%rbx)
	jge	.LBB5_6
# %bb.4:                                #   in Loop: Header=BB5_3 Depth=2
	movq	%rbx, 8(%rdi,%r11,8)
	leaq	-1(%r11), %rbx
	testq	%r11, %r11
	movzbl	%r10b, %r10d
	cmovlel	%edx, %r10d
	movq	%rbx, %r11
	testb	$1, %r10b
	je	.LBB5_3
# %bb.5:                                # %.thread.loopexit
                                        #   in Loop: Header=BB5_2 Depth=1
	movl	%ebx, %r11d
.LBB5_6:                                # %.thread
                                        #   in Loop: Header=BB5_2 Depth=1
	movslq	%r11d, %r9
	movq	%r8, 8(%rdi,%r9,8)
	incq	%rax
	incq	%rcx
	cmpq	%rsi, %rcx
	jne	.LBB5_2
# %bb.7:
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
.LBB5_8:                                # %._crit_edge
	retq
.Lfunc_end5:
	.size	_Z14insertion_sortPP4nodei, .Lfunc_end5-_Z14insertion_sortPP4nodei
	.cfi_endproc
                                        # -- End function
	.globl	_Z20print_char_frequencyv       # -- Begin function _Z20print_char_frequencyv
	.type	_Z20print_char_frequencyv,@function
_Z20print_char_frequencyv:              # @_Z20print_char_frequencyv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	movl	$.Lstr.6, %edi
	callq	puts@PLT
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	xorl	%ebx, %ebx
.LBB6_1:                                # =>This Inner Loop Header: Depth=1
	movl	char_frequency(,%rbx,4), %ecx
	testl	%ecx, %ecx
	je	.LBB6_5
# %bb.2:                                #   in Loop: Header=BB6_1 Depth=1
	cmpq	$10, %rbx
	jne	.LBB6_4
# %bb.3:                                #   in Loop: Header=BB6_1 Depth=1
	movl	$.L.str.14, %edi
	movl	$10, %esi
	movl	%ecx, %edx
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB6_5
.LBB6_4:                                #   in Loop: Header=BB6_1 Depth=1
	movl	$.L.str.15, %edi
	movl	%ebx, %esi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	printf
.LBB6_5:                                #   in Loop: Header=BB6_1 Depth=1
	incq	%rbx
	cmpq	$256, %rbx                      # imm = 0x100
	jne	.LBB6_1
# %bb.6:
	movl	$.Lstr.16, %edi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end6:
	.size	_Z20print_char_frequencyv, .Lfunc_end6-_Z20print_char_frequencyv
	.cfi_endproc
                                        # -- End function
	.globl	_Z24print_char_huffman_tablev   # -- Begin function _Z24print_char_huffman_tablev
	.type	_Z24print_char_huffman_tablev,@function
_Z24print_char_huffman_tablev:          # @_Z24print_char_huffman_tablev
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	movl	$.Lstr.10, %edi
	callq	puts@PLT
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	movl	$char_huffman_table, %r14d
	xorl	%ebx, %ebx
.LBB7_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_2 Depth 2
	xorl	%r15d, %r15d
	xorl	%eax, %eax
.LBB7_2:                                #   Parent Loop BB7_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpl	$-1, (%r14,%r15,4)
	je	.LBB7_8
# %bb.3:                                #   in Loop: Header=BB7_2 Depth=2
	testb	$1, %al
	jne	.LBB7_7
# %bb.4:                                #   in Loop: Header=BB7_2 Depth=2
	cmpq	$10, %rbx
	jne	.LBB7_6
# %bb.5:                                #   in Loop: Header=BB7_2 Depth=2
	movl	$.L.str.9, %edi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB7_7
.LBB7_6:                                #   in Loop: Header=BB7_2 Depth=2
	movl	$.L.str.10, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
.LBB7_7:                                #   in Loop: Header=BB7_2 Depth=2
	movl	(%r14,%r15,4), %esi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movb	$1, %al
.LBB7_8:                                #   in Loop: Header=BB7_2 Depth=2
	incq	%r15
	cmpq	$255, %r15
	jne	.LBB7_2
# %bb.9:                                #   in Loop: Header=BB7_1 Depth=1
	testb	$1, %al
	je	.LBB7_11
# %bb.10:                               #   in Loop: Header=BB7_1 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
.LBB7_11:                               #   in Loop: Header=BB7_1 Depth=1
	incq	%rbx
	addq	$1020, %r14                     # imm = 0x3FC
	cmpq	$256, %rbx                      # imm = 0x100
	jne	.LBB7_1
# %bb.12:
	movl	$.Lstr.16, %edi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end7:
	.size	_Z24print_char_huffman_tablev, .Lfunc_end7-_Z24print_char_huffman_tablev
	.cfi_endproc
                                        # -- End function
	.globl	_Z16printout_inorderP4node      # -- Begin function _Z16printout_inorderP4node
	.type	_Z16printout_inorderP4node,@function
_Z16printout_inorderP4node:             # @_Z16printout_inorderP4node
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
.LBB8_1:                                # %tailrecurse
                                        # =>This Inner Loop Header: Depth=1
	movq	16(%rbx), %rdi
	testq	%rdi, %rdi
	je	.LBB8_3
# %bb.2:                                #   in Loop: Header=BB8_1 Depth=1
	callq	_Z16printout_inorderP4node
.LBB8_3:                                #   in Loop: Header=BB8_1 Depth=1
	movl	(%rbx), %edx
	movl	4(%rbx), %esi
	testl	%edx, %edx
	je	.LBB8_7
# %bb.4:                                #   in Loop: Header=BB8_1 Depth=1
	cmpl	$10, %edx
	jne	.LBB8_6
# %bb.5:                                #   in Loop: Header=BB8_1 Depth=1
	movl	$.L.str.16, %edi
	jmp	.LBB8_8
.LBB8_7:                                #   in Loop: Header=BB8_1 Depth=1
	movl	$.L.str.18, %edi
.LBB8_8:                                #   in Loop: Header=BB8_1 Depth=1
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB8_9
.LBB8_6:                                #   in Loop: Header=BB8_1 Depth=1
	movl	$.L.str.17, %edi
	xorl	%eax, %eax
	callq	printf
.LBB8_9:                                #   in Loop: Header=BB8_1 Depth=1
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.LBB8_1
# %bb.10:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z16printout_inorderP4node, .Lfunc_end8-_Z16printout_inorderP4node
	.cfi_endproc
                                        # -- End function
	.globl	_Z9read_filev                   # -- Begin function _Z9read_filev
	.type	_Z9read_filev,@function
_Z9read_filev:                          # @_Z9read_filev
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	movl	$.L.str.19, %edi
	movl	$.L.str.20, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB9_1
# %bb.2:
	movq	%rax, %rbx
	movl	$50000, %edi                    # imm = 0xC350
	callq	malloc
	movq	%rax, h_input(%rip)
	movl	$255, %ebp
.LBB9_3:                                # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	callq	getc
                                        # kill: def $eax killed $eax def $rax
	movq	h_input(%rip), %rcx
	movslq	number_of_char(%rip), %rdx
	movb	%al, (%rcx,%rdx)
	incl	number_of_char(%rip)
	andl	%ebp, %eax
	incl	char_frequency(,%rax,4)
	cmpl	%ebp, %eax
	jne	.LBB9_3
# %bb.4:
	movq	%rbx, %rdi
	callq	fclose
.LBB9_5:
	movl	$0, char_frequency+1020(%rip)
	decl	number_of_char(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB9_1:
	.cfi_def_cfa_offset 32
	movl	$.L.str.4, %edi
	callq	perror
	jmp	.LBB9_5
.Lfunc_end9:
	.size	_Z9read_filev, .Lfunc_end9-_Z9read_filev
	.cfi_endproc
                                        # -- End function
	.globl	_Z17traverse_preorderP4nodePi   # -- Begin function _Z17traverse_preorderP4nodePi
	.type	_Z17traverse_preorderP4nodePi,@function
_Z17traverse_preorderP4nodePi:          # @_Z17traverse_preorderP4nodePi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	cmpl	$0, (%rdi)
	je	.LBB10_3
# %bb.1:                                # %.preheader37.preheader
	xorl	%eax, %eax
.LBB10_2:                               # %.preheader37
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%rax,4), %ecx
	movslq	(%r14), %rdx
	imulq	$1020, %rdx, %rdx               # imm = 0x3FC
	movl	%ecx, char_huffman_table(%rdx,%rax,4)
	incq	%rax
	cmpq	$255, %rax
	jne	.LBB10_2
.LBB10_3:                               # %.loopexit
	movq	16(%r14), %rdi
	testq	%rdi, %rdi
	je	.LBB10_9
# %bb.4:                                # %.preheader36.preheader
	xorl	%eax, %eax
.LBB10_5:                               # %.preheader36
                                        # =>This Inner Loop Header: Depth=1
	cmpl	$-1, (%rbx,%rax,4)
	je	.LBB10_8
# %bb.6:                                #   in Loop: Header=BB10_5 Depth=1
	incq	%rax
	cmpq	$255, %rax
	jne	.LBB10_5
# %bb.7:
	movl	$255, %eax
.LBB10_8:
	movl	%eax, %r15d
	movl	$1, (%rbx,%r15,4)
	movq	%rbx, %rsi
	callq	_Z17traverse_preorderP4nodePi
	movl	$-1, (%rbx,%r15,4)
.LBB10_9:
	movq	8(%r14), %rdi
	testq	%rdi, %rdi
	je	.LBB10_15
# %bb.10:                               # %.preheader.preheader
	xorl	%eax, %eax
.LBB10_11:                              # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	cmpl	$-1, (%rbx,%rax,4)
	je	.LBB10_14
# %bb.12:                               #   in Loop: Header=BB10_11 Depth=1
	incq	%rax
	cmpq	$255, %rax
	jne	.LBB10_11
# %bb.13:
	movl	$255, %eax
.LBB10_14:
	movl	%eax, %r14d
	movl	$0, (%rbx,%r14,4)
	movq	%rbx, %rsi
	callq	_Z17traverse_preorderP4nodePi
	movl	$-1, (%rbx,%r14,4)
.LBB10_15:                              # %common.ret56
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	_Z17traverse_preorderP4nodePi, .Lfunc_end10-_Z17traverse_preorderP4nodePi
	.cfi_endproc
                                        # -- End function
	.globl	_Z23construct_huffman_tableP4node # -- Begin function _Z23construct_huffman_tableP4node
	.type	_Z23construct_huffman_tableP4node,@function
_Z23construct_huffman_tableP4node:      # @_Z23construct_huffman_tableP4node
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$1032, %rsp                     # imm = 0x408
	.cfi_def_cfa_offset 1056
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %rbx
	movq	%rsp, %r14
	movl	$1020, %edx                     # imm = 0x3FC
	movq	%r14, %rdi
	movl	$255, %esi
	callq	memset@PLT
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_Z17traverse_preorderP4nodePi
	addq	$1032, %rsp                     # imm = 0x408
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end11:
	.size	_Z23construct_huffman_tableP4node, .Lfunc_end11-_Z23construct_huffman_tableP4node
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z17build_binary_treev
.LCPI12_0:
	.zero	16
	.text
	.globl	_Z17build_binary_treev
	.type	_Z17build_binary_treev,@function
_Z17build_binary_treev:                 # @_Z17build_binary_treev
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$3080, %rsp                     # imm = 0xC08
	.cfi_def_cfa_offset 3120
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%r14d, %r14d
	xorl	%ebx, %ebx
.LBB12_1:                               # =>This Inner Loop Header: Depth=1
	movl	char_frequency(,%r14,4), %ebp
	testl	%ebp, %ebp
	je	.LBB12_3
# %bb.2:                                #   in Loop: Header=BB12_1 Depth=1
	movl	$24, %edi
	callq	malloc
	xorps	%xmm0, %xmm0
	movups	%xmm0, 8(%rax)
	movl	%r14d, (%rax)
	movl	%ebp, 4(%rax)
	movslq	%ebx, %rbx
	movq	%rax, (%rsp,%rbx,8)
	incl	%ebx
.LBB12_3:                               #   in Loop: Header=BB12_1 Depth=1
	incq	%r14
	cmpq	$256, %r14                      # imm = 0x100
	jne	.LBB12_1
# %bb.4:
	movq	%rsp, %rdi
	movl	%ebx, %esi
	callq	_Z14insertion_sortPP4nodei
	cmpl	$2, %ebx
	jl	.LBB12_7
# %bb.5:                                # %.lr.ph.preheader
	movl	%ebx, %r15d
	movq	%rsp, %rbx
.LBB12_6:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$24, %edi
	callq	malloc
	leaq	-1(%r15), %r14
	movq	-8(%rsp,%r15,8), %rcx
	movq	%rcx, 8(%rax)
	movq	-16(%rsp,%r15,8), %rdx
	movq	%rdx, 16(%rax)
	movl	4(%rdx), %edx
	addl	4(%rcx), %edx
	movl	%edx, 4(%rax)
	movl	$0, (%rax)
	movq	$0, -8(%rsp,%r15,8)
	movq	%rax, -16(%rsp,%r15,8)
	movq	%rbx, %rdi
	movl	%r14d, %esi
	callq	_Z14insertion_sortPP4nodei
	cmpq	$2, %r15
	movq	%r14, %r15
	ja	.LBB12_6
.LBB12_7:                               # %._crit_edge
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	movl	$.Lstr.14, %edi
	callq	puts@PLT
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	movq	(%rsp), %rbx
	movq	%rbx, %rdi
	callq	_Z16printout_inorderP4node
	movl	$.Lstr.16, %edi
	callq	puts@PLT
	leaq	2048(%rsp), %r14
	movl	$1020, %edx                     # imm = 0x3FC
	movq	%r14, %rdi
	movl	$255, %esi
	callq	memset@PLT
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_Z17traverse_preorderP4nodePi
	addq	$3080, %rsp                     # imm = 0xC08
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end12:
	.size	_Z17build_binary_treev, .Lfunc_end12-_Z17build_binary_treev
	.cfi_endproc
                                        # -- End function
	.globl	_Z17array_initializerv          # -- Begin function _Z17array_initializerv
	.type	_Z17array_initializerv,@function
_Z17array_initializerv:                 # @_Z17array_initializerv
	.cfi_startproc
# %bb.0:                                # %.preheader.preheader
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$char_frequency, %edi
	movl	$1024, %edx                     # imm = 0x400
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$char_huffman_table, %edi
	movl	$261120, %edx                   # imm = 0x3FC00
	movl	$255, %esi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	memset@PLT                      # TAILCALL
.Lfunc_end13:
	.size	_Z17array_initializerv, .Lfunc_end13-_Z17array_initializerv
	.cfi_endproc
                                        # -- End function
	.globl	_Z13compress_filev              # -- Begin function _Z13compress_filev
	.type	_Z13compress_filev,@function
_Z13compress_filev:                     # @_Z13compress_filev
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$.L.str.19, %edi
	movl	$.L.str.22, %esi
	callq	fopen
	movq	%rax, %rbx
	movl	$.L.str.23, %edi
	movl	$.L.str.3, %esi
	callq	fopen
	movq	%rbx, (%rsp)                    # 8-byte Spill
	testq	%rbx, %rbx
	je	.LBB14_15
# %bb.1:
	movq	%rax, %r14
	testq	%rax, %rax
	je	.LBB14_15
# %bb.2:                                # %.preheader.preheader
	xorl	%r15d, %r15d
	xorl	%ebp, %ebp
.LBB14_3:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB14_4 Depth 2
	movq	(%rsp), %rdi                    # 8-byte Reload
	callq	getc
	movzbl	%al, %r12d
	imulq	$1020, %r12, %r13               # imm = 0x3FC
	xorl	%ebx, %ebx
.LBB14_4:                               #   Parent Loop BB14_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	char_huffman_table(%r13,%rbx,4), %eax
	cmpl	$1, %eax
	je	.LBB14_9
# %bb.5:                                #   in Loop: Header=BB14_4 Depth=2
	testl	%eax, %eax
	jne	.LBB14_7
# %bb.6:                                #   in Loop: Header=BB14_4 Depth=2
	addb	%bpl, %bpl
	jmp	.LBB14_10
.LBB14_9:                               #   in Loop: Header=BB14_4 Depth=2
	addb	%bpl, %bpl
	orb	$1, %bpl
.LBB14_10:                              #   in Loop: Header=BB14_4 Depth=2
	incl	%r15d
	cmpl	$8, %r15d
	jne	.LBB14_12
# %bb.11:                               #   in Loop: Header=BB14_4 Depth=2
	movzbl	%bpl, %ebp
	xorl	%r15d, %r15d
	movl	$.L.str.5, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %edi
	movq	%r14, %rsi
	callq	putc
	xorl	%ebp, %ebp
.LBB14_12:                              #   in Loop: Header=BB14_4 Depth=2
	incq	%rbx
	cmpq	$255, %rbx
	jne	.LBB14_4
	jmp	.LBB14_13
.LBB14_7:                               #   in Loop: Header=BB14_3 Depth=1
	cmpl	$255, %r12d
	je	.LBB14_8
.LBB14_13:                              # %.loopexit
                                        #   in Loop: Header=BB14_3 Depth=1
	cmpl	$255, %r12d
	jne	.LBB14_3
	jmp	.LBB14_14
.LBB14_8:                               # %.loopexit.thread.sink.split
	movzbl	%bpl, %eax
	movb	$8, %cl
	subb	%r15b, %cl
	movl	%eax, %edx
	shll	%cl, %edx
	testl	%r15d, %r15d
	movzbl	%dl, %ebp
	cmovel	%eax, %ebp
	movl	$.L.str.5, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %edi
	movq	%r14, %rsi
	callq	putc
.LBB14_14:                              # %.loopexit.thread
	movq	(%rsp), %rdi                    # 8-byte Reload
	callq	fclose
	movq	%r14, %rdi
	callq	fclose
	movl	%r15d, last_byte_padding(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB14_15:
	.cfi_def_cfa_offset 64
	movl	$.L.str.4, %edi
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	perror                          # TAILCALL
.Lfunc_end14:
	.size	_Z13compress_filev, .Lfunc_end14-_Z13compress_filev
	.cfi_endproc
                                        # -- End function
	.globl	_Z25print_gpu_compressed_filePci # -- Begin function _Z25print_gpu_compressed_filePci
	.type	_Z25print_gpu_compressed_filePci,@function
_Z25print_gpu_compressed_filePci:       # @_Z25print_gpu_compressed_filePci
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	callq	fopen
	movq	%rax, %r14
	testl	%ebp, %ebp
	jle	.LBB15_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r12d
	xorl	%r15d, %r15d
.LBB15_2:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%rbx,%r15), %ebp
	movl	$.L.str.24, %edi
	movl	%r15d, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %edi
	movq	%r14, %rsi
	callq	putc
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB15_2
.LBB15_3:                               # %._crit_edge
	movq	%r14, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end15:
	.size	_Z25print_gpu_compressed_filePci, .Lfunc_end15-_Z25print_gpu_compressed_filePci
	.cfi_endproc
                                        # -- End function
	.globl	_Z15decompress_filev            # -- Begin function _Z15decompress_filev
	.type	_Z15decompress_filev,@function
_Z15decompress_filev:                   # @_Z15decompress_filev
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$1064, %rsp                     # imm = 0x428
	.cfi_def_cfa_offset 1120
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	32(%rsp), %rdi
	movl	$1020, %edx                     # imm = 0x3FC
	movl	$255, %esi
	callq	memset@PLT
	movl	$.L.str.23, %edi
	movl	$.L.str.22, %esi
	callq	fopen
	movq	%rax, %rbx
	movl	$.L.str.25, %edi
	movl	$.L.str.3, %esi
	callq	fopen
	movq	%rbx, 16(%rsp)                  # 8-byte Spill
	testq	%rbx, %rbx
	je	.LBB16_19
# %bb.1:
	testq	%rax, %rax
	je	.LBB16_19
# %bb.2:
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	16(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	callq	getc
	movl	%eax, %r13d
	movq	%rbx, %rdi
	callq	getc
	movl	%eax, %ebp
	xorl	%ebx, %ebx
	movb	$1, %al
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	movl	$-1, %r14d
	xorl	%r15d, %r15d
.LBB16_3:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB16_13 Depth 2
                                        #       Child Loop BB16_15 Depth 3
	cmpl	$7, %ebx
	je	.LBB16_4
# %bb.11:                               #   in Loop: Header=BB16_3 Depth=1
	movl	%ebp, %r12d
	leal	(,%r13,2), %ebp
	incl	%ebx
                                        # kill: def $bpl killed $bpl killed $ebp def $ebp
	jmp	.LBB16_12
.LBB16_4:                               #   in Loop: Header=BB16_3 Depth=1
	xorl	%ebx, %ebx
	testb	$1, 12(%rsp)                    # 1-byte Folded Reload
	jne	.LBB16_6
# %bb.5:                                #   in Loop: Header=BB16_3 Depth=1
	movl	%ebp, %r12d
	jmp	.LBB16_9
.LBB16_6:                               #   in Loop: Header=BB16_3 Depth=1
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	getc
	movl	%eax, %r12d
	cmpb	$-1, %r12b
	jne	.LBB16_9
# %bb.7:                                #   in Loop: Header=BB16_3 Depth=1
	movl	number_of_char(%rip), %eax
	subl	%r15d, %eax
	cmpl	$7, %eax
	jg	.LBB16_9
# %bb.8:                                #   in Loop: Header=BB16_3 Depth=1
	movl	$7, %ebx
	subl	last_byte_padding(%rip), %ebx
	movl	$0, 12(%rsp)                    # 4-byte Folded Spill
.LBB16_9:                               #   in Loop: Header=BB16_3 Depth=1
	cmpb	$-1, %bpl
	jne	.LBB16_12
# %bb.10:                               #   in Loop: Header=BB16_3 Depth=1
	movl	number_of_char(%rip), %eax
	subl	%r15d, %eax
	movb	$-1, %bpl
	cmpl	$8, %eax
	jl	.LBB16_18
.LBB16_12:                              #   in Loop: Header=BB16_3 Depth=1
	incl	%r14d
	movslq	%r14d, %rax
	shrb	$7, %r13b
	movzbl	%r13b, %ecx
	movl	%ecx, 32(%rsp,%rax,4)
	movl	$char_huffman_table, %eax
	xorl	%edi, %edi
.LBB16_13:                              # %.preheader
                                        #   Parent Loop BB16_3 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB16_15 Depth 3
	xorl	%ecx, %ecx
.LBB16_15:                              #   Parent Loop BB16_3 Depth=1
                                        #     Parent Loop BB16_13 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%rax,%rcx,4), %edx
	cmpl	32(%rsp,%rcx,4), %edx
	jne	.LBB16_16
# %bb.14:                               #   in Loop: Header=BB16_15 Depth=3
	incq	%rcx
	cmpq	$255, %rcx
	jne	.LBB16_15
	jmp	.LBB16_20
.LBB16_16:                              #   in Loop: Header=BB16_13 Depth=2
	incq	%rdi
	addq	$1020, %rax                     # imm = 0x3FC
	cmpq	$256, %rdi                      # imm = 0x100
	jne	.LBB16_13
	jmp	.LBB16_17
.LBB16_20:                              # %.critedge
                                        #   in Loop: Header=BB16_3 Depth=1
                                        # kill: def $edi killed $edi killed $rdi
	movq	24(%rsp), %rsi                  # 8-byte Reload
	callq	putc
	movl	$1020, %edx                     # imm = 0x3FC
	leaq	32(%rsp), %rdi
	movl	$255, %esi
	callq	memset@PLT
	incl	%r15d
	movl	$-1, %r14d
.LBB16_17:                              # %.loopexit
                                        #   in Loop: Header=BB16_3 Depth=1
	movl	%ebp, %r13d
	movl	%r12d, %ebp
	cmpl	$255, %r14d
	jl	.LBB16_3
.LBB16_18:
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	fclose
	movq	24(%rsp), %rdi                  # 8-byte Reload
	addq	$1064, %rsp                     # imm = 0x428
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.LBB16_19:
	.cfi_def_cfa_offset 1120
	movl	$.L.str.4, %edi
	addq	$1064, %rsp                     # imm = 0x428
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	perror                          # TAILCALL
.Lfunc_end16:
	.size	_Z15decompress_filev, .Lfunc_end16-_Z15decompress_filev
	.cfi_endproc
                                        # -- End function
	.globl	_Z10initializev                 # -- Begin function _Z10initializev
	.type	_Z10initializev,@function
_Z10initializev:                        # @_Z10initializev
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$char_frequency, %edi
	movl	$1024, %edx                     # imm = 0x400
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$char_huffman_table, %edi
	movl	$261120, %edx                   # imm = 0x3FC00
	movl	$255, %esi
	callq	memset@PLT
	callq	_Z9read_filev
	callq	_Z20print_char_frequencyv
	callq	_Z17build_binary_treev
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Z24print_char_huffman_tablev   # TAILCALL
.Lfunc_end17:
	.size	_Z10initializev, .Lfunc_end17-_Z10initializev
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__read2darrayPii # -- Begin function _Z26__device_stub__read2darrayPii
	.type	_Z26__device_stub__read2darrayPii,@function
_Z26__device_stub__read2darrayPii:      # @_Z26__device_stub__read2darrayPii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z11read2darrayPii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end18:
	.size	_Z26__device_stub__read2darrayPii, .Lfunc_end18-_Z26__device_stub__read2darrayPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__check_boolPb # -- Begin function _Z25__device_stub__check_boolPb
	.type	_Z25__device_stub__check_boolPb,@function
_Z25__device_stub__check_boolPb:        # @_Z25__device_stub__check_boolPb
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z10check_boolPb, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end19:
	.size	_Z25__device_stub__check_boolPb, .Lfunc_end19-_Z25__device_stub__check_boolPb
	.cfi_endproc
                                        # -- End function
	.globl	_Z13print_huffmanv              # -- Begin function _Z13print_huffmanv
	.type	_Z13print_huffmanv,@function
_Z13print_huffmanv:                     # @_Z13print_huffmanv
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$.L.str.26, %edi
	xorl	%eax, %eax
	callq	printf
	movq	h_input(%rip), %rax
	movzbl	(%rax), %r15d
	movzbl	1(%rax), %r14d
	movzbl	2(%rax), %ebp
	movzbl	3(%rax), %ebx
	movq	huffman_check(%rip), %rax
	imulq	$1020, %r15, %r12               # imm = 0x3FC
	xorl	%r13d, %r13d
.LBB20_1:                               # =>This Inner Loop Header: Depth=1
	leaq	(%rax,%r12), %rcx
	movl	(%rcx,%r13,4), %edx
	cmpl	$-1, %edx
	je	.LBB20_3
# %bb.2:                                #   in Loop: Header=BB20_1 Depth=1
	movl	$.L.str.27, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	huffman_check(%rip), %rax
.LBB20_3:                               #   in Loop: Header=BB20_1 Depth=1
	incq	%r13
	cmpq	$255, %r13
	jne	.LBB20_1
# %bb.4:                                # %.preheader39
	movl	%r14d, %ecx
	imulq	$1020, %rcx, %r15               # imm = 0x3FC
	xorl	%r12d, %r12d
.LBB20_5:                               # =>This Inner Loop Header: Depth=1
	leaq	(%rax,%r15), %rcx
	movl	(%rcx,%r12,4), %edx
	cmpl	$-1, %edx
	je	.LBB20_7
# %bb.6:                                #   in Loop: Header=BB20_5 Depth=1
	movl	$.L.str.27, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	huffman_check(%rip), %rax
.LBB20_7:                               #   in Loop: Header=BB20_5 Depth=1
	incq	%r12
	cmpq	$255, %r12
	jne	.LBB20_5
# %bb.8:                                # %.preheader38
	movl	%ebp, %ecx
	imulq	$1020, %rcx, %r14               # imm = 0x3FC
	xorl	%r15d, %r15d
.LBB20_9:                               # =>This Inner Loop Header: Depth=1
	leaq	(%rax,%r14), %rcx
	movl	(%rcx,%r15,4), %edx
	cmpl	$-1, %edx
	je	.LBB20_11
# %bb.10:                               #   in Loop: Header=BB20_9 Depth=1
	movl	$.L.str.27, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movq	huffman_check(%rip), %rax
.LBB20_11:                              #   in Loop: Header=BB20_9 Depth=1
	incq	%r15
	cmpq	$255, %r15
	jne	.LBB20_9
# %bb.12:                               # %.preheader
	movl	%ebx, %ecx
	imulq	$1020, %rcx, %r14               # imm = 0x3FC
	xorl	%r15d, %r15d
.LBB20_13:                              # =>This Inner Loop Header: Depth=1
	leaq	(%rax,%r14), %rcx
	movl	(%rcx,%r15,4), %edx
	cmpl	$-1, %edx
	je	.LBB20_15
# %bb.14:                               #   in Loop: Header=BB20_13 Depth=1
	movl	$.L.str.27, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movq	huffman_check(%rip), %rax
.LBB20_15:                              #   in Loop: Header=BB20_13 Depth=1
	incq	%r15
	cmpq	$255, %r15
	jne	.LBB20_13
# %bb.16:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end20:
	.size	_Z13print_huffmanv, .Lfunc_end20-_Z13print_huffmanv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI21_0:
	.long	0                               # 0x0
	.long	1                               # 0x1
	.long	1                               # 0x1
	.long	1                               # 0x1
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI21_1:
	.long	0x49742400                      # float 1.0E+6
.LCPI21_2:
	.long	0x447a0000                      # float 1000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$.Lstr.17, %edi
	callq	puts@PLT
	callq	_Z10initializev
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movslq	number_of_char(%rip), %rsi
	movl	$d_input, %edi
	callq	hipMalloc
	movl	$.L.str.29, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	d_input(%rip), %rdi
	movq	h_input(%rip), %rsi
	movslq	number_of_char(%rip), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.30, %edi
	callq	_Z14checkCUDAErrorPKc
	movslq	number_of_char(%rip), %rax
	movq	%rax, %rsi
	shlq	$8, %rsi
	subq	%rax, %rsi
	movl	$compressedfile_array, %edi
	callq	hipMalloc
	movl	$.L.str.31, %edi
	callq	_Z14checkCUDAErrorPKc
	movl	$d_char_huffman_table, %edi
	movl	$261120, %esi                   # imm = 0x3FC00
	callq	hipMalloc
	movl	$.L.str.32, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	d_char_huffman_table(%rip), %rdi
	movl	$char_huffman_table, %esi
	movl	$261120, %edx                   # imm = 0x3FC00
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.33, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	huffman_check(%rip), %rdi
	movq	d_char_huffman_table(%rip), %rsi
	movl	$261120, %edx                   # imm = 0x3FC00
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.34, %edi
	callq	_Z14checkCUDAErrorPKc
	movslq	number_of_char(%rip), %rsi
	shlq	$2, %rsi
	movl	$block_cntr_array, %edi
	callq	hipMalloc
	movl	$.L.str.35, %edi
	callq	_Z14checkCUDAErrorPKc
	movl	$d_last_byte_padding, %edi
	movl	$4, %esi
	callq	hipMalloc
	movl	$.L.str.36, %edi
	callq	_Z14checkCUDAErrorPKc
	movl	$finalsize, %edi
	movl	$4, %esi
	callq	hipMalloc
	movl	$.L.str.37, %edi
	callq	_Z14checkCUDAErrorPKc
	movl	$orig_number_of_char, %edi
	movl	$4, %esi
	callq	hipMalloc
	movl	$.L.str.38, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	orig_number_of_char(%rip), %rdi
	movl	$number_of_char, %esi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.39, %edi
	callq	_Z14checkCUDAErrorPKc
	movl	$2, %edi
	callq	malloc
	movq	%rax, h_bool(%rip)
	movw	$257, (%rax)                    # imm = 0x101
	movl	$.L.str.40, %edi
	movl	$1, %esi
	movl	$1, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$d_bool, %edi
	movl	$2, %esi
	callq	hipMalloc
	movl	$.L.str.41, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	d_bool(%rip), %rdi
	movq	h_bool(%rip), %rsi
	movl	$2, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.42, %edi
	callq	_Z14checkCUDAErrorPKc
	movl	$.L.str.43, %edi
	callq	_Z14checkCUDAErrorPKc
	callq	hipDeviceSynchronize
	movl	$.L.str.44, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	h_bool(%rip), %rdi
	movq	d_bool(%rip), %rsi
	movl	$2, %edx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.45, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	h_bool(%rip), %rax
	movzbl	(%rax), %esi
	movzbl	1(%rax), %edx
	movl	$.L.str.46, %edi
	xorl	%eax, %eax
	callq	printf
	movaps	.LCPI21_0(%rip), %xmm0          # xmm0 = [0,1,1,1]
	movups	%xmm0, 40(%rsp)
	movq	$0, 32(%rsp)
	movb	$1, %bpl
	movq	h_bool(%rip), %rax
	xorl	%ecx, %ecx
.LBB21_1:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB21_3 Depth 2
	leaq	(%rcx,%rcx,2), %r14
	leaq	(%rsp,%r14,4), %r15
	addq	$32, %r15
	movb	$1, %r12b
	xorl	%r13d, %r13d
.LBB21_3:                               #   Parent Loop BB21_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	(%rax,%r13), %esi
	movl	(%r15,%r13,4), %ebx
	movl	$.L.str.47, %edi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	printf
	movq	h_bool(%rip), %rax
	movzbl	(%rax,%r13), %ecx
	cmpl	%ecx, %ebx
	jne	.LBB21_5
# %bb.2:                                #   in Loop: Header=BB21_3 Depth=2
	movl	$1, %r13d
	testb	$1, %r12b
	movl	$0, %r12d
	jne	.LBB21_3
# %bb.4:                                # %.critedge
                                        #   in Loop: Header=BB21_1 Depth=1
	movl	32(%rsp,%r14,4), %esi
	movl	$.L.str.48, %edi
	xorl	%eax, %eax
	callq	printf
	movq	h_bool(%rip), %rax
.LBB21_5:                               # %.loopexit
                                        #   in Loop: Header=BB21_1 Depth=1
	movl	$1, %ecx
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB21_1
# %bb.6:
	movabsq	$4294967552, %rbx               # imm = 0x100000100
	movl	number_of_char(%rip), %esi
	movl	$.L.str.49, %edi
	xorl	%eax, %eax
	callq	printf
	callq	getchar
	callq	getchar
	callq	_Z13print_huffmanv
	movl	number_of_char(%rip), %r15d
	leal	255(%r15), %r14d
	addl	$510, %r15d                     # imm = 0x1FE
	testl	%r14d, %r14d
	cmovsl	%r15d, %r14d
	sarl	$8, %r14d
	movl	$.L.str.50, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	cmpl	$511, %r15d                     # imm = 0x1FF
	movl	$1, %eax
	cmovbl	%eax, %r14d
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	$.L.str.51, %edi
	callq	_Z14checkCUDAErrorPKc
	leaq	(%r14,%rbx), %r15
	addq	$-256, %r15
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB21_8
# %bb.7:
	movq	d_input(%rip), %rdi
	movq	compressedfile_array(%rip), %rsi
	movq	d_char_huffman_table(%rip), %rdx
	movq	block_cntr_array(%rip), %rcx
	movq	d_last_byte_padding(%rip), %r8
	movq	finalsize(%rip), %r9
	movl	number_of_char(%rip), %eax
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	pushq	orig_number_of_char(%rip)
	.cfi_adjust_cfa_offset 8
	callq	_Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB21_8:
	movl	$.L.str.52, %edi
	callq	_Z14checkCUDAErrorPKc
	callq	hipDeviceSynchronize
	movslq	number_of_char(%rip), %r14
	shlq	$2, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, block_cntr_array_check(%rip)
	movq	block_cntr_array(%rip), %rsi
	movq	%rax, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.53, %edi
	callq	_Z14checkCUDAErrorPKc
	cmpl	$0, number_of_char(%rip)
	jle	.LBB21_11
# %bb.9:                                # %.lr.ph.preheader
	xorl	%r14d, %r14d
.LBB21_10:                              # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	block_cntr_array_check(%rip), %rax
	movl	(%rax,%r14,4), %edx
	movl	$.L.str.54, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	incq	%r14
	movslq	number_of_char(%rip), %rax
	cmpq	%rax, %r14
	jl	.LBB21_10
.LBB21_11:                              # %._crit_edge
	movl	$.L.str.55, %edi
	callq	_Z14checkCUDAErrorPKc
	movl	$4, %edi
	callq	malloc
	movq	%rax, %r14
	movq	finalsize(%rip), %rsi
	movl	$4, %edx
	movq	%rax, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	(%r14), %esi
	movl	$.L.str.56, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.57, %edi
	callq	_Z14checkCUDAErrorPKc
	movslq	(%r14), %rsi
	movl	$finalcompressed_array, %edi
	callq	hipMalloc
	movl	$.L.str.58, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB21_13
# %bb.12:
	movq	block_cntr_array(%rip), %rdi
	movq	compressedfile_array(%rip), %rsi
	movq	finalcompressed_array(%rip), %rdx
	movl	number_of_char(%rip), %ecx
	callq	_Z32__device_stub__final_compressionPiPbS0_i
.LBB21_13:
	movl	$.L.str.59, %edi
	callq	_Z14checkCUDAErrorPKc
	callq	hipDeviceSynchronize
	movl	$.L.str.60, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	8(%rsp), %rdi
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	$.L.str.61, %edi
	callq	_Z14checkCUDAErrorPKc
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	4(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.62, %edi
	movb	$1, %al
	callq	printf
	movslq	(%r14), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	finalcompressed_array(%rip), %rsi
	movq	%rax, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.63, %edi
	callq	_Z14checkCUDAErrorPKc
	movl	$.L.str.64, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_Z20write_GPU_compressedPbPi
	cmpl	$0, (%r14)
	jle	.LBB21_15
.LBB21_14:                              # %.lr.ph64
                                        # =>This Inner Loop Header: Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incl	%r12d
	cmpl	(%r14), %r12d
	jl	.LBB21_14
.LBB21_15:                              # %._crit_edge65
	movl	$.Lstr.18, %edi
	callq	puts@PLT
	callq	clock
	movq	%rax, %rbx
	callq	_Z13compress_filev
	callq	clock
	subq	%rbx, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI21_1(%rip), %xmm0
	mulss	.LCPI21_2(%rip), %xmm0
	movss	%xmm0, 20(%rsp)                 # 4-byte Spill
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.66, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rsp), %xmm0
	movl	$.L.str.62, %edi
	movb	$1, %al
	callq	printf
	movss	20(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	divss	4(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.67, %edi
	movb	$1, %al
	callq	printf
	movl	$.Lstr.19, %edi
	callq	puts@PLT
	callq	_Z15decompress_filev
	callq	getchar
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end21:
	.size	main, .Lfunc_end21-main
	.cfi_endproc
                                        # -- End function
	.section	.text.startup,"ax",@progbits
	.type	_GLOBAL__sub_I_gpulab1_1.hip,@function # -- Begin function _GLOBAL__sub_I_gpulab1_1.hip
_GLOBAL__sub_I_gpulab1_1.hip:           # @_GLOBAL__sub_I_gpulab1_1.hip
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$261120, %edi                   # imm = 0x3FC00
	callq	malloc
	movq	%rax, huffman_check(%rip)
	popq	%rax
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end22:
	.size	_GLOBAL__sub_I_gpulab1_1.hip, .Lfunc_end22-_GLOBAL__sub_I_gpulab1_1.hip
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB23_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB23_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17final_compressionPiPbS0_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11read2darrayPii, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10check_boolPb, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$char_huffman_table_gpu, %esi
	movl	$.L__unnamed_5, %edx
	movl	$.L__unnamed_5, %ecx
	movl	$261120, %r9d                   # imm = 0x3FC00
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end23:
	.size	__hip_module_ctor, .Lfunc_end23-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB24_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB24_2:
	retq
.Lfunc_end24:
	.size	__hip_module_dtor, .Lfunc_end24-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Cuda error: %s: %s.\n"
	.size	.L.str, 21

	.type	char_frequency,@object          # @char_frequency
	.bss
	.globl	char_frequency
	.p2align	4, 0x0
char_frequency:
	.zero	1024
	.size	char_frequency, 1024

	.type	char_huffman_table,@object      # @char_huffman_table
	.globl	char_huffman_table
	.p2align	4, 0x0
char_huffman_table:
	.zero	261120
	.size	char_huffman_table, 261120

	.type	last_byte_padding,@object       # @last_byte_padding
	.globl	last_byte_padding
	.p2align	2, 0x0
last_byte_padding:
	.long	0                               # 0x0
	.size	last_byte_padding, 4

	.type	last_byte_padding_gpu,@object   # @last_byte_padding_gpu
	.globl	last_byte_padding_gpu
	.p2align	2, 0x0
last_byte_padding_gpu:
	.long	0                               # 0x0
	.size	last_byte_padding_gpu, 4

	.type	number_of_char,@object          # @number_of_char
	.globl	number_of_char
	.p2align	2, 0x0
number_of_char:
	.long	0                               # 0x0
	.size	number_of_char, 4

	.type	h_input,@object                 # @h_input
	.globl	h_input
	.p2align	3, 0x0
h_input:
	.quad	0
	.size	h_input, 8

	.type	d_input,@object                 # @d_input
	.globl	d_input
	.p2align	3, 0x0
d_input:
	.quad	0
	.size	d_input, 8

	.type	d_char_huffman_table,@object    # @d_char_huffman_table
	.globl	d_char_huffman_table
	.p2align	3, 0x0
d_char_huffman_table:
	.quad	0
	.size	d_char_huffman_table, 8

	.type	copiedarray2,@object            # @copiedarray2
	.globl	copiedarray2
	.p2align	4, 0x0
copiedarray2:
	.zero	261120
	.size	copiedarray2, 261120

	.type	char_huffman_table_gpu,@object  # @char_huffman_table_gpu
	.local	char_huffman_table_gpu
	.comm	char_huffman_table_gpu,261120,16
	.type	compressedfile_array,@object    # @compressedfile_array
	.globl	compressedfile_array
	.p2align	3, 0x0
compressedfile_array:
	.quad	0
	.size	compressedfile_array, 8

	.type	finalcompressed_array,@object   # @finalcompressed_array
	.globl	finalcompressed_array
	.p2align	3, 0x0
finalcompressed_array:
	.quad	0
	.size	finalcompressed_array, 8

	.type	block_cntr_array,@object        # @block_cntr_array
	.globl	block_cntr_array
	.p2align	3, 0x0
block_cntr_array:
	.quad	0
	.size	block_cntr_array, 8

	.type	block_cntr_array_check,@object  # @block_cntr_array_check
	.globl	block_cntr_array_check
	.p2align	3, 0x0
block_cntr_array_check:
	.quad	0
	.size	block_cntr_array_check, 8

	.type	d_last_byte_padding,@object     # @d_last_byte_padding
	.globl	d_last_byte_padding
	.p2align	3, 0x0
d_last_byte_padding:
	.quad	0
	.size	d_last_byte_padding, 8

	.type	finalsize,@object               # @finalsize
	.globl	finalsize
	.p2align	3, 0x0
finalsize:
	.quad	0
	.size	finalsize, 8

	.type	orig_number_of_char,@object     # @orig_number_of_char
	.globl	orig_number_of_char
	.p2align	3, 0x0
orig_number_of_char:
	.quad	0
	.size	orig_number_of_char, 8

	.type	huffman_check,@object           # @huffman_check
	.globl	huffman_check
	.p2align	3, 0x0
huffman_check:
	.quad	0
	.size	huffman_check, 8

	.type	d_bool,@object                  # @d_bool
	.globl	d_bool
	.p2align	3, 0x0
d_bool:
	.quad	0
	.size	d_bool, 8

	.type	h_bool,@object                  # @h_bool
	.globl	h_bool
	.p2align	3, 0x0
h_bool:
	.quad	0
	.size	h_bool, 8

	.type	_Z17final_compressionPiPbS0_i,@object # @_Z17final_compressionPiPbS0_i
	.section	.rodata,"a",@progbits
	.globl	_Z17final_compressionPiPbS0_i
	.p2align	3, 0x0
_Z17final_compressionPiPbS0_i:
	.quad	_Z32__device_stub__final_compressionPiPbS0_i
	.size	_Z17final_compressionPiPbS0_i, 8

	.type	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i,@object # @_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.globl	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.p2align	3, 0x0
_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i:
	.quad	_Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.size	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"compressed_gpu.txt"
	.size	.L.str.2, 19

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"wb"
	.size	.L.str.3, 3

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Error reading file"
	.size	.L.str.4, 19

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Compressed char in decimal is %d \n"
	.size	.L.str.5, 35

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"\n dchar huffman table "
	.size	.L.str.6, 23

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"\\n:\t"
	.size	.L.str.9, 5

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"%c:\t"
	.size	.L.str.10, 5

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"%d "
	.size	.L.str.11, 4

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"%d)\tval: \\n\tfreq: %d\n"
	.size	.L.str.14, 22

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"%d)\tval: %c\tfreq: %d\n"
	.size	.L.str.15, 22

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"weight: %d\tvalue: \\n\n"
	.size	.L.str.16, 22

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"weight: %d\tvalue: %c\n"
	.size	.L.str.17, 22

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"weight: %d\tvalue: NULL\n"
	.size	.L.str.18, 24

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"input.txt"
	.size	.L.str.19, 10

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"r"
	.size	.L.str.20, 2

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"rb"
	.size	.L.str.22, 3

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"compressed.txt"
	.size	.L.str.23, 15

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"i is %d and c is %c"
	.size	.L.str.24, 20

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"decompressed.txt"
	.size	.L.str.25, 17

	.type	_Z11read2darrayPii,@object      # @_Z11read2darrayPii
	.section	.rodata,"a",@progbits
	.globl	_Z11read2darrayPii
	.p2align	3, 0x0
_Z11read2darrayPii:
	.quad	_Z26__device_stub__read2darrayPii
	.size	_Z11read2darrayPii, 8

	.type	_Z10check_boolPb,@object        # @_Z10check_boolPb
	.globl	_Z10check_boolPb
	.p2align	3, 0x0
_Z10check_boolPb:
	.quad	_Z25__device_stub__check_boolPb
	.size	_Z10check_boolPb, 8

	.type	.L.str.26,@object               # @.str.26
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.26:
	.asciz	" \n Huffman after copying back \n "
	.size	.L.str.26, 33

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"\t%c code is  %d  \n"
	.size	.L.str.27, 19

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"Error in allocating d_input"
	.size	.L.str.29, 28

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"Error in copying d_input"
	.size	.L.str.30, 25

	.type	.L.str.31,@object               # @.str.31
.L.str.31:
	.asciz	"Error in allocating compressedfile_array"
	.size	.L.str.31, 41

	.type	.L.str.32,@object               # @.str.32
.L.str.32:
	.asciz	"Error in allocating d_char_huffman_table"
	.size	.L.str.32, 41

	.type	.L.str.33,@object               # @.str.33
.L.str.33:
	.asciz	"Error in copying d_char_huffman_table"
	.size	.L.str.33, 38

	.type	.L.str.34,@object               # @.str.34
.L.str.34:
	.asciz	"Error in copying back"
	.size	.L.str.34, 22

	.type	.L.str.35,@object               # @.str.35
.L.str.35:
	.asciz	"Error in allocating block_cntr_array"
	.size	.L.str.35, 37

	.type	.L.str.36,@object               # @.str.36
.L.str.36:
	.asciz	"Error in allocating d_last_byte_padding"
	.size	.L.str.36, 40

	.type	.L.str.37,@object               # @.str.37
.L.str.37:
	.asciz	"Error in allocating finalsize"
	.size	.L.str.37, 30

	.type	.L.str.38,@object               # @.str.38
.L.str.38:
	.asciz	"Error in allocating orig_number_of_char"
	.size	.L.str.38, 40

	.type	.L.str.39,@object               # @.str.39
.L.str.39:
	.asciz	"Error in copying orig_number_of_char"
	.size	.L.str.39, 37

	.type	.L.str.40,@object               # @.str.40
.L.str.40:
	.asciz	"bool1 is %d and bool2 is %d \n"
	.size	.L.str.40, 30

	.type	.L.str.41,@object               # @.str.41
.L.str.41:
	.asciz	"Error in d_bool"
	.size	.L.str.41, 16

	.type	.L.str.42,@object               # @.str.42
.L.str.42:
	.asciz	"Error in copying d_bool"
	.size	.L.str.42, 24

	.type	.L.str.43,@object               # @.str.43
.L.str.43:
	.asciz	"Error in kernel changing d_bool"
	.size	.L.str.43, 32

	.type	.L.str.44,@object               # @.str.44
.L.str.44:
	.asciz	"Error in hipDeviceSynchronize"
	.size	.L.str.44, 30

	.type	.L.str.45,@object               # @.str.45
.L.str.45:
	.asciz	"Error in copying d_bool back"
	.size	.L.str.45, 29

	.type	.L.str.46,@object               # @.str.46
.L.str.46:
	.asciz	"Now bool1 is %d and bool2 is %d \n"
	.size	.L.str.46, 34

	.type	.L.str.47,@object               # @.str.47
.L.str.47:
	.asciz	"h_bool is %d \t checkhuff is %d \n"
	.size	.L.str.47, 33

	.type	.L.str.48,@object               # @.str.48
.L.str.48:
	.asciz	"pattern for %d is found\n"
	.size	.L.str.48, 25

	.type	.L.str.49,@object               # @.str.49
.L.str.49:
	.asciz	"\n the number of characters in the input file is %d \n"
	.size	.L.str.49, 53

	.type	.L.str.50,@object               # @.str.50
.L.str.50:
	.asciz	"no_of_blocksis %d \n"
	.size	.L.str.50, 20

	.type	.L.str.51,@object               # @.str.51
.L.str.51:
	.asciz	"Error in hipEventRecord start \n"
	.size	.L.str.51, 32

	.type	.L.str.52,@object               # @.str.52
.L.str.52:
	.asciz	"Error in compress_file_gpu \n"
	.size	.L.str.52, 29

	.type	.L.str.53,@object               # @.str.53
.L.str.53:
	.asciz	"Error in copying back block_cntr_array_check"
	.size	.L.str.53, 45

	.type	.L.str.54,@object               # @.str.54
.L.str.54:
	.asciz	" block size for i = %d is %d \n"
	.size	.L.str.54, 31

	.type	.L.str.55,@object               # @.str.55
.L.str.55:
	.asciz	"Error in Compute array \n"
	.size	.L.str.55, 25

	.type	.L.str.56,@object               # @.str.56
.L.str.56:
	.asciz	"The final compressed array size is %d \n "
	.size	.L.str.56, 41

	.type	.L.str.57,@object               # @.str.57
.L.str.57:
	.asciz	"Error in finalsize_cpu"
	.size	.L.str.57, 23

	.type	.L.str.58,@object               # @.str.58
.L.str.58:
	.asciz	"hipMemcpyHostToDevice"
	.size	.L.str.58, 22

	.type	.L.str.59,@object               # @.str.59
.L.str.59:
	.asciz	"Error in final_compression call \n"
	.size	.L.str.59, 34

	.type	.L.str.60,@object               # @.str.60
.L.str.60:
	.asciz	"Error in hipDeviceSynchronize \n"
	.size	.L.str.60, 32

	.type	.L.str.61,@object               # @.str.61
.L.str.61:
	.asciz	"Error in hipEventRecord stop \n"
	.size	.L.str.61, 31

	.type	.L.str.62,@object               # @.str.62
.L.str.62:
	.asciz	"Time to calculate results: %f ms.\n"
	.size	.L.str.62, 35

	.type	.L.str.63,@object               # @.str.63
.L.str.63:
	.asciz	"Error in copying final_compressed_cpu\n"
	.size	.L.str.63, 39

	.type	.L.str.64,@object               # @.str.64
.L.str.64:
	.asciz	"The compressed value in binary is "
	.size	.L.str.64, 35

	.type	.L.str.66,@object               # @.str.66
.L.str.66:
	.asciz	"Time in cpu : %3.1f ms\n"
	.size	.L.str.66, 24

	.type	.L.str.67,@object               # @.str.67
.L.str.67:
	.asciz	"Speedup achieved is %lf \n"
	.size	.L.str.67, 26

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z17final_compressionPiPbS0_i"
	.size	.L__unnamed_1, 30

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i"
	.size	.L__unnamed_2, 41

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z11read2darrayPii"
	.size	.L__unnamed_3, 19

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"_Z10check_boolPb"
	.size	.L__unnamed_4, 17

	.type	.L__unnamed_5,@object           # @4
.L__unnamed_5:
	.asciz	"char_huffman_table_gpu"
	.size	.L__unnamed_5, 23

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	_GLOBAL__sub_I_gpulab1_1.hip
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"\nPress ENTER to exit..."
	.size	.Lstr, 24

	.type	.Lstr.6,@object                 # @str.6
.Lstr.6:
	.asciz	"character frequency:"
	.size	.Lstr.6, 21

	.type	.Lstr.10,@object                # @str.10
.Lstr.10:
	.asciz	"Huffman table:"
	.size	.Lstr.10, 15

	.type	.Lstr.14,@object                # @str.14
.Lstr.14:
	.asciz	"Huffman tree (inorder traversal sequence):"
	.size	.Lstr.14, 43

	.type	.Lstr.16,@object                # @str.16
.Lstr.16:
	.asciz	"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
	.size	.Lstr.16, 78

	.type	.Lstr.17,@object                # @str.17
.Lstr.17:
	.asciz	"start"
	.size	.Lstr.17, 6

	.type	.Lstr.18,@object                # @str.18
.Lstr.18:
	.asciz	"compressing on CPU..."
	.size	.Lstr.18, 22

	.type	.Lstr.19,@object                # @str.19
.Lstr.19:
	.asciz	"decompressing on CPU..."
	.size	.Lstr.19, 24

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z32__device_stub__final_compressionPiPbS0_i
	.addrsig_sym _Z32__device_stub__compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.addrsig_sym _Z26__device_stub__read2darrayPii
	.addrsig_sym _Z25__device_stub__check_boolPb
	.addrsig_sym _GLOBAL__sub_I_gpulab1_1.hip
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym char_huffman_table
	.addrsig_sym number_of_char
	.addrsig_sym d_input
	.addrsig_sym d_char_huffman_table
	.addrsig_sym char_huffman_table_gpu
	.addrsig_sym compressedfile_array
	.addrsig_sym finalcompressed_array
	.addrsig_sym block_cntr_array
	.addrsig_sym d_last_byte_padding
	.addrsig_sym finalsize
	.addrsig_sym orig_number_of_char
	.addrsig_sym d_bool
	.addrsig_sym _Z17final_compressionPiPbS0_i
	.addrsig_sym _Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.addrsig_sym _Z11read2darrayPii
	.addrsig_sym _Z10check_boolPb
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z17final_compressionPiPbS0_i ; -- Begin function _Z17final_compressionPiPbS0_i
	.globl	_Z17final_compressionPiPbS0_i
	.p2align	8
	.type	_Z17final_compressionPiPbS0_i,@function
_Z17final_compressionPiPbS0_i:          ; @_Z17final_compressionPiPbS0_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b32 s3, s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_8
; %bb.1:                                ; %.preheader23
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	v_mov_b32_e32 v0, 0
	s_mov_b32 s9, 0
	s_mov_b32 s8, exec_lo
	v_cmpx_lt_i32_e32 0, v1
	s_cbranch_execz .LBB0_5
; %bb.2:                                ; %.lr.ph.preheader
	v_mov_b32_e32 v2, v1
	s_waitcnt lgkmcnt(0)
	s_mov_b32 s2, s4
	s_mov_b32 s3, s5
	s_mov_b32 s10, 0
.LBB0_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s11, s[2:3], 0x0
	v_add_nc_u32_e32 v2, -1, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_eq_u32_e32 vcc_lo, 0, v2
	s_waitcnt lgkmcnt(0)
	s_add_i32 s10, s11, s10
	s_add_u32 s2, s2, 4
	v_mov_b32_e32 v0, s10
	s_addc_u32 s3, s3, 0
	s_or_b32 s9, vcc_lo, s9
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s9
	s_cbranch_execnz .LBB0_3
; %bb.4:                                ; %Flow49
	s_or_b32 exec_lo, exec_lo, s9
.LBB0_5:                                ; %Flow50
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s8
	v_ashrrev_i32_e32 v2, 31, v1
	s_mov_b32 s2, 0
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	global_load_b32 v4, v[2:3], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, 0, v4
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_8
; %bb.6:                                ; %.lr.ph27.preheader
	v_mul_lo_u32 v2, 0xff, v1
	v_ashrrev_i32_e32 v1, 31, v0
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	v_ashrrev_i32_e32 v3, 31, v2
	v_add_co_u32 v2, vcc_lo, s6, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo
.LBB0_7:                                ; %.lr.ph27
                                        ; =>This Inner Loop Header: Depth=1
	global_load_u8 v5, v[2:3], off
	v_add_nc_u32_e32 v4, -1, v4
	v_add_co_u32 v2, vcc_lo, v2, 1
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_cmp_eq_u32_e32 vcc_lo, 0, v4
	s_or_b32 s2, vcc_lo, s2
	s_waitcnt vmcnt(0)
	global_store_b8 v[0:1], v5, off
	v_add_co_u32 v0, s0, v0, 1
	v_add_co_ci_u32_e64 v1, s0, 0, v1, s0
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB0_7
.LBB0_8:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17final_compressionPiPbS0_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z17final_compressionPiPbS0_i, .Lfunc_end0-_Z17final_compressionPiPbS0_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 384
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i ; -- Begin function _Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.globl	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
	.p2align	8
	.type	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i,@function
_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i: ; @_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x4c
	s_load_b32 s3, s[0:1], 0x38
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s2, s15, s2
	v_add_nc_u32_e32 v1, s2, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_i32_e32 vcc_lo, s3, v1
	s_and_saveexec_b32 s3, vcc_lo
	s_cbranch_execz .LBB1_16
; %bb.1:
	s_load_b256 s[4:11], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_mulk_i32 s2, 0xff
                                        ; implicit-def: $sgpr3
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u32_u24 v0, 0xff, v0, s2
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v3, vcc_lo, s4, v1
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v2, vcc_lo
	s_mov_b32 s5, 0
                                        ; implicit-def: $sgpr4
	global_load_u8 v3, v[3:4], off
	s_waitcnt vmcnt(0)
	v_mul_u32_u24_e32 v3, 0xff, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v3, 2, v3
	v_add_co_u32 v3, s2, s8, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v4, null, s9, 0, s2
	s_mov_b32 s2, 0
.LBB1_2:                                ; %NodeBlock
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v7, v[3:4], off
	s_mov_b32 s8, 0
	s_mov_b32 s13, exec_lo
                                        ; implicit-def: $sgpr9
                                        ; implicit-def: $sgpr12
	s_waitcnt vmcnt(0)
	v_cmpx_lt_i32_e32 0, v7
	s_xor_b32 s13, exec_lo, s13
	s_cbranch_execz .LBB1_6
; %bb.3:                                ; %LeafBlock63
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_mov_b32 s9, exec_lo
                                        ; implicit-def: $sgpr12
	v_cmpx_eq_u32_e32 1, v7
; %bb.4:                                ;   in Loop: Header=BB1_2 Depth=1
	s_mov_b32 s8, exec_lo
	s_mov_b32 s12, 1
; %bb.5:                                ; %Flow67
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s9
	s_mov_b32 s9, -1
	s_and_b32 s8, s8, exec_lo
                                        ; implicit-def: $vgpr7
.LBB1_6:                                ; %Flow66
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_saveexec_b32 s13, s13
	v_dual_mov_b32 v5, s5 :: v_dual_mov_b32 v6, s12
	s_xor_b32 exec_lo, exec_lo, s13
; %bb.7:                                ; %LeafBlock
                                        ;   in Loop: Header=BB1_2 Depth=1
	v_cmp_eq_u32_e32 vcc_lo, 0, v7
	v_dual_mov_b32 v5, s5 :: v_dual_mov_b32 v6, 0
	s_and_not1_b32 s8, s8, exec_lo
	s_or_b32 s9, s9, exec_lo
	s_and_b32 s12, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s8, s8, s12
; %bb.8:                                ; %Flow68
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s13
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 s4, s4, exec_lo
	s_and_b32 s9, s9, exec_lo
	s_mov_b32 s13, -1
	s_or_b32 s4, s4, s9
                                        ; implicit-def: $sgpr12
	s_and_saveexec_b32 s9, s8
	s_cbranch_execz .LBB1_10
; %bb.9:                                ;   in Loop: Header=BB1_2 Depth=1
	v_add_nc_u32_e32 v5, s5, v0
	v_add_co_u32 v3, vcc_lo, v3, 4
	s_add_i32 s8, s5, 1
	v_add_co_ci_u32_e32 v4, vcc_lo, 0, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v8, 31, v5
	v_add_co_u32 v7, vcc_lo, s6, v5
	s_cmpk_eq_i32 s8, 0xff
	v_mov_b32_e32 v5, s5
	v_add_co_ci_u32_e32 v8, vcc_lo, s7, v8, vcc_lo
	s_cselect_b32 s13, -1, 0
	s_movk_i32 s12, 0xff
	s_and_not1_b32 s4, s4, exec_lo
	s_or_not1_b32 s13, s13, exec_lo
	s_mov_b32 s5, s8
	global_store_b8 v[7:8], v6, off
.LBB1_10:                               ; %Flow69
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s9
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	s_and_b32 s8, exec_lo, s13
	v_mov_b32_e32 v6, s12
	s_or_b32 s2, s8, s2
	s_and_not1_b32 s3, s3, exec_lo
	s_and_b32 s8, s4, exec_lo
	s_or_b32 s3, s3, s8
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB1_2
; %bb.11:                               ; %loop.exit.guard
	s_or_b32 exec_lo, exec_lo, s2
	s_and_saveexec_b32 s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s2, exec_lo, s2
; %bb.12:                               ; %._crit_edge
	v_mov_b32_e32 v6, v5
; %bb.13:
	s_or_b32 exec_lo, exec_lo, s2
	s_load_b128 s[0:3], s[0:1], 0x28
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s10, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s11, v1, vcc_lo
	v_mov_b32_e32 v0, 0
	global_store_b32 v[2:3], v6, off
	s_waitcnt lgkmcnt(0)
	global_store_b32 v0, v0, s[0:1]
	global_load_b32 v1, v0, s[2:3]
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, 1, v1
	s_cbranch_vccnz .LBB1_16
; %bb.14:                               ; %.lr.ph.i.preheader
	v_mov_b32_e32 v1, 0
	s_mov_b32 s4, 0
.LBB1_15:                               ; %.lr.ph.i
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v2, v0, s[10:11]
	s_add_i32 s4, s4, 1
	s_add_u32 s10, s10, 4
	s_addc_u32 s11, s11, 0
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v1, v2, v1
	global_store_b32 v0, v1, s[0:1]
	global_load_b32 v2, v0, s[2:3]
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, s4, v2
	s_cbranch_vccnz .LBB1_15
.LBB1_16:                               ; %_Z17computearray_sizePiS_S_.exit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 9
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i, .Lfunc_end1-_Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 596
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z11read2darrayPii      ; -- Begin function _Z11read2darrayPii
	.globl	_Z11read2darrayPii
	.p2align	8
	.type	_Z11read2darrayPii,@function
_Z11read2darrayPii:                     ; @_Z11read2darrayPii
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11read2darrayPii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 12
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z11read2darrayPii, .Lfunc_end2-_Z11read2darrayPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z10check_boolPb        ; -- Begin function _Z10check_boolPb
	.globl	_Z10check_boolPb
	.p2align	8
	.type	_Z10check_boolPb,@function
_Z10check_boolPb:                       ; @_Z10check_boolPb
; %bb.0:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_mov_b32_e32 v0, 0
	s_waitcnt lgkmcnt(0)
	global_store_b16 v0, v0, s[0:1]
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10check_boolPb
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 8
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 2
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end3:
	.size	_Z10check_boolPb, .Lfunc_end3-_Z10check_boolPb
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 36
; NumSgprs: 2
; NumVgprs: 1
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 2
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	char_huffman_table_gpu  ; @char_huffman_table_gpu
	.type	char_huffman_table_gpu,@object
	.section	.bss,"aw",@nobits
	.globl	char_huffman_table_gpu
	.p2align	4, 0x0
char_huffman_table_gpu:
	.zero	261120
	.size	char_huffman_table_gpu, 261120

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17final_compressionPiPbS0_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17final_compressionPiPbS0_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         48
        .size:           8
        .value_kind:     global_buffer
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17compress_file_gpuPhPbPiS1_S1_S1_S1_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 12
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11read2darrayPii
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z11read2darrayPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 8
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10check_boolPb
    .private_segment_fixed_size: 0
    .sgpr_count:     2
    .sgpr_spill_count: 0
    .symbol:         _Z10check_boolPb.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     1
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
