/**
 * @file ex_particle_OPENMP_seq.c
 * @author Michael Trotter & Matt Goodrum
 * @brief Particle filter implementation in C/OpenMP 
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <unistd.h>
#include <fcntl.h>
#include <float.h>
#include <sys/time.h>
#include<ctime>
#define PI 3.1415926535897932
#define BLOCK_X 16
#define BLOCK_Y 16

/**
@var M value for Linear Congruential Generator (LCG); use GCC's value
*/
long M = INT_MAX;
/**
@var A value for LCG
*/
int A = 1103515245;
/**
@var C value for LCG
*/
int C = 12345;

const int threads_per_block = 128;

/*****************************
*GET_TIME
*returns a long int representing the time
*****************************/
long long get_time() {
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return (tv.tv_sec * 1000000) + tv.tv_usec;
}
// Returns the number of seconds elapsed between the two specified times
float elapsed_time(long long start_time, long long end_time) {
        return (float) (end_time - start_time) / (1000 * 1000);
}
/*****************************
* CHECK_ERROR
* Checks for CUDA errors and prints them to the screen to help with
* debugging of CUDA related programming
*****************************/
void check_error(cudaError e) {
     if (e != cudaSuccess) {
     	printf("\nCUDA error: %s\n", cudaGetErrorString(e));
	    exit(1);
     }
}
__device__ int findIndexSeq(double * CDF, int lengthCDF, double value)
{
	int index = -1;
	int x;
	for(x = 0; x < lengthCDF; x++)
	{
		if(CDF[x] >= value)
		{
			index = x;
			break;
		}
	}
	if(index == -1)
		return lengthCDF-1;
	return index;
}
__device__ int findIndexBin(double * CDF, int beginIndex, int endIndex, double value)
{
	if(endIndex < beginIndex)
		return -1;
	int middleIndex;
	while(endIndex > beginIndex)
	{
		middleIndex = beginIndex + ((endIndex-beginIndex)/2);
		if(CDF[middleIndex] >= value)
		{
			if(middleIndex == 0)
				return middleIndex;
			else if(CDF[middleIndex-1] < value)
				return middleIndex;
			else if(CDF[middleIndex-1] == value)
			{
				while(CDF[middleIndex] == value && middleIndex >= 0)
					middleIndex--;
				middleIndex++;
				return middleIndex;
			}
		}
		if(CDF[middleIndex] > value)
			endIndex = middleIndex-1;
		else
			beginIndex = middleIndex+1;
	}
	return -1;
}
/*****************************
* CUDA Kernel Function to replace FindIndex
* param1: arrayX
* param2: arrayY
* param3: CDF
* param4: u
* param5: xj
* param6: yj
* param7: Nparticles
*****************************/
__global__ void kernel(double * arrayX, double * arrayY, double * CDF, double * u, double * xj, double * yj, int Nparticles){
	int block_id = blockIdx.x;// + gridDim.x * blockIdx.y;
	int i = blockDim.x * block_id + threadIdx.x;
	
	if(i < Nparticles){
	
		int index = -1;
		int x;
		
		for(x = 0; x < Nparticles; x++){
			if(CDF[x] >= u[i]){
				index = x;
				break;
			}
		}
		if(index == -1){
			index = Nparticles-1;
		}
		
		xj[i] = arrayX[index];
		yj[i] = arrayY[index];
		
	}
}
/** 
* Takes in a double and returns an integer that approximates to that double
* @return if the mantissa < .5 => return value < input value; else return value > input value
*/
double roundDouble(double value){
	int newValue = (int)(value);
	if(value - newValue < .5)
	return newValue;
	else
	return newValue++;
}
/**
* Set values of the 3D array to a newValue if that value is equal to the testValue
* @param testValue The value to be replaced
* @param newValue The value to replace testValue with
* @param array3D The image vector
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
*/
void setIf(int testValue, int newValue, int * array3D, int * dimX, int * dimY, int * dimZ){
	int x, y, z;
	for(x = 0; x < *dimX; x++){
		for(y = 0; y < *dimY; y++){
			for(z = 0; z < *dimZ; z++){
				if(array3D[x * *dimY * *dimZ+y * *dimZ + z] == testValue)
				array3D[x * *dimY * *dimZ + y * *dimZ + z] = newValue;
			}
		}
	}
}
/**
* Generates a uniformly distributed random number using the provided seed and GCC's settings for the Linear Congruential Generator (LCG)
* @see http://en.wikipedia.org/wiki/Linear_congruential_generator
* @note This function is thread-safe
* @param seed The seed array
* @param index The specific index of the seed to be advanced
* @return a uniformly distributed number [0, 1)
*/
double randu(int * seed, int index)
{
	int num = A*seed[index] + C;
	seed[index] = num % M;
	return fabs(seed[index]/((double) M));
}
/**
* Generates a normally distributed random number using the Box-Muller transformation
* @note This function is thread-safe
* @param seed The seed array
* @param index The specific index of the seed to be advanced
* @return a double representing random number generated using the Box-Muller algorithm
* @see http://en.wikipedia.org/wiki/Normal_distribution, section computing value for normal random distribution
*/
double randn(int * seed, int index){
	/*Box-Muller algorithm*/
	double u = randu(seed, index);
	double v = randu(seed, index);
	double cosine = cos(2*PI*v);
	double rt = -2*log(u);
	return sqrt(rt)*cosine;
}
/**
* Sets values of 3D matrix using randomly generated numbers from a normal distribution
* @param array3D The video to be modified
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
* @param seed The seed array
*/
void addNoise(int * array3D, int * dimX, int * dimY, int * dimZ, int * seed){
	int x, y, z;
	for(x = 0; x < *dimX; x++){
		for(y = 0; y < *dimY; y++){
			for(z = 0; z < *dimZ; z++){
				array3D[x * *dimY * *dimZ + y * *dimZ + z] = array3D[x * *dimY * *dimZ + y * *dimZ + z] + (int)(5*randn(seed, 0));
			}
		}
	}
}
/**
* Fills a radius x radius matrix representing the disk
* @param disk The pointer to the disk to be made
* @param radius  The radius of the disk to be made
*/
void strelDisk(int * disk, int radius)
{
	int diameter = radius*2 - 1;
	int x, y;
	for(x = 0; x < diameter; x++){
		for(y = 0; y < diameter; y++){
			double distance = sqrt(pow((double)(x-radius+1),2) + pow((double)(y-radius+1),2));
			if(distance < radius)
			disk[x*diameter + y] = 1;
		}
	}
}
/**
* Dilates the provided video
* @param matrix The video to be dilated
* @param posX The x location of the pixel to be dilated
* @param posY The y location of the pixel to be dilated
* @param poxZ The z location of the pixel to be dilated
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
* @param error The error radius
*/
void dilate_matrix(int * matrix, int posX, int posY, int posZ, int dimX, int dimY, int dimZ, int error)
{
	int startX = posX - error;
	while(startX < 0)
	startX++;
	int startY = posY - error;
	while(startY < 0)
	startY++;
	int endX = posX + error;
	while(endX > dimX)
	endX--;
	int endY = posY + error;
	while(endY > dimY)
	endY--;
	int x,y;
	for(x = startX; x < endX; x++){
		for(y = startY; y < endY; y++){
			double distance = sqrt( pow((double)(x-posX),2) + pow((double)(y-posY),2) );
			if(distance < error)
			matrix[x*dimY*dimZ + y*dimZ + posZ] = 1;
		}
	}
}

/**
* Dilates the target matrix using the radius as a guide
* @param matrix The reference matrix
* @param dimX The x dimension of the video
* @param dimY The y dimension of the video
* @param dimZ The z dimension of the video
* @param error The error radius to be dilated
* @param newMatrix The target matrix
*/
void imdilate_disk(int * matrix, int dimX, int dimY, int dimZ, int error, int * newMatrix)
{
	int x, y, z;
	for(z = 0; z < dimZ; z++){
		for(x = 0; x < dimX; x++){
			for(y = 0; y < dimY; y++){
				if(matrix[x*dimY*dimZ + y*dimZ + z] == 1){
					dilate_matrix(newMatrix, x, y, z, dimX, dimY, dimZ, error);
				}
			}
		}
	}
}
/**
* Fills a 2D array describing the offsets of the disk object
* @param se The disk object
* @param numOnes The number of ones in the disk
* @param neighbors The array that will contain the offsets
* @param radius The radius used for dilation
*/
void getneighbors(int * se, int numOnes, double * neighbors, int radius){
	int x, y;
	int neighY = 0;
	int center = radius - 1;
	int diameter = radius*2 -1;
	for(x = 0; x < diameter; x++){
		for(y = 0; y < diameter; y++){
			if(se[x*diameter + y]){
				neighbors[neighY*2] = (int)(y - center);
				neighbors[neighY*2 + 1] = (int)(x - center);
				neighY++;
			}
		}
	}
}
/**
* The synthetic video sequence we will work with here is composed of a
* single moving object, circular in shape (fixed radius)
* The motion here is a linear motion
* the foreground intensity and the backgrounf intensity is known
* the image is corrupted with zero mean Gaussian noise
* @param I The video itself
* @param IszX The x dimension of the video
* @param IszY The y dimension of the video
* @param Nfr The number of frames of the video
* @param seed The seed array used for number generation
*/
void videoSequence(int * I, int IszX, int IszY, int Nfr, int * seed){
	int k;
	int max_size = IszX*IszY*Nfr;
	/*get object centers*/
	int x0 = (int)roundDouble(IszY/2.0);
	int y0 = (int)roundDouble(IszX/2.0);
	I[x0 *IszY *Nfr + y0 * Nfr  + 0] = 1;
	
	/*move point*/
	int xk, yk, pos;
	for(k = 1; k < Nfr; k++){
		xk = abs(x0 + (k-1));
		yk = abs(y0 - 2*(k-1));
		pos = yk * IszY * Nfr + xk *Nfr + k;
		if(pos >= max_size)
		pos = 0;
		I[pos] = 1;
	}
	
	/*dilate matrix*/
	int * newMatrix = (int *)malloc(sizeof(int)*IszX*IszY*Nfr);
	imdilate_disk(I, IszX, IszY, Nfr, 5, newMatrix);
	int x, y;
	for(x = 0; x < IszX; x++){
		for(y = 0; y < IszY; y++){
			for(k = 0; k < Nfr; k++){
				I[x*IszY*Nfr + y*Nfr + k] = newMatrix[x*IszY*Nfr + y*Nfr + k];
			}
		}
	}
	free(newMatrix);
	
	/*define background, add noise*/
	setIf(0, 100, I, &IszX, &IszY, &Nfr);
	setIf(1, 228, I, &IszX, &IszY, &Nfr);
	/*add noise*/
	addNoise(I, &IszX, &IszY, &Nfr, seed);
}
/**
* Determines the likelihood sum based on the formula: SUM( (IK[IND] - 100)^2 - (IK[IND] - 228)^2)/ 100
* @param I The 3D matrix
* @param ind The current ind array
* @param numOnes The length of ind array
* @return A double representing the sum
*/
double calcLikelihoodSum(int * I, int * ind, int numOnes){
	double likelihoodSum = 0.0;
	int y;
	for(y = 0; y < numOnes; y++)
	likelihoodSum += (pow((double)(I[ind[y]] - 100),2) - pow((double)(I[ind[y]]-228),2))/50.0;
	return likelihoodSum;
}
/**
* Finds the first element in the CDF that is greater than or equal to the provided value and returns that index
* @note This function uses sequential search
* @param CDF The CDF
* @param lengthCDF The length of CDF
* @param value The value to be found
* @return The index of value in the CDF; if value is never found, returns the last index
*/
int findIndex(double * CDF, int lengthCDF, double value){
	int index = -1;
	int x;
	for(x = 0; x < lengthCDF; x++){
		if(CDF[x] >= value){
			index = x;
			break;
		}
	}
	if(index == -1){
		return lengthCDF-1;
	}
	return index;
}
/**
* The implementation of the particle filter using OpenMP for many frames
* @see http://openmp.org/wp/
* @note This function is designed to work with a video of several frames. In addition, it references a provided MATLAB function which takes the video, the objxy matrix and the x and y arrays as arguments and returns the likelihoods
* @param I The video to be run
* @param IszX The x dimension of the video
* @param IszY The y dimension of the video
* @param Nfr The number of frames
* @param seed The seed array used for random number generation
* @param Nparticles The number of particles to be used
*/
void particleFilter(int * I, int IszX, int IszY, int Nfr, int * seed, int Nparticles){
	int max_size = IszX*IszY*Nfr;
	long long start = get_time();
	//original particle centroid
	double xe = roundDouble(IszY/2.0);
	double ye = roundDouble(IszX/2.0);
	
	//expected object locations, compared to center
	int radius = 5;
	int diameter = radius*2 - 1;
	int * disk = (int *)malloc(diameter*diameter*sizeof(int));
	strelDisk(disk, radius);
	int countOnes = 0;
	int x, y;
	for(x = 0; x < diameter; x++){
		for(y = 0; y < diameter; y++){
			if(disk[x*diameter + y] == 1)
				countOnes++;
		}
	}
	double * objxy = (double *)malloc(countOnes*2*sizeof(double));
	getneighbors(disk, countOnes, objxy, radius);
	
	long long get_neighbors = get_time();
	printf("TIME TO GET NEIGHBORS TOOK: %f\n", elapsed_time(start, get_neighbors));
	//initial weights are all equal (1/Nparticles)
	double * weights = (double *)malloc(sizeof(double)*Nparticles);
	for(x = 0; x < Nparticles; x++){
		weights[x] = 1/((double)(Nparticles));
	}
	long long get_weights = get_time();
	printf("TIME TO GET WEIGHTSTOOK: %f\n", elapsed_time(get_neighbors, get_weights));
	//initial likelihood to 0.0
	double * likelihood = (double *)malloc(sizeof(double)*Nparticles);
	double * arrayX = (double *)malloc(sizeof(double)*Nparticles);
	double * arrayY = (double *)malloc(sizeof(double)*Nparticles);
	double * xj = (double *)malloc(sizeof(double)*Nparticles);
	double * yj = (double *)malloc(sizeof(double)*Nparticles);
	double * CDF = (double *)malloc(sizeof(double)*Nparticles);
	
	//GPU copies of arrays
	double * arrayX_GPU;
	double * arrayY_GPU;
	double * xj_GPU;
	double * yj_GPU;
	double * CDF_GPU;
	
	int * ind = (int*)malloc(sizeof(int)*countOnes);
	double * u = (double *)malloc(sizeof(double)*Nparticles);
	double * u_GPU;
	
	//CUDA memory allocation
	check_error(cudaMalloc((void **) &arrayX_GPU, sizeof(double)*Nparticles));
	check_error(cudaMalloc((void **) &arrayY_GPU, sizeof(double)*Nparticles));
	check_error(cudaMalloc((void **) &xj_GPU, sizeof(double)*Nparticles));
	check_error(cudaMalloc((void **) &yj_GPU, sizeof(double)*Nparticles));
	check_error(cudaMalloc((void **) &CDF_GPU, sizeof(double)*Nparticles));
	check_error(cudaMalloc((void **) &u_GPU, sizeof(double)*Nparticles));
	
	for(x = 0; x < Nparticles; x++){
		arrayX[x] = xe;
		arrayY[x] = ye;
	}
	int k;
	//double * Ik = (double *)malloc(sizeof(double)*IszX*IszY);
	int indX, indY;
	for(k = 1; k < Nfr; k++){
		long long set_arrays = get_time();
		//printf("TIME TO SET ARRAYS TOOK: %f\n", elapsed_time(get_weights, set_arrays));
		//apply motion model
		//draws sample from motion model (random walk). The only prior information
		//is that the object moves 2x as fast as in the y direction
		
		for(x = 0; x < Nparticles; x++){
			arrayX[x] = arrayX[x] + 1.0 + 5.0*randn(seed, x);
			arrayY[x] = arrayY[x] - 2.0 + 2.0*randn(seed, x);
		}
		//particle filter likelihood
		long long error = get_time();
		printf("TIME TO SET ERROR TOOK: %f\n", elapsed_time(set_arrays, error));
		for(x = 0; x < Nparticles; x++){
		
			//compute the likelihood: remember our assumption is that you know
			// foreground and the background image intensity distribution.
			// Notice that we consider here a likelihood ratio, instead of
			// p(z|x). It is possible in this case. why? a hometask for you.		
			//calc ind
			for(y = 0; y < countOnes; y++){
				indX = roundDouble(arrayX[x]) + objxy[y*2 + 1];
				indY = roundDouble(arrayY[x]) + objxy[y*2];
				ind[y] = fabs(indX*IszY*Nfr + indY*Nfr + k);
				if(ind[y] >= max_size)
					ind[y] = 0;
			}
			likelihood[x] = calcLikelihoodSum(I, ind, countOnes);
			likelihood[x] = likelihood[x]/countOnes;
		}
		long long likelihood_time = get_time();
		printf("TIME TO GET LIKELIHOODS TOOK: %f\n", elapsed_time(error, likelihood_time));
		// update & normalize weights
		// using equation (63) of Arulampalam Tutorial		
		for(x = 0; x < Nparticles; x++){
			weights[x] = weights[x] * exp(likelihood[x]);
		}
		long long exponential = get_time();
		printf("TIME TO GET EXP TOOK: %f\n", elapsed_time(likelihood_time, exponential));
		double sumWeights = 0;	
		for(x = 0; x < Nparticles; x++){
			sumWeights += weights[x];
		}
		long long sum_time = get_time();
		printf("TIME TO SUM WEIGHTS TOOK: %f\n", elapsed_time(exponential, sum_time));
		for(x = 0; x < Nparticles; x++){
				weights[x] = weights[x]/sumWeights;
		}
		long long normalize = get_time();
		printf("TIME TO NORMALIZE WEIGHTS TOOK: %f\n", elapsed_time(sum_time, normalize));
		xe = 0;
		ye = 0;
		// estimate the object location by expected values
		for(x = 0; x < Nparticles; x++){
			xe += arrayX[x] * weights[x];
			ye += arrayY[x] * weights[x];
		}
		long long move_time = get_time();
		printf("TIME TO MOVE OBJECT TOOK: %f\n", elapsed_time(normalize, move_time));
		printf("XE: %lf\n", xe);
		printf("YE: %lf\n", ye);
		double distance = sqrt( pow((double)(xe-(int)roundDouble(IszY/2.0)),2) + pow((double)(ye-(int)roundDouble(IszX/2.0)),2) );
		printf("%lf\n", distance);
		//display(hold off for now)
		
		//pause(hold off for now)
		
		//resampling
		
		
		CDF[0] = weights[0];
		for(x = 1; x < Nparticles; x++){
			CDF[x] = weights[x] + CDF[x-1];
		}
		long long cum_sum = get_time();
		printf("TIME TO CALC CUM SUM TOOK: %f\n", elapsed_time(move_time, cum_sum));
		double u1 = (1/((double)(Nparticles)))*randu(seed, 0);
		for(x = 0; x < Nparticles; x++){
			u[x] = u1 + x/((double)(Nparticles));
		}
		long long u_time = get_time();
		printf("TIME TO CALC U TOOK: %f\n", elapsed_time(cum_sum, u_time));
		long long start_copy = get_time();
		//CUDA memory copying from CPU memory to GPU memory
		cudaMemcpy(arrayX_GPU, arrayX, sizeof(double)*Nparticles, cudaMemcpyHostToDevice);
		cudaMemcpy(arrayY_GPU, arrayY, sizeof(double)*Nparticles, cudaMemcpyHostToDevice);
		cudaMemcpy(xj_GPU, xj, sizeof(double)*Nparticles, cudaMemcpyHostToDevice);
		cudaMemcpy(yj_GPU, yj, sizeof(double)*Nparticles, cudaMemcpyHostToDevice);
		cudaMemcpy(CDF_GPU, CDF, sizeof(double)*Nparticles, cudaMemcpyHostToDevice);
		cudaMemcpy(u_GPU, u, sizeof(double)*Nparticles, cudaMemcpyHostToDevice);
		long long end_copy = get_time();
		//Set number of threads
		int num_blocks = ceil((double) Nparticles/(double) threads_per_block);
		
		//KERNEL FUNCTION CALL
		kernel <<< num_blocks, threads_per_block >>> (arrayX_GPU, arrayY_GPU, CDF_GPU, u_GPU, xj_GPU, yj_GPU, Nparticles);
                cudaThreadSynchronize();
                long long start_copy_back = get_time();
		//CUDA memory copying back from GPU to CPU memory
		cudaMemcpy(yj, yj_GPU, sizeof(double)*Nparticles, cudaMemcpyDeviceToHost);
		cudaMemcpy(xj, xj_GPU, sizeof(double)*Nparticles, cudaMemcpyDeviceToHost);
		long long end_copy_back = get_time();
		printf("SENDING TO GPU TOOK: %lf\n", elapsed_time(start_copy, end_copy));
		printf("CUDA EXEC TOOK: %lf\n", elapsed_time(end_copy, start_copy_back));
		printf("SENDING BACK FROM GPU TOOK: %lf\n", elapsed_time(start_copy_back, end_copy_back));
		long long xyj_time = get_time();
		printf("TIME TO CALC NEW ARRAY X AND Y TOOK: %f\n", elapsed_time(u_time, xyj_time));
		
		for(x = 0; x < Nparticles; x++){
			//reassign arrayX and arrayY
			arrayX[x] = xj[x];
			arrayY[x] = yj[x];
			weights[x] = 1/((double)(Nparticles));
		}
		long long reset = get_time();
		printf("TIME TO RESET WEIGHTS TOOK: %f\n", elapsed_time(xyj_time, reset));
	}
	
	//CUDA freeing of memory
	cudaFree(u_GPU);
	cudaFree(CDF_GPU);
	cudaFree(yj_GPU);
	cudaFree(xj_GPU);
	cudaFree(arrayY_GPU);
	cudaFree(arrayX_GPU);
	
	//free memory
	free(disk);
	free(objxy);
	free(weights);
	free(likelihood);
	free(arrayX);
	free(arrayY);
	free(xj);
	free(yj);
	free(CDF);
	free(u);
	free(ind);
}
int main(int argc, char * argv[]){
	
	char* usage = "naive.out -x <dimX> -y <dimY> -z <Nfr> -np <Nparticles>";
	//check number of arguments
	if(argc != 9)
	{
		printf("%s\n", usage);
		return 0;
	}
	//check args deliminators
	if( strcmp( argv[1], "-x" ) ||  strcmp( argv[3], "-y" ) || strcmp( argv[5], "-z" ) || strcmp( argv[7], "-np" ) ) {
		printf( "%s\n",usage );
		return 0;
	}
	
	int IszX, IszY, Nfr, Nparticles;
	
	//converting a string to a integer
	if( sscanf( argv[2], "%d", &IszX ) == EOF ) {
	   printf("ERROR: dimX input is incorrect");
	   return 0;
	}
	
	if( IszX <= 0 ) {
		printf("dimX must be > 0\n");
		return 0;
	}
	
	//converting a string to a integer
	if( sscanf( argv[4], "%d", &IszY ) == EOF ) {
	   printf("ERROR: dimY input is incorrect");
	   return 0;
	}
	
	if( IszY <= 0 ) {
		printf("dimY must be > 0\n");
		return 0;
	}
	
	//converting a string to a integer
	if( sscanf( argv[6], "%d", &Nfr ) == EOF ) {
	   printf("ERROR: Number of frames input is incorrect");
	   return 0;
	}
	
	if( Nfr <= 0 ) {
		printf("number of frames must be > 0\n");
		return 0;
	}
	
	//converting a string to a integer
	if( sscanf( argv[8], "%d", &Nparticles ) == EOF ) {
	   printf("ERROR: Number of particles input is incorrect");
	   return 0;
	}
	
	if( Nparticles <= 0 ) {
		printf("Number of particles must be > 0\n");
		return 0;
	}
	//establish seed
	int * seed = (int *)malloc(sizeof(int)*Nparticles);
	int i;
	for(i = 0; i < Nparticles; i++)
		seed[i] = time(0)*i;
	//malloc matrix
	int * I = (int *)malloc(sizeof(int)*IszX*IszY*Nfr);
	long long start = get_time();
	//call video sequence
	videoSequence(I, IszX, IszY, Nfr, seed);
	long long endVideoSequence = get_time();
	printf("VIDEO SEQUENCE TOOK %f\n", elapsed_time(start, endVideoSequence));
	//call particle filter
	particleFilter(I, IszX, IszY, Nfr, seed, Nparticles);
	long long endParticleFilter = get_time();
	printf("PARTICLE FILTER TOOK %f\n", elapsed_time(endVideoSequence, endParticleFilter));
	printf("ENTIRE PROGRAM TOOK %f\n", elapsed_time(start, endParticleFilter));
	
	free(seed);
	free(I);
	return 0;
}

	.file	"tmpxft_00374a73_00000000-6_ex_particle_CUDA_naive_seq.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2065:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2065:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z8get_timev
	.type	_Z8get_timev, @function
