// Salt and pepper noise simulation with Cuda C/C++
// Original framework for code taken from imflipG.cu
// Modified by Ethan Webster

#include <cuda_runtime.h>
#include <curand_kernel.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <ctype.h>
#include <cuda.h>
#include <time.h>

#define DATAMB(bytes)			(bytes/1024/1024)
#define DATABW(bytes,timems)	((float)bytes/(timems * 1.024*1024.0*1024.0))
#define	CEIL(a,b)				((a+b-1)/b)

typedef unsigned char uch;
typedef unsigned long ul;
typedef unsigned int  ui;

uch *TheImg, *CopyImg;					// Where images are stored in CPU
uch *GPUImg, *GPUCopyImg, *GPUptr, *GPUResult;	// Where images are stored in GPU


struct ImgProp{
	int Hpixels;
	int Vpixels;
	uch HeaderInfo[54];
	ul Hbytes;
} ip;


#define	IPHB		ip.Hbytes
#define	IPH			ip.Hpixels
#define	IPV			ip.Vpixels
#define	IMAGESIZE	(IPHB*IPV)
#define	IMAGEPIX	(IPH*IPV)


// Kernel that adds salt&pepper noise of given probability density to an image
__global__
void corruptPixels(uch *ImgDst, uch *ImgSrc, ui Hpixels, ui Vpixels, double prob)
{
	// threads/blocks info and IDs
	ui ThrPerBlk = blockDim.x;
	ui MYbid = blockIdx.x;
	ui MYtid = threadIdx.x;
	ui MYgtid = ThrPerBlk * MYbid + MYtid;

	//ui NumBlocks = gridDim.x;
	ui BlkPerRow = CEIL(Hpixels, ThrPerBlk);
	ui MYrow = MYbid / BlkPerRow;
	ui MYcol = MYgtid - MYrow*BlkPerRow*ThrPerBlk;

	// leave buffer frame around image to avoid 8 edge cases for convolutions
	if (MYcol > Hpixels-4 || MYcol < 3 || MYrow > Vpixels-4 || MYrow < 3) return;

	ui MYpixIndex = MYrow * Hpixels + MYcol; // pixel index in B&W image

	ui RowBytes = (Hpixels * 3 + 3) & (~3);  // bytes in row of R=G=B grayscale output image

	ui MYresultIndex = MYrow * RowBytes + 3 * MYcol; // pixel index in grayscale image (R=B=G)

	// seed cuRAND random number generator function with clock cycle + threadID
	curandState state;
	curand_init((unsigned long long)clock() + MYtid, 0, 0, &state);

	// sample uniform distribution from 0 to 255 (random pixel intensity)
	ui loc = ((ui)(curand(&state)))%255;

/* 
	half of the probability is used for the following because
	the salt vs pepper contribution is split 50/50 
*/
	// if pixel intensity is located in the lower half of the 
	// probability region, then add pepper noise
	if( loc <= (ui)(prob/2.0f)) {
		ImgDst[MYresultIndex] = 0;
		ImgDst[MYresultIndex+1] = 0;
		ImgDst[MYresultIndex+2] = 0;
	}

	// otherwise if pixel intensity is located in the upper half of the 
	// probability region, then add salt noise
	else if(loc > (ui)(prob/2.0f) && loc < (ui)prob ) {
		ImgDst[MYresultIndex] = 255;
		ImgDst[MYresultIndex+1] = 255;
		ImgDst[MYresultIndex+2] = 255;
	}

	// if we reached this, then no noise is added
	else {
		ImgDst[MYresultIndex] = ImgSrc[MYpixIndex];
		ImgDst[MYresultIndex+1] = ImgSrc[MYpixIndex];
		ImgDst[MYresultIndex+2] = ImgSrc[MYpixIndex];
	}


}


// Kernel that calculates a B&W image from an RGB image
// resulting image has a double type for each pixel position
__global__
void BWKernel(uch *ImgBW, uch *ImgGPU, ui Hpixels)
{
	ui ThrPerBlk = blockDim.x;
	ui MYbid = blockIdx.x;
	ui MYtid = threadIdx.x;
	ui MYgtid = ThrPerBlk * MYbid + MYtid;
	double R, G, B;

	//ui NumBlocks = gridDim.x;
	ui BlkPerRow = CEIL(Hpixels, ThrPerBlk);
	ui RowBytes = (Hpixels * 3 + 3) & (~3);
	ui MYrow = MYbid / BlkPerRow;
	ui MYcol = MYgtid - MYrow*BlkPerRow*ThrPerBlk;
	if (MYcol >= Hpixels) return;			// col out of range

	ui MYsrcIndex = MYrow * RowBytes + 3 * MYcol;
	ui MYpixIndex = MYrow * Hpixels + MYcol;

	B = (double)ImgGPU[MYsrcIndex];
	G = (double)ImgGPU[MYsrcIndex + 1];
	R = (double)ImgGPU[MYsrcIndex + 2];
	ImgBW[MYpixIndex] = (uch)((R+G+B)/3.0);
}


// Kernel that copies an image from one part of the
// GPU memory (ImgSrc) to another (ImgDst)
__global__
void PixCopy(uch *ImgDst, uch *ImgSrc, ui FS)
{
	ui ThrPerBlk = blockDim.x;
	ui MYbid = blockIdx.x;
	ui MYtid = threadIdx.x;
	ui MYgtid = ThrPerBlk * MYbid + MYtid;

	if (MYgtid > FS) return;				// outside the allocated memory
	ImgDst[MYgtid] = ImgSrc[MYgtid];
}



// Read a 24-bit/pixel BMP file into a 1D linear array.
// Allocate memory to store the 1D image and return its pointer.
uch *ReadBMPlin(char* fn)
{
	static uch *Img;
	FILE* f = fopen(fn, "rb");
	if (f == NULL){	printf("\n\n%s NOT FOUND\n\n", fn);	exit(EXIT_FAILURE); }

	uch HeaderInfo[54];
	fread(HeaderInfo, sizeof(uch), 54, f); // read the 54-byte header
	// extract image height and width from header
	int width = *(int*)&HeaderInfo[18];			ip.Hpixels = width;
	int height = *(int*)&HeaderInfo[22];		ip.Vpixels = height;
	int RowBytes = (width * 3 + 3) & (~3);		ip.Hbytes = RowBytes;
	//save header for re-use
	memcpy(ip.HeaderInfo, HeaderInfo,54);
	printf("\n Input File name: %17s  (%u x %u)   File Size=%u", fn, 
			ip.Hpixels, ip.Vpixels, IMAGESIZE);
	// allocate memory to store the main image (1 Dimensional array)
	Img  = (uch *)malloc(IMAGESIZE);
	if (Img == NULL) return Img;      // Cannot allocate memory
	// read the image from disk
	fread(Img, sizeof(uch), IMAGESIZE, f);
	fclose(f);
	return Img;
}


// Write the 1D linear-memory stored image into file.
void WriteBMPlin(uch *Img, char* fn)
{
	FILE* f = fopen(fn, "wb");
	if (f == NULL){ printf("\n\nFILE CREATION ERROR: %s\n\n", fn); exit(1); }
	//write header
	fwrite(ip.HeaderInfo, sizeof(uch), 54, f);
	//write data
	fwrite(Img, sizeof(uch), IMAGESIZE, f);
	printf("\nOutput File name: %17s  (%u x %u)   File Size=%u", fn, ip.Hpixels, ip.Vpixels, IMAGESIZE);
	fclose(f);
}


