#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>

#define GIGABYTE 1000000000

struct entry
{
	int origIndex;
	float xValue, yValue;
};//entry


int h_binarySearchLB(entry * data, float val, int n)
{
	//return index of greatest leftmost xValue that is greater than val
	int left = 0;
	int right = n;
	int mid;

	while (left != right)
	{
		mid = (left+right)/2;
		
		if (data[mid].xValue <= val)
			left = mid + 1;
		else
			right = mid;
	}//while
	return left;
}//binarySearchLB


int h_binarySearchUB(entry * data, float val, int n)
{
	//return index of greatest leftmost xValue that is greater than val
	int left = 0;
	int right = n;
	int mid;

	while (left != right)
	{
		mid = (left+right)/2;
		
		if (data[mid].xValue >= val)
			right = mid;
		else
			left = mid + 1;
	}//while

	return left;
}//binarySearchUB


__device__ int binarySearchLB(entry * data, float val, int n)//val is x val +/- tuning parameter
{
	//return index of greatest leftmost xValue that is greater than val
	int left = 0;
	int right = n;
	int mid;

	while (left != right)
	{
		mid = (left+right)/2;
		
		if (data[mid].xValue <= val)
			left = mid + 1;
		else
			right = mid;
	}//while
	return left;
}//binarySearchLB


__device__ int binarySearchUB(entry * data, float val, int n)
{
	//return index of greatest leftmost xValue that is greater than val
	int left = 0;
	int right = n;
	int mid;

	while (left != right)
	{
		mid = (left+right)/2;
		
		if (data[mid].xValue >= val)
			right = mid;
		else
			left = mid + 1;
	}//while

	return left;
}//binarySearchUB


__global__ void kernel1(entry * array, int n, float h)
{
	int idx = blockIdx.x * blockDim.x + threadIdx.x; 
	int lowerBound = binarySearchLB(array, array[idx].xValue-h, n);//binsearchlb device func
	int upperBound = binarySearchUB(array, array[idx].xValue+h, n);//ub is device func

	float avg = 0;
	//calculate y average
	for (int i=lowerBound; i<upperBound; i++)
		avg += array[i].yValue;
	avg = avg/((float) (upperBound-lowerBound));

	//yValue stores the avg
	array[idx].yValue = avg;	
}//kernel1


__global__ void kernel2(entry * array, int n)
{
	float avg = 0;
	for (int i=0; i<n; i++)
		avg += array[i].yValue;
	avg = avg / (float) n;

	array[0].yValue = avg;			
}//kernel2


void merge(entry * a, int low, int high)
{
	int pivot = (low+high)/2;
	int i = 0;
	int j = low;
	int k = pivot+1;

	entry * temp = new entry[high-low+1];

	while ((j <= pivot) && (k <= high))
	{
		if (a[j].xValue < a[k].xValue)
			temp[i++] = a[j++];
		else
			temp[i++] = a[k++];
	}//while

	while (j <= pivot)
		temp[i++] = a[j++];

	while (k <= high)
		temp[i++] = a[k++];

	for (int h=low; h<= high; h++)
		a[h] = temp[h-low];
	
	delete [] temp;
}//merge


void mergeSort(entry * a, int low, int high)
{
	int pivot;
	if (low < high)
	{
		pivot = (low+high)/2;
		mergeSort(a, low, pivot);
		mergeSort(a, pivot+1, high);
		merge(a, low, high);
	}//if
}//mergeSort


void smoothc(float * x, float * y, float * m, int n, float h)
{
	entry * array = new entry[n];
	entry * deviceArray;
	int * countArray = new int[n];// should not be there, mem leak
	int blockSize = 1024;//num thread per block 

	//creat array of structs	
	for (int i=0; i<n; i++)
	{
		entry temp;
		temp.origIndex = i;
		temp.xValue = x[i];
		temp.yValue = y[i];
		array[i] = temp;
	}//for

	//sort by xValue
	mergeSort(array, 0, n-1);

	if (n < GIGABYTE/sizeof(entry))// if fits into 1 gig of mem hard code in line 5
	{
		//put array onto device array
		cudaMalloc(&deviceArray, sizeof(entry) * n);
		cudaMemcpy(deviceArray, array, sizeof(entry) * n, cudaMemcpyHostToDevice);

		dim3 dimBlock(blockSize);
		dim3 dimGrid(ceil(n/blockSize));

		//stores smoothed average in yValue
		kernel1 <<< dimGrid, dimBlock >>> (deviceArray, n, h);//send to line 96
		cudaMemcpy(array, deviceArray, sizeof(entry) * n, cudaMemcpyDeviceToHost);
		
	//rearrange array in original order
		for (int i=0; i<n; i++)
			m[array[i].origIndex] = array[i].yValue;
		cudaFree(deviceArray);
	}//if
	else //have to chunk up data
	{
		int lb, ub;
		for (int i=0; i<n; i++)
		{
			lb = h_binarySearchLB(array, array[i].xValue-h, n);
			ub = h_binarySearchUB(array, array[i].xValue+h, n);
			entry * chunkArray = new entry[ub-lb];
	
			for (int j=0; j<ub-lb; j++)
				chunkArray[j] = array[lb+j];
			
			cudaMalloc(&deviceArray, sizeof(entry) * (ub-lb));
			cudaMemcpy(deviceArray, chunkArray, sizeof(entry) * (ub-lb), cudaMemcpyHostToDevice);

			kernel2 <<< 1, 1 >>> (deviceArray, ub-lb);
			cudaMemcpy(chunkArray, deviceArray, sizeof(entry) * (ub-lb), cudaMemcpyDeviceToHost);

			m[array[i].origIndex] = chunkArray[0].yValue;//store y avg
			cudaFree(deviceArray);
			delete [] chunkArray;
		}//for
	}//else
	
	delete [] array;
}//smoothc

/*
int main()
{
	int n = 200;
	float * x = new float[n];
	float * y = new float[n];
	float * m = new float[n];
	float h = 2;
	
	for (int i=0; i<n; i++)
	{
		x[i] = rand() % 100;
		y[i] = rand() % 100;
	}//for
	float x[20] = {1, 1,2,2, 3,3, 4,4, 5,5, 6,6, 7,7, 8,8, 9,9, 10,10};
	float y[20] = {11,11, 12,12, 13,13, 14,14, 15,15, 16,16, 17,17, 18,18, 19,19, 20,20};
	float m[20];
	int n = 20;
	float h = 2;
	smoothc(x, y, m, n, h);
//	delete [] x;
//	delete [] y;
//	delete [] m;
}//main
*/

	.file	"tmpxft_0025bb9e_00000000-6_SmoothC.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2036:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2036:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z16h_binarySearchLBP5entryfi
	.type	_Z16h_binarySearchLBP5entryfi, @function
