#include <cuda_runtime.h>
#include <stdio.h>     

unsigned char *d_red, *d_green, *d_blue;
float *d_filter;
uchar4 *d_inputImageRGBA__;
uchar4 *d_outputImageRGBA__;
float *h_filter__;

__global__ void gaussian_blur(const unsigned char* const inputChannel,
                   unsigned char* const outputChannel,
                   int numRows, int numCols, const float* const filter, const int filterWidth) {
  
	int col = blockIdx.x * blockDim.x + threadIdx.x;
	int row = blockIdx.y * blockDim.y + threadIdx.y;
	if ( col >= numCols || row >= numRows )
		return;

	float result = 0.f;
	
	//For every value in the filter around the pixel (c, r)
	for (int filter_r = -filterWidth/2; filter_r <= filterWidth/2; ++filter_r) {
		for (int filter_c = -filterWidth/2; filter_c <= filterWidth/2; ++filter_c) {
			//Find the global image position for this filter position
			//clamp to boundary of the image
			int image_r = min(max(row + filter_r, 0), static_cast<int>(numRows - 1));
			int image_c = min(max(col + filter_c, 0), static_cast<int>(numCols - 1));

			float image_value = static_cast<float>(inputChannel[image_r * numCols + image_c]);
			float filter_value = filter[(filter_r + filterWidth/2) * filterWidth + filter_c + filterWidth/2];

			result += image_value * filter_value;
		}
	}
	outputChannel[row * numCols + col] = result;
}

__global__ void separateChannels(const uchar4* const inputImageRGBA,
                      int numRows,
                      int numCols,
                      unsigned char* const redChannel,
                      unsigned char* const greenChannel,
                      unsigned char* const blueChannel) {

	int absolute_image_position_x = blockDim.x * blockIdx.x + threadIdx.x;
	int absolute_image_position_y = blockDim.y * blockIdx.y + threadIdx.y;

	if ( absolute_image_position_x >= numCols || absolute_image_position_y >= numRows )
		return;

	int thread_1D_pos = absolute_image_position_y * numCols + absolute_image_position_x;

	redChannel[thread_1D_pos] = inputImageRGBA[thread_1D_pos].x;
	greenChannel[thread_1D_pos] = inputImageRGBA[thread_1D_pos].y;
	blueChannel[thread_1D_pos] = inputImageRGBA[thread_1D_pos].z;
}

__global__ void recombineChannels(const unsigned char* const redChannel,
                       const unsigned char* const greenChannel,
                       const unsigned char* const blueChannel,
                       uchar4* const outputImageRGBA,
                       int numRows,
                       int numCols) {

	const int2 thread_2D_pos = make_int2( blockIdx.x * blockDim.x + threadIdx.x,
	                                    blockIdx.y * blockDim.y + threadIdx.y);

	const int thread_1D_pos = thread_2D_pos.y * numCols + thread_2D_pos.x;

	if (thread_2D_pos.x >= numCols || thread_2D_pos.y >= numRows)
	return;

	unsigned char red   = redChannel[thread_1D_pos];
	unsigned char green = greenChannel[thread_1D_pos];
	unsigned char blue  = blueChannel[thread_1D_pos];

	//Alpha should be 255 for no transparency
	uchar4 outputPixel = make_uchar4(red, green, blue, 255);

	outputImageRGBA[thread_1D_pos] = outputPixel;
}




void allocateMemoryAndCopyToGPU(const size_t numRowsImage, const size_t numColsImage, const float* const h_filter, const size_t filterWidth) { 
	//allocate memory for the three different channels
  	//original
	cudaMalloc(&d_red,   sizeof(unsigned char) * numRowsImage * numColsImage);
	cudaMalloc(&d_green, sizeof(unsigned char) * numRowsImage * numColsImage);
	cudaMalloc(&d_blue,  sizeof(unsigned char) * numRowsImage * numColsImage);

	//Allocate memory for the filter on the GPU
	cudaMalloc(&d_filter, sizeof(float)*filterWidth*filterWidth);
	cudaMemcpy(d_filter,h_filter,sizeof(float)*filterWidth*filterWidth,cudaMemcpyHostToDevice);
}

void cleanup() {
	cudaFree(d_red);
	cudaFree(d_green);
	cudaFree(d_blue);
	cudaFree(d_filter);
}


void setFilter(float **h_filter, int *filterWidth, int blurKernelWidth, float blurKernelSigma) { 
	//Normally blurKernelWidth = 9 and blurKernelSigma = 2.0 
	*h_filter = new float[blurKernelWidth * blurKernelWidth];
	*filterWidth = blurKernelWidth;
	float filterSum = 0.f; //for normalization

	for (int r = -blurKernelWidth/2; r <= blurKernelWidth/2; ++r) {
		for (int c = -blurKernelWidth/2; c <= blurKernelWidth/2; ++c) {
	  		float filterValue = expf( -(float)(c * c + r * r) / (2.f * blurKernelSigma * blurKernelSigma));
	  		(*h_filter)[(r + blurKernelWidth/2) * blurKernelWidth + c + blurKernelWidth/2] = filterValue;
	  		filterSum += filterValue;
		}
	}

	float normalizationFactor = 1.f / filterSum;

	for (int r = -blurKernelWidth/2; r <= blurKernelWidth/2; ++r) 
		for (int c = -blurKernelWidth/2; c <= blurKernelWidth/2; ++c) 
	  		(*h_filter)[(r + blurKernelWidth/2) * blurKernelWidth + c + blurKernelWidth/2] *= normalizationFactor;
}