_Z8get_timev:
.LFB2044:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	imulq	$1000000, 8(%rsp), %rax
	addq	16(%rsp), %rax
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L3
	call	__stack_chk_fail@PLT
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2044:
	.size	_Z8get_timev, .-_Z8get_timev
	.globl	_Z12elapsed_timexx
	.type	_Z12elapsed_timexx, @function
_Z12elapsed_timexx:
.LFB2045:
	.cfi_startproc
	endbr64
	subq	%rdi, %rsi
	cvtsi2ssq	%rsi, %xmm0
	divss	.LC0(%rip), %xmm0
	ret
	.cfi_endproc
.LFE2045:
	.size	_Z12elapsed_timexx, .-_Z12elapsed_timexx
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"\nCUDA error: %s\n"
	.text
	.globl	_Z11check_error9cudaError
	.type	_Z11check_error9cudaError, @function
_Z11check_error9cudaError:
.LFB2046:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L7
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	cudaGetErrorString@PLT
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L7:
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2046:
	.size	_Z11check_error9cudaError, .-_Z11check_error9cudaError
	.globl	_Z12findIndexSeqPdid
	.type	_Z12findIndexSeqPdid, @function
_Z12findIndexSeqPdid:
.LFB2047:
	.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
.LFE2047:
	.size	_Z12findIndexSeqPdid, .-_Z12findIndexSeqPdid
	.globl	_Z12findIndexBinPdiid
	.type	_Z12findIndexBinPdiid, @function
_Z12findIndexBinPdiid:
.LFB2048:
	.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
.LFE2048:
	.size	_Z12findIndexBinPdiid, .-_Z12findIndexBinPdiid
	.globl	_Z11roundDoubled
	.type	_Z11roundDoubled, @function
_Z11roundDoubled:
.LFB2049:
	.cfi_startproc
	endbr64
	cvttsd2sil	%xmm0, %eax
	cvtsi2sdl	%eax, %xmm0
	ret
	.cfi_endproc
.LFE2049:
	.size	_Z11roundDoubled, .-_Z11roundDoubled
	.globl	_Z5setIfiiPiS_S_S_
	.type	_Z5setIfiiPiS_S_S_, @function
_Z5setIfiiPiS_S_S_:
.LFB2050:
	.cfi_startproc
	endbr64
	movq	%rdx, %r10
	movq	%rcx, %r11
	xorl	%edx, %edx
.L26:
	cmpl	%edx, (%r11)
	jle	.L31
	xorl	%ecx, %ecx
	cmpl	%ecx, (%r8)
	jg	.L30
	incl	%edx
	jmp	.L26
.L31:
	ret
.L30:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
.L23:
	xorl	%ebx, %ebx
.L21:
	movl	(%r9), %ebp
	movl	(%r8), %eax
	cmpl	%ebx, %ebp
	jle	.L32
	imull	%edx, %eax
	addl	%ecx, %eax
	imull	%ebp, %eax
	addl	%ebx, %eax
	cltq
	leaq	(%r10,%rax,4), %rax
	cmpl	%edi, (%rax)
	jne	.L19
	movl	%esi, (%rax)
.L19:
	incl	%ebx
	jmp	.L21
.L32:
	incl	%ecx
.L22:
	cmpl	%ecx, (%r8)
	jg	.L23
	incl	%edx
	cmpl	%edx, (%r11)
	jle	.L33
	xorl	%ecx, %ecx
	jmp	.L22
.L33:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2050:
	.size	_Z5setIfiiPiS_S_S_, .-_Z5setIfiiPiS_S_S_
	.globl	_Z5randuPii
	.type	_Z5randuPii, @function
_Z5randuPii:
.LFB2051:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movq	M(%rip), %rcx
	leaq	(%rdi,%rsi,4), %rsi
	movl	(%rsi), %eax
	imull	A(%rip), %eax
	addl	C(%rip), %eax
	cvtsi2sdq	%rcx, %xmm1
	cltq
	cqto
	idivq	%rcx
	cvtsi2sdl	%edx, %xmm0
	movl	%edx, (%rsi)
	divsd	%xmm1, %xmm0
	andps	.LC2(%rip), %xmm0
	ret
	.cfi_endproc
.LFE2051:
	.size	_Z5randuPii, .-_Z5randuPii
	.globl	_Z5randnPii
	.type	_Z5randnPii, @function
_Z5randnPii:
.LFB2052:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movl	%esi, 8(%rsp)
	call	_Z5randuPii
	movl	8(%rsp), %esi
	movq	%xmm0, %rbx
	call	_Z5randuPii
	mulsd	.LC3(%rip), %xmm0
	call	cos@PLT
	movsd	%xmm0, 8(%rsp)
	movq	%rbx, %xmm0
	call	log@PLT
	mulsd	.LC4(%rip), %xmm0
	call	sqrt@PLT
	mulsd	8(%rsp), %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z5randnPii, .-_Z5randnPii
	.globl	_Z8addNoisePiS_S_S_S_
	.type	_Z8addNoisePiS_S_S_S_, @function
_Z8addNoisePiS_S_S_S_:
.LFB2053:
	.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
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdx, %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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%r8, 16(%rsp)
.L38:
	cmpl	%ebx, (%r14)
	jle	.L45
	xorl	%ebp, %ebp
.L41:
	cmpl	%ebp, (%r12)
	jle	.L46
	xorl	%r15d, %r15d
.L40:
	movl	(%rcx), %esi
	movl	(%r12), %eax
	cmpl	%r15d, %esi
	jle	.L47
	imull	%ebx, %eax
	movq	16(%rsp), %rdi
	movq	%rcx, 24(%rsp)
	addl	%ebp, %eax
	imull	%esi, %eax
	xorl	%esi, %esi
	addl	%r15d, %eax
	cltq
	movl	0(%r13,%rax,4), %eax
	movl	%eax, 12(%rsp)
	call	_Z5randnPii
	movl	(%r12), %eax
	movq	24(%rsp), %rcx
	mulsd	.LC5(%rip), %xmm0
	movl	12(%rsp), %edx
	imull	%ebx, %eax
	addl	%ebp, %eax
	imull	(%rcx), %eax
	cvttsd2sil	%xmm0, %esi
	addl	%r15d, %eax
	incl	%r15d
	cltq
	addl	%edx, %esi
	movl	%esi, 0(%r13,%rax,4)
	jmp	.L40
.L47:
	incl	%ebp
	jmp	.L41
.L46:
	incl	%ebx
	jmp	.L38
.L45:
	addq	$40, %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
.LFE2053:
	.size	_Z8addNoisePiS_S_S_S_, .-_Z8addNoisePiS_S_S_S_
	.globl	_Z9strelDiskPii
	.type	_Z9strelDiskPii, @function
_Z9strelDiskPii:
.LFB2054:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leal	-1(%rsi,%rsi), %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	negl	%r14d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L49:
	leal	(%r14,%rbx), %ecx
	cmpl	%ecx, %r15d
	jle	.L57
	incl	%r14d
	movl	$1, %r13d
	xorl	%ebp, %ebp
	cvtsi2sdl	%r14d, %xmm0
	subl	%ebx, %r13d
	mulsd	%xmm0, %xmm0
	movsd	%xmm0, (%rsp)
.L52:
	leal	0(%r13,%rbp), %ecx
	movq	%rdi, 8(%rsp)
	cvtsi2sdl	%ecx, %xmm0
	mulsd	%xmm0, %xmm0
	addsd	(%rsp), %xmm0
	call	sqrt@PLT
	cvtsi2sdl	%ebx, %xmm1
	movq	8(%rsp), %rdi
	comisd	%xmm0, %xmm1
	jbe	.L50
	leal	(%r12,%rbp), %ecx
	movslq	%ecx, %rcx
	movl	$1, (%rdi,%rcx,4)
.L50:
	incl	%ebp
	cmpl	%ebp, %r15d
	jg	.L52
	addl	%r15d, %r12d
	jmp	.L49
.L57:
	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
.LFE2054:
	.size	_Z9strelDiskPii, .-_Z9strelDiskPii
	.globl	_Z13dilate_matrixPiiiiiiii
	.type	_Z13dilate_matrixPiiiiiiii, @function
_Z13dilate_matrixPiiiiiiii:
.LFB2055:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	movl	%ecx, %edi
	xorl	%r10d, %r10d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	movl	%r14d, %eax
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	104(%rsp), %edx
	movl	96(%rsp), %esi
	subl	%edx, %eax
	movl	%edx, %ecx
	leal	(%r14,%rdx), %ebp
	movl	%edx, %r11d
	subl	%r14d, %ecx
	testl	%eax, %eax
	leal	(%rdx,%r13), %r12d
	cmovg	%r10d, %ecx
	subl	%r13d, %r11d
	addl	%ecx, %eax
	movl	%r13d, %ecx
	subl	%edx, %ecx
	testl	%ecx, %ecx
	cmovg	%r10d, %r11d
	addl	%r11d, %ecx
	movl	%r8d, %r11d
	subl	%ebp, %r11d
	cmpl	%r8d, %ebp
	movl	%r9d, %r8d
	cmovl	%r10d, %r11d
	subl	%r12d, %r8d
	cmpl	%r9d, %r12d
	cmovl	%r10d, %r8d
	leal	0(%rbp,%r11), %ebx
	movl	%ebx, 12(%rsp)
	leal	(%r12,%r8), %ebx
	movl	%r9d, %r8d
	imull	%eax, %r9d
	movl	%ebx, 16(%rsp)
	subl	%r14d, %eax
	imull	%esi, %r8d
	leal	(%r9,%rcx), %ebx
	imull	%esi, %ebx
	addl	%edi, %ebx
.L59:
	leal	(%r14,%rax), %edi
	cmpl	%edi, 12(%rsp)
	jle	.L58
	movl	%ecx, %r12d
	movl	%ebx, %ebp
	subl	%r13d, %r12d
.L64:
	leal	0(%r13,%r12), %r10d
	cmpl	%r10d, 16(%rsp)
	jle	.L67
	cvtsi2sdl	%eax, %xmm0
	movl	%edx, 104(%rsp)
	cvtsi2sdl	%r12d, %xmm1
	movl	%esi, 96(%rsp)
	movl	%r8d, 28(%rsp)
	movl	%ecx, 24(%rsp)
	mulsd	%xmm0, %xmm0
	movl	%eax, 20(%rsp)
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	call	sqrt@PLT
	movl	104(%rsp), %edx
	movl	20(%rsp), %eax
	movl	24(%rsp), %ecx
	movl	28(%rsp), %r8d
	cvtsi2sdl	%edx, %xmm1
	movl	96(%rsp), %esi
	comisd	%xmm0, %xmm1
	jbe	.L60
	movslq	%ebp, %r10
	movl	$1, (%r15,%r10,4)
.L60:
	incl	%r12d
	addl	%esi, %ebp
	jmp	.L64
.L67:
	addl	%r8d, %ebx
	incl	%eax
	jmp	.L59
.L58:
	addq	$40, %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
.LFE2055:
	.size	_Z13dilate_matrixPiiiiiiii, .-_Z13dilate_matrixPiiiiiiii
	.globl	_Z13imdilate_diskPiiiiiS_
	.type	_Z13imdilate_diskPiiiiiS_, @function
_Z13imdilate_diskPiiiiiS_:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%ecx, %r15
	movq	%rdi, %rax
	movl	%r8d, %r10d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	0(,%r15,4), %rcx
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%esi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r15, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%r9, 16(%rsp)
	movq	%rcx, 8(%rsp)
.L69:
	movl	%ebp, 4(%rsp)
	cmpl	%ebp, %ebx
	jle	.L68
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.L75:
	cmpl	%r13d, %r15d
	jge	.L72
	movl	%r14d, %edx
	imull	%ebx, %edx
	movslq	%edx, %rdx
	addq	%rbp, %rdx
	leaq	(%rax,%rdx,4), %r11
	xorl	%edx, %edx
.L73:
	cmpl	%r12d, %edx
	jge	.L77
	cmpl	$1, (%r11)
	jne	.L70
	movq	%r11, 32(%rsp)
	movl	%r12d, %r9d
	movl	%r13d, %r8d
	movl	%r15d, %esi
	movq	%rax, 40(%rsp)
	pushq	%r10
	.cfi_def_cfa_offset 120
	movl	%r10d, 36(%rsp)
	pushq	%rbx
	.cfi_def_cfa_offset 128
	movl	20(%rsp), %ecx
	movq	32(%rsp), %rdi
	movl	%edx, 40(%rsp)
	call	_Z13dilate_matrixPiiiiiiii
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
	movq	40(%rsp), %rax
	movq	32(%rsp), %r11
	movl	28(%rsp), %r10d
	movl	24(%rsp), %edx
.L70:
	movq	8(%rsp), %rsi
	incl	%edx
	addq	%rsi, %r11
	jmp	.L73
.L77:
	incl	%r15d
	addl	%r12d, %r14d
	jmp	.L75
.L72:
	incq	%rbp
	jmp	.L69
.L68:
	addq	$56, %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
.LFE2056:
	.size	_Z13imdilate_diskPiiiiiS_, .-_Z13imdilate_diskPiiiiiS_
	.globl	_Z12getneighborsPiiPdi
	.type	_Z12getneighborsPiiPdi, @function
_Z12getneighborsPiiPdi:
.LFB2057:
	.cfi_startproc
	endbr64
	leal	-1(%rcx,%rcx), %r9d
	movl	$1, %r8d
	xorl	%esi, %esi
	movq	%rdi, %rax
	movslq	%r9d, %r11
	movq	%rdx, %rdi
	xorl	%r10d, %r10d
	subl	%ecx, %r8d
	salq	$2, %r11
	cmpl	%r9d, %esi
	jl	.L86
	ret
.L86:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
.L82:
	xorl	%edx, %edx
	leal	(%rsi,%r8), %ebx
.L81:
	cmpl	$0, (%rax,%rdx,4)
	je	.L80
	leal	(%r8,%rdx), %ebp
	leal	(%r10,%r10), %ecx
	incl	%r10d
	cvtsi2sdl	%ebp, %xmm0
	movslq	%ecx, %rcx
	movsd	%xmm0, (%rdi,%rcx,8)
	cvtsi2sdl	%ebx, %xmm0
	movsd	%xmm0, 8(%rdi,%rcx,8)
.L80:
	incq	%rdx
	cmpl	%edx, %r9d
	jg	.L81
	incl	%esi
	addq	%r11, %rax
	cmpl	%r9d, %esi
	jl	.L82
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z12getneighborsPiiPdi, .-_Z12getneighborsPiiPdi
	.globl	_Z13videoSequencePiiiiS_
	.type	_Z13videoSequencePiiiiS_, @function
_Z13videoSequencePiiiiS_:
.LFB2058:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	cvtsi2sdl	%edx, %xmm0
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%r13d, %eax
	movq	%r8, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	movl	%esi, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	imull	%edx, %edi
	movl	%ecx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movsd	.LC6(%rip), %xmm1
	imull	%ecx, %edi
	movl	%esi, 12(%rsp)
	mulsd	%xmm1, %xmm0
	movl	%edx, 8(%rsp)
	movl	%ecx, 4(%rsp)
	cvttsd2sil	%xmm0, %esi
	cvtsi2sdl	%r14d, %xmm0
	imull	%esi, %eax
	decl	%esi
	mulsd	%xmm1, %xmm0
	cvttsd2sil	%xmm0, %edx
	addl	%edx, %eax
	imull	%ecx, %eax
	movl	$1, %ecx
	cltq
	movl	$1, 0(%rbp,%rax,4)