_Z16h_binarySearchLBP5entryfi:
.LFB2027:
	.cfi_startproc
	endbr64
	xorl	%ecx, %ecx
	movl	$2, %r8d
.L4:
	cmpl	%ecx, %esi
	je	.L11
	leal	(%rsi,%rcx), %eax
	cltd
	idivl	%r8d
	movslq	%eax, %rdx
	imulq	$12, %rdx, %rdx
	comiss	4(%rdi,%rdx), %xmm0
	jb	.L9
	leal	1(%rax), %ecx
	jmp	.L4
.L9:
	movl	%eax, %esi
	jmp	.L4
.L11:
	movl	%esi, %eax
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z16h_binarySearchLBP5entryfi, .-_Z16h_binarySearchLBP5entryfi
	.globl	_Z16h_binarySearchUBP5entryfi
	.type	_Z16h_binarySearchUBP5entryfi, @function
_Z16h_binarySearchUBP5entryfi:
.LFB2028:
	.cfi_startproc
	endbr64
	xorl	%ecx, %ecx
	movl	$2, %r8d
.L14:
	cmpl	%ecx, %esi
	je	.L17
	leal	(%rsi,%rcx), %eax
	cltd
	idivl	%r8d
	movslq	%eax, %rdx
	imulq	$12, %rdx, %rdx
	movss	4(%rdi,%rdx), %xmm1
	comiss	%xmm0, %xmm1
	jnb	.L16
	leal	1(%rax), %ecx
	jmp	.L14
.L16:
	movl	%eax, %esi
	jmp	.L14
.L17:
	movl	%esi, %eax
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z16h_binarySearchUBP5entryfi, .-_Z16h_binarySearchUBP5entryfi
	.globl	_Z14binarySearchLBP5entryfi
	.type	_Z14binarySearchLBP5entryfi, @function
_Z14binarySearchLBP5entryfi:
.LFB2029:
	.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
.LFE2029:
	.size	_Z14binarySearchLBP5entryfi, .-_Z14binarySearchLBP5entryfi
	.globl	_Z14binarySearchUBP5entryfi
	.type	_Z14binarySearchUBP5entryfi, @function
_Z14binarySearchUBP5entryfi:
.LFB2183:
	.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
.LFE2183:
	.size	_Z14binarySearchUBP5entryfi, .-_Z14binarySearchUBP5entryfi
	.globl	_Z5mergeP5entryii
	.type	_Z5mergeP5entryii, @function
_Z5mergeP5entryii:
.LFB2031:
	.cfi_startproc
	endbr64
	leal	(%rsi,%rdx), %eax
	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	%edx, %r12d
	cltd
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	movl	%r12d, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subl	%esi, %edi
	pushq	%rcx
	.cfi_def_cfa_offset 64
	movl	$2, %ecx
	incl	%edi
	idivl	%ecx
	movslq	%edi, %rdi
	movl	%eax, %r13d
	leal	1(%rax), %r14d
	movabsq	$768614336404564650, %rax
	cmpq	%rdi, %rax
	jb	.L23
	imulq	$12, %rdi, %rdi
	movl	%esi, %ebx
	call	_Znam@PLT
	movl	%r14d, %ecx
	movl	%ebx, %r8d
	xorl	%r9d, %r9d
	movq	%rax, %rdi
	movq	%rax, %rsi
	movq	%rax, %r10
	jmp	.L24
.L23:
	call	__cxa_throw_bad_array_new_length@PLT
.L44:
	cmpl	%r12d, %ecx
	jg	.L37
	movslq	%ecx, %rax
	imulq	$12, %rdx, %rdx
	incl	%r9d
	imulq	$12, %rax, %rax
	addq	%rbp, %rdx
	addq	%rbp, %rax
	movss	4(%rax), %xmm0
	comiss	4(%rdx), %xmm0
	jbe	.L41
	movq	(%rdx), %rax
	incl	%r8d
	movq	%rax, (%r10)
	movl	8(%rdx), %eax
.L43:
	movl	%eax, 8(%r10)
	addq	$12, %r10
.L24:
	cmpl	%r13d, %r8d
	movslq	%r8d, %rdx
	jle	.L44
	jmp	.L37
.L41:
	movq	(%rax), %rdx
	incl	%ecx
	movl	8(%rax), %eax
	movq	%rdx, (%r10)
	jmp	.L43
.L37:
	movslq	%r9d, %rax
.L30:
	cmpl	%edx, %r13d
	jl	.L45
	imulq	$12, %rdx, %r11
	incq	%rdx
	imulq	$12, %rax, %r10
	incq	%rax
	movq	0(%rbp,%r11), %r15
	movl	8(%rbp,%r11), %r11d
	movq	%r15, (%rdi,%r10)
	movl	%r11d, 8(%rdi,%r10)
	jmp	.L30
.L45:
	movl	%r14d, %edx
	xorl	%eax, %eax
	subl	%r8d, %edx
	cmpl	%r14d, %r8d
	cmovg	%eax, %edx
	movslq	%ecx, %rax
	addl	%r9d, %edx
	movslq	%edx, %rdx
.L32:
	cmpl	%eax, %r12d
	jl	.L46
	imulq	$12, %rax, %r8
	incq	%rax
	imulq	$12, %rdx, %rcx
	incq	%rdx
	movq	0(%rbp,%r8), %r9
	movl	8(%rbp,%r8), %r8d
	movq	%r9, (%rdi,%rcx)
	movl	%r8d, 8(%rdi,%rcx)
	jmp	.L32
.L46:
	movslq	%ebx, %rax
.L34:
	cmpl	%eax, %r12d
	jl	.L47
	imulq	$12, %rax, %rdx
	movq	(%rsi), %rcx
	incq	%rax
	addq	$12, %rsi
	movq	%rcx, 0(%rbp,%rdx)
	movl	-4(%rsi), %ecx
	movl	%ecx, 8(%rbp,%rdx)
	jmp	.L34
.L47:
	popq	%rax
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_ZdaPv@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z5mergeP5entryii, .-_Z5mergeP5entryii
	.globl	_Z9mergeSortP5entryii
	.type	_Z9mergeSortP5entryii, @function
_Z9mergeSortP5entryii:
.LFB2032:
	.cfi_startproc
	endbr64
	cmpl	%edx, %esi
	jge	.L48
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edx, %r13d
	movl	$2, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rax
	.cfi_def_cfa_offset 48
	leal	(%rsi,%rdx), %eax
	cltd
	idivl	%ecx
	movl	%eax, %ebx
	movl	%eax, %edx
	call	_Z9mergeSortP5entryii
	leal	1(%rbx), %esi
	movl	%r13d, %edx
	movq	%r12, %rdi
	call	_Z9mergeSortP5entryii
	popq	%rcx
	.cfi_def_cfa_offset 40
	movl	%r13d, %edx
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 32
	movl	%ebp, %esi
	movq	%r12, %rdi
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_restore 12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_restore 13
	.cfi_def_cfa_offset 8
	jmp	_Z5mergeP5entryii