int main(int argc, char **argv)
{

	cudaError_t cudaStatus;
	char InputFileName[255], OutputFileName[255], ProgName[255];
	ui BlkPerRow, ThrPerBlk=256, NumBlocks;
	//cudaDeviceProp GPUprop;
	//ul SupportedKBlocks, SupportedMBlocks, MaxThrPerBlk;		char SupportedBlocks[100]; 

	ui amt, GPUtotalBufferSize;

	double inputNL;

	strcpy(ProgName, "randNoise");
	switch (argc){
	case 5:  ThrPerBlk=atoi(argv[4]);
	case 4:  amt=atoi(argv[3]);
	case 3:  strcpy(InputFileName, argv[1]);
			 strcpy(OutputFileName, argv[2]);
			 break;
	default: printf("\n\nUsage:   %s InputFilename OutputFilename [NoiseDensity] [ThrPerBlk]", ProgName);
			 printf("\n\nExample: %s Astronaut.bmp Output.bmp", ProgName);
			 printf("\n\nExample: %s Astronaut.bmp Output.bmp 50", ProgName);
			 printf("\n\nExample: %s Astronaut.bmp Output.bmp 50  128",ProgName);
			 printf("\n\nNoise Density is in percent, from 0-100\n\n");
			 exit(EXIT_FAILURE);
	}
	if (amt > 100) {
		printf("Invalid noise amount. Must be between 0 and 100");
		exit(EXIT_FAILURE);
	}
	if ((ThrPerBlk < 32) || (ThrPerBlk > 1024)) {
		printf("Invalid ThrPerBlk option '%u'. Must be between 32 and 1024. \n", ThrPerBlk);
		exit(EXIT_FAILURE);
	}

	// Create CPU memory to store the input and output images
	TheImg = ReadBMPlin(InputFileName); // Read the input image if memory can be allocated
	if (TheImg == NULL){
		printf("Cannot allocate memory for the input image...\n");
		exit(EXIT_FAILURE);
	}
	CopyImg = (uch *)malloc(IMAGESIZE);
	if (CopyImg == NULL){
		free(TheImg);
		printf("Cannot allocate memory for the input image...\n");
		exit(EXIT_FAILURE);
	}


	// Choose which GPU to run on, change this on a multi-GPU system.
	int NumGPUs = 0;
	cudaGetDeviceCount(&NumGPUs);
	if (NumGPUs == 0){
		printf("\nNo CUDA Device is available\n");
		exit(EXIT_FAILURE);
	}
	cudaStatus = cudaSetDevice(0);
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaSetDevice failed!  Do you have a CUDA-capable GPU installed?");
		exit(EXIT_FAILURE);
	}

	
	// cudaGetDeviceProperties(&GPUprop, 0);
	// SupportedKBlocks = (ui)GPUprop.maxGridSize[0] * (ui)GPUprop.maxGridSize[1] * (ui)GPUprop.maxGridSize[2] / 1024;
	// SupportedMBlocks = SupportedKBlocks / 1024;
	// sprintf(SupportedBlocks, "%u %c", (SupportedMBlocks >= 5) ? SupportedMBlocks : SupportedKBlocks, (SupportedMBlocks >= 5) ? 'M' : 'K');
	// MaxThrPerBlk = (ui)GPUprop.maxThreadsPerBlock;

	// allocate sufficient memory on the GPU to hold B&W image and grayscale output image
	GPUtotalBufferSize = IMAGEPIX+IMAGESIZE;
	cudaStatus = cudaMalloc((void**)&GPUptr, GPUtotalBufferSize);
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMalloc failed! Can't allocate GPU memory");
		exit(EXIT_FAILURE);
	}

	// setup pointers to B&W image and output corrupted image
	GPUImg			= (uch *)GPUptr;
	GPUCopyImg	= GPUImg + IMAGESIZE;

	// Copy input vectors from host memory to GPU buffers.
	cudaStatus = cudaMemcpy(GPUImg, TheImg, IMAGESIZE, cudaMemcpyHostToDevice);
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMemcpy  CPU to GPU  failed!");
		exit(EXIT_FAILURE);
	}

	BlkPerRow = CEIL(ip.Hpixels, ThrPerBlk);
	NumBlocks = IPV*BlkPerRow;

	BWKernel <<< NumBlocks, ThrPerBlk >>> (GPUCopyImg, GPUImg, IPH);
	cudaStatus = cudaDeviceSynchronize();
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "\n\n cudaDeviceSynchronize 1 returned error code %d after launching the kernel!\n", cudaStatus);
		exit(EXIT_FAILURE);
	}

	// add random noise to the image
	inputNL = 255.0f*(double)amt/100.0f;
		 corruptPixels <<< NumBlocks, ThrPerBlk >>> (GPUImg, GPUCopyImg, IPH, IPV, inputNL);
				  GPUResult = GPUImg;


	// cudaDeviceSynchronize waits for the kernel to finish, and returns
	// any errors encountered during the launch.
	cudaStatus = cudaDeviceSynchronize();
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "\n\ncudaDeviceSynchronize 2 returned error code %d after launching the kernel!\n", cudaStatus);
		exit(EXIT_FAILURE);
	}
	

	// Copy output (results) from GPU buffer to host (CPU) memory.
	cudaStatus = cudaMemcpy(CopyImg, GPUResult, IMAGESIZE, cudaMemcpyDeviceToHost);
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMemcpy GPU to CPU  failed!");
		exit(EXIT_FAILURE);
	}
	

	cudaStatus = cudaDeviceSynchronize();
	//checkError(cudaGetLastError());	// screen for errors in kernel launches
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "\n Program failed after cudaDeviceSynchronize()!");
		free(TheImg);
		free(CopyImg);
		exit(EXIT_FAILURE);
	}


	WriteBMPlin(CopyImg, OutputFileName);		// Write the flipped image back to disk

	printf("\n\n--------------------------------------------------------------------------\n");
	printf("Successfully added %d%% noise to the given image and converted to grayscale.\n", amt);

	// Deallocate CPU, GPU memory and destroy events.
	cudaFree(GPUptr);

	cudaStatus = cudaDeviceReset();
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaDeviceReset failed!");
		free(TheImg);
		free(CopyImg);
		exit(EXIT_FAILURE);
	}

	free(TheImg);
	free(CopyImg);
	return(EXIT_SUCCESS);
}




	.file	"tmpxft_00280937_00000000-6_randNoise.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3854:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3854:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"rb"
.LC1:
	.string	"\n\n%s NOT FOUND\n\n"
.LC2:
	.string	"\n Input File name: %17s  (%u x %u)   File Size=%u"
	.text
	.globl	_Z10ReadBMPlinPc
	.type	_Z10ReadBMPlinPc, @function