.L88:
	cmpl	%ecx, %ebx
	jle	.L99
	leal	(%rsi,%rcx), %r8d
	movl	%r8d, %eax
	negl	%eax
	cmovs	%r8d, %eax
	movl	%edx, %r8d
	negl	%r8d
	cmovs	%edx, %r8d
	imull	%r13d, %r8d
	addl	%r8d, %eax
	imull	%ebx, %eax
	addl	%ecx, %eax
	cmpl	%eax, %edi
	jg	.L89
	xorl	%eax, %eax
.L89:
	cltq
	incl	%ecx
	subl	$2, %edx
	movl	$1, 0(%rbp,%rax,4)
	jmp	.L88
.L99:
	movslq	%r13d, %rax
	movslq	%r14d, %rdi
	imulq	%rax, %rdi
	movslq	%ebx, %rax
	imulq	%rax, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movl	%ebx, %ecx
	movl	%r13d, %edx
	movl	$5, %r8d
	movq	%rax, %r9
	movl	%r14d, %esi
	movq	%rbp, %rdi
	movq	%rax, %r15
	call	_Z13imdilate_diskPiiiiiS_
	movl	%r13d, %r9d
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	imull	%ebx, %r9d
.L91:
	cmpl	%edx, %r14d
	jle	.L100
	movl	%ecx, %edi
	xorl	%r8d, %r8d
.L95:
	cmpl	%r8d, %r13d
	jle	.L93
	movslq	%edi, %rax
	xorl	%esi, %esi
	salq	$2, %rax
.L94:
	cmpl	%esi, %ebx
	jle	.L101
	movl	(%r15,%rax), %r10d
	incl	%esi
	movl	%r10d, 0(%rbp,%rax)
	addq	$4, %rax
	jmp	.L94
.L101:
	incl	%r8d
	addl	%ebx, %edi
	jmp	.L95
.L93:
	incl	%edx
	addl	%r9d, %ecx
	jmp	.L91
.L100:
	leaq	12(%rsp), %rbx
	leaq	8(%rsp), %r13
	movq	%r15, %rdi
	call	free@PLT
	leaq	4(%rsp), %r9
	movq	%r13, %r8
	movq	%rbx, %rcx
	movq	%rbp, %rdx
	movl	$100, %esi
	xorl	%edi, %edi
	call	_Z5setIfiiPiS_S_S_
	movq	%rbx, %rcx
	movq	%rbp, %rdx
	movl	$228, %esi
	movl	$1, %edi
	call	_Z5setIfiiPiS_S_S_
	movq	%r12, %r8
	movq	%r13, %rdx
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	movq	%r9, %rcx
	call	_Z8addNoisePiS_S_S_S_
	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
.LFE2058:
	.size	_Z13videoSequencePiiiiS_, .-_Z13videoSequencePiiiiS_
	.globl	_Z17calcLikelihoodSumPiS_i
	.type	_Z17calcLikelihoodSumPiS_i, @function
_Z17calcLikelihoodSumPiS_i:
.LFB2059:
	.cfi_startproc
	endbr64
	movsd	.LC8(%rip), %xmm3
	xorl	%eax, %eax
	xorps	%xmm2, %xmm2
.L103:
	cmpl	%eax, %edx
	jle	.L105
	movslq	(%rsi,%rax,4), %rcx
	incq	%rax
	movl	(%rdi,%rcx,4), %ecx
	leal	-100(%rcx), %r8d
	subl	$228, %ecx
	cvtsi2sdl	%r8d, %xmm0
	cvtsi2sdl	%ecx, %xmm1
	mulsd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm1
	subsd	%xmm1, %xmm0
	divsd	%xmm3, %xmm0
	addsd	%xmm0, %xmm2
	jmp	.L103
.L105:
	movaps	%xmm2, %xmm0
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z17calcLikelihoodSumPiS_i, .-_Z17calcLikelihoodSumPiS_i
	.globl	_Z9findIndexPdid
	.type	_Z9findIndexPdid, @function
_Z9findIndexPdid:
.LFB2060:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L107:
	cmpl	%eax, %esi
	jle	.L113
	leaq	1(%rax), %rdx
	movsd	-8(%rdi,%rdx,8), %xmm1
	comisd	%xmm0, %xmm1
	jnb	.L106
	movq	%rdx, %rax
	jmp	.L107
.L113:
	leal	-1(%rsi), %eax
.L106:
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z9findIndexPdid, .-_Z9findIndexPdid
	.globl	_Z36__device_stub__Z6kernelPdS_S_S_S_S_iPdS_S_S_S_S_i
	.type	_Z36__device_stub__Z6kernelPdS_S_S_S_S_iPdS_S_S_S_S_i, @function