.L48:
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z9mergeSortP5entryii, .-_Z9mergeSortP5entryii
	.globl	_Z33__device_stub__Z7kernel1P5entryifP5entryif
	.type	_Z33__device_stub__Z7kernel1P5entryifP5entryif, @function
_Z33__device_stub__Z7kernel1P5entryifP5entryif:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	32(%rsp), %rdi
	leaq	44(%rsp), %rsi
	movss	%xmm0, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L53
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z7kernel1P5entryif(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L53:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L55
	call	__stack_chk_fail@PLT
.L55:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z33__device_stub__Z7kernel1P5entryifP5entryif, .-_Z33__device_stub__Z7kernel1P5entryifP5entryif
	.globl	_Z7kernel1P5entryif
	.type	_Z7kernel1P5entryif, @function
_Z7kernel1P5entryif:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z7kernel1P5entryifP5entryif
	.cfi_endproc
.LFE2059:
	.size	_Z7kernel1P5entryif, .-_Z7kernel1P5entryif
	.globl	_Z32__device_stub__Z7kernel2P5entryiP5entryi
	.type	_Z32__device_stub__Z7kernel2P5entryiP5entryi, @function
_Z32__device_stub__Z7kernel2P5entryiP5entryi:
.LFB2060:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L58
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z7kernel2P5entryi(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L58:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L60
	call	__stack_chk_fail@PLT
.L60:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z32__device_stub__Z7kernel2P5entryiP5entryi, .-_Z32__device_stub__Z7kernel2P5entryiP5entryi
	.globl	_Z7kernel2P5entryi
	.type	_Z7kernel2P5entryi, @function
_Z7kernel2P5entryi:
.LFB2061:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z7kernel2P5entryiP5entryi
	.cfi_endproc
.LFE2061:
	.size	_Z7kernel2P5entryi, .-_Z7kernel2P5entryi
	.globl	_Z7smoothcPfS_S_if
	.type	_Z7smoothcPfS_S_if, @function
_Z7smoothcPfS_S_if:
.LFB2033:
	.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
	movslq	%ecx, %r13
	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	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%rsi, 16(%rsp)
	movss	%xmm0, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	movabsq	$768614336404564650, %rax
	cmpq	%r13, %rax
	jb	.L64
	imulq	$12, %r13, %rax
	movq	%rdi, %r15
	movq	%rdx, %r14
	movq	%r13, %rbp
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	_Znam@PLT
	movq	16(%rsp), %rsi
	movq	%rax, %rbx
	movq	%rax, %r12
	movq	%rax, %rdx
	xorl	%eax, %eax
	jmp	.L65
.L64:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L81
	call	__cxa_throw_bad_array_new_length@PLT
.L65:
	cmpl	%eax, %ebp
	jle	.L82
	movss	(%r15,%rax,4), %xmm1
	movss	(%rsi,%rax,4), %xmm0
	movl	%eax, (%rdx)
	incq	%rax
	addq	$12, %rdx
	movss	%xmm1, -8(%rdx)
	movss	%xmm0, -4(%rdx)
	jmp	.L65
.L82:
	leal	-1(%rbp), %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	xorl	%r15d, %r15d
	call	_Z9mergeSortP5entryii
	cmpq	$83333332, %r13
	ja	.L68
	movq	8(%rsp), %rsi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rdi
	movq	%rbx, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%ebp, %eax
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	sarl	$10, %eax
	salq	$10, %rdx
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movl	%eax, 60(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	60(%rsp), %rdi
	movl	68(%rsp), %esi
	movq	%rdx, 48(%rsp)
	movl	$1, 56(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L69
	movss	24(%rsp), %xmm0
	movq	40(%rsp), %rdi
	movl	%ebp, %esi
	call	_Z33__device_stub__Z7kernel1P5entryifP5entryif
.L69:
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L70:
	cmpl	%ebp, %eax
	je	.L83
	movslq	(%r12), %rdx
	movss	8(%r12), %xmm0
	incl	%eax
	addq	$12, %r12
	movss	%xmm0, (%r14,%rdx,4)
	jmp	.L70
.L83:
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	jmp	.L72
.L84:
	movq	8(%rsp), %rsi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movl	$1, 68(%rsp)
	movq	%rdi, %rdx
	movq	%rdi, 60(%rsp)
	movq	%rdi, 48(%rsp)
	movl	$1, 56(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L75
	movl	16(%rsp), %esi
	movq	40(%rsp), %rdi
	call	_Z32__device_stub__Z7kernel2P5entryiP5entryi
.L75:
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	%r13, %rdi
	incl	%r15d
	movl	$2, %ecx
	addq	$12, %r12
	call	cudaMemcpy@PLT
	movss	8(%r13), %xmm0
	movslq	-12(%r12), %rax
	movq	40(%rsp), %rdi
	movss	%xmm0, (%r14,%rax,4)
	call	cudaFree@PLT
	movq	%r13, %rdi
	call	_ZdaPv@PLT
	cmpl	%r15d, %ebp
	jle	.L72
.L68:
	movss	4(%r12), %xmm1
	movl	%ebp, %esi
	movq	%rbx, %rdi
	movaps	%xmm1, %xmm0
	subss	24(%rsp), %xmm0
	call	_Z16h_binarySearchLBP5entryfi
	addss	24(%rsp), %xmm1
	movl	%ebp, %esi
	movl	%eax, 28(%rsp)
	movaps	%xmm1, %xmm0
	call	_Z16h_binarySearchUBP5entryfi
	movl	28(%rsp), %ecx
	subl	%ecx, %eax
	movabsq	$768614336404564650, %rcx
	movl	%eax, 16(%rsp)
	cltq
	cmpq	%rax, %rcx
	jb	.L64
	imulq	$12, %rax, %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	_Znam@PLT
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	movq	%rax, %r13
	movslq	28(%rsp), %rax
	imulq	$12, %rax, %rax
	addq	%rbx, %rax
.L73:
	cmpl	%ecx, 16(%rsp)
	jle	.L84
	movq	(%rax,%rdx), %rsi
	incl	%ecx
	movq	%rsi, 0(%r13,%rdx)
	movl	8(%rax,%rdx), %esi
	movl	%esi, 8(%r13,%rdx)
	addq	$12, %rdx
	jmp	.L73
.L72:
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L76
.L81:
	call	__stack_chk_fail@PLT
.L76:
	addq	$88, %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
.LFE2033:
	.size	_Z7smoothcPfS_S_if, .-_Z7smoothcPfS_S_if
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z7kernel2P5entryi"
.LC1:
	.string	"_Z7kernel1P5entryif"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2063:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z7kernel2P5entryi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC1(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7kernel1P5entryif(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2063:
	.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
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>
#include <hip/hip_runtime.h>

#define GIGABYTE 1000000000

struct entry
{
	int origIndex;
	float xValue, yValue;
};//entry


int h_binarySearchLB(entry * data, float val, int n)
{
	//return index of greatest leftmost xValue that is greater than val
	int left = 0;
	int right = n;
	int mid;

	while (left != right)
	{
		mid = (left+right)/2;
		
		if (data[mid].xValue <= val)
			left = mid + 1;
		else
			right = mid;
	}//while
	return left;
}//binarySearchLB


int h_binarySearchUB(entry * data, float val, int n)
{
	//return index of greatest leftmost xValue that is greater than val
	int left = 0;
	int right = n;
	int mid;

	while (left != right)
	{
		mid = (left+right)/2;
		
		if (data[mid].xValue >= val)
			right = mid;
		else
			left = mid + 1;
	}//while

	return left;
}//binarySearchUB


__device__ int binarySearchLB(entry * data, float val, int n)//val is x val +/- tuning parameter
{
	//return index of greatest leftmost xValue that is greater than val
	int left = 0;
	int right = n;
	int mid;

	while (left != right)
	{
		mid = (left+right)/2;
		
		if (data[mid].xValue <= val)
			left = mid + 1;
		else
			right = mid;
	}//while
	return left;
}//binarySearchLB


__device__ int binarySearchUB(entry * data, float val, int n)
{
	//return index of greatest leftmost xValue that is greater than val
	int left = 0;
	int right = n;
	int mid;

	while (left != right)
	{
		mid = (left+right)/2;
		
		if (data[mid].xValue >= val)
			right = mid;
		else
			left = mid + 1;
	}//while

	return left;
}//binarySearchUB


__global__ void kernel1(entry * array, int n, float h)
{
	int idx = blockIdx.x * blockDim.x + threadIdx.x; 
	int lowerBound = binarySearchLB(array, array[idx].xValue-h, n);//binsearchlb device func
	int upperBound = binarySearchUB(array, array[idx].xValue+h, n);//ub is device func

	float avg = 0;
	//calculate y average
	for (int i=lowerBound; i<upperBound; i++)
		avg += array[i].yValue;
	avg = avg/((float) (upperBound-lowerBound));

	//yValue stores the avg
	array[idx].yValue = avg;	
}//kernel1


__global__ void kernel2(entry * array, int n)
{
	float avg = 0;
	for (int i=0; i<n; i++)
		avg += array[i].yValue;
	avg = avg / (float) n;

	array[0].yValue = avg;			
}//kernel2


void merge(entry * a, int low, int high)
{
	int pivot = (low+high)/2;
	int i = 0;
	int j = low;
	int k = pivot+1;

	entry * temp = new entry[high-low+1];

	while ((j <= pivot) && (k <= high))
	{
		if (a[j].xValue < a[k].xValue)
			temp[i++] = a[j++];
		else
			temp[i++] = a[k++];
	}//while

	while (j <= pivot)
		temp[i++] = a[j++];

	while (k <= high)
		temp[i++] = a[k++];

	for (int h=low; h<= high; h++)
		a[h] = temp[h-low];
	
	delete [] temp;
}//merge


void mergeSort(entry * a, int low, int high)
{
	int pivot;
	if (low < high)
	{
		pivot = (low+high)/2;
		mergeSort(a, low, pivot);
		mergeSort(a, pivot+1, high);
		merge(a, low, high);
	}//if
}//mergeSort


void smoothc(float * x, float * y, float * m, int n, float h)
{
	entry * array = new entry[n];
	entry * deviceArray;
	int * countArray = new int[n];// should not be there, mem leak
	int blockSize = 1024;//num thread per block 

	//creat array of structs	
	for (int i=0; i<n; i++)
	{
		entry temp;
		temp.origIndex = i;
		temp.xValue = x[i];
		temp.yValue = y[i];
		array[i] = temp;
	}//for

	//sort by xValue
	mergeSort(array, 0, n-1);

	if (n < GIGABYTE/sizeof(entry))// if fits into 1 gig of mem hard code in line 5
	{
		//put array onto device array
		hipMalloc(&deviceArray, sizeof(entry) * n);
		hipMemcpy(deviceArray, array, sizeof(entry) * n, hipMemcpyHostToDevice);

		dim3 dimBlock(blockSize);
		dim3 dimGrid(ceil(n/blockSize));

		//stores smoothed average in yValue
		kernel1 <<< dimGrid, dimBlock >>> (deviceArray, n, h);//send to line 96
		hipMemcpy(array, deviceArray, sizeof(entry) * n, hipMemcpyDeviceToHost);
		
	//rearrange array in original order
		for (int i=0; i<n; i++)
			m[array[i].origIndex] = array[i].yValue;
		hipFree(deviceArray);
	}//if
	else //have to chunk up data
	{
		int lb, ub;
		for (int i=0; i<n; i++)
		{
			lb = h_binarySearchLB(array, array[i].xValue-h, n);
			ub = h_binarySearchUB(array, array[i].xValue+h, n);
			entry * chunkArray = new entry[ub-lb];
	
			for (int j=0; j<ub-lb; j++)
				chunkArray[j] = array[lb+j];
			
			hipMalloc(&deviceArray, sizeof(entry) * (ub-lb));
			hipMemcpy(deviceArray, chunkArray, sizeof(entry) * (ub-lb), hipMemcpyHostToDevice);

			kernel2 <<< 1, 1 >>> (deviceArray, ub-lb);
			hipMemcpy(chunkArray, deviceArray, sizeof(entry) * (ub-lb), hipMemcpyDeviceToHost);

			m[array[i].origIndex] = chunkArray[0].yValue;//store y avg
			hipFree(deviceArray);
			delete [] chunkArray;
		}//for
	}//else
	
	delete [] array;
}//smoothc

/*
int main()
{
	int n = 200;
	float * x = new float[n];
	float * y = new float[n];
	float * m = new float[n];
	float h = 2;
	
	for (int i=0; i<n; i++)
	{
		x[i] = rand() % 100;
		y[i] = rand() % 100;
	}//for
	float x[20] = {1, 1,2,2, 3,3, 4,4, 5,5, 6,6, 7,7, 8,8, 9,9, 10,10};
	float y[20] = {11,11, 12,12, 13,13, 14,14, 15,15, 16,16, 17,17, 18,18, 19,19, 20,20};
	float m[20];
	int n = 20;
	float h = 2;
	smoothc(x, y, m, n, h);
//	delete [] x;
//	delete [] y;
//	delete [] m;
}//main
*/

	.text
	.file	"SmoothC.hip"
	.globl	_Z16h_binarySearchLBP5entryfi   # -- Begin function _Z16h_binarySearchLBP5entryfi
	.type	_Z16h_binarySearchLBP5entryfi,@function
_Z16h_binarySearchLBP5entryfi:          # @_Z16h_binarySearchLBP5entryfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB0_7
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leal	(%rcx,%rax), %esi
	movl	%esi, %edx
	shrl	$31, %edx
	addl	%esi, %edx
	sarl	%edx
	movslq	%edx, %rsi
	leaq	(%rsi,%rsi,2), %rsi
	ucomiss	4(%rdi,%rsi,4), %xmm0
	jb	.LBB0_4
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	incl	%edx
	movl	%edx, %ecx
	jmp	.LBB0_5
.LBB0_4:                                #   in Loop: Header=BB0_2 Depth=1
	movl	%edx, %eax
.LBB0_5:                                # %.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	cmpl	%eax, %ecx
	jne	.LBB0_2
# %bb.6:                                # %._crit_edge
                                        # kill: def $eax killed $eax killed $rax
	retq
.LBB0_7:
	xorl	%eax, %eax
                                        # kill: def $eax killed $eax killed $rax
	retq
.Lfunc_end0:
	.size	_Z16h_binarySearchLBP5entryfi, .Lfunc_end0-_Z16h_binarySearchLBP5entryfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z16h_binarySearchUBP5entryfi   # -- Begin function _Z16h_binarySearchUBP5entryfi
	.type	_Z16h_binarySearchUBP5entryfi,@function
_Z16h_binarySearchUBP5entryfi:          # @_Z16h_binarySearchUBP5entryfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB1_7
# %bb.1:                                # %.lr.ph.preheader
	movl	%esi, %eax
	xorl	%ecx, %ecx
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leal	(%rcx,%rax), %esi
	movl	%esi, %edx
	shrl	$31, %edx
	addl	%esi, %edx
	sarl	%edx
	movslq	%edx, %rsi
	leaq	(%rsi,%rsi,2), %rsi
	movss	4(%rdi,%rsi,4), %xmm1           # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jb	.LBB1_4
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	%edx, %eax
	jmp	.LBB1_5
.LBB1_4:                                #   in Loop: Header=BB1_2 Depth=1
	incl	%edx
	movl	%edx, %ecx
.LBB1_5:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	cmpl	%eax, %ecx
	jne	.LBB1_2
# %bb.6:                                # %._crit_edge
                                        # kill: def $eax killed $eax killed $rax
	retq
.LBB1_7:
	xorl	%eax, %eax
                                        # kill: def $eax killed $eax killed $rax
	retq
.Lfunc_end1:
	.size	_Z16h_binarySearchUBP5entryfi, .Lfunc_end1-_Z16h_binarySearchUBP5entryfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__kernel1P5entryif # -- Begin function _Z22__device_stub__kernel1P5entryif
	.type	_Z22__device_stub__kernel1P5entryif,@function
_Z22__device_stub__kernel1P5entryif:    # @_Z22__device_stub__kernel1P5entryif
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	movq	%rsp, %rdx
	movss	%xmm0, (%rdx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rdx, 16(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z7kernel1P5entryif, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z22__device_stub__kernel1P5entryif, .Lfunc_end2-_Z22__device_stub__kernel1P5entryif
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__kernel2P5entryi # -- Begin function _Z22__device_stub__kernel2P5entryi
	.type	_Z22__device_stub__kernel2P5entryi,@function
_Z22__device_stub__kernel2P5entryi:     # @_Z22__device_stub__kernel2P5entryi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z7kernel2P5entryi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z22__device_stub__kernel2P5entryi, .Lfunc_end3-_Z22__device_stub__kernel2P5entryi
	.cfi_endproc
                                        # -- End function
	.globl	_Z5mergeP5entryii               # -- Begin function _Z5mergeP5entryii
	.type	_Z5mergeP5entryii,@function
_Z5mergeP5entryii:                      # @_Z5mergeP5entryii
	.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
	movl	%edx, %r15d
	movl	%esi, %r14d
	movq	%rdi, %rbx
	leal	(%r15,%r14), %eax
	movl	%eax, %r12d
	shrl	$31, %r12d
	addl	%eax, %r12d
	sarl	%r12d
	leal	1(%r12), %ebp
	movl	%edx, %eax
	subl	%esi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	incl	%eax
	cltq
	movl	$12, %ecx
	mulq	%rcx
	movq	$-1, %rdi
	cmovnoq	%rax, %rdi
	callq	_Znam
	movq	%rax, %r11
	xorl	%r13d, %r13d
	cmpl	%r14d, %r12d
	jl	.LBB4_1
# %bb.9:
	cmpl	%r15d, %r12d
	jge	.LBB4_1
# %bb.10:                               # %.lr.ph.preheader
	xorl	%r13d, %r13d
	movq	%r11, %rcx
	movl	%r14d, %eax
.LBB4_11:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movslq	%eax, %rsi
	leaq	(%rsi,%rsi,2), %rdi
	movslq	%ebp, %r9
	leaq	(%r9,%r9,2), %rdx
	movss	4(%rbx,%rdx,4), %xmm0           # xmm0 = mem[0],zero,zero,zero
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	ucomiss	4(%rbx,%rdi,4), %xmm0
	setbe	%dil
	seta	%r10b
	ja	.LBB4_13
# %bb.12:                               # %.lr.ph
                                        #   in Loop: Header=BB4_11 Depth=1
	movq	%r9, %rsi
.LBB4_13:                               # %.lr.ph
                                        #   in Loop: Header=BB4_11 Depth=1
	leaq	(%rsi,%rsi,2), %rsi
	movb	%r10b, %r8b
	addl	%r8d, %eax
	movb	%dil, %dl
	addl	%edx, %ebp
	movl	8(%rbx,%rsi,4), %edx
	movl	%edx, 8(%rcx)
	movq	(%rbx,%rsi,4), %rdx
	movq	%rdx, (%rcx)
	incl	%r13d
	cmpl	%r12d, %eax
	jg	.LBB4_2
# %bb.14:                               # %.lr.ph
                                        #   in Loop: Header=BB4_11 Depth=1
	addq	$12, %rcx
	cmpl	%r15d, %ebp
	jle	.LBB4_11
	jmp	.LBB4_2
.LBB4_1:
	movl	%r14d, %eax
.LBB4_2:                                # %.preheader54
	subl	%eax, %r12d
	jl	.LBB4_4
# %bb.3:                                # %.lr.ph63.preheader
	movl	%r13d, %ecx
	leaq	(%rcx,%rcx,2), %rcx
	leaq	(%r11,%rcx,4), %rdi
	cltq
	leaq	(%rax,%rax,2), %rax
	leaq	(%rbx,%rax,4), %rsi
	leaq	(%r12,%r12,2), %rax
	leaq	12(,%rax,4), %rdx
	movq	%r14, 8(%rsp)                   # 8-byte Spill
	movq	%r11, %r14
	callq	memcpy@PLT
	movq	%r14, %r11
	movq	8(%rsp), %r14                   # 8-byte Reload
	addl	%r12d, %r13d
	incl	%r13d
.LBB4_4:                                # %.preheader53
	movl	%r15d, %eax
	subl	%ebp, %eax
	jl	.LBB4_6
# %bb.5:                                # %.lr.ph68.preheader
	movl	%r13d, %ecx
	leaq	(%rcx,%rcx,2), %rcx
	leaq	(%r11,%rcx,4), %rdi
	movslq	%ebp, %rcx
	leaq	(%rcx,%rcx,2), %rcx
	leaq	(%rbx,%rcx,4), %rsi
	leaq	(%rax,%rax,2), %rax
	leaq	12(,%rax,4), %rdx
	movq	%r14, %r12
	movq	%r11, %r14
	callq	memcpy@PLT
	movq	%r14, %r11
	movq	%r12, %r14
.LBB4_6:                                # %.preheader
	cmpl	%r14d, %r15d
	jl	.LBB4_8
# %bb.7:                                # %.lr.ph71.preheader
	movslq	%r14d, %rax
	leaq	(%rax,%rax,2), %rax
	leaq	(%rbx,%rax,4), %rdi
	movl	16(%rsp), %eax                  # 4-byte Reload
	leaq	(%rax,%rax,2), %rax
	leaq	12(,%rax,4), %rdx
	movq	%r11, %rsi
	movq	%r11, %rbx
	callq	memcpy@PLT
	movq	%rbx, %r11
.LBB4_8:                                # %._crit_edge
	movq	%r11, %rdi
	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
	jmp	_ZdaPv                          # TAILCALL
.Lfunc_end4:
	.size	_Z5mergeP5entryii, .Lfunc_end4-_Z5mergeP5entryii
	.cfi_endproc
                                        # -- End function
	.globl	_Z9mergeSortP5entryii           # -- Begin function _Z9mergeSortP5entryii
	.type	_Z9mergeSortP5entryii,@function
_Z9mergeSortP5entryii:                  # @_Z9mergeSortP5entryii
	.cfi_startproc
# %bb.0:
	cmpl	%edx, %esi
	jge	.LBB5_1
# %bb.2:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movl	%esi, %r14d
	movq	%rdi, %r15
	leal	(%rbx,%r14), %eax
	movl	%eax, %ebp
	shrl	$31, %ebp
	addl	%eax, %ebp
	sarl	%ebp
	movl	%ebp, %edx
	callq	_Z9mergeSortP5entryii
	incl	%ebp
	movq	%r15, %rdi
	movl	%ebp, %esi
	movl	%ebx, %edx
	callq	_Z9mergeSortP5entryii
	movq	%r15, %rdi
	movl	%r14d, %esi
	movl	%ebx, %edx
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z5mergeP5entryii               # TAILCALL
.LBB5_1:                                # %common.ret13
	.cfi_restore %rbx
	.cfi_restore %rbp
	.cfi_restore %r14
	.cfi_restore %r15
	retq
.Lfunc_end5:
	.size	_Z9mergeSortP5entryii, .Lfunc_end5-_Z9mergeSortP5entryii
	.cfi_endproc
                                        # -- End function
	.globl	_Z7smoothcPfS_S_if              # -- Begin function _Z7smoothcPfS_S_if
	.type	_Z7smoothcPfS_S_if,@function
_Z7smoothcPfS_S_if:                     # @_Z7smoothcPfS_S_if
	.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
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movl	%ecx, %r15d
	movq	%rdx, %rbx
	movq	%rsi, %r13
	movq	%rdi, %rbp
	movslq	%ecx, %r12
	movl	$12, %ecx
	movq	%r12, %rax
	mulq	%rcx
	movq	$-1, %rdi
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	cmovnoq	%rax, %rdi
	callq	_Znam
	movq	%rax, %r14
	movl	%r12d, %edx
	testl	%r12d, %r12d
	movq	%rdx, 16(%rsp)                  # 8-byte Spill
	jle	.LBB6_9
# %bb.1:                                # %.lr.ph.preheader
	leaq	8(%r14), %rax
	xorl	%ecx, %ecx
.LBB6_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rbp,%rcx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	(%r13,%rcx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movl	%ecx, -8(%rax)
	movss	%xmm0, -4(%rax)
	movss	%xmm1, (%rax)
	incq	%rcx
	addq	$12, %rax
	cmpq	%rcx, %rdx
	jne	.LBB6_2
# %bb.3:                                # %._crit_edge
	leal	-1(%r15), %edx
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_Z9mergeSortP5entryii
	movq	16(%rsp), %rsi                  # 8-byte Reload
	cmpl	$83333333, %r15d                # imm = 0x4F790D5
	jb	.LBB6_10
# %bb.4:                                # %.preheader
	testl	%r15d, %r15d
	jle	.LBB6_28
# %bb.5:                                # %.lr.ph109.preheader
	xorl	%eax, %eax
	movq	%rbx, 40(%rsp)                  # 8-byte Spill
	movq	%r15, 32(%rsp)                  # 8-byte Spill
.LBB6_6:                                # %.lr.ph109
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_7 Depth 2
                                        #     Child Loop BB6_19 Depth 2
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	leaq	(%rax,%rax,2), %rax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movss	4(%r14,%rax,4), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm1
	subss	12(%rsp), %xmm1                 # 4-byte Folded Reload
	xorl	%eax, %eax
                                        # kill: def $r15d killed $r15d killed $r15 def $r15
.LBB6_7:                                # %.lr.ph.i
                                        #   Parent Loop BB6_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r15,%rax), %edx
	movl	%edx, %ecx
	shrl	$31, %ecx
	addl	%edx, %ecx
	sarl	%ecx
	movslq	%ecx, %rdx
	leaq	(%rdx,%rdx,2), %rdx
	ucomiss	4(%r14,%rdx,4), %xmm1
	jb	.LBB6_8
# %bb.16:                               # %.lr.ph.i
                                        #   in Loop: Header=BB6_7 Depth=2
	incl	%ecx
	movl	%ecx, %eax
	jmp	.LBB6_17
.LBB6_8:                                #   in Loop: Header=BB6_7 Depth=2
	movl	%ecx, %r15d
.LBB6_17:                               # %.lr.ph.i
                                        #   in Loop: Header=BB6_7 Depth=2
	cmpl	%r15d, %eax
	jne	.LBB6_7
# %bb.18:                               # %_Z16h_binarySearchLBP5entryfi.exit
                                        #   in Loop: Header=BB6_6 Depth=1
	addss	12(%rsp), %xmm0                 # 4-byte Folded Reload
	xorl	%eax, %eax
	movl	%esi, %ebx
.LBB6_19:                               # %.lr.ph.i91
                                        #   Parent Loop BB6_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rbx,%rax), %edx
	movl	%edx, %ecx
	shrl	$31, %ecx
	addl	%edx, %ecx
	sarl	%ecx
	movslq	%ecx, %rdx
	leaq	(%rdx,%rdx,2), %rdx
	movss	4(%r14,%rdx,4), %xmm1           # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jb	.LBB6_20
# %bb.21:                               # %.lr.ph.i91
                                        #   in Loop: Header=BB6_19 Depth=2
	movl	%ecx, %ebx
	jmp	.LBB6_22
.LBB6_20:                               #   in Loop: Header=BB6_19 Depth=2
	incl	%ecx
	movl	%ecx, %eax
.LBB6_22:                               # %.lr.ph.i91
                                        #   in Loop: Header=BB6_19 Depth=2
	cmpl	%ebx, %eax
	jne	.LBB6_19
# %bb.23:                               # %_Z16h_binarySearchUBP5entryfi.exit
                                        #   in Loop: Header=BB6_6 Depth=1
	movl	%ebx, %r13d
	subl	%r15d, %r13d
	movslq	%r13d, %r12
	movq	%r12, %rax
	movl	$12, %ecx
	mulq	%rcx
	movq	$-1, %rcx
	cmovoq	%rcx, %rax
	movq	%rax, %rdi
	callq	_Znam
	movq	%rax, %rbp
	testl	%r12d, %r12d
	jle	.LBB6_25
# %bb.24:                               # %.lr.ph106.preheader
                                        #   in Loop: Header=BB6_6 Depth=1
	movslq	%r15d, %rax
	leaq	(%rax,%rax,2), %rax
	leaq	(%r14,%rax,4), %rsi
	notl	%r15d
	addl	%r15d, %ebx
	leaq	(%rbx,%rbx,2), %rax
	leaq	12(,%rax,4), %rdx
	movq	%rbp, %rdi
	callq	memcpy@PLT
.LBB6_25:                               # %._crit_edge107
                                        #   in Loop: Header=BB6_6 Depth=1
	shlq	$2, %r12
	leaq	(%r12,%r12,2), %r12
	movq	%rsp, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	movq	(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movq	%rdi, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_27
# %bb.26:                               #   in Loop: Header=BB6_6 Depth=1
	movq	(%rsp), %rdi
	movl	%r13d, %esi
	callq	_Z22__device_stub__kernel2P5entryi
.LBB6_27:                               #   in Loop: Header=BB6_6 Depth=1
	movq	48(%rsp), %rax                  # 8-byte Reload
	leaq	(%r14,%rax,4), %rbx
	movq	(%rsp), %rsi
	movq	%rbp, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movss	8(%rbp), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	movslq	(%rbx), %rax
	movq	40(%rsp), %rbx                  # 8-byte Reload
	movss	%xmm0, (%rbx,%rax,4)
	movq	(%rsp), %rdi
	callq	hipFree
	movq	%rbp, %rdi
	callq	_ZdaPv
	movq	24(%rsp), %rax                  # 8-byte Reload
	incq	%rax
	movq	16(%rsp), %rsi                  # 8-byte Reload
	cmpq	%rsi, %rax
	movq	32(%rsp), %r15                  # 8-byte Reload
	jne	.LBB6_6
	jmp	.LBB6_28
.LBB6_9:                                # %._crit_edge.thread
	leal	-1(%r15), %edx
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_Z9mergeSortP5entryii
	cmpl	$1, %r15d
	jae	.LBB6_28
.LBB6_10:
	movq	%rsp, %r12
	movq	%r12, %rdi
	movq	24(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rsi
	callq	hipMalloc
	movq	(%r12), %rdi
	movq	%r14, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%r15d, %eax
	shrl	$10, %eax
	movabsq	$4294967297, %rdx               # imm = 0x100000001
	leaq	(%rax,%rdx), %rdi
	decq	%rdi
	addq	$1023, %rdx                     # imm = 0x3FF
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_12
# %bb.11:
	movq	(%rsp), %rdi
	movl	%r15d, %esi
	movss	12(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	callq	_Z22__device_stub__kernel1P5entryif
.LBB6_12:
	movq	(%rsp), %rsi
	movq	%r14, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%r15d, %r15d
	je	.LBB6_15
# %bb.13:                               # %.lr.ph112.preheader
	movq	16(%rsp), %rax                  # 8-byte Reload
	shlq	$2, %rax
	leaq	(%rax,%rax,2), %rax
	xorl	%ecx, %ecx
.LBB6_14:                               # %.lr.ph112
                                        # =>This Inner Loop Header: Depth=1
	movss	8(%r14,%rcx), %xmm0             # xmm0 = mem[0],zero,zero,zero
	movslq	(%r14,%rcx), %rdx
	movss	%xmm0, (%rbx,%rdx,4)
	addq	$12, %rcx
	cmpq	%rcx, %rax
	jne	.LBB6_14
.LBB6_15:                               # %._crit_edge113
	movq	(%rsp), %rdi
	callq	hipFree
.LBB6_28:                               # %.loopexit
	movq	%r14, %rdi
	callq	_ZdaPv
	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_end6:
	.size	_Z7smoothcPfS_S_if, .Lfunc_end6-_Z7smoothcPfS_S_if
	.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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7kernel1P5entryif, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7kernel2P5entryi, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z7kernel1P5entryif,@object     # @_Z7kernel1P5entryif
	.section	.rodata,"a",@progbits
	.globl	_Z7kernel1P5entryif
	.p2align	3, 0x0
_Z7kernel1P5entryif:
	.quad	_Z22__device_stub__kernel1P5entryif
	.size	_Z7kernel1P5entryif, 8

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

	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z7kernel1P5entryif"
	.size	.L__unnamed_1, 20

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z7kernel2P5entryi"
	.size	.L__unnamed_2, 19

	.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

	.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 _Z22__device_stub__kernel1P5entryif
	.addrsig_sym _Z22__device_stub__kernel2P5entryi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z7kernel1P5entryif
	.addrsig_sym _Z7kernel2P5entryi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7kernel1P5entryif     ; -- Begin function _Z7kernel1P5entryif
	.globl	_Z7kernel1P5entryif
	.p2align	8
	.type	_Z7kernel1P5entryif,@function
_Z7kernel1P5entryif:                    ; @_Z7kernel1P5entryif
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b128 s[4:7], s[0:1], 0x0
	s_mov_b32 s1, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s2, 0xffff
	s_cmp_lg_u32 s6, 0
	v_mad_u64_u32 v[1:2], null, s15, s0, v[0:1]
	v_mov_b32_e32 v0, 0
	s_cselect_b32 s0, -1, 0
	s_cmp_eq_u32 s6, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_mad_i64_i32 v[2:3], null, v1, 12, s[4:5]
	global_load_b32 v2, v[2:3], off offset:4
	s_cbranch_scc1 .LBB0_4
; %bb.1:                                ; %.lr.ph.i.preheader
	s_waitcnt vmcnt(0)
	v_dual_subrev_f32 v3, s7, v2 :: v_dual_mov_b32 v4, 0
	v_mov_b32_e32 v0, s6
.LBB0_2:                                ; %.lr.ph.i
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v5, v0, v4
	v_lshrrev_b32_e32 v6, 31, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v5, v5, v6
	v_ashrrev_i32_e32 v7, 1, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_i64_i32 v[5:6], null, v7, 12, s[4:5]
	global_load_b32 v5, v[5:6], off offset:4
	v_add_nc_u32_e32 v6, 1, v7
	s_waitcnt vmcnt(0)
	v_cmp_nle_f32_e32 vcc_lo, v5, v3
	v_cndmask_b32_e32 v0, v0, v7, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v4, v6, v4, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, v4, v0
	s_or_b32 s1, vcc_lo, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_2
; %bb.3:                                ; %Flow46
	s_or_b32 exec_lo, exec_lo, s1
.LBB0_4:                                ; %_Z14binarySearchLBP5entryfi.exit
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 vcc_lo, exec_lo, s0
	s_cbranch_vccnz .LBB0_8
; %bb.5:                                ; %.lr.ph.i26.preheader
	s_waitcnt vmcnt(0)
	v_dual_add_f32 v2, s7, v2 :: v_dual_mov_b32 v3, 0
	v_mov_b32_e32 v4, s6
	s_mov_b32 s0, 0
.LBB0_6:                                ; %.lr.ph.i26
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v5, v4, v3
	v_lshrrev_b32_e32 v6, 31, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v5, v5, v6
	v_ashrrev_i32_e32 v7, 1, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_i64_i32 v[5:6], null, v7, 12, s[4:5]
	global_load_b32 v5, v[5:6], off offset:4
	v_add_nc_u32_e32 v6, 1, v7
	s_waitcnt vmcnt(0)
	v_cmp_nge_f32_e32 vcc_lo, v5, v2
	v_cndmask_b32_e32 v4, v7, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v3, v3, v6, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, v3, v4
	s_or_b32 s0, vcc_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s0
	s_cbranch_execnz .LBB0_6
; %bb.7:                                ; %Flow44
	s_or_b32 exec_lo, exec_lo, s0
	s_branch .LBB0_9
.LBB0_8:
	v_mov_b32_e32 v4, 0
.LBB0_9:                                ; %_Z14binarySearchUBP5entryfi.exit
	v_mov_b32_e32 v5, 0
	s_mov_b32 s1, exec_lo
	s_delay_alu instid0(VALU_DEP_2)
	v_cmpx_gt_i32_e64 v4, v0
	s_cbranch_execz .LBB0_13
; %bb.10:                               ; %.lr.ph.preheader
	s_waitcnt vmcnt(0)
	v_mad_i64_i32 v[2:3], null, v0, 12, s[4:5]
	v_dual_mov_b32 v5, 0 :: v_dual_mov_b32 v6, v0
	s_mov_b32 s2, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v2, vcc_lo, v2, 8
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
.LBB0_11:                               ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v7, v[2:3], off
	v_add_nc_u32_e32 v6, 1, v6
	v_add_co_u32 v2, vcc_lo, v2, 12
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v5, v5, v7
	v_cmp_ge_i32_e64 s0, v6, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s2, s0, s2
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB0_11
; %bb.12:                               ; %Flow
	s_or_b32 exec_lo, exec_lo, s2
.LBB0_13:                               ; %Flow43
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s1
	v_sub_nc_u32_e32 v0, v4, v0
	v_cvt_f32_i32_e32 v0, v0
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_scale_f32 v2, null, v0, v0, v5
	v_rcp_f32_e32 v3, v2
	s_waitcnt_depctr 0xfff
	v_fma_f32 v4, -v2, v3, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v3, v4, v3
	v_div_scale_f32 v4, vcc_lo, v5, v0, v5
	v_mul_f32_e32 v6, v4, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v7, -v2, v6, v4
	v_fmac_f32_e32 v6, v7, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v2, -v2, v6, v4
	v_div_fmas_f32 v4, v2, v3, v6
	v_mad_i64_i32 v[2:3], null, v1, 12, s[4:5]
	s_delay_alu instid0(VALU_DEP_2)
	v_div_fixup_f32 v0, v4, v0, v5
	global_store_b32 v[2:3], v0, off offset:8
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel1P5entryif
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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	_Z7kernel1P5entryif, .Lfunc_end0-_Z7kernel1P5entryif
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 592
; 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
	.protected	_Z7kernel2P5entryi      ; -- Begin function _Z7kernel2P5entryi
	.globl	_Z7kernel2P5entryi
	.p2align	8
	.type	_Z7kernel2P5entryi,@function
_Z7kernel2P5entryi:                     ; @_Z7kernel2P5entryi
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x8
	s_load_b64 s[0:1], s[0:1], 0x0
	v_mov_b32_e32 v0, 0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s4, 1
	s_cbranch_scc1 .LBB1_3
; %bb.1:                                ; %.lr.ph.preheader
	s_add_u32 s2, s0, 8
	s_addc_u32 s3, s1, 0
	s_mov_b32 s5, s4
.LBB1_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s6, s[2:3], 0x0
	s_add_i32 s5, s5, -1
	s_add_u32 s2, s2, 12
	s_addc_u32 s3, s3, 0
	s_cmp_eq_u32 s5, 0
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v0, s6, v0
	s_cbranch_scc0 .LBB1_2
.LBB1_3:                                ; %Flow19
	v_cvt_f32_i32_e32 v1, s4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v2, null, v1, v1, v0
	v_div_scale_f32 v5, vcc_lo, v0, v1, v0
	v_rcp_f32_e32 v3, v2
	s_waitcnt_depctr 0xfff
	v_fma_f32 v4, -v2, v3, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v3, v4, v3
	v_mul_f32_e32 v4, v5, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v6, -v2, v4, v5
	v_fmac_f32_e32 v4, v6, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v2, -v2, v4, v5
	v_div_fmas_f32 v2, v2, v3, v4
	s_delay_alu instid0(VALU_DEP_1)
	v_div_fixup_f32 v0, v2, v1, v0
	v_mov_b32_e32 v1, 0
	global_store_b32 v1, v0, s[0:1] offset:8
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel2P5entryi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 12
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 7
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z7kernel2P5entryi, .Lfunc_end1-_Z7kernel2P5entryi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 208
; NumSgprs: 9
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 9
; NumVGPRsForWavesPerEU: 7
; 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
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7kernel1P5entryif
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel1P5entryif.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 12
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7kernel2P5entryi
    .private_segment_fixed_size: 0
    .sgpr_count:     9
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel2P5entryi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