uchar4* blur_ops(uchar4* d_inputImageRGBA, size_t numRows, size_t numCols, int blurKernelWidth) { 
	
	float blurKernelSigma = blurKernelWidth/4.0f;
  	//Set filter array
	float* h_filter;
	int filterWidth;
	setFilter(&h_filter, &filterWidth, blurKernelWidth, blurKernelSigma);

	//Set reasonable block size (i.e., number of threads per block)
	const dim3 blockSize(16,16,1);
	//Calculate Grid SIze
	int a=numCols/blockSize.x, b=numRows/blockSize.y;	
	const dim3 gridSize(a+1,b+1,1);
	const size_t numPixels = numRows * numCols;

	uchar4 *d_outputImageRGBA;
	cudaMalloc((void **)&d_outputImageRGBA, sizeof(uchar4) * numPixels);
	cudaMemset(d_outputImageRGBA, 0, numPixels * sizeof(uchar4)); //make sure no memory is left laying around

	d_inputImageRGBA__  = d_inputImageRGBA;
	d_outputImageRGBA__ = d_outputImageRGBA;

	//blurred
	unsigned char *d_redBlurred, *d_greenBlurred, *d_blueBlurred;
	cudaMalloc(&d_redBlurred,    sizeof(unsigned char) * numPixels);
	cudaMalloc(&d_greenBlurred,  sizeof(unsigned char) * numPixels);
	cudaMalloc(&d_blueBlurred,   sizeof(unsigned char) * numPixels);
	cudaMemset(d_redBlurred,   0, sizeof(unsigned char) * numPixels);
	cudaMemset(d_greenBlurred, 0, sizeof(unsigned char) * numPixels);
	cudaMemset(d_blueBlurred,  0, sizeof(unsigned char) * numPixels);

	allocateMemoryAndCopyToGPU(numRows, numCols, h_filter, filterWidth);

	//Launch a kernel for separating the RGBA image into different color channels
	separateChannels<<<gridSize, blockSize>>>(d_inputImageRGBA, numRows, numCols, d_red,d_green, d_blue);

	cudaDeviceSynchronize(); 

	//Call blur kernel here 3 times, once for each color channel.
	gaussian_blur<<<gridSize, blockSize>>>(d_red, d_redBlurred, numRows, numCols,  d_filter, filterWidth);
	gaussian_blur<<<gridSize, blockSize>>>(d_green, d_greenBlurred, numRows, numCols,  d_filter, filterWidth);
	gaussian_blur<<<gridSize, blockSize>>>(d_blue, d_blueBlurred, numRows, numCols,  d_filter, filterWidth);

	cudaDeviceSynchronize(); 

	//Now we recombine the results.
	recombineChannels<<<gridSize, blockSize>>>(d_redBlurred,
	                                    	d_greenBlurred,
	                                        d_blueBlurred,
	                                        d_outputImageRGBA,
	                                        numRows,
	                                        numCols);
	
	cudaDeviceSynchronize(); 

	//cleanup memory
	cleanup();
	cudaFree(d_redBlurred);
	cudaFree(d_greenBlurred);
	cudaFree(d_blueBlurred);

	cudaDeviceSynchronize(); 

	//Initialize memory on host for output uchar4*
	uchar4* h_out;
	h_out = (uchar4*)malloc(sizeof(uchar4) * numPixels);

	//copy output from device to host
	cudaMemcpy(h_out, d_outputImageRGBA, sizeof(uchar4) * numPixels, cudaMemcpyDeviceToHost);

	cudaDeviceSynchronize(); 

	//cleanup memory on device
	cudaFree(d_inputImageRGBA__);
	cudaFree(d_outputImageRGBA__);
	delete[] h_filter__;

	//return h_out
	return h_out;
}
	.file	"tmpxft_003b1cb4_00000000-6_blur_ops.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z26allocateMemoryAndCopyToGPUmmPKfm
	.type	_Z26allocateMemoryAndCopyToGPUmmPKfm, @function