_Z10ReadBMPlinPc:
.LFB3849:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L3
	movl	$2, %edi
	movq	%rbp, %rdx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L3:
	leaq	2(%rsp), %r12
	movq	%rax, %r8
	movl	$54, %ecx
	movq	%rax, %rbx
	movl	$1, %edx
	movl	$54, %esi
	movq	%r12, %rdi
	call	__fread_chk@PLT
	movl	20(%rsp), %edx
	movl	24(%rsp), %r8d
	movq	%r12, %rsi
	leaq	8+ip(%rip), %r9
	movl	$54, %ecx
	leal	1(%rdx), %eax
	movq	%r9, %rdi
	movslq	%r8d, %r9
	movl	%edx, ip(%rip)
	rep movsb
	leal	(%rax,%rax,2), %eax
	movl	%edx, %ecx
	leaq	.LC2(%rip), %rsi
	andl	$-4, %eax
	movq	%rbp, %rdx
	movl	$2, %edi
	movl	%r8d, 4+ip(%rip)
	cltq
	imulq	%rax, %r9
	movq	%rax, 64+ip(%rip)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	4+ip(%rip), %rbp
	imulq	64+ip(%rip), %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	movq	%rax, _ZZ10ReadBMPlinPcE3Img(%rip)
	testq	%rax, %rax
	je	.L2
	movq	%rbx, %r8
	movq	%rbp, %rcx
	movl	$1, %edx
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	__fread_chk@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	_ZZ10ReadBMPlinPcE3Img(%rip), %rax
.L2:
	movq	56(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$64, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3849:
	.size	_Z10ReadBMPlinPc, .-_Z10ReadBMPlinPc
	.section	.rodata.str1.1
.LC3:
	.string	"wb"
.LC4:
	.string	"\n\nFILE CREATION ERROR: %s\n\n"
.LC5:
	.string	"\nOutput File name: %17s  (%u x %u)   File Size=%u"
	.text
	.globl	_Z11WriteBMPlinPhPc
	.type	_Z11WriteBMPlinPhPc, @function
_Z11WriteBMPlinPhPc:
.LFB3850:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	leaq	.LC3(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rbp, %rdi
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L12
	movl	$2, %edi
	movq	%rbp, %rdx
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L12:
	movq	%rax, %rcx
	movl	$54, %edx
	movl	$1, %esi
	movq	%rax, %rbx
	leaq	8+ip(%rip), %rdi
	call	fwrite@PLT
	movq	%rbx, %rcx
	movq	%r12, %rdi
	movl	$1, %esi
	movslq	4+ip(%rip), %rdx
	imulq	64+ip(%rip), %rdx
	call	fwrite@PLT
	movl	ip(%rip), %ecx
	movq	%rbp, %rdx
	xorl	%eax, %eax
	movslq	4+ip(%rip), %r9
	imulq	64+ip(%rip), %r9
	movl	$2, %edi
	leaq	.LC5(%rip), %rsi
	movl	4+ip(%rip), %r8d
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE3850:
	.size	_Z11WriteBMPlinPhPc, .-_Z11WriteBMPlinPhPc
	.globl	_Z38__device_stub__Z13corruptPixelsPhS_jjdPhS_jjd
	.type	_Z38__device_stub__Z13corruptPixelsPhS_jjdPhS_jjd, @function
_Z38__device_stub__Z13corruptPixelsPhS_jjdPhS_jjd:
.LFB3876:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movsd	%xmm0, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z13corruptPixelsPhS_jjd(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L14:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3876:
	.size	_Z38__device_stub__Z13corruptPixelsPhS_jjdPhS_jjd, .-_Z38__device_stub__Z13corruptPixelsPhS_jjdPhS_jjd
	.globl	_Z13corruptPixelsPhS_jjd
	.type	_Z13corruptPixelsPhS_jjd, @function
_Z13corruptPixelsPhS_jjd:
.LFB3877:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z13corruptPixelsPhS_jjdPhS_jjd
	.cfi_endproc
.LFE3877:
	.size	_Z13corruptPixelsPhS_jjd, .-_Z13corruptPixelsPhS_jjd
	.globl	_Z30__device_stub__Z8BWKernelPhS_jPhS_j
	.type	_Z30__device_stub__Z8BWKernelPhS_jPhS_j, @function
_Z30__device_stub__Z8BWKernelPhS_jPhS_j:
.LFB3878:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L19
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z8BWKernelPhS_j(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L19:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3878:
	.size	_Z30__device_stub__Z8BWKernelPhS_jPhS_j, .-_Z30__device_stub__Z8BWKernelPhS_jPhS_j
	.globl	_Z8BWKernelPhS_j
	.type	_Z8BWKernelPhS_j, @function
_Z8BWKernelPhS_j:
.LFB3879:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z8BWKernelPhS_jPhS_j
	.cfi_endproc
.LFE3879:
	.size	_Z8BWKernelPhS_j, .-_Z8BWKernelPhS_j
	.section	.rodata.str1.1
.LC6:
	.string	"\n\nUsage:   %s InputFilename OutputFilename [NoiseDensity] [ThrPerBlk]"
.LC7:
	.string	"\n\nExample: %s Astronaut.bmp Output.bmp"
.LC8:
	.string	"\n\nExample: %s Astronaut.bmp Output.bmp 50"
.LC9:
	.string	"\n\nExample: %s Astronaut.bmp Output.bmp 50  128"
.LC10:
	.string	"\n\nNoise Density is in percent, from 0-100\n\n"
.LC11:
	.string	"Invalid noise amount. Must be between 0 and 100"
.LC12:
	.string	"Invalid ThrPerBlk option '%u'. Must be between 32 and 1024. \n"
.LC13:
	.string	"Cannot allocate memory for the input image...\n"
.LC14:
	.string	"\nNo CUDA Device is available\n"
.LC15:
	.string	"cudaSetDevice failed!  Do you have a CUDA-capable GPU installed?"
.LC16:
	.string	"cudaMalloc failed! Can't allocate GPU memory"
.LC17:
	.string	"cudaMemcpy  CPU to GPU  failed!"
.LC18:
	.string	"\n\n cudaDeviceSynchronize 1 returned error code %d after launching the kernel!\n"
.LC21:
	.string	"\n\ncudaDeviceSynchronize 2 returned error code %d after launching the kernel!\n"
.LC22:
	.string	"cudaMemcpy GPU to CPU  failed!"
.LC23:
	.string	"\n Program failed after cudaDeviceSynchronize()!"
.LC24:
	.string	"\n\n--------------------------------------------------------------------------\n"
.LC25:
	.string	"Successfully added %d%% noise to the given image and converted to grayscale.\n"
.LC26:
	.string	"cudaDeviceReset failed!"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3851:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$816, %rsp
	.cfi_def_cfa_offset 864
	movq	%fs:40, %rax
	movq	%rax, 808(%rsp)
	movabsq	$8316300569399419250, %rax
	movw	$101, 561(%rsp)
	movq	%rax, 553(%rsp)
	cmpl	$4, %edi
	je	.L46
	cmpl	$5, %edi
	je	.L26
	movl	$256, %ebx
	cmpl	$3, %edi
	je	.L27
	jmp	.L58
.L26:
	movq	32(%rsi), %rdi
	call	atoi@PLT
	movl	%eax, %ebx
	jmp	.L25
.L46:
	movl	$256, %ebx
.L25:
	movq	24(%rbp), %rdi
	call	atoi@PLT
	movl	%eax, %r12d
.L27:
	movq	8(%rbp), %rsi
	leaq	43(%rsp), %r14
	movl	$255, %edx
	leaq	298(%rsp), %r13
	movq	%r14, %rdi
	call	__strcpy_chk@PLT
	movq	16(%rbp), %rsi
	movl	$255, %edx
	movq	%r13, %rdi
	call	__strcpy_chk@PLT
	cmpl	$100, %r12d
	jbe	.L50
	leaq	.LC11(%rip), %rsi
	jmp	.L52
.L58:
	leaq	553(%rsp), %r13
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%r13, %rdx
	call	__printf_chk@PLT
	movq	%r13, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC7(%rip), %rsi
	call	__printf_chk@PLT
	movq	%r13, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rsi
	call	__printf_chk@PLT
	movq	%r13, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC9(%rip), %rsi
	call	__printf_chk@PLT
	leaq	.LC10(%rip), %rsi
	jmp	.L52
.L31:
	movq	%r14, %rdi
	call	_Z10ReadBMPlinPc
	movq	%rax, TheImg(%rip)
	movq	%rax, %rbp
	testq	%rax, %rax
	jne	.L32
.L54:
	leaq	.LC13(%rip), %rsi
.L52:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L53:
	movl	$1, %edi
	call	exit@PLT
.L50:
	leal	-32(%rbx), %eax
	cmpl	$992, %eax
	jbe	.L31
	movl	%ebx, %edx
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L53
.L32:
	movslq	4+ip(%rip), %rdi
	imulq	64+ip(%rip), %rdi
	call	malloc@PLT
	movq	%rax, CopyImg(%rip)
	testq	%rax, %rax
	jne	.L33
	movq	%rbp, %rdi
	call	free@PLT
	jmp	.L54
.L33:
	xorl	%eax, %eax
	leaq	12(%rsp), %rdi
	movl	%eax, 12(%rsp)
	call	cudaGetDeviceCount@PLT
	cmpl	$0, 12(%rsp)
	leaq	.LC14(%rip), %rsi
	je	.L52
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	leaq	.LC15(%rip), %rdx
	testl	%eax, %eax
	jne	.L56
	movl	4+ip(%rip), %eax
	movl	ip(%rip), %edx
	leaq	GPUptr(%rip), %rdi
	imull	%eax, %edx
	imull	64+ip(%rip), %eax
	leal	(%rdx,%rax), %esi
	call	cudaMalloc@PLT
	leaq	.LC16(%rip), %rdx
	testl	%eax, %eax
	jne	.L56
	movslq	4+ip(%rip), %rdx
	imulq	64+ip(%rip), %rdx
	movl	$1, %ecx
	movq	GPUptr(%rip), %rdi
	movq	TheImg(%rip), %rsi
	leaq	(%rdi,%rdx), %rax
	movq	%rdi, GPUImg(%rip)
	movq	%rax, GPUCopyImg(%rip)
	call	cudaMemcpy@PLT
	leaq	.LC17(%rip), %rdx
	testl	%eax, %eax
	jne	.L56
	movl	ip(%rip), %eax
	xorl	%edx, %edx
	movl	%ebx, 28(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	leal	-1(%rbx,%rax), %eax
	divl	%ebx
	imull	4+ip(%rip), %eax
	movl	%eax, %ebp
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movl	36(%rsp), %ecx
	movq	%rax, 20(%rsp)
	movq	28(%rsp), %rdx
	movl	%ebp, 16(%rsp)
	movl	24(%rsp), %esi
	movq	16(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L38
	movl	ip(%rip), %edx
	movq	GPUImg(%rip), %rsi
	movq	GPUCopyImg(%rip), %rdi
	call	_Z30__device_stub__Z8BWKernelPhS_jPhS_j
.L38:
	call	cudaDeviceSynchronize@PLT
	leaq	.LC18(%rip), %rdx
	movl	%eax, %ecx
	testl	%eax, %eax
	jne	.L57
	movabsq	$4294967297, %rax
	movl	%ebx, 28(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%rax, 32(%rsp)
	movl	36(%rsp), %ecx
	movq	%rax, 20(%rsp)
	movq	28(%rsp), %rdx
	movl	%ebp, 16(%rsp)
	movl	24(%rsp), %esi
	movq	16(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L40
	movl	4+ip(%rip), %ecx
	movl	ip(%rip), %edx
	cvtsi2sdl	%r12d, %xmm0
	movq	GPUCopyImg(%rip), %rsi
	movq	GPUImg(%rip), %rdi
	mulsd	.LC19(%rip), %xmm0
	divsd	.LC20(%rip), %xmm0
	call	_Z38__device_stub__Z13corruptPixelsPhS_jjdPhS_jjd
.L40:
	movq	GPUImg(%rip), %rax
	movq	%rax, GPUResult(%rip)
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %ecx
	testl	%eax, %eax
	je	.L41
	leaq	.LC21(%rip), %rdx
.L57:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L53
.L41:
	movslq	4+ip(%rip), %rdx
	imulq	64+ip(%rip), %rdx
	movl	$2, %ecx
	movq	GPUResult(%rip), %rsi
	movq	CopyImg(%rip), %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L42
	leaq	.LC22(%rip), %rdx
.L56:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L53
.L42:
	call	cudaDeviceSynchronize@PLT
	leaq	.LC23(%rip), %rdx
	testl	%eax, %eax
	jne	.L55
	movq	CopyImg(%rip), %rdi
	movq	%r13, %rsi
	call	_Z11WriteBMPlinPhPc
	leaq	.LC24(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%r12d, %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC25(%rip), %rsi
	call	__printf_chk@PLT
	movq	GPUptr(%rip), %rdi
	call	cudaFree@PLT
	call	cudaDeviceReset@PLT
	testl	%eax, %eax
	je	.L44
	leaq	.LC26(%rip), %rdx
.L55:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	TheImg(%rip), %rdi
	call	free@PLT
	movq	CopyImg(%rip), %rdi
	call	free@PLT
	jmp	.L53
.L44:
	movq	TheImg(%rip), %rdi
	call	free@PLT
	movq	CopyImg(%rip), %rdi
	call	free@PLT
	movq	808(%rsp), %rax
	subq	%fs:40, %rax
	je	.L45
	call	__stack_chk_fail@PLT
.L45:
	addq	$816, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3851:
	.size	main, .-main
	.text
	.globl	_Z29__device_stub__Z7PixCopyPhS_jPhS_j
	.type	_Z29__device_stub__Z7PixCopyPhS_jPhS_j, @function
_Z29__device_stub__Z7PixCopyPhS_jPhS_j:
.LFB3880:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L59
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z7PixCopyPhS_j(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L59:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L61
	call	__stack_chk_fail@PLT
.L61:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3880:
	.size	_Z29__device_stub__Z7PixCopyPhS_jPhS_j, .-_Z29__device_stub__Z7PixCopyPhS_jPhS_j
	.globl	_Z7PixCopyPhS_j
	.type	_Z7PixCopyPhS_j, @function
_Z7PixCopyPhS_j:
.LFB3881:
	.cfi_startproc
	endbr64
	jmp	_Z29__device_stub__Z7PixCopyPhS_jPhS_j
	.cfi_endproc
.LFE3881:
	.size	_Z7PixCopyPhS_j, .-_Z7PixCopyPhS_j
	.section	.rodata.str1.1
.LC27:
	.string	"_Z7PixCopyPhS_j"
.LC28:
	.string	"_Z8BWKernelPhS_j"
.LC29:
	.string	"_Z13corruptPixelsPhS_jjd"
.LC30:
	.string	"precalc_xorwow_matrix"
.LC31:
	.string	"precalc_xorwow_offset_matrix"
.LC32:
	.string	"mrg32k3aM1"
.LC33:
	.string	"mrg32k3aM2"
.LC34:
	.string	"mrg32k3aM1SubSeq"
.LC35:
	.string	"mrg32k3aM2SubSeq"
.LC36:
	.string	"mrg32k3aM1Seq"
.LC37:
	.string	"mrg32k3aM2Seq"
.LC38:
	.string	"__cr_lgamma_table"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3883:
	.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	.LC27(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z7PixCopyPhS_j(%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	.LC28(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z8BWKernelPhS_j(%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	.LC29(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z13corruptPixelsPhS_jjd(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC30(%rip), %rdx
	movl	$102400, %r9d
	leaq	_ZL21precalc_xorwow_matrix(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC31(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$102400, %r9d
	leaq	_ZL28precalc_xorwow_offset_matrix(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC32(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM1(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC33(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM2(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC34(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM1SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rax
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC35(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM2SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC36(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM1Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC37(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM2Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC38(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$72, %r9d
	movq	%rdx, %rcx
	leaq	_ZL17__cr_lgamma_table(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.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
.LFE3883:
	.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
	.local	_ZZ10ReadBMPlinPcE3Img
	.comm	_ZZ10ReadBMPlinPcE3Img,8,8
	.globl	ip
	.bss
	.align 32
	.type	ip, @object
	.size	ip, 72
ip:
	.zero	72
	.globl	GPUResult
	.align 8
	.type	GPUResult, @object
	.size	GPUResult, 8
GPUResult:
	.zero	8
	.globl	GPUptr
	.align 8
	.type	GPUptr, @object
	.size	GPUptr, 8
GPUptr:
	.zero	8
	.globl	GPUCopyImg
	.align 8
	.type	GPUCopyImg, @object
	.size	GPUCopyImg, 8
GPUCopyImg:
	.zero	8
	.globl	GPUImg
	.align 8
	.type	GPUImg, @object
	.size	GPUImg, 8
GPUImg:
	.zero	8
	.globl	CopyImg
	.align 8
	.type	CopyImg, @object
	.size	CopyImg, 8
CopyImg:
	.zero	8
	.globl	TheImg
	.align 8
	.type	TheImg, @object
	.size	TheImg, 8
TheImg:
	.zero	8
	.local	_ZL17__cr_lgamma_table
	.comm	_ZL17__cr_lgamma_table,72,32
	.local	_ZL13mrg32k3aM2Seq
	.comm	_ZL13mrg32k3aM2Seq,2304,32
	.local	_ZL13mrg32k3aM1Seq
	.comm	_ZL13mrg32k3aM1Seq,2304,32
	.local	_ZL16mrg32k3aM2SubSeq
	.comm	_ZL16mrg32k3aM2SubSeq,2016,32
	.local	_ZL16mrg32k3aM1SubSeq
	.comm	_ZL16mrg32k3aM1SubSeq,2016,32
	.local	_ZL10mrg32k3aM2
	.comm	_ZL10mrg32k3aM2,2304,32
	.local	_ZL10mrg32k3aM1
	.comm	_ZL10mrg32k3aM1,2304,32
	.local	_ZL28precalc_xorwow_offset_matrix
	.comm	_ZL28precalc_xorwow_offset_matrix,102400,32
	.local	_ZL21precalc_xorwow_matrix
	.comm	_ZL21precalc_xorwow_matrix,102400,32
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC19:
	.long	0
	.long	1081073664
	.align 8
.LC20:
	.long	0
	.long	1079574528
	.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:

// Salt and pepper noise simulation with Cuda C/C++
// Original framework for code taken from imflipG.cu
// Modified by Ethan Webster

#include <hip/hip_runtime.h>
#include <hiprand/hiprand_kernel.h>

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <ctype.h>

#include <time.h>

#define DATAMB(bytes)			(bytes/1024/1024)
#define DATABW(bytes,timems)	((float)bytes/(timems * 1.024*1024.0*1024.0))
#define	CEIL(a,b)				((a+b-1)/b)

typedef unsigned char uch;
typedef unsigned long ul;
typedef unsigned int  ui;

uch *TheImg, *CopyImg;					// Where images are stored in CPU
uch *GPUImg, *GPUCopyImg, *GPUptr, *GPUResult;	// Where images are stored in GPU


struct ImgProp{
	int Hpixels;
	int Vpixels;
	uch HeaderInfo[54];
	ul Hbytes;
} ip;


#define	IPHB		ip.Hbytes
#define	IPH			ip.Hpixels
#define	IPV			ip.Vpixels
#define	IMAGESIZE	(IPHB*IPV)
#define	IMAGEPIX	(IPH*IPV)


// Kernel that adds salt&pepper noise of given probability density to an image
__global__
void corruptPixels(uch *ImgDst, uch *ImgSrc, ui Hpixels, ui Vpixels, double prob)
{
	// threads/blocks info and IDs
	ui ThrPerBlk = blockDim.x;
	ui MYbid = blockIdx.x;
	ui MYtid = threadIdx.x;
	ui MYgtid = ThrPerBlk * MYbid + MYtid;

	//ui NumBlocks = gridDim.x;
	ui BlkPerRow = CEIL(Hpixels, ThrPerBlk);
	ui MYrow = MYbid / BlkPerRow;
	ui MYcol = MYgtid - MYrow*BlkPerRow*ThrPerBlk;

	// leave buffer frame around image to avoid 8 edge cases for convolutions
	if (MYcol > Hpixels-4 || MYcol < 3 || MYrow > Vpixels-4 || MYrow < 3) return;

	ui MYpixIndex = MYrow * Hpixels + MYcol; // pixel index in B&W image

	ui RowBytes = (Hpixels * 3 + 3) & (~3);  // bytes in row of R=G=B grayscale output image

	ui MYresultIndex = MYrow * RowBytes + 3 * MYcol; // pixel index in grayscale image (R=B=G)

	// seed cuRAND random number generator function with clock cycle + threadID
	hiprandState state;
	hiprand_init((unsigned long long)clock() + MYtid, 0, 0, &state);

	// sample uniform distribution from 0 to 255 (random pixel intensity)
	ui loc = ((ui)(hiprand(&state)))%255;

/* 
	half of the probability is used for the following because
	the salt vs pepper contribution is split 50/50 
*/
	// if pixel intensity is located in the lower half of the 
	// probability region, then add pepper noise
	if( loc <= (ui)(prob/2.0f)) {
		ImgDst[MYresultIndex] = 0;
		ImgDst[MYresultIndex+1] = 0;
		ImgDst[MYresultIndex+2] = 0;
	}

	// otherwise if pixel intensity is located in the upper half of the 
	// probability region, then add salt noise
	else if(loc > (ui)(prob/2.0f) && loc < (ui)prob ) {
		ImgDst[MYresultIndex] = 255;
		ImgDst[MYresultIndex+1] = 255;
		ImgDst[MYresultIndex+2] = 255;
	}

	// if we reached this, then no noise is added
	else {
		ImgDst[MYresultIndex] = ImgSrc[MYpixIndex];
		ImgDst[MYresultIndex+1] = ImgSrc[MYpixIndex];
		ImgDst[MYresultIndex+2] = ImgSrc[MYpixIndex];
	}


}


// Kernel that calculates a B&W image from an RGB image
// resulting image has a double type for each pixel position
__global__
void BWKernel(uch *ImgBW, uch *ImgGPU, ui Hpixels)
{
	ui ThrPerBlk = blockDim.x;
	ui MYbid = blockIdx.x;
	ui MYtid = threadIdx.x;
	ui MYgtid = ThrPerBlk * MYbid + MYtid;
	double R, G, B;

	//ui NumBlocks = gridDim.x;
	ui BlkPerRow = CEIL(Hpixels, ThrPerBlk);
	ui RowBytes = (Hpixels * 3 + 3) & (~3);
	ui MYrow = MYbid / BlkPerRow;
	ui MYcol = MYgtid - MYrow*BlkPerRow*ThrPerBlk;
	if (MYcol >= Hpixels) return;			// col out of range

	ui MYsrcIndex = MYrow * RowBytes + 3 * MYcol;
	ui MYpixIndex = MYrow * Hpixels + MYcol;

	B = (double)ImgGPU[MYsrcIndex];
	G = (double)ImgGPU[MYsrcIndex + 1];
	R = (double)ImgGPU[MYsrcIndex + 2];
	ImgBW[MYpixIndex] = (uch)((R+G+B)/3.0);
}


// Kernel that copies an image from one part of the
// GPU memory (ImgSrc) to another (ImgDst)
__global__
void PixCopy(uch *ImgDst, uch *ImgSrc, ui FS)
{
	ui ThrPerBlk = blockDim.x;
	ui MYbid = blockIdx.x;
	ui MYtid = threadIdx.x;
	ui MYgtid = ThrPerBlk * MYbid + MYtid;

	if (MYgtid > FS) return;				// outside the allocated memory
	ImgDst[MYgtid] = ImgSrc[MYgtid];
}



// Read a 24-bit/pixel BMP file into a 1D linear array.
// Allocate memory to store the 1D image and return its pointer.
uch *ReadBMPlin(char* fn)
{
	static uch *Img;
	FILE* f = fopen(fn, "rb");
	if (f == NULL){	printf("\n\n%s NOT FOUND\n\n", fn);	exit(EXIT_FAILURE); }

	uch HeaderInfo[54];
	fread(HeaderInfo, sizeof(uch), 54, f); // read the 54-byte header
	// extract image height and width from header
	int width = *(int*)&HeaderInfo[18];			ip.Hpixels = width;
	int height = *(int*)&HeaderInfo[22];		ip.Vpixels = height;
	int RowBytes = (width * 3 + 3) & (~3);		ip.Hbytes = RowBytes;
	//save header for re-use
	memcpy(ip.HeaderInfo, HeaderInfo,54);
	printf("\n Input File name: %17s  (%u x %u)   File Size=%u", fn, 
			ip.Hpixels, ip.Vpixels, IMAGESIZE);
	// allocate memory to store the main image (1 Dimensional array)
	Img  = (uch *)malloc(IMAGESIZE);
	if (Img == NULL) return Img;      // Cannot allocate memory
	// read the image from disk
	fread(Img, sizeof(uch), IMAGESIZE, f);
	fclose(f);
	return Img;
}


// Write the 1D linear-memory stored image into file.
void WriteBMPlin(uch *Img, char* fn)
{
	FILE* f = fopen(fn, "wb");
	if (f == NULL){ printf("\n\nFILE CREATION ERROR: %s\n\n", fn); exit(1); }
	//write header
	fwrite(ip.HeaderInfo, sizeof(uch), 54, f);
	//write data
	fwrite(Img, sizeof(uch), IMAGESIZE, f);
	printf("\nOutput File name: %17s  (%u x %u)   File Size=%u", fn, ip.Hpixels, ip.Vpixels, IMAGESIZE);
	fclose(f);
}


int main(int argc, char **argv)
{

	hipError_t cudaStatus;
	char InputFileName[255], OutputFileName[255], ProgName[255];
	ui BlkPerRow, ThrPerBlk=256, NumBlocks;
	//cudaDeviceProp GPUprop;
	//ul SupportedKBlocks, SupportedMBlocks, MaxThrPerBlk;		char SupportedBlocks[100]; 

	ui amt, GPUtotalBufferSize;

	double inputNL;

	strcpy(ProgName, "randNoise");
	switch (argc){
	case 5:  ThrPerBlk=atoi(argv[4]);
	case 4:  amt=atoi(argv[3]);
	case 3:  strcpy(InputFileName, argv[1]);
			 strcpy(OutputFileName, argv[2]);
			 break;
	default: printf("\n\nUsage:   %s InputFilename OutputFilename [NoiseDensity] [ThrPerBlk]", ProgName);
			 printf("\n\nExample: %s Astronaut.bmp Output.bmp", ProgName);
			 printf("\n\nExample: %s Astronaut.bmp Output.bmp 50", ProgName);
			 printf("\n\nExample: %s Astronaut.bmp Output.bmp 50  128",ProgName);
			 printf("\n\nNoise Density is in percent, from 0-100\n\n");
			 exit(EXIT_FAILURE);
	}
	if (amt > 100) {
		printf("Invalid noise amount. Must be between 0 and 100");
		exit(EXIT_FAILURE);
	}
	if ((ThrPerBlk < 32) || (ThrPerBlk > 1024)) {
		printf("Invalid ThrPerBlk option '%u'. Must be between 32 and 1024. \n", ThrPerBlk);
		exit(EXIT_FAILURE);
	}

	// Create CPU memory to store the input and output images
	TheImg = ReadBMPlin(InputFileName); // Read the input image if memory can be allocated
	if (TheImg == NULL){
		printf("Cannot allocate memory for the input image...\n");
		exit(EXIT_FAILURE);
	}
	CopyImg = (uch *)malloc(IMAGESIZE);
	if (CopyImg == NULL){
		free(TheImg);
		printf("Cannot allocate memory for the input image...\n");
		exit(EXIT_FAILURE);
	}


	// Choose which GPU to run on, change this on a multi-GPU system.
	int NumGPUs = 0;
	hipGetDeviceCount(&NumGPUs);
	if (NumGPUs == 0){
		printf("\nNo CUDA Device is available\n");
		exit(EXIT_FAILURE);
	}
	cudaStatus = hipSetDevice(0);
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipSetDevice failed!  Do you have a CUDA-capable GPU installed?");
		exit(EXIT_FAILURE);
	}

	
	// cudaGetDeviceProperties(&GPUprop, 0);
	// SupportedKBlocks = (ui)GPUprop.maxGridSize[0] * (ui)GPUprop.maxGridSize[1] * (ui)GPUprop.maxGridSize[2] / 1024;
	// SupportedMBlocks = SupportedKBlocks / 1024;
	// sprintf(SupportedBlocks, "%u %c", (SupportedMBlocks >= 5) ? SupportedMBlocks : SupportedKBlocks, (SupportedMBlocks >= 5) ? 'M' : 'K');
	// MaxThrPerBlk = (ui)GPUprop.maxThreadsPerBlock;

	// allocate sufficient memory on the GPU to hold B&W image and grayscale output image
	GPUtotalBufferSize = IMAGEPIX+IMAGESIZE;
	cudaStatus = hipMalloc((void**)&GPUptr, GPUtotalBufferSize);
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMalloc failed! Can't allocate GPU memory");
		exit(EXIT_FAILURE);
	}

	// setup pointers to B&W image and output corrupted image
	GPUImg			= (uch *)GPUptr;
	GPUCopyImg	= GPUImg + IMAGESIZE;

	// Copy input vectors from host memory to GPU buffers.
	cudaStatus = hipMemcpy(GPUImg, TheImg, IMAGESIZE, hipMemcpyHostToDevice);
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMemcpy  CPU to GPU  failed!");
		exit(EXIT_FAILURE);
	}

	BlkPerRow = CEIL(ip.Hpixels, ThrPerBlk);
	NumBlocks = IPV*BlkPerRow;

	BWKernel <<< NumBlocks, ThrPerBlk >>> (GPUCopyImg, GPUImg, IPH);
	cudaStatus = hipDeviceSynchronize();
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "\n\n hipDeviceSynchronize 1 returned error code %d after launching the kernel!\n", cudaStatus);
		exit(EXIT_FAILURE);
	}

	// add random noise to the image
	inputNL = 255.0f*(double)amt/100.0f;
		 corruptPixels <<< NumBlocks, ThrPerBlk >>> (GPUImg, GPUCopyImg, IPH, IPV, inputNL);
				  GPUResult = GPUImg;


	// cudaDeviceSynchronize waits for the kernel to finish, and returns
	// any errors encountered during the launch.
	cudaStatus = hipDeviceSynchronize();
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "\n\nhipDeviceSynchronize 2 returned error code %d after launching the kernel!\n", cudaStatus);
		exit(EXIT_FAILURE);
	}
	

	// Copy output (results) from GPU buffer to host (CPU) memory.
	cudaStatus = hipMemcpy(CopyImg, GPUResult, IMAGESIZE, hipMemcpyDeviceToHost);
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMemcpy GPU to CPU  failed!");
		exit(EXIT_FAILURE);
	}
	

	cudaStatus = hipDeviceSynchronize();
	//checkError(cudaGetLastError());	// screen for errors in kernel launches
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "\n Program failed after cudaDeviceSynchronize()!");
		free(TheImg);
		free(CopyImg);
		exit(EXIT_FAILURE);
	}


	WriteBMPlin(CopyImg, OutputFileName);		// Write the flipped image back to disk

	printf("\n\n--------------------------------------------------------------------------\n");
	printf("Successfully added %d%% noise to the given image and converted to grayscale.\n", amt);

	// Deallocate CPU, GPU memory and destroy events.
	hipFree(GPUptr);

	cudaStatus = hipDeviceReset();
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipDeviceReset failed!");
		free(TheImg);
		free(CopyImg);
		exit(EXIT_FAILURE);
	}

	free(TheImg);
	free(CopyImg);
	return(EXIT_SUCCESS);
}




	.text
	.file	"randNoise.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z28__device_stub__corruptPixelsPhS_jjd # -- Begin function _Z28__device_stub__corruptPixelsPhS_jjd
	.type	_Z28__device_stub__corruptPixelsPhS_jjd,@function
_Z28__device_stub__corruptPixelsPhS_jjd: # @_Z28__device_stub__corruptPixelsPhS_jjd
	.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	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	4(%rsp), %rsi
	movl	%edx, (%rsi)
	movq	%rsp, %rdx
	movl	%ecx, (%rdx)
	leaq	24(%rsp), %rcx
	movsd	%xmm0, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z13corruptPixelsPhS_jjd, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	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__corruptPixelsPhS_jjd, .Lfunc_end0-_Z28__device_stub__corruptPixelsPhS_jjd
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__BWKernelPhS_j # -- Begin function _Z23__device_stub__BWKernelPhS_j
	.type	_Z23__device_stub__BWKernelPhS_j,@function
_Z23__device_stub__BWKernelPhS_j:       # @_Z23__device_stub__BWKernelPhS_j
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z8BWKernelPhS_j, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z23__device_stub__BWKernelPhS_j, .Lfunc_end1-_Z23__device_stub__BWKernelPhS_j
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__PixCopyPhS_j # -- Begin function _Z22__device_stub__PixCopyPhS_j
	.type	_Z22__device_stub__PixCopyPhS_j,@function
_Z22__device_stub__PixCopyPhS_j:        # @_Z22__device_stub__PixCopyPhS_j
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z7PixCopyPhS_j, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z22__device_stub__PixCopyPhS_j, .Lfunc_end2-_Z22__device_stub__PixCopyPhS_j
	.cfi_endproc
                                        # -- End function
	.globl	_Z10ReadBMPlinPc                # -- Begin function _Z10ReadBMPlinPc
	.type	_Z10ReadBMPlinPc,@function
_Z10ReadBMPlinPc:                       # @_Z10ReadBMPlinPc
	.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
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %r14
	movl	$.L.str, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB3_4
# %bb.1:
	movq	%rax, %rbx
	movq	%rsp, %r15
	movl	$1, %esi
	movl	$54, %edx
	movq	%r15, %rdi
	movq	%rax, %rcx
	callq	fread
	movslq	18(%r15), %rdx
	movl	%edx, ip(%rip)
	movslq	22(%r15), %rcx
	movl	%ecx, ip+4(%rip)
	leaq	(%rdx,%rdx,2), %r8
	addq	$3, %r8
	andq	$-4, %r8
	movq	%r8, ip+64(%rip)
	movaps	(%r15), %xmm0
	movaps	16(%r15), %xmm1
	movaps	32(%r15), %xmm2
	movups	%xmm0, ip+8(%rip)
	movups	%xmm1, ip+24(%rip)
	movups	%xmm2, ip+40(%rip)
	movq	46(%r15), %rax
	movq	%rax, ip+54(%rip)
	imulq	%rcx, %r8
	xorl	%r15d, %r15d
	movl	$.L.str.2, %edi
	movq	%r14, %rsi
                                        # kill: def $edx killed $edx killed $rdx
                                        # kill: def $ecx killed $ecx killed $rcx
	xorl	%eax, %eax
	callq	printf
	movslq	ip+4(%rip), %r14
	imulq	ip+64(%rip), %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, _ZZ10ReadBMPlinPcE3Img(%rip)
	testq	%rax, %rax
	je	.LBB3_3
# %bb.2:
	movl	$1, %esi
	movq	%rax, %rdi
	movq	%r14, %rdx
	movq	%rbx, %rcx
	callq	fread
	movq	%rbx, %rdi
	callq	fclose
	movq	_ZZ10ReadBMPlinPcE3Img(%rip), %r15
.LBB3_3:
	movq	%r15, %rax
	addq	$64, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB3_4:
	.cfi_def_cfa_offset 96
	movl	$.L.str.1, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end3:
	.size	_Z10ReadBMPlinPc, .Lfunc_end3-_Z10ReadBMPlinPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z11WriteBMPlinPhPc             # -- Begin function _Z11WriteBMPlinPhPc
	.type	_Z11WriteBMPlinPhPc,@function
_Z11WriteBMPlinPhPc:                    # @_Z11WriteBMPlinPhPc
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r15
	movl	$.L.str.3, %esi
	movq	%rbx, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB4_1
# %bb.2:
	movq	%rax, %r14
	movl	$ip+8, %edi
	movl	$1, %esi
	movl	$54, %edx
	movq	%rax, %rcx
	callq	fwrite
	movslq	ip+4(%rip), %rdx
	imulq	ip+64(%rip), %rdx
	movl	$1, %esi
	movq	%r15, %rdi
	movq	%r14, %rcx
	callq	fwrite
	movl	ip(%rip), %edx
	movslq	ip+4(%rip), %rcx
	movq	%rcx, %r8
	imulq	ip+64(%rip), %r8
	movl	$.L.str.5, %edi
	movq	%rbx, %rsi
                                        # kill: def $ecx killed $ecx killed $rcx
	xorl	%eax, %eax
	callq	printf
	movq	%r14, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.LBB4_1:
	.cfi_def_cfa_offset 32
	movl	$.L.str.4, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end4:
	.size	_Z11WriteBMPlinPhPc, .Lfunc_end4-_Z11WriteBMPlinPhPc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI5_0:
	.quad	0x406fe00000000000              # double 255
.LCPI5_1:
	.quad	0x4059000000000000              # double 100
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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
	subq	$784, %rsp                      # imm = 0x310
	.cfi_def_cfa_offset 816
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %r15
	movabsq	$8316300569399419250, %rax      # imm = 0x73696F4E646E6172
	movq	%rax, 16(%rsp)
	movw	$101, 24(%rsp)
	movl	$256, %r14d                     # imm = 0x100
	cmpl	$3, %edi
	je	.LBB5_5
# %bb.1:
	cmpl	$4, %edi
	je	.LBB5_4
# %bb.2:
	cmpl	$5, %edi
	jne	.LBB5_40
# %bb.3:
	movq	32(%r15), %rdi
	callq	atoi
	movl	%eax, %r14d
.LBB5_4:
	movq	24(%r15), %rdi
	callq	atoi
	movl	%eax, %ebx
	jmp	.LBB5_6
.LBB5_5:
                                        # implicit-def: $ebx
.LBB5_6:
	movq	8(%r15), %rsi
	leaq	528(%rsp), %rdi
	callq	strcpy
	movq	16(%r15), %rsi
	leaq	272(%rsp), %rdi
	callq	strcpy
	cmpl	$100, %ebx
	ja	.LBB5_24
# %bb.7:
	leal	-1025(%r14), %eax
	cmpl	$-994, %eax                     # imm = 0xFC1E
	jbe	.LBB5_25
# %bb.8:
	leaq	528(%rsp), %rdi
	callq	_Z10ReadBMPlinPc
	movq	%rax, TheImg(%rip)
	testq	%rax, %rax
	je	.LBB5_27
# %bb.9:
	movq	%rax, %r15
	movslq	ip+4(%rip), %rdi
	imulq	ip+64(%rip), %rdi
	callq	malloc
	movq	%rax, CopyImg(%rip)
	testq	%rax, %rax
	je	.LBB5_26
# %bb.10:
	leaq	12(%rsp), %r15
	movl	$0, (%r15)
	movq	%r15, %rdi
	callq	hipGetDeviceCount
	cmpl	$0, (%r15)
	je	.LBB5_28
# %bb.11:
	xorl	%edi, %edi
	callq	hipSetDevice
	testl	%eax, %eax
	jne	.LBB5_29
# %bb.12:
	movl	ip(%rip), %esi
	addl	ip+64(%rip), %esi
	imull	ip+4(%rip), %esi
	movl	$GPUptr, %edi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_30
# %bb.13:
	movq	GPUptr(%rip), %rdi
	movslq	ip+4(%rip), %rdx
	imulq	ip+64(%rip), %rdx
	movq	%rdi, GPUImg(%rip)
	leaq	(%rdi,%rdx), %rax
	movq	%rax, GPUCopyImg(%rip)
	movq	TheImg(%rip), %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_31
# %bb.14:
	movl	ip(%rip), %eax
	addl	%r14d, %eax
	decl	%eax
	xorl	%edx, %edx
	divl	%r14d
	movl	%eax, %r15d
	imull	ip+4(%rip), %r15d
	btsq	$32, %r15
	movl	%r14d, %r14d
	btsq	$32, %r14
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_16
# %bb.15:
	movq	GPUCopyImg(%rip), %rdi
	movq	GPUImg(%rip), %rsi
	movl	ip(%rip), %edx
	callq	_Z23__device_stub__BWKernelPhS_j
.LBB5_16:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB5_32
# %bb.17:
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_19
# %bb.18:
	movl	%ebx, %eax
	cvtsi2sd	%rax, %xmm0
	mulsd	.LCPI5_0(%rip), %xmm0
	divsd	.LCPI5_1(%rip), %xmm0
	movq	GPUImg(%rip), %rdi
	movq	GPUCopyImg(%rip), %rsi
	movl	ip(%rip), %edx
	movl	ip+4(%rip), %ecx
	callq	_Z28__device_stub__corruptPixelsPhS_jjd
.LBB5_19:
	movq	GPUImg(%rip), %rax
	movq	%rax, GPUResult(%rip)
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB5_33
# %bb.20:
	movq	CopyImg(%rip), %rdi
	movq	GPUResult(%rip), %rsi
	movslq	ip+4(%rip), %rdx
	imulq	ip+64(%rip), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_35
# %bb.21:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB5_37
# %bb.22:
	movq	CopyImg(%rip), %rdi
	leaq	272(%rsp), %rsi
	callq	_Z11WriteBMPlinPhPc
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.L.str.24, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movq	GPUptr(%rip), %rdi
	callq	hipFree
	callq	hipDeviceReset
	testl	%eax, %eax
	jne	.LBB5_38
# %bb.23:
	movq	TheImg(%rip), %rdi
	callq	free
	movq	CopyImg(%rip), %rdi
	callq	free
	xorl	%eax, %eax
	addq	$784, %rsp                      # imm = 0x310
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB5_24:
	.cfi_def_cfa_offset 816
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB5_42
.LBB5_25:
	movl	$.L.str.13, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB5_42
.LBB5_26:
	movq	%r15, %rdi
	callq	free
.LBB5_27:
	movl	$.Lstr.3, %edi
	jmp	.LBB5_41
.LBB5_28:
	movl	$.Lstr.1, %edi
	jmp	.LBB5_41
.LBB5_29:
	movq	stderr(%rip), %rcx
	movl	$.L.str.16, %edi
	movl	$63, %esi
	jmp	.LBB5_36
.LBB5_30:
	movq	stderr(%rip), %rcx
	movl	$.L.str.17, %edi
	movl	$43, %esi
	jmp	.LBB5_36
.LBB5_31:
	movq	stderr(%rip), %rcx
	movl	$.L.str.18, %edi
	movl	$30, %esi
	jmp	.LBB5_36
.LBB5_32:
	movq	stderr(%rip), %rdi
	movl	$.L.str.19, %esi
	jmp	.LBB5_34
.LBB5_33:
	movq	stderr(%rip), %rdi
	movl	$.L.str.20, %esi
.LBB5_34:
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB5_42
.LBB5_35:
	movq	stderr(%rip), %rcx
	movl	$.L.str.21, %edi
	movl	$29, %esi
.LBB5_36:
	movl	$1, %edx
	callq	fwrite
	jmp	.LBB5_42
.LBB5_37:
	movq	stderr(%rip), %rcx
	movl	$.L.str.22, %edi
	movl	$47, %esi
	jmp	.LBB5_39
.LBB5_38:
	movq	stderr(%rip), %rcx
	movl	$.L.str.25, %edi
	movl	$22, %esi
.LBB5_39:
	movl	$1, %edx
	callq	fwrite
	movq	TheImg(%rip), %rdi
	callq	free
	movq	CopyImg(%rip), %rdi
	callq	free
	jmp	.LBB5_42
.LBB5_40:
	leaq	16(%rsp), %rbx
	movl	$.L.str.7, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.8, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.9, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.10, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.4, %edi
.LBB5_41:
	callq	puts@PLT
.LBB5_42:
	movl	$1, %edi
	callq	exit
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13corruptPixelsPhS_jjd, %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	$_Z8BWKernelPhS_j, %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	$_Z7PixCopyPhS_j, %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_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	TheImg,@object                  # @TheImg
	.bss
	.globl	TheImg
	.p2align	3, 0x0
TheImg:
	.quad	0
	.size	TheImg, 8

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

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

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

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

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

	.type	ip,@object                      # @ip
	.globl	ip
	.p2align	3, 0x0
ip:
	.zero	72
	.size	ip, 72

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

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

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

	.type	_ZZ10ReadBMPlinPcE3Img,@object  # @_ZZ10ReadBMPlinPcE3Img
	.local	_ZZ10ReadBMPlinPcE3Img
	.comm	_ZZ10ReadBMPlinPcE3Img,8,8
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"rb"
	.size	.L.str, 3

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"\n\n%s NOT FOUND\n\n"
	.size	.L.str.1, 17

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"\n Input File name: %17s  (%u x %u)   File Size=%u"
	.size	.L.str.2, 50

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"\n\nFILE CREATION ERROR: %s\n\n"
	.size	.L.str.4, 28

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"\nOutput File name: %17s  (%u x %u)   File Size=%u"
	.size	.L.str.5, 50

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"randNoise"
	.size	.L.str.6, 10

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"\n\nUsage:   %s InputFilename OutputFilename [NoiseDensity] [ThrPerBlk]"
	.size	.L.str.7, 70

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"\n\nExample: %s Astronaut.bmp Output.bmp"
	.size	.L.str.8, 39

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"\n\nExample: %s Astronaut.bmp Output.bmp 50"
	.size	.L.str.9, 42

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"\n\nExample: %s Astronaut.bmp Output.bmp 50  128"
	.size	.L.str.10, 47

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Invalid noise amount. Must be between 0 and 100"
	.size	.L.str.12, 48

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Invalid ThrPerBlk option '%u'. Must be between 32 and 1024. \n"
	.size	.L.str.13, 62

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"hipSetDevice failed!  Do you have a CUDA-capable GPU installed?"
	.size	.L.str.16, 64

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"hipMalloc failed! Can't allocate GPU memory"
	.size	.L.str.17, 44

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"hipMemcpy  CPU to GPU  failed!"
	.size	.L.str.18, 31

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"\n\n hipDeviceSynchronize 1 returned error code %d after launching the kernel!\n"
	.size	.L.str.19, 78

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"\n\nhipDeviceSynchronize 2 returned error code %d after launching the kernel!\n"
	.size	.L.str.20, 77

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"hipMemcpy GPU to CPU  failed!"
	.size	.L.str.21, 30

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"\n Program failed after cudaDeviceSynchronize()!"
	.size	.L.str.22, 48

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"Successfully added %d%% noise to the given image and converted to grayscale.\n"
	.size	.L.str.24, 78

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"hipDeviceReset failed!"
	.size	.L.str.25, 23

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13corruptPixelsPhS_jjd"
	.size	.L__unnamed_1, 25

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z8BWKernelPhS_j"
	.size	.L__unnamed_2, 17

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z7PixCopyPhS_j"
	.size	.L__unnamed_3, 16

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"\n\n--------------------------------------------------------------------------"
	.size	.Lstr, 77

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"\nNo CUDA Device is available"
	.size	.Lstr.1, 29

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Cannot allocate memory for the input image..."
	.size	.Lstr.3, 46

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"\n\nNoise Density is in percent, from 0-100\n"
	.size	.Lstr.4, 43

	.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__corruptPixelsPhS_jjd
	.addrsig_sym _Z23__device_stub__BWKernelPhS_j
	.addrsig_sym _Z22__device_stub__PixCopyPhS_j
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym GPUptr
	.addrsig_sym ip
	.addrsig_sym _Z13corruptPixelsPhS_jjd
	.addrsig_sym _Z8BWKernelPhS_j
	.addrsig_sym _Z7PixCopyPhS_j
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13corruptPixelsPhS_jjd ; -- Begin function _Z13corruptPixelsPhS_jjd
	.globl	_Z13corruptPixelsPhS_jjd
	.p2align	8
	.type	_Z13corruptPixelsPhS_jjd,@function
_Z13corruptPixelsPhS_jjd:               ; @_Z13corruptPixelsPhS_jjd
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x2c
	s_load_b64 s[4:5], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_cvt_f32_u32_e32 v1, s2
	s_sub_i32 s6, 0, s2
	s_add_i32 s7, s4, s2
	s_add_i32 s7, s7, -1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	v_cvt_u32_f32_e32 v1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_readfirstlane_b32 s3, v1
	s_mul_i32 s6, s6, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s6, s3, s6
	s_add_i32 s3, s3, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s3, s7, s3
	s_mul_i32 s6, s3, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s6, s7, s6
	s_add_i32 s7, s3, 1
	s_sub_i32 s8, s6, s2
	s_cmp_ge_u32 s6, s2
	s_cselect_b32 s3, s7, s3
	s_cselect_b32 s6, s8, s6
	s_add_i32 s7, s3, 1
	s_cmp_ge_u32 s6, s2
	s_cselect_b32 s3, s7, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f32_u32_e32 v1, s3
	s_sub_i32 s7, 0, s3
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_readfirstlane_b32 s6, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s7, s7, s6
	s_mul_hi_u32 s7, s6, s7
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s6, s6, s7
	s_mul_hi_u32 s6, s15, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_mul_i32 s7, s6, s3
	s_add_i32 s8, s6, 1
	s_sub_i32 s7, s15, s7
	s_sub_i32 s9, s7, s3
	s_cmp_ge_u32 s7, s3
	s_cselect_b32 s6, s8, s6
	s_cselect_b32 s7, s9, s7
	s_add_i32 s8, s6, 1
	s_cmp_ge_u32 s7, s3
	s_cselect_b32 s8, s8, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s3, s8, s3
	s_sub_i32 s3, s15, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s3, s2, v[0:1]
	s_add_i32 s2, s4, -4
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_ge_u32_e32 vcc_lo, s2, v1
	v_cmp_lt_u32_e64 s2, 2, 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_11
; %bb.1:
	s_add_i32 s2, s5, -4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	s_cmp_gt_u32 s8, s2
	s_cselect_b32 s2, -1, 0
	s_cmp_lt_u32 s8, 3
	s_cselect_b32 s3, -1, 0
	s_or_b32 s2, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 vcc_lo, exec_lo, s2
	s_cbranch_vccnz .LBB0_11
; %bb.2:
	s_load_b64 s[6:7], s[0:1], 0x18
	s_getreg_b32 s2, hwreg(HW_REG_SHADER_CYCLES, 0, 20)
	s_mul_i32 s5, s4, 3
	v_add_co_u32 v0, s2, s2, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e64 v4, null, 0, 0, s2
	s_load_b128 s[0:3], s[0:1], 0x0
	v_xor_b32_e32 v0, 0x2c7f967f, v0
	s_add_i32 s5, s5, 3
	s_delay_alu instid0(VALU_DEP_2)
	v_xor_b32_e32 v9, 0xa03697cb, v4
	s_and_b32 s5, s5, -4
	s_mov_b32 s9, 0
	v_mul_lo_u32 v0, 0x493c4aa1, v0
	s_mul_i32 s10, s8, s5
	s_waitcnt lgkmcnt(0)
	v_mul_f64 v[2:3], s[6:7], 0.5
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v5, 0x75bcd15, v0
	v_add_nc_u32_e32 v7, 0x583f19, v0
	v_lshrrev_b32_e32 v6, 2, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_xor_b32_e32 v6, v6, v5
	v_lshlrev_b32_e32 v5, 4, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v8, 1, v6
	v_xor_b32_e32 v8, v5, v8
	v_mad_u64_u32 v[4:5], null, 0x7b99840d, v9, v[0:1]
	v_cvt_u32_f64_e32 v0, v[2:3]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_xor3_b32 v2, v8, v7, v6
	v_add3_u32 v2, v4, v2, 0x6a788e
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v3, 0x80808081, v2
	v_lshrrev_b32_e32 v3, 7, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v5, 0xff, v3
	v_mad_u64_u32 v[3:4], null, v1, 3, s[10:11]
	v_sub_nc_u32_e32 v4, v2, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cmp_le_u32_e32 vcc_lo, v4, v0
	v_add_nc_u32_e32 v0, 1, v3
	s_and_saveexec_b32 s5, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s5, exec_lo, s5
; %bb.3:
	v_mov_b32_e32 v1, 0
                                        ; implicit-def: $vgpr4
	s_clause 0x1
	global_store_b8 v3, v1, s[0:1]
	global_store_b8 v0, v1, s[0:1]
                                        ; implicit-def: $vgpr0
                                        ; implicit-def: $vgpr1_vgpr2
; %bb.4:                                ; %Flow80
	s_or_saveexec_b32 s5, s5
	v_mov_b32_e32 v2, s9
	s_xor_b32 exec_lo, exec_lo, s5
	s_cbranch_execz .LBB0_10
; %bb.5:
	v_cvt_u32_f64_e32 v2, s[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_ge_u32_e32 vcc_lo, v4, v2
                                        ; implicit-def: $vgpr2
	s_and_saveexec_b32 s6, vcc_lo
	s_xor_b32 s6, exec_lo, s6
	s_cbranch_execz .LBB0_7
; %bb.6:
	v_mad_u64_u32 v[4:5], null, s8, s4, v[1:2]
	global_load_u8 v1, v4, s[2:3]
	s_waitcnt vmcnt(0)
	s_clause 0x1
	global_store_b8 v3, v1, s[0:1]
	global_store_b8 v0, v1, s[0:1]
	global_load_u8 v2, v4, s[2:3]
                                        ; implicit-def: $vgpr0
.LBB0_7:                                ; %Flow
	s_and_not1_saveexec_b32 s2, s6
	s_cbranch_execz .LBB0_9
; %bb.8:
	s_waitcnt vmcnt(0)
	v_mov_b32_e32 v2, 0xff
	s_clause 0x1
	global_store_b8 v3, v2, s[0:1]
	global_store_b8 v0, v2, s[0:1]
.LBB0_9:                                ; %Flow79
	s_or_b32 exec_lo, exec_lo, s2
.LBB0_10:                               ; %.sink.split
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s5
	v_add_nc_u32_e32 v0, 2, v3
	s_waitcnt vmcnt(0)
	global_store_b8 v0, v2, s[0:1]
.LBB0_11:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13corruptPixelsPhS_jjd
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 10
		.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	_Z13corruptPixelsPhS_jjd, .Lfunc_end0-_Z13corruptPixelsPhS_jjd
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 816
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; 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	_Z8BWKernelPhS_j        ; -- Begin function _Z8BWKernelPhS_j
	.globl	_Z8BWKernelPhS_j
	.p2align	8
	.type	_Z8BWKernelPhS_j,@function
_Z8BWKernelPhS_j:                       ; @_Z8BWKernelPhS_j
; %bb.0:
	s_load_b32 s2, s[0:1], 0x24
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s2, 0xffff
	s_load_b32 s2, s[0:1], 0x10
	v_cvt_f32_u32_e32 v1, s4
	s_sub_i32 s5, 0, s4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_waitcnt lgkmcnt(0)
	s_add_i32 s6, s2, s4
	v_cvt_u32_f32_e32 v1, v1
	s_add_i32 s6, s6, -1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_readfirstlane_b32 s3, v1
	s_mul_i32 s5, s5, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s5, s3, s5
	s_add_i32 s3, s3, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s3, s6, s3
	s_mul_i32 s5, s3, s4
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s5, s6, s5
	s_add_i32 s6, s3, 1
	s_sub_i32 s7, s5, s4
	s_cmp_ge_u32 s5, s4
	s_cselect_b32 s3, s6, s3
	s_cselect_b32 s5, s7, s5
	s_add_i32 s6, s3, 1
	s_cmp_ge_u32 s5, s4
	s_cselect_b32 s5, s6, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f32_u32_e32 v1, s5
	s_sub_i32 s6, 0, s5
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_readfirstlane_b32 s3, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s6, s6, s3
	s_mul_hi_u32 s6, s3, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s3, s3, s6
	s_mul_hi_u32 s3, s15, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_mul_i32 s6, s3, s5
	s_add_i32 s7, s3, 1
	s_sub_i32 s6, s15, s6
	s_sub_i32 s8, s6, s5
	s_cmp_ge_u32 s6, s5
	s_cselect_b32 s3, s7, s3
	s_cselect_b32 s6, s8, s6
	s_add_i32 s7, s3, 1
	s_cmp_ge_u32 s6, s5
	s_cselect_b32 s3, s7, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s5, s3, s5
	s_sub_i32 s5, s15, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s5, s4, v[0:1]
	s_mov_b32 s4, exec_lo
	v_cmpx_gt_u32_e64 s2, v1
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_mul_i32 s8, s2, 3
	s_load_b128 s[4:7], s[0:1], 0x0
	s_add_i32 s8, s8, 3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, s8, -4
	s_mul_i32 s0, s3, s0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[2:3], null, v1, 3, s[0:1]
	v_add_nc_u32_e32 v0, 1, v2
	v_add_nc_u32_e32 v3, 2, v2
	s_waitcnt lgkmcnt(0)
	s_clause 0x2
	global_load_u8 v0, v0, s[6:7]
	global_load_u8 v4, v3, s[6:7]
	global_load_u8 v6, v2, s[6:7]
	s_waitcnt vmcnt(2)
	v_cvt_f64_u32_e32 v[2:3], v0
	s_waitcnt vmcnt(1)
	v_cvt_f64_u32_e32 v[4:5], v4
	s_waitcnt vmcnt(0)
	v_cvt_f64_u32_e32 v[6:7], v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[2:3], v[2:3], v[4:5]
	v_add_f64 v[2:3], v[2:3], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_scale_f64 v[4:5], null, 0x40080000, 0x40080000, v[2:3]
	v_rcp_f64_e32 v[6:7], v[4:5]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[8:9], -v[4:5], v[6:7], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[6:7], v[6:7], v[8:9], v[6:7]
	v_fma_f64 v[8:9], -v[4:5], v[6:7], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fma_f64 v[6:7], v[6:7], v[8:9], v[6:7]
	v_div_scale_f64 v[8:9], vcc_lo, v[2:3], 0x40080000, v[2:3]
	v_mul_f64 v[10:11], v[8:9], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[4:5], -v[4:5], v[10:11], v[8:9]
	v_div_fmas_f64 v[4:5], v[4:5], v[6:7], v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f64 v[2:3], v[4:5], 0x40080000, v[2:3]
	v_cvt_i32_f64_e32 v0, v[2:3]
	v_mad_u64_u32 v[2:3], null, s3, s2, v[1:2]
	global_store_b8 v2, v0, s[4:5]
.LBB1_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8BWKernelPhS_j
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 12
		.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	_Z8BWKernelPhS_j, .Lfunc_end1-_Z8BWKernelPhS_j
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 572
; NumSgprs: 18
; NumVgprs: 12
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 12
; 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	_Z7PixCopyPhS_j         ; -- Begin function _Z7PixCopyPhS_j
	.globl	_Z7PixCopyPhS_j
	.p2align	8
	.type	_Z7PixCopyPhS_j,@function
_Z7PixCopyPhS_j:                        ; @_Z7PixCopyPhS_j
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b32 s3, s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_ge_u32_e64 s3, v1
	s_cbranch_execz .LBB2_2
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	global_load_u8 v0, v1, s[2:3]
	s_waitcnt vmcnt(0)
	global_store_b8 v1, v0, s[0:1]
.LBB2_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7PixCopyPhS_j
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 3
		.amdhsa_next_free_sgpr 16
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z7PixCopyPhS_j, .Lfunc_end2-_Z7PixCopyPhS_j
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 104
; NumSgprs: 16
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 3
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13corruptPixelsPhS_jjd
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13corruptPixelsPhS_jjd.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8BWKernelPhS_j
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8BWKernelPhS_j.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     12
    .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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7PixCopyPhS_j
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z7PixCopyPhS_j.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