_Z36__device_stub__Z6kernelPdS_S_S_S_S_iPdS_S_S_S_S_i:
.LFB2087:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%r9, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	movq	%rsp, %rax
	movq	%rax, 152(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L114
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z6kernelPdS_S_S_S_S_i(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L114:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L116
	call	__stack_chk_fail@PLT
.L116:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2087:
	.size	_Z36__device_stub__Z6kernelPdS_S_S_S_S_iPdS_S_S_S_S_i, .-_Z36__device_stub__Z6kernelPdS_S_S_S_S_iPdS_S_S_S_S_i
	.globl	_Z6kernelPdS_S_S_S_S_i
	.type	_Z6kernelPdS_S_S_S_S_i, @function
_Z6kernelPdS_S_S_S_S_i:
.LFB2088:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z6kernelPdS_S_S_S_S_iPdS_S_S_S_S_i
	.cfi_endproc
.LFE2088:
	.size	_Z6kernelPdS_S_S_S_S_i, .-_Z6kernelPdS_S_S_S_S_i
	.section	.rodata.str1.1
.LC9:
	.string	"TIME TO GET NEIGHBORS TOOK: %f\n"
.LC11:
	.string	"TIME TO GET WEIGHTSTOOK: %f\n"
.LC13:
	.string	"TIME TO SET ERROR TOOK: %f\n"
.LC14:
	.string	"TIME TO GET LIKELIHOODS TOOK: %f\n"
.LC15:
	.string	"TIME TO GET EXP TOOK: %f\n"
.LC16:
	.string	"TIME TO SUM WEIGHTS TOOK: %f\n"
.LC17:
	.string	"TIME TO NORMALIZE WEIGHTS TOOK: %f\n"
.LC18:
	.string	"TIME TO MOVE OBJECT TOOK: %f\n"
.LC19:
	.string	"XE: %lf\n"
.LC20:
	.string	"YE: %lf\n"
.LC21:
	.string	"%lf\n"
.LC22:
	.string	"TIME TO CALC CUM SUM TOOK: %f\n"
.LC23:
	.string	"TIME TO CALC U TOOK: %f\n"
.LC25:
	.string	"SENDING TO GPU TOOK: %lf\n"
.LC26:
	.string	"CUDA EXEC TOOK: %lf\n"
.LC27:
	.string	"SENDING BACK FROM GPU TOOK: %lf\n"
.LC28:
	.string	"TIME TO CALC NEW ARRAY X AND Y TOOK: %f\n"
.LC29:
	.string	"TIME TO RESET WEIGHTS TOOK: %f\n"
	.text
	.globl	_Z14particleFilterPiiiiS_i
	.type	_Z14particleFilterPiiiiS_i, @function
_Z14particleFilterPiiiiS_i:
.LFB2061:
	.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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r9d, %ebx
	subq	$264, %rsp
	.cfi_def_cfa_offset 320
	movl	%edx, 108(%rsp)
	movl	%ecx, 152(%rsp)
	movq	%r8, 112(%rsp)
	movq	%rdi, 168(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 248(%rsp)
	movl	%edx, %eax
	imull	%esi, %eax
	imull	%ecx, %eax
	movl	%eax, 156(%rsp)
	call	_Z8get_timev
	cvtsi2sdl	108(%rsp), %xmm0
	movl	$324, %edi
	movsd	.LC6(%rip), %xmm1
	movq	%rax, %rbp
	mulsd	%xmm1, %xmm0
	cvttsd2sil	%xmm0, %eax
	cvtsi2sdl	%r12d, %xmm0
	cvtsi2sdl	%eax, %xmm4
	mulsd	%xmm1, %xmm0
	movsd	%xmm4, 120(%rsp)
	cvttsd2sil	%xmm0, %eax
	cvtsi2sdl	%eax, %xmm5
	movsd	%xmm5, 128(%rsp)
	call	malloc@PLT
	movl	$5, %esi
	movq	%rax, %rdi
	movq	%rax, 48(%rsp)
	call	_Z9strelDiskPii
	xorl	%esi, %esi
	movq	48(%rsp), %rcx
	xorl	%edx, %edx
	movl	%esi, 20(%rsp)
.L120:
	xorl	%eax, %eax
.L122:
	cmpl	$1, (%rcx,%rax,4)
	jne	.L121
	incl	20(%rsp)
.L121:
	incq	%rax
	cmpq	$9, %rax
	jne	.L122
	addl	$9, %edx
	addq	$36, %rcx
	cmpl	$81, %edx
	jne	.L120
	movl	20(%rsp), %eax
	leal	(%rax,%rax), %edi
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	movl	20(%rsp), %esi
	movq	48(%rsp), %rdi
	movl	$5, %ecx
	movq	%rax, %rdx
	movq	%rax, 72(%rsp)
	call	_Z12getneighborsPiiPdi
	call	_Z8get_timev
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r12
	subq	%rbp, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movslq	%ebx, %rax
	salq	$3, %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movsd	.LC10(%rip), %xmm0
	movq	%rax, %rbp
	xorl	%eax, %eax
.L124:
	cmpl	%eax, %ebx
	jle	.L156
	cvtsi2sdl	%ebx, %xmm2
	movaps	%xmm0, %xmm1
	divsd	%xmm2, %xmm1
	movsd	%xmm1, 0(%rbp,%rax,8)
	incq	%rax
	jmp	.L124
.L156:
	call	_Z8get_timev
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, 80(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, %r15
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, 56(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, 64(%rsp)
	call	malloc@PLT
	movslq	20(%rsp), %rdi
	movq	%rax, 24(%rsp)
	salq	$2, %rdi
	call	malloc@PLT
	movq	8(%rsp), %rdi
	movq	%rax, 88(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rsi
	leaq	176(%rsp), %rdi
	movq	%rax, 96(%rsp)
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z11check_error9cudaError
	movq	8(%rsp), %rsi
	leaq	184(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z11check_error9cudaError
	movq	8(%rsp), %rsi
	leaq	192(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z11check_error9cudaError
	movq	8(%rsp), %rsi
	leaq	200(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z11check_error9cudaError
	movq	8(%rsp), %rsi
	leaq	208(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z11check_error9cudaError
	movq	8(%rsp), %rsi
	leaq	216(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z11check_error9cudaError
	xorl	%eax, %eax
.L126:
	cmpl	%eax, %ebx
	jle	.L157
	movsd	128(%rsp), %xmm7
	movsd	120(%rsp), %xmm6
	movsd	%xmm7, (%r14,%rax,8)
	movsd	%xmm6, (%r15,%rax,8)
	incq	%rax
	jmp	.L126
.L157:
	movl	$1, 104(%rsp)
.L128:
	movl	152(%rsp), %ecx
	cmpl	%ecx, 104(%rsp)
	jge	.L158
	call	_Z8get_timev
	xorl	%r12d, %r12d
	movq	%rax, %r13
.L129:
	movl	%r12d, %esi
	cmpl	%r12d, %ebx
	jle	.L159
	movsd	.LC10(%rip), %xmm3
	addsd	(%r15,%r12,8), %xmm3
	movl	%esi, 40(%rsp)
	movq	112(%rsp), %rdi
	movsd	%xmm3, 32(%rsp)
	call	_Z5randnPii
	movl	40(%rsp), %esi
	movq	112(%rsp), %rdi
	mulsd	.LC5(%rip), %xmm0
	addsd	32(%rsp), %xmm0
	movsd	%xmm0, (%r15,%r12,8)
	movsd	(%r14,%r12,8), %xmm0
	subsd	.LC12(%rip), %xmm0
	movsd	%xmm0, 32(%rsp)
	call	_Z5randnPii
	addsd	%xmm0, %xmm0
	addsd	32(%rsp), %xmm0
	movsd	%xmm0, (%r14,%r12,8)
	incq	%r12
	jmp	.L129
.L159:
	call	_Z8get_timev
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r12
	subq	%r13, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	xorl	%r9d, %r9d
.L131:
	cmpl	%r9d, %ebx
	jle	.L134
	movq	72(%rsp), %rcx
	xorl	%edx, %edx
.L135:
	cmpl	%edx, 20(%rsp)
	jle	.L160
	cvttsd2sil	(%r15,%r9,8), %eax
	movl	108(%rsp), %esi
	cvtsi2sdl	%eax, %xmm0
	addsd	8(%rcx), %xmm0
	cvttsd2sil	%xmm0, %eax
	imull	%esi, %eax
	cvttsd2sil	(%r14,%r9,8), %esi
	cvtsi2sdl	%esi, %xmm0
	addsd	(%rcx), %xmm0
	cvttsd2sil	%xmm0, %esi
	addl	%esi, %eax
	movl	152(%rsp), %esi
	imull	%esi, %eax
	movl	104(%rsp), %esi
	addl	%esi, %eax
	movl	156(%rsp), %esi
	cvtsi2sdl	%eax, %xmm0
	andps	.LC2(%rip), %xmm0
	cvttsd2sil	%xmm0, %eax
	cmpl	%esi, %eax
	jl	.L132
	xorl	%eax, %eax
.L132:
	movq	88(%rsp), %rsi
	addq	$16, %rcx
	movl	%eax, (%rsi,%rdx,4)
	incq	%rdx
	jmp	.L135
.L160:
	movl	20(%rsp), %edx
	movq	88(%rsp), %rsi
	movq	168(%rsp), %rdi
	call	_Z17calcLikelihoodSumPiS_i
	cvtsi2sdl	%edx, %xmm1
	movq	80(%rsp), %rax
	divsd	%xmm1, %xmm0
	movsd	%xmm0, (%rax,%r9,8)
	incq	%r9
	jmp	.L131
.L134:
	call	_Z8get_timev
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r13
	subq	%r12, %rax
	xorl	%r12d, %r12d
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
.L136:
	cmpl	%r12d, %ebx
	jle	.L161
	movq	80(%rsp), %rax
	movsd	0(%rbp,%r12,8), %xmm5
	movsd	(%rax,%r12,8), %xmm0
	movsd	%xmm5, 32(%rsp)
	call	exp@PLT
	mulsd	32(%rsp), %xmm0
	movsd	%xmm0, 0(%rbp,%r12,8)
	incq	%r12
	jmp	.L136
.L161:
	call	_Z8get_timev
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r12
	subq	%r13, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	xorl	%eax, %eax
	xorps	%xmm1, %xmm1
.L138:
	cmpl	%eax, %ebx
	jle	.L162
	addsd	0(%rbp,%rax,8), %xmm1
	incq	%rax
	jmp	.L138
.L162:
	movsd	%xmm1, 32(%rsp)
	call	_Z8get_timev
	leaq	.LC16(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r13
	subq	%r12, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movsd	32(%rsp), %xmm1
	xorl	%eax, %eax
.L140:
	cmpl	%eax, %ebx
	jle	.L163
	movsd	0(%rbp,%rax,8), %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 0(%rbp,%rax,8)
	incq	%rax
	jmp	.L140
.L163:
	call	_Z8get_timev
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r12
	subq	%r13, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	xorl	%eax, %eax
	movq	$0x000000000, 40(%rsp)
	movq	$0x000000000, 32(%rsp)
.L142:
	cmpl	%eax, %ebx
	jle	.L164
	movsd	0(%rbp,%rax,8), %xmm0
	movsd	(%r15,%rax,8), %xmm1
	mulsd	%xmm0, %xmm1
	mulsd	(%r14,%rax,8), %xmm0
	addsd	32(%rsp), %xmm1
	incq	%rax
	addsd	40(%rsp), %xmm0
	movsd	%xmm1, 32(%rsp)
	movsd	%xmm0, 40(%rsp)
	jmp	.L142
.L164:
	call	_Z8get_timev
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r13
	subq	%r12, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movsd	32(%rsp), %xmm0
	leaq	.LC19(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movsd	40(%rsp), %xmm0
	leaq	.LC20(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movsd	32(%rsp), %xmm1
	movsd	40(%rsp), %xmm0
	subsd	128(%rsp), %xmm0
	subsd	120(%rsp), %xmm1
	mulsd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	call	sqrt@PLT
	leaq	.LC21(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	movsd	0(%rbp), %xmm0
	movsd	%xmm0, (%rax)
	xorl	%eax, %eax
.L144:
	incq	%rax
	cmpl	%eax, %ebx
	jle	.L165
	movq	24(%rsp), %rcx
	movsd	0(%rbp,%rax,8), %xmm0
	addsd	-8(%rcx,%rax,8), %xmm0
	movsd	%xmm0, (%rcx,%rax,8)
	jmp	.L144
.L165:
	call	_Z8get_timev
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r12
	subq	%r13, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	cvtsi2sdl	%ebx, %xmm5
	movq	112(%rsp), %rdi
	xorl	%esi, %esi
	movsd	.LC10(%rip), %xmm0
	divsd	%xmm5, %xmm0
	movsd	%xmm5, 32(%rsp)
	movsd	%xmm0, 40(%rsp)
	call	_Z5randuPii
	mulsd	40(%rsp), %xmm0
	xorl	%eax, %eax
.L146:
	cmpl	%eax, %ebx
	jle	.L166
	cvtsi2sdl	%eax, %xmm1
	divsd	32(%rsp), %xmm1
	addsd	%xmm0, %xmm1
	movq	96(%rsp), %rcx
	movsd	%xmm1, (%rcx,%rax,8)
	incq	%rax
	jmp	.L146
.L166:
	call	_Z8get_timev
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	movq	%rax, 136(%rsp)
	subq	%r12, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	call	_Z8get_timev
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	movq	%r15, %rsi
	movq	176(%rsp), %rdi
	movq	%rax, 160(%rsp)
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	movq	%r14, %rsi
	movq	184(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	56(%rsp), %rsi
	movl	$1, %ecx
	movq	192(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	64(%rsp), %rsi
	movl	$1, %ecx
	movq	200(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	$1, %ecx
	movq	208(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	96(%rsp), %rsi
	movl	$1, %ecx
	movq	216(%rsp), %rdi
	call	cudaMemcpy@PLT
	call	_Z8get_timev
	movsd	32(%rsp), %xmm0
	mulsd	.LC24(%rip), %xmm0
	movq	%rax, 144(%rsp)
	call	ceil@PLT
	movl	$33554433, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	cvttsd2sil	%xmm0, %eax
	salq	$7, %rdx
	movl	$1, %ecx
	movl	%eax, 224(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 228(%rsp)
	movq	224(%rsp), %rdi
	movl	232(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L148
	pushq	%rax
	.cfi_def_cfa_offset 328
	pushq	%rbx
	.cfi_def_cfa_offset 336
	movq	216(%rsp), %r9
	movq	208(%rsp), %r8
	movq	232(%rsp), %rcx
	movq	224(%rsp), %rdx
	movq	200(%rsp), %rsi
	movq	192(%rsp), %rdi
	call	_Z36__device_stub__Z6kernelPdS_S_S_S_S_iPdS_S_S_S_S_i
	popq	%rdx
	.cfi_def_cfa_offset 328
	popq	%rcx
	.cfi_def_cfa_offset 320
.L148:
	call	cudaThreadSynchronize@PLT
	call	_Z8get_timev
	movq	8(%rsp), %rdx
	movq	64(%rsp), %rdi
	movl	$2, %ecx
	movq	200(%rsp), %rsi
	movq	%rax, %r13
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	56(%rsp), %rdi
	movl	$2, %ecx
	movq	192(%rsp), %rsi
	call	cudaMemcpy@PLT
	call	_Z8get_timev
	movq	160(%rsp), %rdx
	movl	$2, %edi
	leaq	.LC25(%rip), %rsi
	movq	%rax, %r12
	movq	144(%rsp), %rax
	subq	%r13, %r12
	subq	%rdx, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	144(%rsp), %rcx
	movq	%r13, %rax
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	subq	%rcx, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	leaq	.LC27(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtsi2ssq	%r12, %xmm0
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	call	_Z8get_timev
	movq	136(%rsp), %rdx
	movl	$2, %edi
	leaq	.LC28(%rip), %rsi
	movq	%rax, %r12
	subq	%rdx, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	xorl	%eax, %eax
.L149:
	cmpl	%eax, %ebx
	jle	.L167
	movq	56(%rsp), %rcx
	movq	64(%rsp), %rdx
	movsd	40(%rsp), %xmm2
	movsd	(%rcx,%rax,8), %xmm0
	movsd	%xmm2, 0(%rbp,%rax,8)
	movsd	%xmm0, (%r15,%rax,8)
	movsd	(%rdx,%rax,8), %xmm0
	movsd	%xmm0, (%r14,%rax,8)
	incq	%rax
	jmp	.L149
.L167:
	call	_Z8get_timev
	leaq	.LC29(%rip), %rsi
	movl	$2, %edi
	subq	%r12, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	incl	104(%rsp)
	jmp	.L128
.L158:
	movq	216(%rsp), %rdi
	call	cudaFree@PLT
	movq	208(%rsp), %rdi
	call	cudaFree@PLT
	movq	200(%rsp), %rdi
	call	cudaFree@PLT
	movq	192(%rsp), %rdi
	call	cudaFree@PLT
	movq	184(%rsp), %rdi
	call	cudaFree@PLT
	movq	176(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	free@PLT
	movq	72(%rsp), %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	80(%rsp), %rdi
	call	free@PLT
	movq	%r15, %rdi
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	56(%rsp), %rdi
	call	free@PLT
	movq	64(%rsp), %rdi
	call	free@PLT
	movq	24(%rsp), %rdi
	call	free@PLT
	movq	96(%rsp), %rdi
	call	free@PLT
	movq	248(%rsp), %rax
	subq	%fs:40, %rax
	je	.L152
	call	__stack_chk_fail@PLT
.L152:
	movq	88(%rsp), %rdi
	addq	$264, %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	free@PLT
	.cfi_endproc
.LFE2061:
	.size	_Z14particleFilterPiiiiS_i, .-_Z14particleFilterPiiiiS_i
	.section	.rodata.str1.1
.LC30:
	.string	"naive.out -x <dimX> -y <dimY> -z <Nfr> -np <Nparticles>"
.LC31:
	.string	"%s\n"
.LC32:
	.string	"-x"
.LC33:
	.string	"-y"
.LC34:
	.string	"-z"
.LC35:
	.string	"-np"
.LC36:
	.string	"%d"
.LC37:
	.string	"ERROR: dimX input is incorrect"
.LC38:
	.string	"dimX must be > 0\n"
.LC39:
	.string	"ERROR: dimY input is incorrect"
.LC40:
	.string	"dimY must be > 0\n"
.LC41:
	.string	"ERROR: Number of frames input is incorrect"
.LC42:
	.string	"number of frames must be > 0\n"
.LC43:
	.string	"ERROR: Number of particles input is incorrect"
.LC44:
	.string	"Number of particles must be > 0\n"
.LC45:
	.string	"VIDEO SEQUENCE TOOK %f\n"
.LC46:
	.string	"PARTICLE FILTER TOOK %f\n"
.LC47:
	.string	"ENTIRE PROGRAM TOOK %f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2062:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	cmpl	$9, %edi
	je	.L169
.L171:
	leaq	.LC30(%rip), %rdx
	leaq	.LC31(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L170
.L169:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	leaq	.LC32(%rip), %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L171
	movq	24(%rbx), %rdi
	leaq	.LC33(%rip), %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L171
	movq	40(%rbx), %rdi
	leaq	.LC34(%rip), %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L171
	movq	56(%rbx), %rdi
	leaq	.LC35(%rip), %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L171
	movq	16(%rbx), %rdi
	leaq	.LC36(%rip), %rbp
	leaq	8(%rsp), %rdx
	movq	%rbp, %rsi
	call	__isoc23_sscanf@PLT
	leaq	.LC37(%rip), %rsi
	incl	%eax
	je	.L184
	cmpl	$0, 8(%rsp)
	leaq	.LC38(%rip), %rsi
	jle	.L184
	movq	32(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	call	__isoc23_sscanf@PLT
	leaq	.LC39(%rip), %rsi
	incl	%eax
	je	.L184
	cmpl	$0, 12(%rsp)
	leaq	.LC40(%rip), %rsi
	jle	.L184
	movq	48(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	call	__isoc23_sscanf@PLT
	leaq	.LC41(%rip), %rsi
	incl	%eax
	je	.L184
	cmpl	$0, 16(%rsp)
	leaq	.LC42(%rip), %rsi
	jle	.L184
	movq	64(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	20(%rsp), %rdx
	call	__isoc23_sscanf@PLT
	leaq	.LC43(%rip), %rsi
	incl	%eax
	je	.L184
	movslq	20(%rsp), %rdi
	testl	%edi, %edi
	jg	.L179
	leaq	.LC44(%rip), %rsi
.L184:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L170
.L179:
	salq	$2, %rdi
	xorl	%ebp, %ebp
	call	malloc@PLT
	movq	%rax, %rbx
.L180:
	cmpl	%ebp, 20(%rsp)
	jle	.L185
	xorl	%edi, %edi
	call	time@PLT
	imull	%ebp, %eax
	movl	%eax, (%rbx,%rbp,4)
	incq	%rbp
	jmp	.L180
.L185:
	movslq	12(%rsp), %rax
	movslq	8(%rsp), %rdi
	imulq	%rax, %rdi
	movslq	16(%rsp), %rax
	imulq	%rax, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %r12
	call	_Z8get_timev
	movl	16(%rsp), %ecx
	movl	12(%rsp), %edx
	movq	%rbx, %r8
	movl	8(%rsp), %esi
	movq	%r12, %rdi
	movq	%rax, %r13
	call	_Z13videoSequencePiiiiS_
	call	_Z8get_timev
	leaq	.LC45(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r14
	subq	%r13, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movl	20(%rsp), %r9d
	movq	%rbx, %r8
	movq	%r12, %rdi
	movl	16(%rsp), %ecx
	movl	12(%rsp), %edx
	movl	8(%rsp), %esi
	call	_Z14particleFilterPiiiiS_i
	call	_Z8get_timev
	leaq	.LC46(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rbp
	subq	%r14, %rax
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	subq	%r13, %rbp
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	cvtsi2ssq	%rbp, %xmm0
	leaq	.LC47(%rip), %rsi
	divss	.LC0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
.L170:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L182
	call	__stack_chk_fail@PLT
.L182:
	addq	$32, %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
.LFE2062:
	.size	main, .-main
	.section	.rodata.str1.1
.LC48:
	.string	"_Z6kernelPdS_S_S_S_S_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2090:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC48(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6kernelPdS_S_S_S_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2090:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.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	C
	.data
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.long	12345
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.long	1103515245
	.globl	M
	.align 8
	.type	M, @object
	.size	M, 8
M:
	.quad	2147483647
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	1232348160
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	1413754136
	.long	1075388923
	.align 8
.LC4:
	.long	0
	.long	-1073741824
	.align 8
.LC5:
	.long	0
	.long	1075052544
	.align 8
.LC6:
	.long	0
	.long	1071644672
	.align 8
.LC8:
	.long	0
	.long	1078525952
	.align 8
.LC10:
	.long	0
	.long	1072693248
	.align 8
.LC12:
	.long	0
	.long	1073741824
	.align 8
.LC24:
	.long	0
	.long	1065353216
	.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:

/**
 * @file ex_particle_OPENMP_seq.c
 * @author Michael Trotter & Matt Goodrum
 * @brief Particle filter implementation in C/OpenMP 
 */

#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <unistd.h>
#include <fcntl.h>
#include <float.h>
#include <sys/time.h>
#include<ctime>
#define PI 3.1415926535897932
#define BLOCK_X 16
#define BLOCK_Y 16

/**
@var M value for Linear Congruential Generator (LCG); use GCC's value
*/
long M = INT_MAX;
/**
@var A value for LCG
*/
int A = 1103515245;
/**
@var C value for LCG
*/
int C = 12345;

const int threads_per_block = 128;

/*****************************
*GET_TIME
*returns a long int representing the time
*****************************/
long long get_time() {
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return (tv.tv_sec * 1000000) + tv.tv_usec;
}
// Returns the number of seconds elapsed between the two specified times
float elapsed_time(long long start_time, long long end_time) {
        return (float) (end_time - start_time) / (1000 * 1000);
}
/*****************************
* CHECK_ERROR
* Checks for CUDA errors and prints them to the screen to help with
* debugging of CUDA related programming
*****************************/
void check_error(hipError_t e) {
     if (e != hipSuccess) {
     	printf("\nCUDA error: %s\n", hipGetErrorString(e));
	    exit(1);
     }
}
__device__ int findIndexSeq(double * CDF, int lengthCDF, double value)
{
	int index = -1;
	int x;
	for(x = 0; x < lengthCDF; x++)
	{
		if(CDF[x] >= value)
		{
			index = x;
			break;
		}
	}
	if(index == -1)
		return lengthCDF-1;
	return index;
}
__device__ int findIndexBin(double * CDF, int beginIndex, int endIndex, double value)
{
	if(endIndex < beginIndex)
		return -1;
	int middleIndex;
	while(endIndex > beginIndex)
	{
		middleIndex = beginIndex + ((endIndex-beginIndex)/2);
		if(CDF[middleIndex] >= value)
		{
			if(middleIndex == 0)
				return middleIndex;
			else if(CDF[middleIndex-1] < value)
				return middleIndex;
			else if(CDF[middleIndex-1] == value)
			{
				while(CDF[middleIndex] == value && middleIndex >= 0)
					middleIndex--;
				middleIndex++;
				return middleIndex;
			}
		}
		if(CDF[middleIndex] > value)
			endIndex = middleIndex-1;
		else
			beginIndex = middleIndex+1;
	}
	return -1;
}
/*****************************
* CUDA Kernel Function to replace FindIndex
* param1: arrayX
* param2: arrayY
* param3: CDF
* param4: u
* param5: xj
* param6: yj
* param7: Nparticles
*****************************/
__global__ void kernel(double * arrayX, double * arrayY, double * CDF, double * u, double * xj, double * yj, int Nparticles){
	int block_id = blockIdx.x;// + gridDim.x * blockIdx.y;
	int i = blockDim.x * block_id + threadIdx.x;
	
	if(i < Nparticles){
	
		int index = -1;
		int x;
		
		for(x = 0; x < Nparticles; x++){
			if(CDF[x] >= u[i]){
				index = x;
				break;
			}
		}
		if(index == -1){
			index = Nparticles-1;
		}
		
		xj[i] = arrayX[index];
		yj[i] = arrayY[index];
		
	}
}
/** 
* Takes in a double and returns an integer that approximates to that double
* @return if the mantissa < .5 => return value < input value; else return value > input value
*/
double roundDouble(double value){
	int newValue = (int)(value);
	if(value - newValue < .5)
	return newValue;
	else
	return newValue++;
}
/**
* Set values of the 3D array to a newValue if that value is equal to the testValue
* @param testValue The value to be replaced
* @param newValue The value to replace testValue with
* @param array3D The image vector
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
*/
void setIf(int testValue, int newValue, int * array3D, int * dimX, int * dimY, int * dimZ){
	int x, y, z;
	for(x = 0; x < *dimX; x++){
		for(y = 0; y < *dimY; y++){
			for(z = 0; z < *dimZ; z++){
				if(array3D[x * *dimY * *dimZ+y * *dimZ + z] == testValue)
				array3D[x * *dimY * *dimZ + y * *dimZ + z] = newValue;
			}
		}
	}
}
/**
* Generates a uniformly distributed random number using the provided seed and GCC's settings for the Linear Congruential Generator (LCG)
* @see http://en.wikipedia.org/wiki/Linear_congruential_generator
* @note This function is thread-safe
* @param seed The seed array
* @param index The specific index of the seed to be advanced
* @return a uniformly distributed number [0, 1)
*/
double randu(int * seed, int index)
{
	int num = A*seed[index] + C;
	seed[index] = num % M;
	return fabs(seed[index]/((double) M));
}
/**
* Generates a normally distributed random number using the Box-Muller transformation
* @note This function is thread-safe
* @param seed The seed array
* @param index The specific index of the seed to be advanced
* @return a double representing random number generated using the Box-Muller algorithm
* @see http://en.wikipedia.org/wiki/Normal_distribution, section computing value for normal random distribution
*/
double randn(int * seed, int index){
	/*Box-Muller algorithm*/
	double u = randu(seed, index);
	double v = randu(seed, index);
	double cosine = cos(2*PI*v);
	double rt = -2*log(u);
	return sqrt(rt)*cosine;
}
/**
* Sets values of 3D matrix using randomly generated numbers from a normal distribution
* @param array3D The video to be modified
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
* @param seed The seed array
*/
void addNoise(int * array3D, int * dimX, int * dimY, int * dimZ, int * seed){
	int x, y, z;
	for(x = 0; x < *dimX; x++){
		for(y = 0; y < *dimY; y++){
			for(z = 0; z < *dimZ; z++){
				array3D[x * *dimY * *dimZ + y * *dimZ + z] = array3D[x * *dimY * *dimZ + y * *dimZ + z] + (int)(5*randn(seed, 0));
			}
		}
	}
}
/**
* Fills a radius x radius matrix representing the disk
* @param disk The pointer to the disk to be made
* @param radius  The radius of the disk to be made
*/
void strelDisk(int * disk, int radius)
{
	int diameter = radius*2 - 1;
	int x, y;
	for(x = 0; x < diameter; x++){
		for(y = 0; y < diameter; y++){
			double distance = sqrt(pow((double)(x-radius+1),2) + pow((double)(y-radius+1),2));
			if(distance < radius)
			disk[x*diameter + y] = 1;
		}
	}
}
/**
* Dilates the provided video
* @param matrix The video to be dilated
* @param posX The x location of the pixel to be dilated
* @param posY The y location of the pixel to be dilated
* @param poxZ The z location of the pixel to be dilated
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
* @param error The error radius
*/
void dilate_matrix(int * matrix, int posX, int posY, int posZ, int dimX, int dimY, int dimZ, int error)
{
	int startX = posX - error;
	while(startX < 0)
	startX++;
	int startY = posY - error;
	while(startY < 0)
	startY++;
	int endX = posX + error;
	while(endX > dimX)
	endX--;
	int endY = posY + error;
	while(endY > dimY)
	endY--;
	int x,y;
	for(x = startX; x < endX; x++){
		for(y = startY; y < endY; y++){
			double distance = sqrt( pow((double)(x-posX),2) + pow((double)(y-posY),2) );
			if(distance < error)
			matrix[x*dimY*dimZ + y*dimZ + posZ] = 1;
		}
	}
}

/**
* Dilates the target matrix using the radius as a guide
* @param matrix The reference matrix
* @param dimX The x dimension of the video
* @param dimY The y dimension of the video
* @param dimZ The z dimension of the video
* @param error The error radius to be dilated
* @param newMatrix The target matrix
*/
void imdilate_disk(int * matrix, int dimX, int dimY, int dimZ, int error, int * newMatrix)
{
	int x, y, z;
	for(z = 0; z < dimZ; z++){
		for(x = 0; x < dimX; x++){
			for(y = 0; y < dimY; y++){
				if(matrix[x*dimY*dimZ + y*dimZ + z] == 1){
					dilate_matrix(newMatrix, x, y, z, dimX, dimY, dimZ, error);
				}
			}
		}
	}
}
/**
* Fills a 2D array describing the offsets of the disk object
* @param se The disk object
* @param numOnes The number of ones in the disk
* @param neighbors The array that will contain the offsets
* @param radius The radius used for dilation
*/
void getneighbors(int * se, int numOnes, double * neighbors, int radius){
	int x, y;
	int neighY = 0;
	int center = radius - 1;
	int diameter = radius*2 -1;
	for(x = 0; x < diameter; x++){
		for(y = 0; y < diameter; y++){
			if(se[x*diameter + y]){
				neighbors[neighY*2] = (int)(y - center);
				neighbors[neighY*2 + 1] = (int)(x - center);
				neighY++;
			}
		}
	}
}
/**
* The synthetic video sequence we will work with here is composed of a
* single moving object, circular in shape (fixed radius)
* The motion here is a linear motion
* the foreground intensity and the backgrounf intensity is known
* the image is corrupted with zero mean Gaussian noise
* @param I The video itself
* @param IszX The x dimension of the video
* @param IszY The y dimension of the video
* @param Nfr The number of frames of the video
* @param seed The seed array used for number generation
*/
void videoSequence(int * I, int IszX, int IszY, int Nfr, int * seed){
	int k;
	int max_size = IszX*IszY*Nfr;
	/*get object centers*/
	int x0 = (int)roundDouble(IszY/2.0);
	int y0 = (int)roundDouble(IszX/2.0);
	I[x0 *IszY *Nfr + y0 * Nfr  + 0] = 1;
	
	/*move point*/
	int xk, yk, pos;
	for(k = 1; k < Nfr; k++){
		xk = abs(x0 + (k-1));
		yk = abs(y0 - 2*(k-1));
		pos = yk * IszY * Nfr + xk *Nfr + k;
		if(pos >= max_size)
		pos = 0;
		I[pos] = 1;
	}
	
	/*dilate matrix*/
	int * newMatrix = (int *)malloc(sizeof(int)*IszX*IszY*Nfr);
	imdilate_disk(I, IszX, IszY, Nfr, 5, newMatrix);
	int x, y;
	for(x = 0; x < IszX; x++){
		for(y = 0; y < IszY; y++){
			for(k = 0; k < Nfr; k++){
				I[x*IszY*Nfr + y*Nfr + k] = newMatrix[x*IszY*Nfr + y*Nfr + k];
			}
		}
	}
	free(newMatrix);
	
	/*define background, add noise*/
	setIf(0, 100, I, &IszX, &IszY, &Nfr);
	setIf(1, 228, I, &IszX, &IszY, &Nfr);
	/*add noise*/
	addNoise(I, &IszX, &IszY, &Nfr, seed);
}
/**
* Determines the likelihood sum based on the formula: SUM( (IK[IND] - 100)^2 - (IK[IND] - 228)^2)/ 100
* @param I The 3D matrix
* @param ind The current ind array
* @param numOnes The length of ind array
* @return A double representing the sum
*/
double calcLikelihoodSum(int * I, int * ind, int numOnes){
	double likelihoodSum = 0.0;
	int y;
	for(y = 0; y < numOnes; y++)
	likelihoodSum += (pow((double)(I[ind[y]] - 100),2) - pow((double)(I[ind[y]]-228),2))/50.0;
	return likelihoodSum;
}
/**
* Finds the first element in the CDF that is greater than or equal to the provided value and returns that index
* @note This function uses sequential search
* @param CDF The CDF
* @param lengthCDF The length of CDF
* @param value The value to be found
* @return The index of value in the CDF; if value is never found, returns the last index
*/
int findIndex(double * CDF, int lengthCDF, double value){
	int index = -1;
	int x;
	for(x = 0; x < lengthCDF; x++){
		if(CDF[x] >= value){
			index = x;
			break;
		}
	}
	if(index == -1){
		return lengthCDF-1;
	}
	return index;
}
/**
* The implementation of the particle filter using OpenMP for many frames
* @see http://openmp.org/wp/
* @note This function is designed to work with a video of several frames. In addition, it references a provided MATLAB function which takes the video, the objxy matrix and the x and y arrays as arguments and returns the likelihoods
* @param I The video to be run
* @param IszX The x dimension of the video
* @param IszY The y dimension of the video
* @param Nfr The number of frames
* @param seed The seed array used for random number generation
* @param Nparticles The number of particles to be used
*/
void particleFilter(int * I, int IszX, int IszY, int Nfr, int * seed, int Nparticles){
	int max_size = IszX*IszY*Nfr;
	long long start = get_time();
	//original particle centroid
	double xe = roundDouble(IszY/2.0);
	double ye = roundDouble(IszX/2.0);
	
	//expected object locations, compared to center
	int radius = 5;
	int diameter = radius*2 - 1;
	int * disk = (int *)malloc(diameter*diameter*sizeof(int));
	strelDisk(disk, radius);
	int countOnes = 0;
	int x, y;
	for(x = 0; x < diameter; x++){
		for(y = 0; y < diameter; y++){
			if(disk[x*diameter + y] == 1)
				countOnes++;
		}
	}
	double * objxy = (double *)malloc(countOnes*2*sizeof(double));
	getneighbors(disk, countOnes, objxy, radius);
	
	long long get_neighbors = get_time();
	printf("TIME TO GET NEIGHBORS TOOK: %f\n", elapsed_time(start, get_neighbors));
	//initial weights are all equal (1/Nparticles)
	double * weights = (double *)malloc(sizeof(double)*Nparticles);
	for(x = 0; x < Nparticles; x++){
		weights[x] = 1/((double)(Nparticles));
	}
	long long get_weights = get_time();
	printf("TIME TO GET WEIGHTSTOOK: %f\n", elapsed_time(get_neighbors, get_weights));
	//initial likelihood to 0.0
	double * likelihood = (double *)malloc(sizeof(double)*Nparticles);
	double * arrayX = (double *)malloc(sizeof(double)*Nparticles);
	double * arrayY = (double *)malloc(sizeof(double)*Nparticles);
	double * xj = (double *)malloc(sizeof(double)*Nparticles);
	double * yj = (double *)malloc(sizeof(double)*Nparticles);
	double * CDF = (double *)malloc(sizeof(double)*Nparticles);
	
	//GPU copies of arrays
	double * arrayX_GPU;
	double * arrayY_GPU;
	double * xj_GPU;
	double * yj_GPU;
	double * CDF_GPU;
	
	int * ind = (int*)malloc(sizeof(int)*countOnes);
	double * u = (double *)malloc(sizeof(double)*Nparticles);
	double * u_GPU;
	
	//CUDA memory allocation
	check_error(hipMalloc((void **) &arrayX_GPU, sizeof(double)*Nparticles));
	check_error(hipMalloc((void **) &arrayY_GPU, sizeof(double)*Nparticles));
	check_error(hipMalloc((void **) &xj_GPU, sizeof(double)*Nparticles));
	check_error(hipMalloc((void **) &yj_GPU, sizeof(double)*Nparticles));
	check_error(hipMalloc((void **) &CDF_GPU, sizeof(double)*Nparticles));
	check_error(hipMalloc((void **) &u_GPU, sizeof(double)*Nparticles));
	
	for(x = 0; x < Nparticles; x++){
		arrayX[x] = xe;
		arrayY[x] = ye;
	}
	int k;
	//double * Ik = (double *)malloc(sizeof(double)*IszX*IszY);
	int indX, indY;
	for(k = 1; k < Nfr; k++){
		long long set_arrays = get_time();
		//printf("TIME TO SET ARRAYS TOOK: %f\n", elapsed_time(get_weights, set_arrays));
		//apply motion model
		//draws sample from motion model (random walk). The only prior information
		//is that the object moves 2x as fast as in the y direction
		
		for(x = 0; x < Nparticles; x++){
			arrayX[x] = arrayX[x] + 1.0 + 5.0*randn(seed, x);
			arrayY[x] = arrayY[x] - 2.0 + 2.0*randn(seed, x);
		}
		//particle filter likelihood
		long long error = get_time();
		printf("TIME TO SET ERROR TOOK: %f\n", elapsed_time(set_arrays, error));
		for(x = 0; x < Nparticles; x++){
		
			//compute the likelihood: remember our assumption is that you know
			// foreground and the background image intensity distribution.
			// Notice that we consider here a likelihood ratio, instead of
			// p(z|x). It is possible in this case. why? a hometask for you.		
			//calc ind
			for(y = 0; y < countOnes; y++){
				indX = roundDouble(arrayX[x]) + objxy[y*2 + 1];
				indY = roundDouble(arrayY[x]) + objxy[y*2];
				ind[y] = fabs(indX*IszY*Nfr + indY*Nfr + k);
				if(ind[y] >= max_size)
					ind[y] = 0;
			}
			likelihood[x] = calcLikelihoodSum(I, ind, countOnes);
			likelihood[x] = likelihood[x]/countOnes;
		}
		long long likelihood_time = get_time();
		printf("TIME TO GET LIKELIHOODS TOOK: %f\n", elapsed_time(error, likelihood_time));
		// update & normalize weights
		// using equation (63) of Arulampalam Tutorial		
		for(x = 0; x < Nparticles; x++){
			weights[x] = weights[x] * exp(likelihood[x]);
		}
		long long exponential = get_time();
		printf("TIME TO GET EXP TOOK: %f\n", elapsed_time(likelihood_time, exponential));
		double sumWeights = 0;	
		for(x = 0; x < Nparticles; x++){
			sumWeights += weights[x];
		}
		long long sum_time = get_time();
		printf("TIME TO SUM WEIGHTS TOOK: %f\n", elapsed_time(exponential, sum_time));
		for(x = 0; x < Nparticles; x++){
				weights[x] = weights[x]/sumWeights;
		}
		long long normalize = get_time();
		printf("TIME TO NORMALIZE WEIGHTS TOOK: %f\n", elapsed_time(sum_time, normalize));
		xe = 0;
		ye = 0;
		// estimate the object location by expected values
		for(x = 0; x < Nparticles; x++){
			xe += arrayX[x] * weights[x];
			ye += arrayY[x] * weights[x];
		}
		long long move_time = get_time();
		printf("TIME TO MOVE OBJECT TOOK: %f\n", elapsed_time(normalize, move_time));
		printf("XE: %lf\n", xe);
		printf("YE: %lf\n", ye);
		double distance = sqrt( pow((double)(xe-(int)roundDouble(IszY/2.0)),2) + pow((double)(ye-(int)roundDouble(IszX/2.0)),2) );
		printf("%lf\n", distance);
		//display(hold off for now)
		
		//pause(hold off for now)
		
		//resampling
		
		
		CDF[0] = weights[0];
		for(x = 1; x < Nparticles; x++){
			CDF[x] = weights[x] + CDF[x-1];
		}
		long long cum_sum = get_time();
		printf("TIME TO CALC CUM SUM TOOK: %f\n", elapsed_time(move_time, cum_sum));
		double u1 = (1/((double)(Nparticles)))*randu(seed, 0);
		for(x = 0; x < Nparticles; x++){
			u[x] = u1 + x/((double)(Nparticles));
		}
		long long u_time = get_time();
		printf("TIME TO CALC U TOOK: %f\n", elapsed_time(cum_sum, u_time));
		long long start_copy = get_time();
		//CUDA memory copying from CPU memory to GPU memory
		hipMemcpy(arrayX_GPU, arrayX, sizeof(double)*Nparticles, hipMemcpyHostToDevice);
		hipMemcpy(arrayY_GPU, arrayY, sizeof(double)*Nparticles, hipMemcpyHostToDevice);
		hipMemcpy(xj_GPU, xj, sizeof(double)*Nparticles, hipMemcpyHostToDevice);
		hipMemcpy(yj_GPU, yj, sizeof(double)*Nparticles, hipMemcpyHostToDevice);
		hipMemcpy(CDF_GPU, CDF, sizeof(double)*Nparticles, hipMemcpyHostToDevice);
		hipMemcpy(u_GPU, u, sizeof(double)*Nparticles, hipMemcpyHostToDevice);
		long long end_copy = get_time();
		//Set number of threads
		int num_blocks = ceil((double) Nparticles/(double) threads_per_block);
		
		//KERNEL FUNCTION CALL
		kernel <<< num_blocks, threads_per_block >>> (arrayX_GPU, arrayY_GPU, CDF_GPU, u_GPU, xj_GPU, yj_GPU, Nparticles);
                hipDeviceSynchronize();
                long long start_copy_back = get_time();
		//CUDA memory copying back from GPU to CPU memory
		hipMemcpy(yj, yj_GPU, sizeof(double)*Nparticles, hipMemcpyDeviceToHost);
		hipMemcpy(xj, xj_GPU, sizeof(double)*Nparticles, hipMemcpyDeviceToHost);
		long long end_copy_back = get_time();
		printf("SENDING TO GPU TOOK: %lf\n", elapsed_time(start_copy, end_copy));
		printf("CUDA EXEC TOOK: %lf\n", elapsed_time(end_copy, start_copy_back));
		printf("SENDING BACK FROM GPU TOOK: %lf\n", elapsed_time(start_copy_back, end_copy_back));
		long long xyj_time = get_time();
		printf("TIME TO CALC NEW ARRAY X AND Y TOOK: %f\n", elapsed_time(u_time, xyj_time));
		
		for(x = 0; x < Nparticles; x++){
			//reassign arrayX and arrayY
			arrayX[x] = xj[x];
			arrayY[x] = yj[x];
			weights[x] = 1/((double)(Nparticles));
		}
		long long reset = get_time();
		printf("TIME TO RESET WEIGHTS TOOK: %f\n", elapsed_time(xyj_time, reset));
	}
	
	//CUDA freeing of memory
	hipFree(u_GPU);
	hipFree(CDF_GPU);
	hipFree(yj_GPU);
	hipFree(xj_GPU);
	hipFree(arrayY_GPU);
	hipFree(arrayX_GPU);
	
	//free memory
	free(disk);
	free(objxy);
	free(weights);
	free(likelihood);
	free(arrayX);
	free(arrayY);
	free(xj);
	free(yj);
	free(CDF);
	free(u);
	free(ind);
}
int main(int argc, char * argv[]){
	
	char* usage = "naive.out -x <dimX> -y <dimY> -z <Nfr> -np <Nparticles>";
	//check number of arguments
	if(argc != 9)
	{
		printf("%s\n", usage);
		return 0;
	}
	//check args deliminators
	if( strcmp( argv[1], "-x" ) ||  strcmp( argv[3], "-y" ) || strcmp( argv[5], "-z" ) || strcmp( argv[7], "-np" ) ) {
		printf( "%s\n",usage );
		return 0;
	}
	
	int IszX, IszY, Nfr, Nparticles;
	
	//converting a string to a integer
	if( sscanf( argv[2], "%d", &IszX ) == EOF ) {
	   printf("ERROR: dimX input is incorrect");
	   return 0;
	}
	
	if( IszX <= 0 ) {
		printf("dimX must be > 0\n");
		return 0;
	}
	
	//converting a string to a integer
	if( sscanf( argv[4], "%d", &IszY ) == EOF ) {
	   printf("ERROR: dimY input is incorrect");
	   return 0;
	}
	
	if( IszY <= 0 ) {
		printf("dimY must be > 0\n");
		return 0;
	}
	
	//converting a string to a integer
	if( sscanf( argv[6], "%d", &Nfr ) == EOF ) {
	   printf("ERROR: Number of frames input is incorrect");
	   return 0;
	}
	
	if( Nfr <= 0 ) {
		printf("number of frames must be > 0\n");
		return 0;
	}
	
	//converting a string to a integer
	if( sscanf( argv[8], "%d", &Nparticles ) == EOF ) {
	   printf("ERROR: Number of particles input is incorrect");
	   return 0;
	}
	
	if( Nparticles <= 0 ) {
		printf("Number of particles must be > 0\n");
		return 0;
	}
	//establish seed
	int * seed = (int *)malloc(sizeof(int)*Nparticles);
	int i;
	for(i = 0; i < Nparticles; i++)
		seed[i] = time(0)*i;
	//malloc matrix
	int * I = (int *)malloc(sizeof(int)*IszX*IszY*Nfr);
	long long start = get_time();
	//call video sequence
	videoSequence(I, IszX, IszY, Nfr, seed);
	long long endVideoSequence = get_time();
	printf("VIDEO SEQUENCE TOOK %f\n", elapsed_time(start, endVideoSequence));
	//call particle filter
	particleFilter(I, IszX, IszY, Nfr, seed, Nparticles);
	long long endParticleFilter = get_time();
	printf("PARTICLE FILTER TOOK %f\n", elapsed_time(endVideoSequence, endParticleFilter));
	printf("ENTIRE PROGRAM TOOK %f\n", elapsed_time(start, endParticleFilter));
	
	free(seed);
	free(I);
	return 0;
}

	.text
	.file	"ex_particle_CUDA_naive_seq.hip"
	.globl	_Z8get_timev                    # -- Begin function _Z8get_timev
	.type	_Z8get_timev,@function
_Z8get_timev:                           # @_Z8get_timev
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%rbx), %rax          # imm = 0xF4240
	addq	8(%rbx), %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z8get_timev, .Lfunc_end0-_Z8get_timev
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z12elapsed_timexx
.LCPI1_0:
	.long	0x49742400                      # float 1.0E+6
	.text
	.globl	_Z12elapsed_timexx
	.type	_Z12elapsed_timexx,@function
_Z12elapsed_timexx:                     # @_Z12elapsed_timexx
	.cfi_startproc
# %bb.0:
	subq	%rdi, %rsi
	cvtsi2ss	%rsi, %xmm0
	divss	.LCPI1_0(%rip), %xmm0
	retq
.Lfunc_end1:
	.size	_Z12elapsed_timexx, .Lfunc_end1-_Z12elapsed_timexx
	.cfi_endproc
                                        # -- End function
	.globl	_Z11check_error10hipError_t     # -- Begin function _Z11check_error10hipError_t
	.type	_Z11check_error10hipError_t,@function
_Z11check_error10hipError_t:            # @_Z11check_error10hipError_t
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB2_2
# %bb.1:
	retq
.LBB2_2:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end2:
	.size	_Z11check_error10hipError_t, .Lfunc_end2-_Z11check_error10hipError_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__kernelPdS_S_S_S_S_i # -- Begin function _Z21__device_stub__kernelPdS_S_S_S_S_i
	.type	_Z21__device_stub__kernelPdS_S_S_S_S_i,@function
_Z21__device_stub__kernelPdS_S_S_S_S_i: # @_Z21__device_stub__kernelPdS_S_S_S_S_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	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	$_Z6kernelPdS_S_S_S_S_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_end3:
	.size	_Z21__device_stub__kernelPdS_S_S_S_S_i, .Lfunc_end3-_Z21__device_stub__kernelPdS_S_S_S_S_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z11roundDoubled                # -- Begin function _Z11roundDoubled
	.type	_Z11roundDoubled,@function
_Z11roundDoubled:                       # @_Z11roundDoubled
	.cfi_startproc
# %bb.0:
	cvttpd2dq	%xmm0, %xmm0
	cvtdq2pd	%xmm0, %xmm0
	retq
.Lfunc_end4:
	.size	_Z11roundDoubled, .Lfunc_end4-_Z11roundDoubled
	.cfi_endproc
                                        # -- End function
	.globl	_Z5setIfiiPiS_S_S_              # -- Begin function _Z5setIfiiPiS_S_S_
	.type	_Z5setIfiiPiS_S_S_,@function
_Z5setIfiiPiS_S_S_:                     # @_Z5setIfiiPiS_S_S_
	.cfi_startproc
# %bb.0:
	movl	(%rcx), %r10d
	testl	%r10d, %r10d
	jle	.LBB5_14
# %bb.1:                                # %.preheader27.preheader
	pushq	%rbp
	.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 %rbp, -16
	movl	(%r8), %r11d
	xorl	%eax, %eax
.LBB5_2:                                # %.preheader27
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
                                        #       Child Loop BB5_6 Depth 3
	testl	%r11d, %r11d
	jle	.LBB5_12
# %bb.3:                                # %.preheader.preheader
                                        #   in Loop: Header=BB5_2 Depth=1
	movl	(%r9), %ebx
	xorl	%r10d, %r10d
.LBB5_4:                                # %.preheader
                                        #   Parent Loop BB5_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB5_6 Depth 3
	testl	%ebx, %ebx
	jle	.LBB5_10
# %bb.5:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB5_4 Depth=2
	xorl	%r11d, %r11d
.LBB5_6:                                # %.lr.ph
                                        #   Parent Loop BB5_2 Depth=1
                                        #     Parent Loop BB5_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%r8), %ebp
	imull	%eax, %ebp
	addl	%r10d, %ebp
	imull	%ebx, %ebp
	movslq	%ebp, %r14
	addq	%r11, %r14
	cmpl	%edi, (%rdx,%r14,4)
	jne	.LBB5_8
# %bb.7:                                #   in Loop: Header=BB5_6 Depth=3
	movl	%esi, (%rdx,%r14,4)
	movl	(%r9), %ebx
.LBB5_8:                                #   in Loop: Header=BB5_6 Depth=3
	incq	%r11
	cmpl	%ebx, %r11d
	jl	.LBB5_6
# %bb.9:                                # %._crit_edge.loopexit
                                        #   in Loop: Header=BB5_4 Depth=2
	movl	(%r8), %r11d
.LBB5_10:                               # %._crit_edge
                                        #   in Loop: Header=BB5_4 Depth=2
	incl	%r10d
	cmpl	%r11d, %r10d
	jl	.LBB5_4
# %bb.11:                               # %._crit_edge30.loopexit
                                        #   in Loop: Header=BB5_2 Depth=1
	movl	(%rcx), %r10d
.LBB5_12:                               # %._crit_edge30
                                        #   in Loop: Header=BB5_2 Depth=1
	incl	%eax
	cmpl	%r10d, %eax
	jl	.LBB5_2
# %bb.13:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %rbp
.LBB5_14:                               # %._crit_edge32
	retq
.Lfunc_end5:
	.size	_Z5setIfiiPiS_S_S_, .Lfunc_end5-_Z5setIfiiPiS_S_S_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z5randuPii
.LCPI6_0:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.text
	.globl	_Z5randuPii
	.type	_Z5randuPii,@function
_Z5randuPii:                            # @_Z5randuPii
	.cfi_startproc
# %bb.0:
	movslq	A(%rip), %rax
	movslq	%esi, %rcx
	movslq	(%rdi,%rcx,4), %rdx
	imulq	%rax, %rdx
	movslq	C(%rip), %rax
	addq	%rdx, %rax
	movq	M(%rip), %rsi
	cqto
	idivq	%rsi
	movl	%edx, (%rdi,%rcx,4)
	cvtsi2sd	%edx, %xmm0
	cvtsi2sd	%rsi, %xmm1
	divsd	%xmm1, %xmm0
	andpd	.LCPI6_0(%rip), %xmm0
	retq
.Lfunc_end6:
	.size	_Z5randuPii, .Lfunc_end6-_Z5randuPii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z5randnPii
.LCPI7_0:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI7_1:
	.quad	0x401921fb54442d18              # double 6.2831853071795862
.LCPI7_2:
	.quad	0xc000000000000000              # double -2
	.text
	.globl	_Z5randnPii
	.type	_Z5randnPii,@function
_Z5randnPii:                            # @_Z5randnPii
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movslq	A(%rip), %rax
	movslq	%esi, %rcx
	movslq	(%rdi,%rcx,4), %rdx
	imulq	%rax, %rdx
	movslq	C(%rip), %rax
	addq	%rdx, %rax
	movq	M(%rip), %rsi
	cqto
	idivq	%rsi
	cvtsi2sd	%edx, %xmm0
	cvtsi2sd	%rsi, %xmm1
	movl	%edx, (%rdi,%rcx,4)
	divsd	%xmm1, %xmm0
	movapd	.LCPI7_0(%rip), %xmm2           # xmm2 = [NaN,NaN]
	andpd	%xmm2, %xmm0
	movapd	%xmm0, 16(%rsp)                 # 16-byte Spill
	movslq	A(%rip), %rax
	movslq	%edx, %rdx
	imulq	%rax, %rdx
	movslq	C(%rip), %rax
	addq	%rdx, %rax
	cqto
	idivq	%rsi
	movl	%edx, (%rdi,%rcx,4)
	xorps	%xmm0, %xmm0
	cvtsi2sd	%edx, %xmm0
	divsd	%xmm1, %xmm0
	andpd	%xmm2, %xmm0
	mulsd	.LCPI7_1(%rip), %xmm0
	callq	cos
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movapd	16(%rsp), %xmm0                 # 16-byte Reload
	callq	log
	mulsd	.LCPI7_2(%rip), %xmm0
	xorpd	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	jb	.LBB7_2
# %bb.1:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB7_3
.LBB7_2:                                # %call.sqrt
	callq	sqrt
.LBB7_3:                                # %.split
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	mulsd	%xmm0, %xmm1
	movapd	%xmm1, %xmm0
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	_Z5randnPii, .Lfunc_end7-_Z5randnPii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z8addNoisePiS_S_S_S_
.LCPI8_0:
	.quad	0x4014000000000000              # double 5
	.text
	.globl	_Z8addNoisePiS_S_S_S_
	.type	_Z8addNoisePiS_S_S_S_,@function
_Z8addNoisePiS_S_S_S_:                  # @_Z8addNoisePiS_S_S_S_
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.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, 8(%rsp)                   # 8-byte Spill
	movl	(%rsi), %esi
	testl	%esi, %esi
	jle	.LBB8_11
# %bb.1:                                # %.preheader26.preheader
	movq	%r8, %r13
	movq	%rcx, %r15
	movq	%rdx, %rbp
	movl	(%rdx), %eax
	xorl	%r14d, %r14d
	movq	%rdi, 16(%rsp)                  # 8-byte Spill
.LBB8_2:                                # %.preheader26
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_4 Depth 2
                                        #       Child Loop BB8_6 Depth 3
	testl	%eax, %eax
	jle	.LBB8_10
# %bb.3:                                # %.preheader.preheader
                                        #   in Loop: Header=BB8_2 Depth=1
	movl	(%r15), %esi
	xorl	%r12d, %r12d
.LBB8_4:                                # %.preheader
                                        #   Parent Loop BB8_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB8_6 Depth 3
	testl	%esi, %esi
	jle	.LBB8_8
# %bb.5:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB8_4 Depth=2
	xorl	%ebx, %ebx
.LBB8_6:                                # %.lr.ph
                                        #   Parent Loop BB8_2 Depth=1
                                        #     Parent Loop BB8_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%rbp), %eax
	imull	%r14d, %eax
	addl	%r12d, %eax
	imull	%esi, %eax
	cltq
	addq	%rbx, %rax
	movl	(%rdi,%rax,4), %eax
	movl	%eax, 4(%rsp)                   # 4-byte Spill
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	_Z5randnPii
	movsd	.LCPI8_0(%rip), %xmm1           # xmm1 = mem[0],zero
	movq	16(%rsp), %rdi                  # 8-byte Reload
	mulsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %eax
	addl	4(%rsp), %eax                   # 4-byte Folded Reload
	movl	(%rbp), %esi
	imull	%r14d, %esi
	addl	%r12d, %esi
	imull	(%r15), %esi
	movslq	%esi, %rsi
	addq	%rbx, %rsi
	movl	%eax, (%rdi,%rsi,4)
	movl	(%r15), %esi
	incq	%rbx
	cmpl	%esi, %ebx
	jl	.LBB8_6
# %bb.7:                                # %._crit_edge.loopexit
                                        #   in Loop: Header=BB8_4 Depth=2
	movl	(%rbp), %eax
.LBB8_8:                                # %._crit_edge
                                        #   in Loop: Header=BB8_4 Depth=2
	incl	%r12d
	cmpl	%eax, %r12d
	jl	.LBB8_4
# %bb.9:                                # %._crit_edge29.loopexit
                                        #   in Loop: Header=BB8_2 Depth=1
	movq	8(%rsp), %rsi                   # 8-byte Reload
	movl	(%rsi), %esi
.LBB8_10:                               # %._crit_edge29
                                        #   in Loop: Header=BB8_2 Depth=1
	incl	%r14d
	cmpl	%esi, %r14d
	jl	.LBB8_2
.LBB8_11:                               # %._crit_edge31
	addq	$24, %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_end8:
	.size	_Z8addNoisePiS_S_S_S_, .Lfunc_end8-_Z8addNoisePiS_S_S_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z9strelDiskPii                 # -- Begin function _Z9strelDiskPii
	.type	_Z9strelDiskPii,@function
_Z9strelDiskPii:                        # @_Z9strelDiskPii
	.cfi_startproc
# %bb.0:
                                        # kill: def $esi killed $esi def $rsi
	testl	%esi, %esi
	jle	.LBB9_7
# %bb.1:                                # %.preheader.lr.ph
	leal	-1(,%rsi,2), %eax
	cvtsi2sd	%esi, %xmm0
	cmpl	$2, %eax
	movl	$1, %ecx
	cmovll	%ecx, %eax
	leal	-2(,%rsi,2), %edx
	movslq	%edx, %rdx
	leaq	4(,%rdx,4), %rdx
	subl	%esi, %ecx
	xorl	%r8d, %r8d
.LBB9_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_3 Depth 2
	movl	%r8d, %r9d
	subl	%esi, %r9d
	incl	%r9d
	xorps	%xmm1, %xmm1
	cvtsi2sd	%r9d, %xmm1
	mulsd	%xmm1, %xmm1
	xorl	%r9d, %r9d
.LBB9_3:                                #   Parent Loop BB9_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rcx,%r9), %r10d
	xorps	%xmm2, %xmm2
	cvtsi2sd	%r10d, %xmm2
	mulsd	%xmm2, %xmm2
	addsd	%xmm1, %xmm2
	sqrtsd	%xmm2, %xmm2
	ucomisd	%xmm2, %xmm0
	jbe	.LBB9_5
# %bb.4:                                #   in Loop: Header=BB9_3 Depth=2
	movl	$1, (%rdi,%r9,4)
.LBB9_5:                                #   in Loop: Header=BB9_3 Depth=2
	incq	%r9
	cmpq	%r9, %rax
	jne	.LBB9_3
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB9_2 Depth=1
	incq	%r8
	addq	%rdx, %rdi
	cmpq	%rax, %r8
	jne	.LBB9_2
.LBB9_7:                                # %._crit_edge21
	retq
.Lfunc_end9:
	.size	_Z9strelDiskPii, .Lfunc_end9-_Z9strelDiskPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z13dilate_matrixPiiiiiiii      # -- Begin function _Z13dilate_matrixPiiiiiiii
	.type	_Z13dilate_matrixPiiiiiiii,@function
_Z13dilate_matrixPiiiiiiii:             # @_Z13dilate_matrixPiiiiiiii
	.cfi_startproc
# %bb.0:                                # %.preheader45
	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
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
                                        # kill: def $edx killed $edx def $rdx
                                        # kill: def $esi killed $esi def $rsi
	movl	64(%rsp), %r14d
	movl	%esi, %eax
	subl	%r14d, %eax
	xorl	%r10d, %r10d
	testl	%eax, %eax
	cmovlel	%r10d, %eax
	leal	(%r14,%rsi), %r11d
	cmpl	%r11d, %r8d
	cmovll	%r8d, %r11d
	cmpl	%r11d, %eax
	jge	.LBB10_8
# %bb.1:                                # %.preheader.lr.ph
	movl	56(%rsp), %r8d
	leal	(%r14,%rdx), %ebx
	cmpl	%ebx, %r9d
	cmovll	%r9d, %ebx
	movl	%edx, %ebp
	subl	%r14d, %ebp
	testl	%ebp, %ebp
	cmovgl	%ebp, %r10d
	cvtsi2sd	%r14d, %xmm0
	movq	%rbx, %r14
	subq	%r10, %r14
	movl	%r10d, %ebp
	subl	%edx, %ebp
	movl	%r8d, %edx
	imull	%r9d, %edx
	imull	%eax, %r9d
	addl	%r10d, %r9d
	imull	%r8d, %r9d
	addl	%r9d, %ecx
.LBB10_2:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_4 Depth 2
	cmpl	%ebx, %r10d
	jge	.LBB10_7
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB10_2 Depth=1
	movl	%eax, %r9d
	subl	%esi, %r9d
	xorps	%xmm1, %xmm1
	cvtsi2sd	%r9d, %xmm1
	mulsd	%xmm1, %xmm1
	movq	%r14, %r9
	movl	%ecx, %r15d
	movl	%ebp, %r12d
.LBB10_4:                               #   Parent Loop BB10_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm2, %xmm2
	cvtsi2sd	%r12d, %xmm2
	mulsd	%xmm2, %xmm2
	addsd	%xmm1, %xmm2
	sqrtsd	%xmm2, %xmm2
	ucomisd	%xmm2, %xmm0
	jbe	.LBB10_6
# %bb.5:                                #   in Loop: Header=BB10_4 Depth=2
	movslq	%r15d, %r13
	movl	$1, (%rdi,%r13,4)
.LBB10_6:                               #   in Loop: Header=BB10_4 Depth=2
	incl	%r12d
	addl	%r8d, %r15d
	decq	%r9
	jne	.LBB10_4
.LBB10_7:                               # %._crit_edge
                                        #   in Loop: Header=BB10_2 Depth=1
	incl	%eax
	addl	%edx, %ecx
	cmpl	%r11d, %eax
	jne	.LBB10_2
.LBB10_8:                               # %._crit_edge48
	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_end10:
	.size	_Z13dilate_matrixPiiiiiiii, .Lfunc_end10-_Z13dilate_matrixPiiiiiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z13imdilate_diskPiiiiiS_       # -- Begin function _Z13imdilate_diskPiiiiiS_
	.type	_Z13imdilate_diskPiiiiiS_,@function
_Z13imdilate_diskPiiiiiS_:              # @_Z13imdilate_diskPiiiiiS_
	.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
	movq	%r9, 48(%rsp)                   # 8-byte Spill
                                        # kill: def $r8d killed $r8d def $r8
	movq	%r8, 40(%rsp)                   # 8-byte Spill
	movl	%edx, 12(%rsp)                  # 4-byte Spill
	movl	%esi, 8(%rsp)                   # 4-byte Spill
	testl	%ecx, %ecx
	jle	.LBB11_11
# %bb.1:                                # %.preheader28.lr.ph
	movl	%ecx, %r15d
	movq	%rdi, %r13
	movl	12(%rsp), %eax                  # 4-byte Reload
	movl	%eax, %ebp
	movl	8(%rsp), %ecx                   # 4-byte Reload
	movq	%rcx, 32(%rsp)                  # 8-byte Spill
	movl	%r15d, %ecx
	imull	%eax, %ecx
	movl	%ecx, 28(%rsp)                  # 4-byte Spill
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
.LBB11_2:                               # %.preheader28
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB11_4 Depth 2
                                        #       Child Loop BB11_6 Depth 3
	cmpl	$0, 8(%rsp)                     # 4-byte Folded Reload
	jle	.LBB11_10
# %bb.3:                                # %.preheader.preheader
                                        #   in Loop: Header=BB11_2 Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
                                        # kill: def $eax killed $eax killed $rax
	movl	%eax, 4(%rsp)                   # 4-byte Spill
	xorl	%r14d, %r14d
.LBB11_4:                               # %.preheader
                                        #   Parent Loop BB11_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB11_6 Depth 3
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	jle	.LBB11_9
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB11_4 Depth=2
	movl	4(%rsp), %ebx                   # 4-byte Reload
	xorl	%r12d, %r12d
.LBB11_6:                               #   Parent Loop BB11_2 Depth=1
                                        #     Parent Loop BB11_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movslq	%ebx, %rax
	cmpl	$1, (%r13,%rax,4)
	jne	.LBB11_8
# %bb.7:                                #   in Loop: Header=BB11_6 Depth=3
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movl	%r14d, %esi
	movl	%r12d, %edx
	movq	16(%rsp), %rcx                  # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	movl	8(%rsp), %r8d                   # 4-byte Reload
	movl	%ebp, %r9d
	pushq	40(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	callq	_Z13dilate_matrixPiiiiiiii
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB11_8:                               #   in Loop: Header=BB11_6 Depth=3
	incq	%r12
	addl	%r15d, %ebx
	cmpq	%r12, %rbp
	jne	.LBB11_6
.LBB11_9:                               # %._crit_edge
                                        #   in Loop: Header=BB11_4 Depth=2
	incq	%r14
	movl	4(%rsp), %eax                   # 4-byte Reload
	addl	28(%rsp), %eax                  # 4-byte Folded Reload
	movl	%eax, 4(%rsp)                   # 4-byte Spill
	cmpq	32(%rsp), %r14                  # 8-byte Folded Reload
	jne	.LBB11_4
.LBB11_10:                              # %._crit_edge31
                                        #   in Loop: Header=BB11_2 Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
	incl	%eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	cmpl	%r15d, %eax
	jne	.LBB11_2
.LBB11_11:                              # %._crit_edge33
	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_end11:
	.size	_Z13imdilate_diskPiiiiiS_, .Lfunc_end11-_Z13imdilate_diskPiiiiiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z12getneighborsPiiPdi          # -- Begin function _Z12getneighborsPiiPdi
	.type	_Z12getneighborsPiiPdi,@function
_Z12getneighborsPiiPdi:                 # @_Z12getneighborsPiiPdi
	.cfi_startproc
# %bb.0:
                                        # kill: def $ecx killed $ecx def $rcx
	testl	%ecx, %ecx
	jle	.LBB12_8
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	leal	-1(,%rcx,2), %eax
	leal	-1(%rcx), %esi
	cmpl	$2, %eax
	movl	$1, %r8d
	cmovll	%r8d, %eax
	leal	-2(,%rcx,2), %r9d
	movslq	%r9d, %r9
	leaq	4(,%r9,4), %r9
	subl	%ecx, %r8d
	xorl	%ecx, %ecx
	xorl	%r10d, %r10d
.LBB12_2:                               # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB12_3 Depth 2
	movl	%ecx, %r11d
	subl	%esi, %r11d
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r11d, %xmm0
	xorl	%r11d, %r11d
.LBB12_3:                               #   Parent Loop BB12_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpl	$0, (%rdi,%r11,4)
	je	.LBB12_5
# %bb.4:                                #   in Loop: Header=BB12_3 Depth=2
	leal	(%r8,%r11), %ebx
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ebx, %xmm1
	leal	(%r10,%r10), %ebx
	movslq	%ebx, %rbx
	movsd	%xmm1, (%rdx,%rbx,8)
	leal	1(,%r10,2), %ebx
	movslq	%ebx, %rbx
	movsd	%xmm0, (%rdx,%rbx,8)
	incl	%r10d
.LBB12_5:                               #   in Loop: Header=BB12_3 Depth=2
	incq	%r11
	cmpq	%r11, %rax
	jne	.LBB12_3
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB12_2 Depth=1
	incq	%rcx
	addq	%r9, %rdi
	cmpq	%rax, %rcx
	jne	.LBB12_2
# %bb.7:
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
.LBB12_8:                               # %._crit_edge27
	retq
.Lfunc_end12:
	.size	_Z12getneighborsPiiPdi, .Lfunc_end12-_Z12getneighborsPiiPdi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z13videoSequencePiiiiS_
.LCPI13_0:
	.quad	0x3fe0000000000000              # double 0.5
	.text
	.globl	_Z13videoSequencePiiiiS_
	.type	_Z13videoSequencePiiiiS_,@function
_Z13videoSequencePiiiiS_:               # @_Z13videoSequencePiiiiS_
	.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
	movq	%r8, 40(%rsp)                   # 8-byte Spill
	movl	%ecx, %r15d
	movl	%edx, %ebp
	movq	%rdi, %r14
	movl	%esi, 36(%rsp)
	cvtsi2sd	%edx, %xmm0
	movsd	.LCPI13_0(%rip), %xmm1          # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %eax
	movl	%esi, 8(%rsp)                   # 4-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sd	%esi, %xmm0
	movl	%edx, 32(%rsp)
	mulsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %ecx
	movl	%r15d, 28(%rsp)
	movl	%eax, %edx
	imull	%ebp, %edx
	addl	%ecx, %edx
	imull	%r15d, %edx
	movslq	%edx, %rdx
	movl	$1, (%rdi,%rdx,4)
	cmpl	$2, %r15d
	jl	.LBB13_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %edx
	imull	8(%rsp), %edx                   # 4-byte Folded Reload
	imull	%r15d, %edx
	leal	-1(%r15), %esi
	movl	%eax, %edi
	negl	%edi
	movl	%ecx, %r8d
	negl	%r8d
	movl	$1, %r9d
	xorl	%r10d, %r10d
.LBB13_2:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	cmpl	%edi, %eax
	movl	%edi, %r11d
	cmovgl	%eax, %r11d
	cmpl	%r8d, %ecx
	movl	%r8d, %ebx
	cmovgl	%ecx, %ebx
	imull	%ebp, %ebx
	addl	%r11d, %ebx
	imull	%r15d, %ebx
	addl	%r9d, %ebx
	cmpl	%edx, %ebx
	cmovgel	%r10d, %ebx
	movslq	%ebx, %r11
	movl	$1, (%r14,%r11,4)
	incl	%r9d
	incl	%eax
	decl	%edi
	addl	$-2, %ecx
	addl	$2, %r8d
	decl	%esi
	jne	.LBB13_2
.LBB13_3:                               # %._crit_edge
	movl	8(%rsp), %ebx                   # 4-byte Reload
	movslq	%ebx, %rax
	movslq	%ebp, %rcx
	imulq	%rax, %rcx
	movslq	%r15d, %rdi
	imulq	%rcx, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %r13
	movq	%r14, %r12
	movq	%r14, %rdi
	movl	%ebx, %esi
	movl	%ebp, %edx
	movl	%r15d, %ecx
	movl	$5, %r8d
	movq	%rax, %r9
	callq	_Z13imdilate_diskPiiiiiS_
	testl	%ebx, %ebx
	jle	.LBB13_11
# %bb.4:                                # %.preheader41.lr.ph
	movl	%r15d, %eax
	imull	%ebp, %eax
	movl	%eax, 16(%rsp)                  # 4-byte Spill
	movl	%r15d, %ebx
	shlq	$2, %rbx
	movl	%ebp, %eax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movl	$0, 12(%rsp)                    # 4-byte Folded Spill
	xorl	%ecx, %ecx
	movl	%ebp, 20(%rsp)                  # 4-byte Spill
.LBB13_5:                               # %.preheader41
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB13_7 Depth 2
	movl	%ecx, 24(%rsp)                  # 4-byte Spill
	testl	%ebp, %ebp
	jle	.LBB13_10
# %bb.6:                                # %.preheader.preheader
                                        #   in Loop: Header=BB13_5 Depth=1
	movq	48(%rsp), %r14                  # 8-byte Reload
	movl	12(%rsp), %ebp                  # 4-byte Reload
.LBB13_7:                               # %.preheader
                                        #   Parent Loop BB13_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	testl	%r15d, %r15d
	jle	.LBB13_9
# %bb.8:                                # %.lr.ph44
                                        #   in Loop: Header=BB13_7 Depth=2
	movslq	%ebp, %rax
	leaq	(,%rax,4), %rsi
	addq	%r13, %rsi
	leaq	(%r12,%rax,4), %rdi
	movq	%rbx, %rdx
	callq	memcpy@PLT
.LBB13_9:                               # %._crit_edge45
                                        #   in Loop: Header=BB13_7 Depth=2
	addl	%r15d, %ebp
	decq	%r14
	jne	.LBB13_7
.LBB13_10:                              # %._crit_edge47
                                        #   in Loop: Header=BB13_5 Depth=1
	movl	24(%rsp), %ecx                  # 4-byte Reload
	incl	%ecx
	movl	12(%rsp), %eax                  # 4-byte Reload
	addl	16(%rsp), %eax                  # 4-byte Folded Reload
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	cmpl	8(%rsp), %ecx                   # 4-byte Folded Reload
	movl	20(%rsp), %ebp                  # 4-byte Reload
	jne	.LBB13_5
.LBB13_11:                              # %._crit_edge49
	movq	%r13, %rdi
	callq	free
	leaq	36(%rsp), %rbx
	leaq	32(%rsp), %r15
	leaq	28(%rsp), %r13
	xorl	%edi, %edi
	movl	$100, %esi
	movq	%r12, %rdx
	movq	%rbx, %rcx
	movq	%r15, %r8
	movq	%r13, %r9
	callq	_Z5setIfiiPiS_S_S_
	movl	$1, %edi
	movl	$228, %esi
	movq	%r12, %rdx
	movq	%rbx, %rcx
	movq	%r15, %r8
	movq	%r13, %r9
	callq	_Z5setIfiiPiS_S_S_
	movq	%r12, %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	movq	%r13, %rcx
	movq	40(%rsp), %r8                   # 8-byte Reload
	callq	_Z8addNoisePiS_S_S_S_
	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_end13:
	.size	_Z13videoSequencePiiiiS_, .Lfunc_end13-_Z13videoSequencePiiiiS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z17calcLikelihoodSumPiS_i
.LCPI14_0:
	.quad	0x4049000000000000              # double 50
	.text
	.globl	_Z17calcLikelihoodSumPiS_i
	.type	_Z17calcLikelihoodSumPiS_i,@function
_Z17calcLikelihoodSumPiS_i:             # @_Z17calcLikelihoodSumPiS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB14_1
# %bb.3:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorpd	%xmm0, %xmm0
	xorl	%ecx, %ecx
	movsd	.LCPI14_0(%rip), %xmm1          # xmm1 = mem[0],zero
.LBB14_4:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movslq	(%rsi,%rcx,4), %rdx
	movl	(%rdi,%rdx,4), %edx
	leal	-100(%rdx), %r8d
	xorps	%xmm2, %xmm2
	cvtsi2sd	%r8d, %xmm2
	addl	$-228, %edx
	mulsd	%xmm2, %xmm2
	xorps	%xmm3, %xmm3
	cvtsi2sd	%edx, %xmm3
	mulsd	%xmm3, %xmm3
	subsd	%xmm3, %xmm2
	divsd	%xmm1, %xmm2
	addsd	%xmm2, %xmm0
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB14_4
# %bb.2:                                # %._crit_edge
	retq
.LBB14_1:
	xorps	%xmm0, %xmm0
	retq
.Lfunc_end14:
	.size	_Z17calcLikelihoodSumPiS_i, .Lfunc_end14-_Z17calcLikelihoodSumPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z9findIndexPdid                # -- Begin function _Z9findIndexPdid
	.type	_Z9findIndexPdid,@function
_Z9findIndexPdid:                       # @_Z9findIndexPdid
	.cfi_startproc
# %bb.0:
	movl	%esi, %eax
	testl	%esi, %esi
	jle	.LBB15_4
# %bb.1:                                # %.lr.ph.preheader
	movl	%eax, %edx
	xorl	%ecx, %ecx
.LBB15_2:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%rdi,%rcx,8), %xmm1            # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	jae	.LBB15_5
# %bb.3:                                #   in Loop: Header=BB15_2 Depth=1
	incq	%rcx
	cmpq	%rcx, %rdx
	jne	.LBB15_2
.LBB15_4:                               # %._crit_edge
	decl	%eax
	retq
.LBB15_5:                               # %.loopexit.loopexit
	movl	%ecx, %eax
	retq
.Lfunc_end15:
	.size	_Z9findIndexPdid, .Lfunc_end15-_Z9findIndexPdid
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z14particleFilterPiiiiS_i
.LCPI16_0:
	.quad	0x3fe0000000000000              # double 0.5
.LCPI16_2:
	.quad	0x3ff0000000000000              # double 1
.LCPI16_3:
	.quad	0x3f80000000000000              # double 0.0078125
.LCPI16_4:
	.quad	0x4014000000000000              # double 5
.LCPI16_5:
	.quad	0xc000000000000000              # double -2
.LCPI16_7:
	.quad	0x4049000000000000              # double 50
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI16_1:
	.long	0x49742400                      # float 1.0E+6
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI16_6:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.text
	.globl	_Z14particleFilterPiiiiS_i
	.type	_Z14particleFilterPiiiiS_i,@function
_Z14particleFilterPiiiiS_i:             # @_Z14particleFilterPiiiiS_i
	.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	$328, %rsp                      # imm = 0x148
	.cfi_def_cfa_offset 384
	.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	%r9d, 12(%rsp)                  # 4-byte Spill
	movq	%r8, 248(%rsp)                  # 8-byte Spill
	movl	%ecx, 68(%rsp)                  # 4-byte Spill
	movl	%edx, %ebp
	movl	%esi, %ebx
	movq	%rdi, 296(%rsp)                 # 8-byte Spill
	movl	%edx, %eax
	imull	%esi, %eax
	movl	%eax, 64(%rsp)                  # 4-byte Spill
	xorl	%r15d, %r15d
	leaq	16(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r14), %r12
	movl	%ebp, 184(%rsp)                 # 4-byte Spill
	cvtsi2sd	%ebp, %xmm0
	movsd	.LCPI16_0(%rip), %xmm1          # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %r13d
	xorps	%xmm0, %xmm0
	cvtsi2sd	%ebx, %xmm0
	movq	8(%r14), %rbp
	mulsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %eax
	movl	%eax, 32(%rsp)                  # 4-byte Spill
	movl	$324, %edi                      # imm = 0x144
	callq	malloc
	movq	%rax, %r14
	movq	%rax, %rdi
	movl	$5, %esi
	callq	_Z9strelDiskPii
	movq	%r14, %rax
	xorl	%esi, %esi
.LBB16_1:                               # %.preheader280
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB16_2 Depth 2
	xorl	%ecx, %ecx
.LBB16_2:                               #   Parent Loop BB16_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorl	%edx, %edx
	cmpl	$1, (%rax,%rcx,4)
	sete	%dl
	addl	%edx, %esi
	incq	%rcx
	cmpq	$9, %rcx
	jne	.LBB16_2
# %bb.3:                                #   in Loop: Header=BB16_1 Depth=1
	incq	%r15
	addq	$36, %rax
	cmpq	$9, %r15
	jne	.LBB16_1
# %bb.4:
	movq	%rsi, 120(%rsp)                 # 8-byte Spill
	leal	(%rsi,%rsi), %eax
	movslq	%eax, %rdi
	shlq	$3, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r14, 256(%rsp)                 # 8-byte Spill
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$5, %ecx
	callq	_Z12getneighborsPiiPdi
	leaq	16(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r14), %r15          # imm = 0xF4240
	addq	8(%r14), %r15
	imulq	$-1000000, %r12, %rax           # imm = 0xFFF0BDC0
	subq	%rbp, %rax
	addq	%r15, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	movl	12(%rsp), %ebp                  # 4-byte Reload
	movslq	%ebp, %r14
	leaq	(,%r14,8), %rdi
	movq	%rdi, 232(%rsp)                 # 8-byte Spill
	callq	malloc
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ebp, %xmm1
	movl	%ebp, %edx
	testl	%r14d, %r14d
	jle	.LBB16_7
# %bb.5:                                # %.lr.ph
	movsd	.LCPI16_2(%rip), %xmm0          # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	xorl	%ecx, %ecx
.LBB16_6:                               # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, (%rax,%rcx,8)
	incq	%rcx
	cmpq	%rcx, %rdx
	jne	.LBB16_6
.LBB16_7:                               # %._crit_edge
	movsd	%xmm1, 200(%rsp)                # 8-byte Spill
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r13d, %xmm0
	movsd	%xmm0, 224(%rsp)                # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sdl	32(%rsp), %xmm0         # 4-byte Folded Reload
	movsd	%xmm0, 208(%rsp)                # 8-byte Spill
	leaq	16(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	movq	%rdx, 40(%rsp)                  # 8-byte Spill
	callq	gettimeofday
	imulq	$1000000, (%r14), %rax          # imm = 0xF4240
	movq	8(%r14), %rcx
	subq	%r15, %rcx
	addq	%rax, %rcx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movq	232(%rsp), %r15                 # 8-byte Reload
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, 144(%rsp)                 # 8-byte Spill
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r12
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %rbp
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r13
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, 128(%rsp)                 # 8-byte Spill
	movslq	120(%rsp), %rdi                 # 4-byte Folded Reload
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, 216(%rsp)                 # 8-byte Spill
	leaq	176(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z11check_error10hipError_t
	leaq	168(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z11check_error10hipError_t
	leaq	112(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z11check_error10hipError_t
	leaq	104(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z11check_error10hipError_t
	leaq	160(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z11check_error10hipError_t
	leaq	152(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z11check_error10hipError_t
	movsd	208(%rsp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movsd	224(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movq	40(%rsp), %rcx                  # 8-byte Reload
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	jle	.LBB16_10
# %bb.8:                                # %.lr.ph288.preheader
	xorl	%eax, %eax
.LBB16_9:                               # %.lr.ph288
                                        # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, (%r12,%rax,8)
	movsd	%xmm1, (%rbp,%rax,8)
	incq	%rax
	cmpq	%rax, %rcx
	jne	.LBB16_9
.LBB16_10:                              # %.preheader279
	movq	%rbp, 72(%rsp)                  # 8-byte Spill
	movq	%r12, 80(%rsp)                  # 8-byte Spill
	movl	68(%rsp), %ebp                  # 4-byte Reload
	cmpl	$2, %ebp
	jl	.LBB16_50
# %bb.11:                               # %.lr.ph332
	movl	64(%rsp), %eax                  # 4-byte Reload
	imull	%ebp, %eax
	movl	%eax, 64(%rsp)                  # 4-byte Spill
	movabsq	$4294967296, %rax               # imm = 0x100000000
	movq	%rax, 192(%rsp)                 # 8-byte Spill
	movq	120(%rsp), %rax                 # 8-byte Reload
	movl	%eax, %r15d
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	%xmm0, 288(%rsp)                # 8-byte Spill
	movsd	.LCPI16_2(%rip), %xmm0          # xmm0 = mem[0],zero
	movsd	200(%rsp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 240(%rsp)                # 8-byte Spill
	movsd	.LCPI16_3(%rip), %xmm0          # xmm0 = mem[0],zero
	mulsd	%xmm1, %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %eax
	btsq	$32, %rax
	movq	%rax, 280(%rsp)                 # 8-byte Spill
	movq	40(%rsp), %rax                  # 8-byte Reload
	leaq	(,%rax,8), %rax
	movq	%rax, 264(%rsp)                 # 8-byte Spill
	movq	%r15, 312(%rsp)                 # 8-byte Spill
	leaq	(,%r15,4), %rax
	movl	$1, %r12d
	leaq	16(%rsp), %r15
	subq	$-128, 192(%rsp)                # 8-byte Folded Spill
	movq	%r13, 136(%rsp)                 # 8-byte Spill
	movq	%rax, 320(%rsp)                 # 8-byte Spill
	movq	%r14, 272(%rsp)                 # 8-byte Spill
.LBB16_12:                              # =>This Loop Header: Depth=1
                                        #     Child Loop BB16_14 Depth 2
                                        #     Child Loop BB16_17 Depth 2
                                        #       Child Loop BB16_19 Depth 3
                                        #       Child Loop BB16_22 Depth 3
                                        #     Child Loop BB16_26 Depth 2
                                        #     Child Loop BB16_30 Depth 2
                                        #     Child Loop BB16_33 Depth 2
                                        #     Child Loop BB16_37 Depth 2
                                        #     Child Loop BB16_40 Depth 2
                                        #     Child Loop BB16_43 Depth 2
                                        #     Child Loop BB16_48 Depth 2
	movl	%r12d, 188(%rsp)                # 4-byte Spill
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	16(%rsp), %rax
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	24(%rsp), %rax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	movq	248(%rsp), %r14                 # 8-byte Reload
	movq	40(%rsp), %r12                  # 8-byte Reload
	movq	72(%rsp), %rax                  # 8-byte Reload
	movq	80(%rsp), %r15                  # 8-byte Reload
	movsd	.LCPI16_2(%rip), %xmm1          # xmm1 = mem[0],zero
	jle	.LBB16_15
# %bb.13:                               # %.lr.ph291.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	xorl	%ebp, %ebp
.LBB16_14:                              # %.lr.ph291
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r15,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	addsd	%xmm1, %xmm0
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movq	%r14, %rdi
	movl	%ebp, %esi
	movq	%r12, %r13
	movq	%rax, %r12
	callq	_Z5randnPii
	mulsd	.LCPI16_4(%rip), %xmm0
	addsd	32(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	%xmm0, (%r15,%rbp,8)
	movsd	(%r12,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	addsd	.LCPI16_5(%rip), %xmm0
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movq	%r14, %rdi
	movl	%ebp, %esi
	callq	_Z5randnPii
	movsd	.LCPI16_2(%rip), %xmm1          # xmm1 = mem[0],zero
	movq	%r12, %rax
	movq	%r13, %r12
	addsd	%xmm0, %xmm0
	addsd	32(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	%xmm0, (%rax,%rbp,8)
	incq	%rbp
	cmpq	%rbp, %r13
	jne	.LBB16_14
.LBB16_15:                              # %._crit_edge292
                                        #   in Loop: Header=BB16_12 Depth=1
	leaq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rcx        # imm = 0xF4240
	addq	24(%rsp), %rcx
	imulq	$-1000000, 88(%rsp), %rax       # 8-byte Folded Reload
                                        # imm = 0xFFF0BDC0
	subq	48(%rsp), %rax                  # 8-byte Folded Reload
	movq	%rcx, 32(%rsp)                  # 8-byte Spill
	addq	%rcx, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	movl	68(%rsp), %r13d                 # 4-byte Reload
	movl	184(%rsp), %edi                 # 4-byte Reload
	movq	296(%rsp), %r8                  # 8-byte Reload
	movl	64(%rsp), %r9d                  # 4-byte Reload
	movq	120(%rsp), %r10                 # 8-byte Reload
	movq	%r12, %r11
	movsd	288(%rsp), %xmm4                # 8-byte Reload
                                        # xmm4 = mem[0],zero
	movapd	.LCPI16_6(%rip), %xmm5          # xmm5 = [NaN,NaN]
	movsd	.LCPI16_7(%rip), %xmm6          # xmm6 = mem[0],zero
	movl	188(%rsp), %r12d                # 4-byte Reload
	movq	272(%rsp), %r14                 # 8-byte Reload
	jle	.LBB16_24
# %bb.16:                               # %.preheader.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	xorl	%eax, %eax
.LBB16_17:                              # %.preheader
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB16_19 Depth 3
                                        #       Child Loop BB16_22 Depth 3
	xorps	%xmm0, %xmm0
	testl	%r10d, %r10d
	movq	320(%rsp), %r15                 # 8-byte Reload
	jle	.LBB16_23
# %bb.18:                               # %.lr.ph294
                                        #   in Loop: Header=BB16_17 Depth=2
	movq	80(%rsp), %rcx                  # 8-byte Reload
	movsd	(%rcx,%rax,8), %xmm1            # xmm1 = mem[0],zero
	cvttpd2dq	%xmm1, %xmm1
	cvtdq2pd	%xmm1, %xmm1
	movq	72(%rsp), %rcx                  # 8-byte Reload
	movsd	(%rcx,%rax,8), %xmm2            # xmm2 = mem[0],zero
	cvttpd2dq	%xmm2, %xmm2
	cvtdq2pd	%xmm2, %xmm2
	xorl	%ecx, %ecx
	xorl	%ebp, %ebp
.LBB16_19:                              #   Parent Loop BB16_12 Depth=1
                                        #     Parent Loop BB16_17 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	8(%rbx,%rcx,4), %xmm3           # xmm3 = mem[0],zero
	addsd	%xmm1, %xmm3
	cvttsd2si	%xmm3, %edx
	movsd	(%rbx,%rcx,4), %xmm3            # xmm3 = mem[0],zero
	addsd	%xmm2, %xmm3
	cvttsd2si	%xmm3, %esi
	imull	%edi, %edx
	addl	%esi, %edx
	imull	%r13d, %edx
	addl	%r12d, %edx
	xorps	%xmm3, %xmm3
	cvtsi2sd	%edx, %xmm3
	andpd	%xmm5, %xmm3
	cvttsd2si	%xmm3, %edx
	cmpl	%edx, %r9d
	cmovlel	%ebp, %edx
	movl	%edx, (%r14,%rcx)
	addq	$4, %rcx
	cmpq	%rcx, %r15
	jne	.LBB16_19
# %bb.20:                               # %._crit_edge295
                                        #   in Loop: Header=BB16_17 Depth=2
	testl	%r10d, %r10d
	movq	312(%rsp), %r15                 # 8-byte Reload
	jle	.LBB16_23
# %bb.21:                               # %.lr.ph.i.preheader
                                        #   in Loop: Header=BB16_17 Depth=2
	xorps	%xmm0, %xmm0
	xorl	%ecx, %ecx
.LBB16_22:                              # %.lr.ph.i
                                        #   Parent Loop BB16_12 Depth=1
                                        #     Parent Loop BB16_17 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movslq	(%r14,%rcx,4), %rdx
	movl	(%r8,%rdx,4), %edx
	leal	-100(%rdx), %esi
	xorps	%xmm1, %xmm1
	cvtsi2sd	%esi, %xmm1
	addl	$-228, %edx
	mulsd	%xmm1, %xmm1
	xorps	%xmm2, %xmm2
	cvtsi2sd	%edx, %xmm2
	mulsd	%xmm2, %xmm2
	subsd	%xmm2, %xmm1
	divsd	%xmm6, %xmm1
	addsd	%xmm1, %xmm0
	incq	%rcx
	cmpq	%rcx, %r15
	jne	.LBB16_22
.LBB16_23:                              # %_Z17calcLikelihoodSumPiS_i.exit
                                        #   in Loop: Header=BB16_17 Depth=2
	divsd	%xmm4, %xmm0
	movq	144(%rsp), %rcx                 # 8-byte Reload
	movsd	%xmm0, (%rcx,%rax,8)
	incq	%rax
	cmpq	%r11, %rax
	jne	.LBB16_17
.LBB16_24:                              # %._crit_edge297
                                        #   in Loop: Header=BB16_12 Depth=1
	leaq	16(%rsp), %rdi
	xorl	%esi, %esi
	movq	%r11, %r15
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rax        # imm = 0xF4240
	addq	24(%rsp), %rax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	subq	32(%rsp), %rax                  # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.4, %edi
	movb	$1, %al
	callq	printf
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	movq	56(%rsp), %rax                  # 8-byte Reload
	movq	144(%rsp), %r13                 # 8-byte Reload
	jle	.LBB16_27
# %bb.25:                               # %.lr.ph300.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	xorl	%ebp, %ebp
.LBB16_26:                              # %.lr.ph300
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rax,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movsd	(%r13,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	callq	exp
	movq	56(%rsp), %rax                  # 8-byte Reload
	mulsd	32(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	%xmm0, (%rax,%rbp,8)
	incq	%rbp
	cmpq	%rbp, %r15
	jne	.LBB16_26
.LBB16_27:                              # %._crit_edge301
                                        #   in Loop: Header=BB16_12 Depth=1
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %r15        # imm = 0xF4240
	addq	24(%rsp), %r15
	movq	%r15, %rax
	subq	48(%rsp), %rax                  # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	jle	.LBB16_28
# %bb.29:                               # %.lr.ph305.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	xorps	%xmm0, %xmm0
	xorl	%eax, %eax
	movq	56(%rsp), %rcx                  # 8-byte Reload
	movq	40(%rsp), %rdx                  # 8-byte Reload
.LBB16_30:                              # %.lr.ph305
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addsd	(%rcx,%rax,8), %xmm0
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB16_30
	jmp	.LBB16_31
.LBB16_28:                              #   in Loop: Header=BB16_12 Depth=1
	xorps	%xmm0, %xmm0
.LBB16_31:                              # %._crit_edge306
                                        #   in Loop: Header=BB16_12 Depth=1
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rbp        # imm = 0xF4240
	addq	24(%rsp), %rbp
	movq	%rbp, %rax
	subq	%r15, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
	movsd	32(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movq	40(%rsp), %rdx                  # 8-byte Reload
	movq	56(%rsp), %rcx                  # 8-byte Reload
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	jle	.LBB16_34
# %bb.32:                               # %.lr.ph309.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	xorl	%eax, %eax
.LBB16_33:                              # %.lr.ph309
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rcx,%rax,8), %xmm0            # xmm0 = mem[0],zero
	divsd	%xmm1, %xmm0
	movsd	%xmm0, (%rcx,%rax,8)
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB16_33
.LBB16_34:                              # %._crit_edge310
                                        #   in Loop: Header=BB16_12 Depth=1
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rax        # imm = 0xF4240
	addq	24(%rsp), %rax
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	subq	%rbp, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	jle	.LBB16_35
# %bb.36:                               # %.lr.ph315.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	xorpd	%xmm2, %xmm2
	xorl	%eax, %eax
	xorpd	%xmm3, %xmm3
	movq	56(%rsp), %rcx                  # 8-byte Reload
	movq	40(%rsp), %rdx                  # 8-byte Reload
	movq	80(%rsp), %rsi                  # 8-byte Reload
	movq	72(%rsp), %rdi                  # 8-byte Reload
.LBB16_37:                              # %.lr.ph315
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rcx,%rax,8), %xmm0            # xmm0 = mem[0],zero
	movsd	(%rsi,%rax,8), %xmm1            # xmm1 = mem[0],zero
	mulsd	%xmm0, %xmm1
	mulsd	(%rdi,%rax,8), %xmm0
	addsd	%xmm1, %xmm2
	addsd	%xmm0, %xmm3
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB16_37
	jmp	.LBB16_38
.LBB16_35:                              #   in Loop: Header=BB16_12 Depth=1
	xorpd	%xmm3, %xmm3
	xorpd	%xmm2, %xmm2
.LBB16_38:                              # %._crit_edge316
                                        #   in Loop: Header=BB16_12 Depth=1
	movsd	%xmm2, 48(%rsp)                 # 8-byte Spill
	movsd	%xmm3, 32(%rsp)                 # 8-byte Spill
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %r15        # imm = 0xF4240
	addq	24(%rsp), %r15
	movq	%r15, %rax
	subq	88(%rsp), %rax                  # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.9, %edi
	movsd	48(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movl	$.L.str.10, %edi
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movsd	48(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	subsd	224(%rsp), %xmm0                # 8-byte Folded Reload
	mulsd	%xmm0, %xmm0
	movapd	%xmm0, %xmm1
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	subsd	208(%rsp), %xmm0                # 8-byte Folded Reload
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	sqrtsd	%xmm0, %xmm0
	movl	$.L.str.11, %edi
	movb	$1, %al
	callq	printf
	movq	40(%rsp), %rdx                  # 8-byte Reload
	movq	56(%rsp), %rcx                  # 8-byte Reload
	movsd	(%rcx), %xmm0                   # xmm0 = mem[0],zero
	movq	128(%rsp), %rsi                 # 8-byte Reload
	movsd	%xmm0, (%rsi)
	cmpl	$2, 12(%rsp)                    # 4-byte Folded Reload
	jl	.LBB16_41
# %bb.39:                               # %.lr.ph321.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	movsd	(%rsi), %xmm0                   # xmm0 = mem[0],zero
	movl	$1, %eax
.LBB16_40:                              # %.lr.ph321
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	addsd	(%rcx,%rax,8), %xmm0
	movsd	%xmm0, (%rsi,%rax,8)
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB16_40
.LBB16_41:                              # %._crit_edge322
                                        #   in Loop: Header=BB16_12 Depth=1
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rbp        # imm = 0xF4240
	addq	24(%rsp), %rbp
	movq	%rbp, %rax
	subq	%r15, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.12, %edi
	movb	$1, %al
	callq	printf
	movq	40(%rsp), %rdi                  # 8-byte Reload
	movslq	A(%rip), %rax
	movq	248(%rsp), %rsi                 # 8-byte Reload
	movslq	(%rsi), %rcx
	imulq	%rax, %rcx
	movslq	C(%rip), %rax
	addq	%rcx, %rax
	movq	M(%rip), %rcx
	cqto
	idivq	%rcx
	movl	%edx, (%rsi)
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	movsd	200(%rsp), %xmm2                # 8-byte Reload
                                        # xmm2 = mem[0],zero
	movq	216(%rsp), %r15                 # 8-byte Reload
	jle	.LBB16_44
# %bb.42:                               # %.lr.ph325.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2sd	%edx, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rcx, %xmm1
	divsd	%xmm1, %xmm0
	andpd	.LCPI16_6(%rip), %xmm0
	mulsd	240(%rsp), %xmm0                # 8-byte Folded Reload
	xorl	%eax, %eax
.LBB16_43:                              # %.lr.ph325
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm1, %xmm1
	cvtsi2sd	%eax, %xmm1
	divsd	%xmm2, %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, (%r15,%rax,8)
	incq	%rax
	cmpq	%rax, %rdi
	jne	.LBB16_43
.LBB16_44:                              # %._crit_edge326
                                        #   in Loop: Header=BB16_12 Depth=1
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rax        # imm = 0xF4240
	addq	24(%rsp), %rax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	subq	%rbp, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	movss	.LCPI16_1(%rip), %xmm1          # xmm1 = mem[0],zero,zero,zero
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.13, %edi
	movb	$1, %al
	callq	printf
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	16(%rsp), %rax
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	24(%rsp), %rax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movq	176(%rsp), %rdi
	movq	80(%rsp), %rsi                  # 8-byte Reload
	movq	232(%rsp), %rbp                 # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	168(%rsp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	112(%rsp), %rdi
	movq	96(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	104(%rsp), %rdi
	movq	136(%rsp), %rsi                 # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	160(%rsp), %rdi
	movq	128(%rsp), %rsi                 # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	152(%rsp), %rdi
	movq	%r15, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %r15        # imm = 0xF4240
	addq	24(%rsp), %r15
	movq	280(%rsp), %rdi                 # 8-byte Reload
	movl	$1, %esi
	movq	192(%rsp), %rdx                 # 8-byte Reload
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB16_46
# %bb.45:                               #   in Loop: Header=BB16_12 Depth=1
	movq	176(%rsp), %rdi
	movq	168(%rsp), %rsi
	movq	160(%rsp), %rdx
	movq	152(%rsp), %rcx
	movq	112(%rsp), %r8
	movq	104(%rsp), %r9
	movl	12(%rsp), %eax                  # 4-byte Reload
	movl	%eax, (%rsp)
	callq	_Z21__device_stub__kernelPdS_S_S_S_S_i
.LBB16_46:                              #   in Loop: Header=BB16_12 Depth=1
	callq	hipDeviceSynchronize
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %r13        # imm = 0xF4240
	addq	24(%rsp), %r13
	movq	104(%rsp), %rsi
	movq	136(%rsp), %rdi                 # 8-byte Reload
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	112(%rsp), %rsi
	movq	96(%rsp), %rdi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rax        # imm = 0xF4240
	movq	%rax, 304(%rsp)                 # 8-byte Spill
	imulq	$-1000000, 88(%rsp), %rax       # 8-byte Folded Reload
                                        # imm = 0xFFF0BDC0
	subq	48(%rsp), %rax                  # 8-byte Folded Reload
	addq	%r15, %rax
	cvtsi2ss	%rax, %xmm0
	movq	24(%rsp), %rbp
	movss	.LCPI16_1(%rip), %xmm1          # xmm1 = mem[0],zero,zero,zero
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.14, %edi
	movb	$1, %al
	callq	printf
	movq	%r13, %rax
	subq	%r15, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.15, %edi
	movb	$1, %al
	callq	printf
	subq	%r13, %rbp
	addq	304(%rsp), %rbp                 # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rbp, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.16, %edi
	movb	$1, %al
	callq	printf
	leaq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rbp        # imm = 0xF4240
	addq	24(%rsp), %rbp
	movq	%rbp, %rax
	subq	32(%rsp), %rax                  # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.17, %edi
	movb	$1, %al
	callq	printf
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	movq	136(%rsp), %r13                 # 8-byte Reload
	jle	.LBB16_49
# %bb.47:                               # %.lr.ph329.preheader
                                        #   in Loop: Header=BB16_12 Depth=1
	movq	80(%rsp), %rdi                  # 8-byte Reload
	movq	96(%rsp), %rsi                  # 8-byte Reload
	movq	264(%rsp), %r15                 # 8-byte Reload
	movq	%r15, %rdx
	callq	memcpy@PLT
	movq	72(%rsp), %rdi                  # 8-byte Reload
	movq	%r13, %rsi
	movq	%r15, %rdx
	callq	memcpy@PLT
	movsd	240(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movq	40(%rsp), %rdx                  # 8-byte Reload
	movq	56(%rsp), %rcx                  # 8-byte Reload
	xorl	%eax, %eax
.LBB16_48:                              # %.lr.ph329
                                        #   Parent Loop BB16_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	%xmm0, (%rcx,%rax,8)
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB16_48
.LBB16_49:                              # %._crit_edge330
                                        #   in Loop: Header=BB16_12 Depth=1
	leaq	16(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, 16(%rsp), %rax        # imm = 0xF4240
	movq	24(%rsp), %rcx
	subq	%rbp, %rcx
	addq	%rax, %rcx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	divss	.LCPI16_1(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.18, %edi
	movb	$1, %al
	callq	printf
	incl	%r12d
	movl	68(%rsp), %ebp                  # 4-byte Reload
	cmpl	%ebp, %r12d
	jne	.LBB16_12
.LBB16_50:                              # %._crit_edge333
	movq	152(%rsp), %rdi
	callq	hipFree
	movq	160(%rsp), %rdi
	callq	hipFree
	movq	104(%rsp), %rdi
	callq	hipFree
	movq	112(%rsp), %rdi
	callq	hipFree
	movq	168(%rsp), %rdi
	callq	hipFree
	movq	176(%rsp), %rdi
	callq	hipFree
	movq	256(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	%rbx, %rdi
	callq	free
	movq	56(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	144(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	80(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	72(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	96(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	128(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	216(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	%r14, %rdi
	callq	free
	addq	$328, %rsp                      # imm = 0x148
	.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_end16:
	.size	_Z14particleFilterPiiiiS_i, .Lfunc_end16-_Z14particleFilterPiiiiS_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI17_0:
	.long	0x49742400                      # float 1.0E+6
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$9, %edi
	jne	.LBB17_5
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	movl	$.L.str.21, %esi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB17_5
# %bb.2:
	movq	24(%rbx), %rdi
	movl	$.L.str.22, %esi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB17_5
# %bb.3:
	movq	40(%rbx), %rdi
	movl	$.L.str.23, %esi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB17_5
# %bb.4:
	movq	56(%rbx), %rdi
	movl	$.L.str.24, %esi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB17_8
.LBB17_5:
	movl	$.L.str.19, %edi
.LBB17_6:
	callq	puts@PLT
.LBB17_7:
	xorl	%eax, %eax
	addq	$40, %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
.LBB17_8:
	.cfi_def_cfa_offset 96
	movq	16(%rbx), %rdi
	leaq	16(%rsp), %rdx
	movl	$.L.str.25, %esi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$-1, %eax
	je	.LBB17_19
# %bb.9:
	cmpl	$0, 16(%rsp)
	jle	.LBB17_20
# %bb.10:
	movq	32(%rbx), %rdi
	leaq	12(%rsp), %rdx
	movl	$.L.str.25, %esi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$-1, %eax
	je	.LBB17_21
# %bb.11:
	cmpl	$0, 12(%rsp)
	jle	.LBB17_22
# %bb.12:
	movq	48(%rbx), %rdi
	leaq	8(%rsp), %rdx
	movl	$.L.str.25, %esi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$-1, %eax
	je	.LBB17_23
# %bb.13:
	cmpl	$0, 8(%rsp)
	jle	.LBB17_24
# %bb.14:
	movq	64(%rbx), %rdi
	leaq	20(%rsp), %rdx
	movl	$.L.str.25, %esi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$-1, %eax
	je	.LBB17_25
# %bb.15:
	movl	20(%rsp), %edi
	testl	%edi, %edi
	jle	.LBB17_27
# %bb.16:                               # %.lr.ph.preheader
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %rbx
	xorl	%r14d, %r14d
.LBB17_17:                              # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	xorl	%edi, %edi
	callq	time
	imull	%r14d, %eax
	movl	%eax, (%rbx,%r14,4)
	incq	%r14
	movslq	20(%rsp), %rax
	cmpq	%rax, %r14
	jl	.LBB17_17
# %bb.18:                               # %._crit_edge
	movslq	16(%rsp), %rax
	movslq	12(%rsp), %rcx
	imulq	%rax, %rcx
	movslq	8(%rsp), %rdi
	imulq	%rcx, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %r14
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r15), %r12          # imm = 0xF4240
	addq	8(%r15), %r12
	movl	16(%rsp), %esi
	movl	12(%rsp), %edx
	movl	8(%rsp), %ecx
	movq	%r14, %rdi
	movq	%rbx, %r8
	callq	_Z13videoSequencePiiiiS_
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r15), %r13          # imm = 0xF4240
	addq	8(%r15), %r13
	movq	%r13, %rax
	subq	%r12, %rax
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI17_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.34, %edi
	movb	$1, %al
	callq	printf
	movl	16(%rsp), %esi
	movl	12(%rsp), %edx
	movl	8(%rsp), %ecx
	movl	20(%rsp), %r9d
	movq	%r14, %rdi
	movq	%rbx, %r8
	callq	_Z14particleFilterPiiiiS_i
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	imulq	$1000000, (%r15), %rbp          # imm = 0xF4240
	addq	8(%r15), %rbp
	movq	%rbp, %rax
	subq	%r13, %rax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI17_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.35, %edi
	movb	$1, %al
	callq	printf
	subq	%r12, %rbp
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rbp, %xmm0
	divss	.LCPI17_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.36, %edi
	movb	$1, %al
	callq	printf
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	jmp	.LBB17_7
.LBB17_19:
	movl	$.L.str.26, %edi
	jmp	.LBB17_26
.LBB17_20:
	movl	$.Lstr.3, %edi
	jmp	.LBB17_6
.LBB17_21:
	movl	$.L.str.28, %edi
	jmp	.LBB17_26
.LBB17_22:
	movl	$.Lstr.2, %edi
	jmp	.LBB17_6
.LBB17_23:
	movl	$.L.str.30, %edi
	jmp	.LBB17_26
.LBB17_24:
	movl	$.Lstr.1, %edi
	jmp	.LBB17_6
.LBB17_25:
	movl	$.L.str.32, %edi
.LBB17_26:
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB17_7
.LBB17_27:
	movl	$.Lstr, %edi
	jmp	.LBB17_6
.Lfunc_end17:
	.size	main, .Lfunc_end17-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB18_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB18_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6kernelPdS_S_S_S_S_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end18:
	.size	__hip_module_ctor, .Lfunc_end18-__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	.LBB19_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
.LBB19_2:
	retq
.Lfunc_end19:
	.size	__hip_module_dtor, .Lfunc_end19-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	M,@object                       # @M
	.data
	.globl	M
	.p2align	3, 0x0
M:
	.quad	2147483647                      # 0x7fffffff
	.size	M, 8

	.type	A,@object                       # @A
	.globl	A
	.p2align	2, 0x0
A:
	.long	1103515245                      # 0x41c64e6d
	.size	A, 4

	.type	C,@object                       # @C
	.globl	C
	.p2align	2, 0x0
C:
	.long	12345                           # 0x3039
	.size	C, 4

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\nCUDA error: %s\n"
	.size	.L.str, 17

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"TIME TO GET NEIGHBORS TOOK: %f\n"
	.size	.L.str.1, 32

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"TIME TO GET WEIGHTSTOOK: %f\n"
	.size	.L.str.2, 29

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"TIME TO SET ERROR TOOK: %f\n"
	.size	.L.str.3, 28

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"TIME TO GET LIKELIHOODS TOOK: %f\n"
	.size	.L.str.4, 34

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"TIME TO GET EXP TOOK: %f\n"
	.size	.L.str.5, 26

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"TIME TO SUM WEIGHTS TOOK: %f\n"
	.size	.L.str.6, 30

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"TIME TO NORMALIZE WEIGHTS TOOK: %f\n"
	.size	.L.str.7, 36

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"TIME TO MOVE OBJECT TOOK: %f\n"
	.size	.L.str.8, 30

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"XE: %lf\n"
	.size	.L.str.9, 9

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"YE: %lf\n"
	.size	.L.str.10, 9

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"%lf\n"
	.size	.L.str.11, 5

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"TIME TO CALC CUM SUM TOOK: %f\n"
	.size	.L.str.12, 31

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"TIME TO CALC U TOOK: %f\n"
	.size	.L.str.13, 25

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"SENDING TO GPU TOOK: %lf\n"
	.size	.L.str.14, 26

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"CUDA EXEC TOOK: %lf\n"
	.size	.L.str.15, 21

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"SENDING BACK FROM GPU TOOK: %lf\n"
	.size	.L.str.16, 33

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"TIME TO CALC NEW ARRAY X AND Y TOOK: %f\n"
	.size	.L.str.17, 41

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"TIME TO RESET WEIGHTS TOOK: %f\n"
	.size	.L.str.18, 32

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"naive.out -x <dimX> -y <dimY> -z <Nfr> -np <Nparticles>"
	.size	.L.str.19, 56

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"-x"
	.size	.L.str.21, 3

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

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"-z"
	.size	.L.str.23, 3

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"-np"
	.size	.L.str.24, 4

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"%d"
	.size	.L.str.25, 3

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"ERROR: dimX input is incorrect"
	.size	.L.str.26, 31

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"ERROR: dimY input is incorrect"
	.size	.L.str.28, 31

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"ERROR: Number of frames input is incorrect"
	.size	.L.str.30, 43

	.type	.L.str.32,@object               # @.str.32
.L.str.32:
	.asciz	"ERROR: Number of particles input is incorrect"
	.size	.L.str.32, 46

	.type	.L.str.34,@object               # @.str.34
.L.str.34:
	.asciz	"VIDEO SEQUENCE TOOK %f\n"
	.size	.L.str.34, 24

	.type	.L.str.35,@object               # @.str.35
.L.str.35:
	.asciz	"PARTICLE FILTER TOOK %f\n"
	.size	.L.str.35, 25

	.type	.L.str.36,@object               # @.str.36
.L.str.36:
	.asciz	"ENTIRE PROGRAM TOOK %f\n"
	.size	.L.str.36, 24

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6kernelPdS_S_S_S_S_i"
	.size	.L__unnamed_1, 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	__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	"Number of particles must be > 0"
	.size	.Lstr, 32

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"number of frames must be > 0"
	.size	.Lstr.1, 29

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"dimY must be > 0"
	.size	.Lstr.2, 17

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"dimX must be > 0"
	.size	.Lstr.3, 17

	.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 _Z21__device_stub__kernelPdS_S_S_S_S_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z6kernelPdS_S_S_S_S_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6kernelPdS_S_S_S_S_i  ; -- Begin function _Z6kernelPdS_S_S_S_S_i
	.globl	_Z6kernelPdS_S_S_S_S_i
	.p2align	8
	.type	_Z6kernelPdS_S_S_S_S_i,@function
_Z6kernelPdS_S_S_S_S_i:                 ; @_Z6kernelPdS_S_S_S_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x44
	s_load_b32 s12, s[0:1], 0x30
	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 s12, v1
	s_cbranch_execz .LBB0_9
; %bb.1:                                ; %.preheader
	s_clause 0x1
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b128 s[0:3], s[0:1], 0x20
	v_ashrrev_i32_e32 v2, 31, v1
	s_cmp_lt_i32 s12, 1
	s_delay_alu instid0(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 3, v[1:2]
	s_cbranch_scc1 .LBB0_7
; %bb.2:                                ; %.lr.ph
	s_waitcnt lgkmcnt(0)
	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
	s_mov_b32 s10, 0
	s_mov_b32 s11, 0
                                        ; implicit-def: $sgpr13
	global_load_b64 v[2:3], v[2:3], off
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	s_load_b64 s[14:15], s[8:9], 0x0
	v_mov_b32_e32 v4, s11
	s_or_b32 s13, s13, exec_lo
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_cmp_nge_f64_e32 vcc_lo, s[14:15], v[2:3]
	s_and_saveexec_b32 s14, vcc_lo
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	s_add_i32 s11, s11, 1
	s_add_u32 s8, s8, 8
	s_addc_u32 s9, s9, 0
	s_cmp_eq_u32 s12, s11
	v_mov_b32_e32 v4, -1
	s_cselect_b32 s15, -1, 0
	s_and_not1_b32 s13, s13, exec_lo
	s_and_b32 s15, s15, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s13, s13, s15
; %bb.5:                                ; %Flow
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s14
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s14, exec_lo, s13
	s_or_b32 s10, s14, s10
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s10
	s_cbranch_execnz .LBB0_3
; %bb.6:                                ; %Flow52
	s_or_b32 exec_lo, exec_lo, s10
	s_branch .LBB0_8
.LBB0_7:
	v_mov_b32_e32 v4, -1
.LBB0_8:                                ; %._crit_edge
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_eq_u32_e32 vcc_lo, -1, v4
	s_add_i32 s12, s12, -1
	v_cndmask_b32_e64 v2, v4, s12, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 3, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v3, vcc_lo
	v_add_co_u32 v6, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v7, vcc_lo, s1, v1, vcc_lo
	global_load_b64 v[4:5], v[4:5], off
	v_add_co_u32 v2, vcc_lo, s6, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b64 v[6:7], v[4:5], off
	global_load_b64 v[2:3], v[2:3], off
	s_waitcnt vmcnt(0)
	global_store_b64 v[0:1], v[2:3], off
.LBB0_9:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6kernelPdS_S_S_S_S_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 312
		.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 8
		.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	_Z6kernelPdS_S_S_S_S_i, .Lfunc_end0-_Z6kernelPdS_S_S_S_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 392
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; 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
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.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
      - .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
      - .offset:         48
        .size:           4
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         60
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         68
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         70
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         72
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         74
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         76
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         78
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         120
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 312
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6kernelPdS_S_S_S_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6kernelPdS_S_S_S_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