_Z26allocateMemoryAndCopyToGPUmmPKfm:
.LFB2027:
	.cfi_startproc
	endbr64
	imulq	%rsi, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rcx, %rbx
	imulq	%rbx, %rbx
	movq	%rdi, %rbp
	movq	%rdi, %rsi
	leaq	d_red(%rip), %rdi
	call	cudaMalloc@PLT
	movq	%rbp, %rsi
	leaq	d_green(%rip), %rdi
	call	cudaMalloc@PLT
	salq	$2, %rbx
	movq	%rbp, %rsi
	leaq	d_blue(%rip), %rdi
	call	cudaMalloc@PLT
	movq	%rbx, %rsi
	leaq	d_filter(%rip), %rdi
	call	cudaMalloc@PLT
	movq	%rbx, %rdx
	movq	d_filter(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	movq	%r12, %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	$1, %ecx
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	cudaMemcpy@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z26allocateMemoryAndCopyToGPUmmPKfm, .-_Z26allocateMemoryAndCopyToGPUmmPKfm
	.globl	_Z7cleanupv
	.type	_Z7cleanupv, @function
_Z7cleanupv:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	d_red(%rip), %rdi
	call	cudaFree@PLT
	movq	d_green(%rip), %rdi
	call	cudaFree@PLT
	movq	d_blue(%rip), %rdi
	call	cudaFree@PLT
	movq	d_filter(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	cudaFree@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z7cleanupv, .-_Z7cleanupv
	.globl	_Z9setFilterPPfPiif
	.type	_Z9setFilterPPfPiif, @function
_Z9setFilterPPfPiif:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	movl	%edx, %edi
	imull	%edx, %edi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	movslq	%edi, %rdi
	salq	$2, %rdi
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movss	%xmm0, 8(%rsp)
	call	_Znam@PLT
	movl	$2, %ecx
	xorps	%xmm1, %xmm1
	movq	%rax, 0(%r13)
	movq	%rax, %r12
	movl	%ebx, %eax
	cltd
	movl	%ebx, 0(%rbp)
	idivl	%ecx
	xorl	%edx, %edx
	movl	%eax, %ebp
	negl	%ebp
	movl	%ebp, %r14d
.L7:
	movl	%ebp, %r15d
	negl	%r15d
	cmpl	%r14d, %r15d
	jl	.L9
	movl	%r14d, %esi
	movslq	%edx, %rax
	movslq	%ebp, %r13
	imull	%r14d, %esi
	leaq	(%r12,%rax,4), %rax
.L10:
	cmpl	%r13d, %r15d
	jl	.L17
	movss	8(%rsp), %xmm2
	movl	%r13d, %ecx
	movl	%edx, 28(%rsp)
	imull	%r13d, %ecx
	movq	%rax, 16(%rsp)
	incq	%r13
	addss	%xmm2, %xmm2
	mulss	8(%rsp), %xmm2
	movl	%esi, 12(%rsp)
	movss	%xmm1, 24(%rsp)
	addl	%esi, %ecx
	cvtsi2ssl	%ecx, %xmm0
	xorps	.LC1(%rip), %xmm0
	divss	%xmm2, %xmm0
	call	expf@PLT
	movq	16(%rsp), %rax
	movss	24(%rsp), %xmm1
	movl	28(%rsp), %edx
	movl	12(%rsp), %esi
	movss	%xmm0, (%rax)
	addss	%xmm0, %xmm1
	addq	$4, %rax
	jmp	.L10
.L17:
	incl	%r14d
	addl	%ebx, %edx
	jmp	.L7
.L9:
	movss	.LC2(%rip), %xmm0
	movl	%ebp, %esi
	xorl	%edx, %edx
	divss	%xmm1, %xmm0
.L11:
	cmpl	%esi, %r15d
	jl	.L6
	movslq	%edx, %rax
	movslq	%ebp, %rcx
	leaq	(%r12,%rax,4), %rax
.L14:
	cmpl	%ecx, %r15d
	jl	.L18
	movss	(%rax), %xmm1
	incq	%rcx
	addq	$4, %rax
	mulss	%xmm0, %xmm1
	movss	%xmm1, -4(%rax)
	jmp	.L14
.L18:
	incl	%esi
	addl	%ebx, %edx
	jmp	.L11
.L6:
	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
.LFE2029:
	.size	_Z9setFilterPPfPiif, .-_Z9setFilterPPfPiif
	.globl	_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi
	.type	_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi, @function
_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movl	%edx, 28(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 24(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L19
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z13gaussian_blurPKhPhiiPKfi(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L19:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi, .-_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi
	.globl	_Z13gaussian_blurPKhPhiiPKfi
	.type	_Z13gaussian_blurPKhPhiiPKfi, @function
_Z13gaussian_blurPKhPhiiPKfi:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi
	.cfi_endproc
.LFE2056:
	.size	_Z13gaussian_blurPKhPhiiPKfi, .-_Z13gaussian_blurPKhPhiiPKfi
	.globl	_Z53__device_stub__Z16separateChannelsPK6uchar4iiPhS2_S2_PK6uchar4iiPhS2_S2_
	.type	_Z53__device_stub__Z16separateChannelsPK6uchar4iiPhS2_S2_PK6uchar4iiPhS2_S2_, @function
_Z53__device_stub__Z16separateChannelsPK6uchar4iiPhS2_S2_PK6uchar4iiPhS2_S2_:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	84(%rsp), %rsi
	movl	%edx, 32(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 24(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 16(%rsp)
	movq	%r9, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L24
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z16separateChannelsPK6uchar4iiPhS2_S2_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L24:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z53__device_stub__Z16separateChannelsPK6uchar4iiPhS2_S2_PK6uchar4iiPhS2_S2_, .-_Z53__device_stub__Z16separateChannelsPK6uchar4iiPhS2_S2_PK6uchar4iiPhS2_S2_
	.globl	_Z16separateChannelsPK6uchar4iiPhS2_S2_
	.type	_Z16separateChannelsPK6uchar4iiPhS2_S2_, @function
_Z16separateChannelsPK6uchar4iiPhS2_S2_:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z53__device_stub__Z16separateChannelsPK6uchar4iiPhS2_S2_PK6uchar4iiPhS2_S2_
	.cfi_endproc
.LFE2058:
	.size	_Z16separateChannelsPK6uchar4iiPhS2_S2_, .-_Z16separateChannelsPK6uchar4iiPhS2_S2_
	.globl	_Z54__device_stub__Z17recombineChannelsPKhS0_S0_P6uchar4iiPKhS0_S0_P6uchar4ii
	.type	_Z54__device_stub__Z17recombineChannelsPKhS0_S0_P6uchar4iiPKhS0_S0_P6uchar4ii, @function
_Z54__device_stub__Z17recombineChannelsPKhS0_S0_P6uchar4iiPKhS0_S0_P6uchar4ii:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 12(%rsp)
	movl	%r9d, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z17recombineChannelsPKhS0_S0_P6uchar4ii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L29:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z54__device_stub__Z17recombineChannelsPKhS0_S0_P6uchar4iiPKhS0_S0_P6uchar4ii, .-_Z54__device_stub__Z17recombineChannelsPKhS0_S0_P6uchar4iiPKhS0_S0_P6uchar4ii
	.globl	_Z17recombineChannelsPKhS0_S0_P6uchar4ii
	.type	_Z17recombineChannelsPKhS0_S0_P6uchar4ii, @function
_Z17recombineChannelsPKhS0_S0_P6uchar4ii:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z54__device_stub__Z17recombineChannelsPKhS0_S0_P6uchar4iiPKhS0_S0_P6uchar4ii
	.cfi_endproc
.LFE2060:
	.size	_Z17recombineChannelsPKhS0_S0_P6uchar4ii, .-_Z17recombineChannelsPKhS0_S0_P6uchar4ii
	.globl	_Z8blur_opsP6uchar4mmi
	.type	_Z8blur_opsP6uchar4mmi, @function
_Z8blur_opsP6uchar4mmi:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	cvtsi2ssl	%ecx, %xmm0
	movq	%rdi, %r14
	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
	movq	%rdx, %rbp
	movl	%ecx, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rsi, %rbx
	movq	%rbp, %r12
	imulq	%rbx, %r12
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	mulss	.LC3(%rip), %xmm0
	leaq	4(%rsp), %rsi
	leaq	8(%rsp), %rdi
	leaq	0(,%r12,4), %r13
	call	_Z9setFilterPPfPiif
	movq	%rbp, %rax
	leaq	16(%rsp), %rdi
	movq	%r13, %rsi
	shrq	$4, %rax
	movl	$1, 68(%rsp)
	incl	%eax
	movl	%eax, 60(%rsp)
	movq	%rbx, %rax
	shrq	$4, %rax
	incl	%eax
	movl	%eax, 64(%rsp)
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdi
	movq	%r13, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movq	16(%rsp), %rax
	movq	%r12, %rsi
	leaq	24(%rsp), %rdi
	movq	%r14, d_inputImageRGBA__(%rip)
	movq	%rax, d_outputImageRGBA__(%rip)
	call	cudaMalloc@PLT
	movq	%r12, %rsi
	leaq	32(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	%r12, %rsi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movq	32(%rsp), %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movq	40(%rsp), %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movslq	4(%rsp), %rcx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	movq	8(%rsp), %rdx
	movq	%rcx, %r12
	call	_Z26allocateMemoryAndCopyToGPUmmPKfm
	movq	60(%rsp), %rdi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	68(%rsp), %esi
	movl	$1, %ecx
	movabsq	$68719476752, %rdx
	movl	$1, 56(%rsp)
	movq	%rdx, 48(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	movq	d_blue(%rip), %r9
	movl	%ebp, %edx
	movl	%ebx, %esi
	movq	%r14, %rdi
	movq	d_green(%rip), %r8
	movq	d_red(%rip), %rcx
	call	_Z53__device_stub__Z16separateChannelsPK6uchar4iiPhS2_S2_PK6uchar4iiPhS2_S2_
.L35:
	call	cudaDeviceSynchronize@PLT
	movl	56(%rsp), %ecx
	movl	68(%rsp), %esi
	xorl	%r9d, %r9d
	movq	48(%rsp), %rdx
	movq	60(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L36
	movq	d_filter(%rip), %r8
	movq	24(%rsp), %rsi
	movl	%ebp, %ecx
	movl	%ebx, %edx
	movq	d_red(%rip), %rdi
	movl	%r12d, %r9d
	call	_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi
.L36:
	movl	56(%rsp), %ecx
	movq	48(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	60(%rsp), %rdi
	movl	68(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	movq	d_filter(%rip), %r8
	movq	32(%rsp), %rsi
	movl	%ebp, %ecx
	movl	%ebx, %edx
	movq	d_green(%rip), %rdi
	movl	%r12d, %r9d
	call	_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi
.L37:
	movl	56(%rsp), %ecx
	movq	48(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	60(%rsp), %rdi
	movl	68(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L38
	movq	d_filter(%rip), %r8
	movq	40(%rsp), %rsi
	movl	%ebp, %ecx
	movl	%ebx, %edx
	movq	d_blue(%rip), %rdi
	movl	%r12d, %r9d
	call	_Z42__device_stub__Z13gaussian_blurPKhPhiiPKfiPKhPhiiPKfi
.L38:
	call	cudaDeviceSynchronize@PLT
	movl	56(%rsp), %ecx
	movl	68(%rsp), %esi
	xorl	%r9d, %r9d
	movq	48(%rsp), %rdx
	movq	60(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L39
	movq	16(%rsp), %rcx
	movq	40(%rsp), %rdx
	movl	%ebp, %r9d
	movl	%ebx, %r8d
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z54__device_stub__Z17recombineChannelsPKhS0_S0_P6uchar4iiPKhS0_S0_P6uchar4ii
.L39:
	call	cudaDeviceSynchronize@PLT
	call	_Z7cleanupv
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaDeviceSynchronize@PLT
	movq	%r13, %rdi
	call	malloc@PLT
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%r13, %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movq	d_inputImageRGBA__(%rip), %rdi
	call	cudaFree@PLT
	movq	d_outputImageRGBA__(%rip), %rdi
	call	cudaFree@PLT
	movq	h_filter__(%rip), %rdi
	testq	%rdi, %rdi
	je	.L34
	call	_ZdaPv@PLT
.L34:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	addq	$80, %rsp
	.cfi_def_cfa_offset 48
	movq	%rbx, %rax
	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
.LFE2030:
	.size	_Z8blur_opsP6uchar4mmi, .-_Z8blur_opsP6uchar4mmi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC4:
	.string	"_Z17recombineChannelsPKhS0_S0_P6uchar4ii"
.LC5:
	.string	"_Z16separateChannelsPK6uchar4iiPhS2_S2_"
.LC6:
	.string	"_Z13gaussian_blurPKhPhiiPKfi"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2062:
	.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	.LC4(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z17recombineChannelsPKhS0_S0_P6uchar4ii(%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	.LC5(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z16separateChannelsPK6uchar4iiPhS2_S2_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC6(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z13gaussian_blurPKhPhiiPKfi(%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
.LFE2062:
	.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	h_filter__
	.bss
	.align 8
	.type	h_filter__, @object
	.size	h_filter__, 8
h_filter__:
	.zero	8
	.globl	d_outputImageRGBA__
	.align 8
	.type	d_outputImageRGBA__, @object
	.size	d_outputImageRGBA__, 8
d_outputImageRGBA__:
	.zero	8
	.globl	d_inputImageRGBA__
	.align 8
	.type	d_inputImageRGBA__, @object
	.size	d_inputImageRGBA__, 8
d_inputImageRGBA__:
	.zero	8
	.globl	d_filter
	.align 8
	.type	d_filter, @object
	.size	d_filter, 8
d_filter:
	.zero	8
	.globl	d_blue
	.align 8
	.type	d_blue, @object
	.size	d_blue, 8
d_blue:
	.zero	8
	.globl	d_green
	.align 8
	.type	d_green, @object
	.size	d_green, 8
d_green:
	.zero	8
	.globl	d_red
	.align 8
	.type	d_red, @object
	.size	d_red, 8
d_red:
	.zero	8
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	-2147483648
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	1065353216
	.align 4
.LC3:
	.long	1048576000
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

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

unsigned char *d_red, *d_green, *d_blue;
float *d_filter;
uchar4 *d_inputImageRGBA__;
uchar4 *d_outputImageRGBA__;
float *h_filter__;

__global__ void gaussian_blur(const unsigned char* const inputChannel,
                   unsigned char* const outputChannel,
                   int numRows, int numCols, const float* const filter, const int filterWidth) {
  
	int col = blockIdx.x * blockDim.x + threadIdx.x;
	int row = blockIdx.y * blockDim.y + threadIdx.y;
	if ( col >= numCols || row >= numRows )
		return;

	float result = 0.f;
	
	//For every value in the filter around the pixel (c, r)
	for (int filter_r = -filterWidth/2; filter_r <= filterWidth/2; ++filter_r) {
		for (int filter_c = -filterWidth/2; filter_c <= filterWidth/2; ++filter_c) {
			//Find the global image position for this filter position
			//clamp to boundary of the image
			int image_r = min(max(row + filter_r, 0), static_cast<int>(numRows - 1));
			int image_c = min(max(col + filter_c, 0), static_cast<int>(numCols - 1));

			float image_value = static_cast<float>(inputChannel[image_r * numCols + image_c]);
			float filter_value = filter[(filter_r + filterWidth/2) * filterWidth + filter_c + filterWidth/2];

			result += image_value * filter_value;
		}
	}
	outputChannel[row * numCols + col] = result;
}

__global__ void separateChannels(const uchar4* const inputImageRGBA,
                      int numRows,
                      int numCols,
                      unsigned char* const redChannel,
                      unsigned char* const greenChannel,
                      unsigned char* const blueChannel) {

	int absolute_image_position_x = blockDim.x * blockIdx.x + threadIdx.x;
	int absolute_image_position_y = blockDim.y * blockIdx.y + threadIdx.y;

	if ( absolute_image_position_x >= numCols || absolute_image_position_y >= numRows )
		return;

	int thread_1D_pos = absolute_image_position_y * numCols + absolute_image_position_x;

	redChannel[thread_1D_pos] = inputImageRGBA[thread_1D_pos].x;
	greenChannel[thread_1D_pos] = inputImageRGBA[thread_1D_pos].y;
	blueChannel[thread_1D_pos] = inputImageRGBA[thread_1D_pos].z;
}

__global__ void recombineChannels(const unsigned char* const redChannel,
                       const unsigned char* const greenChannel,
                       const unsigned char* const blueChannel,
                       uchar4* const outputImageRGBA,
                       int numRows,
                       int numCols) {

	const int2 thread_2D_pos = make_int2( blockIdx.x * blockDim.x + threadIdx.x,
	                                    blockIdx.y * blockDim.y + threadIdx.y);

	const int thread_1D_pos = thread_2D_pos.y * numCols + thread_2D_pos.x;

	if (thread_2D_pos.x >= numCols || thread_2D_pos.y >= numRows)
	return;

	unsigned char red   = redChannel[thread_1D_pos];
	unsigned char green = greenChannel[thread_1D_pos];
	unsigned char blue  = blueChannel[thread_1D_pos];

	//Alpha should be 255 for no transparency
	uchar4 outputPixel = make_uchar4(red, green, blue, 255);

	outputImageRGBA[thread_1D_pos] = outputPixel;
}




void allocateMemoryAndCopyToGPU(const size_t numRowsImage, const size_t numColsImage, const float* const h_filter, const size_t filterWidth) { 
	//allocate memory for the three different channels
  	//original
	hipMalloc(&d_red,   sizeof(unsigned char) * numRowsImage * numColsImage);
	hipMalloc(&d_green, sizeof(unsigned char) * numRowsImage * numColsImage);
	hipMalloc(&d_blue,  sizeof(unsigned char) * numRowsImage * numColsImage);

	//Allocate memory for the filter on the GPU
	hipMalloc(&d_filter, sizeof(float)*filterWidth*filterWidth);
	hipMemcpy(d_filter,h_filter,sizeof(float)*filterWidth*filterWidth,hipMemcpyHostToDevice);
}

void cleanup() {
	hipFree(d_red);
	hipFree(d_green);
	hipFree(d_blue);
	hipFree(d_filter);
}


void setFilter(float **h_filter, int *filterWidth, int blurKernelWidth, float blurKernelSigma) { 
	//Normally blurKernelWidth = 9 and blurKernelSigma = 2.0 
	*h_filter = new float[blurKernelWidth * blurKernelWidth];
	*filterWidth = blurKernelWidth;
	float filterSum = 0.f; //for normalization

	for (int r = -blurKernelWidth/2; r <= blurKernelWidth/2; ++r) {
		for (int c = -blurKernelWidth/2; c <= blurKernelWidth/2; ++c) {
	  		float filterValue = expf( -(float)(c * c + r * r) / (2.f * blurKernelSigma * blurKernelSigma));
	  		(*h_filter)[(r + blurKernelWidth/2) * blurKernelWidth + c + blurKernelWidth/2] = filterValue;
	  		filterSum += filterValue;
		}
	}

	float normalizationFactor = 1.f / filterSum;

	for (int r = -blurKernelWidth/2; r <= blurKernelWidth/2; ++r) 
		for (int c = -blurKernelWidth/2; c <= blurKernelWidth/2; ++c) 
	  		(*h_filter)[(r + blurKernelWidth/2) * blurKernelWidth + c + blurKernelWidth/2] *= normalizationFactor;
}

uchar4* blur_ops(uchar4* d_inputImageRGBA, size_t numRows, size_t numCols, int blurKernelWidth) { 
	
	float blurKernelSigma = blurKernelWidth/4.0f;
  	//Set filter array
	float* h_filter;
	int filterWidth;
	setFilter(&h_filter, &filterWidth, blurKernelWidth, blurKernelSigma);

	//Set reasonable block size (i.e., number of threads per block)
	const dim3 blockSize(16,16,1);
	//Calculate Grid SIze
	int a=numCols/blockSize.x, b=numRows/blockSize.y;	
	const dim3 gridSize(a+1,b+1,1);
	const size_t numPixels = numRows * numCols;

	uchar4 *d_outputImageRGBA;
	hipMalloc((void **)&d_outputImageRGBA, sizeof(uchar4) * numPixels);
	hipMemset(d_outputImageRGBA, 0, numPixels * sizeof(uchar4)); //make sure no memory is left laying around

	d_inputImageRGBA__  = d_inputImageRGBA;
	d_outputImageRGBA__ = d_outputImageRGBA;

	//blurred
	unsigned char *d_redBlurred, *d_greenBlurred, *d_blueBlurred;
	hipMalloc(&d_redBlurred,    sizeof(unsigned char) * numPixels);
	hipMalloc(&d_greenBlurred,  sizeof(unsigned char) * numPixels);
	hipMalloc(&d_blueBlurred,   sizeof(unsigned char) * numPixels);
	hipMemset(d_redBlurred,   0, sizeof(unsigned char) * numPixels);
	hipMemset(d_greenBlurred, 0, sizeof(unsigned char) * numPixels);
	hipMemset(d_blueBlurred,  0, sizeof(unsigned char) * numPixels);

	allocateMemoryAndCopyToGPU(numRows, numCols, h_filter, filterWidth);

	//Launch a kernel for separating the RGBA image into different color channels
	separateChannels<<<gridSize, blockSize>>>(d_inputImageRGBA, numRows, numCols, d_red,d_green, d_blue);

	hipDeviceSynchronize(); 

	//Call blur kernel here 3 times, once for each color channel.
	gaussian_blur<<<gridSize, blockSize>>>(d_red, d_redBlurred, numRows, numCols,  d_filter, filterWidth);
	gaussian_blur<<<gridSize, blockSize>>>(d_green, d_greenBlurred, numRows, numCols,  d_filter, filterWidth);
	gaussian_blur<<<gridSize, blockSize>>>(d_blue, d_blueBlurred, numRows, numCols,  d_filter, filterWidth);

	hipDeviceSynchronize(); 

	//Now we recombine the results.
	recombineChannels<<<gridSize, blockSize>>>(d_redBlurred,
	                                    	d_greenBlurred,
	                                        d_blueBlurred,
	                                        d_outputImageRGBA,
	                                        numRows,
	                                        numCols);
	
	hipDeviceSynchronize(); 

	//cleanup memory
	cleanup();
	hipFree(d_redBlurred);
	hipFree(d_greenBlurred);
	hipFree(d_blueBlurred);

	hipDeviceSynchronize(); 

	//Initialize memory on host for output uchar4*
	uchar4* h_out;
	h_out = (uchar4*)malloc(sizeof(uchar4) * numPixels);

	//copy output from device to host
	hipMemcpy(h_out, d_outputImageRGBA, sizeof(uchar4) * numPixels, hipMemcpyDeviceToHost);

	hipDeviceSynchronize(); 

	//cleanup memory on device
	hipFree(d_inputImageRGBA__);
	hipFree(d_outputImageRGBA__);
	delete[] h_filter__;

	//return h_out
	return h_out;
}
	.text
	.file	"blur_ops.hip"
	.globl	_Z28__device_stub__gaussian_blurPKhPhiiPKfi # -- Begin function _Z28__device_stub__gaussian_blurPKhPhiiPKfi
	.type	_Z28__device_stub__gaussian_blurPKhPhiiPKfi,@function
_Z28__device_stub__gaussian_blurPKhPhiiPKfi: # @_Z28__device_stub__gaussian_blurPKhPhiiPKfi
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.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	20(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	16(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%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	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z13gaussian_blurPKhPhiiPKfi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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_end0:
	.size	_Z28__device_stub__gaussian_blurPKhPhiiPKfi, .Lfunc_end0-_Z28__device_stub__gaussian_blurPKhPhiiPKfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_ # -- Begin function _Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
	.type	_Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_,@function
_Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_: # @_Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.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	12(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	8(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	32(%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	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_, .Lfunc_end1-_Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii # -- Begin function _Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
	.type	_Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii,@function
_Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii: # @_Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.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	12(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	8(%rsp), %r8
	movl	%r9d, (%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	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii, .Lfunc_end2-_Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
	.cfi_endproc
                                        # -- End function
	.globl	_Z26allocateMemoryAndCopyToGPUmmPKfm # -- Begin function _Z26allocateMemoryAndCopyToGPUmmPKfm
	.type	_Z26allocateMemoryAndCopyToGPUmmPKfm,@function
_Z26allocateMemoryAndCopyToGPUmmPKfm:   # @_Z26allocateMemoryAndCopyToGPUmmPKfm
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rcx, %rbx
	movq	%rdx, %r14
	movq	%rsi, %r15
	imulq	%rdi, %r15
	movl	$d_red, %edi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	$d_green, %edi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	$d_blue, %edi
	movq	%r15, %rsi
	callq	hipMalloc
	imulq	%rbx, %rbx
	shlq	$2, %rbx
	movl	$d_filter, %edi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	d_filter(%rip), %rdi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	hipMemcpy                       # TAILCALL
.Lfunc_end3:
	.size	_Z26allocateMemoryAndCopyToGPUmmPKfm, .Lfunc_end3-_Z26allocateMemoryAndCopyToGPUmmPKfm
	.cfi_endproc
                                        # -- End function
	.globl	_Z7cleanupv                     # -- Begin function _Z7cleanupv
	.type	_Z7cleanupv,@function
_Z7cleanupv:                            # @_Z7cleanupv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	d_red(%rip), %rdi
	callq	hipFree
	movq	d_green(%rip), %rdi
	callq	hipFree
	movq	d_blue(%rip), %rdi
	callq	hipFree
	movq	d_filter(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	hipFree                         # TAILCALL
.Lfunc_end4:
	.size	_Z7cleanupv, .Lfunc_end4-_Z7cleanupv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z9setFilterPPfPiif
.LCPI5_0:
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI5_1:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z9setFilterPPfPiif
	.type	_Z9setFilterPPfPiif,@function
_Z9setFilterPPfPiif:                    # @_Z9setFilterPPfPiif
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.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	%edx, %ebx
	movq	%rsi, %r15
	movq	%rdi, %r14
	movl	%edx, %edi
	imull	%edi, %edi
	shlq	$2, %rdi
	callq	_Znam
	movq	%rax, (%r14)
	movl	%ebx, (%r15)
	movl	%ebx, %r15d
	shrl	$31, %r15d
	addl	%ebx, %r15d
	sarl	%r15d
	movl	%r15d, %eax
	negl	%eax
	cmpl	%r15d, %eax
	jg	.LBB5_10
# %bb.1:                                # %.preheader51.lr.ph
	movss	12(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm1
	addss	%xmm0, %xmm1
	mulss	%xmm0, %xmm1
	movl	%eax, %ecx
	leal	1(%r15), %r9d
	leal	(%rax,%r15), %r13d
	imull	%ebx, %r13d
	addl	%r15d, %r13d
	movl	%ebx, 16(%rsp)                  # 4-byte Spill
	movl	%ebx, %edx
	movq	%rdx, 48(%rsp)                  # 8-byte Spill
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	decl	%eax
	movl	%eax, 20(%rsp)                  # 4-byte Spill
	xorps	%xmm2, %xmm2
	movaps	.LCPI5_0(%rip), %xmm3           # xmm3 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
	movq	%r13, 32(%rsp)                  # 8-byte Spill
	movq	%rcx, 56(%rsp)                  # 8-byte Spill
	movq	%rcx, %rbx
	movl	%r9d, 24(%rsp)                  # 4-byte Spill
	movss	%xmm1, 28(%rsp)                 # 4-byte Spill
.LBB5_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_3 Depth 2
	movq	%rbx, 64(%rsp)                  # 8-byte Spill
	imulq	%rbx, %rbx
	movl	20(%rsp), %ebp                  # 4-byte Reload
	movq	56(%rsp), %r12                  # 8-byte Reload
.LBB5_3:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	%xmm2, 12(%rsp)                 # 4-byte Spill
	movl	%r12d, %eax
	imull	%r12d, %eax
	addl	%ebx, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	xorps	%xmm3, %xmm0
	divss	%xmm1, %xmm0
	callq	expf
	movaps	.LCPI5_0(%rip), %xmm3           # xmm3 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
	movss	12(%rsp), %xmm2                 # 4-byte Reload
                                        # xmm2 = mem[0],zero,zero,zero
	movss	28(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	movq	(%r14), %rax
	leal	(%r13,%r12), %ecx
	movslq	%ecx, %rcx
	movss	%xmm0, (%rax,%rcx,4)
	addss	%xmm0, %xmm2
	incq	%r12
	incl	%ebp
	cmpl	%ebp, %r15d
	jne	.LBB5_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	movq	64(%rsp), %rbx                  # 8-byte Reload
	incq	%rbx
	addq	48(%rsp), %r13                  # 8-byte Folded Reload
	movl	24(%rsp), %r9d                  # 4-byte Reload
	cmpl	%ebx, %r9d
	jne	.LBB5_2
# %bb.5:                                # %._crit_edge58
	movq	40(%rsp), %r8                   # 8-byte Reload
	cmpl	%r15d, %r8d
	movl	16(%rsp), %edi                  # 4-byte Reload
	movq	32(%rsp), %r10                  # 8-byte Reload
	jg	.LBB5_10
# %bb.6:                                # %.preheader.lr.ph
	movss	.LCPI5_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	divss	%xmm2, %xmm0
	movl	%r8d, %ecx
.LBB5_7:                                # %.lr.ph63
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_8 Depth 2
	movl	%r8d, %edx
.LBB5_8:                                #   Parent Loop BB5_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r10,%rdx), %esi
	movslq	%esi, %rsi
	movss	(%rax,%rsi,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%rax,%rsi,4)
	incl	%edx
	cmpl	%edx, %r9d
	jne	.LBB5_8
# %bb.9:                                # %._crit_edge64
                                        #   in Loop: Header=BB5_7 Depth=1
	leal	1(%rcx), %edx
	addl	%edi, %r10d
	cmpl	%r15d, %ecx
	movl	%edx, %ecx
	jne	.LBB5_7
.LBB5_10:                               # %._crit_edge67
	addq	$72, %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_end5:
	.size	_Z9setFilterPPfPiif, .Lfunc_end5-_Z9setFilterPPfPiif
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z8blur_opsP15HIP_vector_typeIhLj4EEmmi
.LCPI6_0:
	.long	0x3e800000                      # float 0.25
	.text
	.globl	_Z8blur_opsP15HIP_vector_typeIhLj4EEmmi
	.type	_Z8blur_opsP15HIP_vector_typeIhLj4EEmmi,@function
_Z8blur_opsP15HIP_vector_typeIhLj4EEmmi: # @_Z8blur_opsP15HIP_vector_typeIhLj4EEmmi
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.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	%rdx, %r14
	movq	%rsi, %r15
	cvtsi2ss	%ecx, %xmm0
	movq	%rdi, %r13
	mulss	.LCPI6_0(%rip), %xmm0
	leaq	64(%rsp), %rdi
	leaq	28(%rsp), %rsi
	movl	%ecx, %edx
	callq	_Z9setFilterPPfPiif
	movq	%r14, 48(%rsp)                  # 8-byte Spill
	movq	%r14, %rax
	shrq	$4, %rax
	incl	%eax
	movq	%r15, %rcx
	andq	$-16, %rcx
	shlq	$28, %rcx
	orq	%rax, %rcx
	movabsq	$4294967296, %r12               # imm = 0x100000000
	addq	%rcx, %r12
	imulq	%r15, %r14
	leaq	(,%r14,4), %rbx
	leaq	32(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	(%rbp), %rdi
	xorl	%esi, %esi
	movq	%rbx, 56(%rsp)                  # 8-byte Spill
	movq	%rbx, %rdx
	callq	hipMemset
	movq	%r13, 40(%rsp)                  # 8-byte Spill
	movq	%r13, d_inputImageRGBA__(%rip)
	movq	(%rbp), %rax
	movq	%rax, d_outputImageRGBA__(%rip)
	leaq	16(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	%rsp, %r13
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbp), %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	hipMemset
	movq	(%rbx), %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	callq	hipMemset
	movq	(%r13), %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	movq	%r15, %r14
	movq	48(%rsp), %rbx                  # 8-byte Reload
	movabsq	$68719476752, %r15              # imm = 0x1000000010
	callq	hipMemset
	leaq	64(%rsp), %rax
	movq	(%rax), %rdx
	leaq	28(%rsp), %rax
	movl	(%rax), %ebp
	movslq	%ebp, %rcx
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_Z26allocateMemoryAndCopyToGPUmmPKfm
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_2
# %bb.1:
	movq	d_red(%rip), %rcx
	movq	d_green(%rip), %r8
	movq	d_blue(%rip), %r9
	movq	40(%rsp), %rdi                  # 8-byte Reload
	movl	%r14d, %esi
	movl	%ebx, %edx
	callq	_Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
.LBB6_2:
	callq	hipDeviceSynchronize
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_4
# %bb.3:
	movq	d_red(%rip), %rdi
	movq	16(%rsp), %rsi
	movq	d_filter(%rip), %r8
	movl	%r14d, %edx
	movl	%ebx, %ecx
	movl	%ebp, %r9d
	callq	_Z28__device_stub__gaussian_blurPKhPhiiPKfi
.LBB6_4:
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_6
# %bb.5:
	movq	d_green(%rip), %rdi
	movq	8(%rsp), %rsi
	movq	d_filter(%rip), %r8
	movl	%r14d, %edx
	movl	%ebx, %ecx
	movl	%ebp, %r9d
	callq	_Z28__device_stub__gaussian_blurPKhPhiiPKfi
.LBB6_6:
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_8
# %bb.7:
	movq	d_blue(%rip), %rdi
	movq	(%rsp), %rsi
	movq	d_filter(%rip), %r8
	movl	%r14d, %edx
	movl	%ebx, %ecx
	movl	%ebp, %r9d
	callq	_Z28__device_stub__gaussian_blurPKhPhiiPKfi
.LBB6_8:
	callq	hipDeviceSynchronize
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_10
# %bb.9:
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	movq	32(%rsp), %rcx
	movl	%r14d, %r8d
	movl	%ebx, %r9d
	callq	_Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
.LBB6_10:
	callq	hipDeviceSynchronize
	callq	_Z7cleanupv
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	callq	hipDeviceSynchronize
	movq	56(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	32(%rsp), %rsi
	movq	%rax, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movq	d_inputImageRGBA__(%rip), %rdi
	callq	hipFree
	movq	d_outputImageRGBA__(%rip), %rdi
	callq	hipFree
	movq	h_filter__(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB6_12
# %bb.11:
	callq	_ZdaPv
.LBB6_12:
	movq	%r14, %rax
	addq	$72, %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	_Z8blur_opsP15HIP_vector_typeIhLj4EEmmi, .Lfunc_end6-_Z8blur_opsP15HIP_vector_typeIhLj4EEmmi
	.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	$_Z13gaussian_blurPKhPhiiPKfi, %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	$_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %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	d_red,@object                   # @d_red
	.bss
	.globl	d_red
	.p2align	3, 0x0
d_red:
	.quad	0
	.size	d_red, 8

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

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

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

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

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

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

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

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

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

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

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_"
	.size	.L__unnamed_2, 57

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii"
	.size	.L__unnamed_3, 58

	.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 _Z28__device_stub__gaussian_blurPKhPhiiPKfi
	.addrsig_sym _Z31__device_stub__separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
	.addrsig_sym _Z32__device_stub__recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym d_red
	.addrsig_sym d_green
	.addrsig_sym d_blue
	.addrsig_sym d_filter
	.addrsig_sym _Z13gaussian_blurPKhPhiiPKfi
	.addrsig_sym _Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
	.addrsig_sym _Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13gaussian_blurPKhPhiiPKfi ; -- Begin function _Z13gaussian_blurPKhPhiiPKfi
	.globl	_Z13gaussian_blurPKhPhiiPKfi
	.p2align	8
	.type	_Z13gaussian_blurPKhPhiiPKfi,@function
_Z13gaussian_blurPKhPhiiPKfi:           ; @_Z13gaussian_blurPKhPhiiPKfi
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b64 s[8:9], s[0:1], 0x10
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s9, v0
	v_cmp_gt_i32_e64 s2, s8, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_9
; %bb.1:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x20
	s_load_b128 s[4:7], s[0:1], 0x0
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s3, s2, s3
	s_ashr_i32 s3, s3, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_sub_i32 s10, 0, s3
	s_cmp_gt_i32 s10, s3
	s_cbranch_scc1 .LBB0_8
; %bb.2:                                ; %.preheader.lr.ph
	s_load_b64 s[0:1], s[0:1], 0x18
	s_add_i32 s11, s10, s3
	v_mov_b32_e32 v2, 0
	s_mul_i32 s12, s2, s11
	s_add_i32 s8, s8, -1
	s_add_i32 s11, s9, -1
	s_add_i32 s12, s3, s12
	s_mov_b32 s13, s10
.LBB0_3:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v3, s13, v1
	s_mov_b32 s14, s10
	v_maxmin_i32 v3, v3, 0, s8
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_lo_u32 v3, v3, s9
.LBB0_4:                                ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v4, s14, v0
	s_add_i32 s16, s12, s14
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s17, s16, 31
	s_lshl_b64 s[16:17], s[16:17], 2
	s_delay_alu instid0(VALU_DEP_1)
	v_maxmin_i32 v4, v4, 0, s11
	s_waitcnt lgkmcnt(0)
	s_add_u32 s16, s0, s16
	s_addc_u32 s17, s1, s17
	s_load_b32 s15, s[16:17], 0x0
	v_add_nc_u32_e32 v4, v4, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v5, 31, v4
	v_add_co_u32 v4, vcc_lo, s4, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo
	global_load_u8 v4, v[4:5], off
	s_waitcnt vmcnt(0)
	v_cvt_f32_ubyte0_e32 v4, v4
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_fmac_f32_e32 v2, s15, v4
	s_add_i32 s15, s14, 1
	s_cmp_ge_i32 s14, s3
	s_mov_b32 s14, s15
	s_cbranch_scc0 .LBB0_4
; %bb.5:                                ; %._crit_edge
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_add_i32 s14, s13, 1
	s_add_i32 s12, s12, s2
	s_cmp_ge_i32 s13, s3
	s_cbranch_scc1 .LBB0_7
; %bb.6:                                ;   in Loop: Header=BB0_3 Depth=1
	s_mov_b32 s13, s14
	s_branch .LBB0_3
.LBB0_7:                                ; %._crit_edge55.loopexit
	v_cvt_i32_f32_e32 v2, v2
.LBB0_8:                                ; %._crit_edge55
	v_mad_u64_u32 v[3:4], null, v1, s9, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v1, 31, v3
	v_add_co_u32 v0, vcc_lo, s6, v3
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_store_b8 v[0:1], v2, off
.LBB0_9:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13gaussian_blurPKhPhiiPKfi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 18
		.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	_Z13gaussian_blurPKhPhiiPKfi, .Lfunc_end0-_Z13gaussian_blurPKhPhiiPKfi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 428
; NumSgprs: 20
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 20
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_ ; -- Begin function _Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
	.globl	_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
	.p2align	8
	.type	_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_,@function
_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_: ; @_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x34
	s_load_b64 s[2:3], s[0:1], 0x8
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s5, s4, 16
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s4, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s5, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s3, v0
	v_cmp_gt_i32_e64 s2, s2, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s4, s2
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_clause 0x1
	s_load_b64 s[8:9], s[0:1], 0x0
	s_load_b128 s[4:7], s[0:1], 0x10
	v_mad_u64_u32 v[2:3], null, v1, s3, v[0:1]
	s_load_b64 s[0:1], s[0:1], 0x20
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s8, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s9, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v3, vcc_lo
	global_load_u8 v6, v[0:1], off
	s_waitcnt vmcnt(0)
	global_store_b8 v[4:5], v6, off
	global_load_u8 v6, v[0:1], off offset:1
	v_add_co_u32 v4, vcc_lo, s6, v2
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v3, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b8 v[4:5], v6, off
	global_load_u8 v4, v[0:1], off offset:2
	v_add_co_u32 v0, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v3, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b8 v[0:1], v4, off
.LBB1_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_, .Lfunc_end1-_Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 284
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii ; -- Begin function _Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
	.globl	_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
	.p2align	8
	.type	_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii,@function
_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii: ; @_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x34
	s_load_b64 s[2:3], s[0:1], 0x20
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s5, s4, 16
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s4, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s5, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s3, v0
	v_cmp_gt_i32_e64 s2, s2, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s4, s2
	s_cbranch_execz .LBB2_2
; %bb.1:
	s_load_b256 s[4:11], s[0:1], 0x0
	v_mad_u64_u32 v[2:3], null, v1, s3, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v3, 31, v2
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v3, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v2
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v3, vcc_lo
	v_add_co_u32 v6, vcc_lo, s8, v2
	v_add_co_ci_u32_e32 v7, vcc_lo, s9, v3, vcc_lo
	global_load_u8 v4, v[4:5], off
	global_load_u8 v5, v[6:7], off
	global_load_u8 v0, v[0:1], off
	s_waitcnt vmcnt(2)
	v_lshlrev_b16 v1, 8, v4
	s_waitcnt vmcnt(1)
	v_or_b32_e32 v4, 0xffffff00, v5
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_or_b32_e32 v0, v0, v1
	v_lshlrev_b32_e32 v4, 16, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_and_b32_e32 v5, 0xffff, v0
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	v_or_b32_e32 v2, v5, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v0, vcc_lo, s10, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s11, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB2_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.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_end2:
	.size	_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii, .Lfunc_end2-_Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 292
; 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: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13gaussian_blurPKhPhiiPKfi
    .private_segment_fixed_size: 0
    .sgpr_count:     20
    .sgpr_spill_count: 0
    .symbol:         _Z13gaussian_blurPKhPhiiPKfi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .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
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z16separateChannelsPK15HIP_vector_typeIhLj4EEiiPhS3_S3_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17recombineChannelsPKhS0_S0_P15HIP_vector_typeIhLj4EEii.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
