#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include <stdio.h>
#include <math.h>
#include <iostream>

using namespace std;

#define BLOCKDIM_X		16
#define BLOCKDIM_Y		16

#define GRIDDIM_X		256
#define GRIDDIM_Y		256
#define MASK_WIDTH		5

__constant__ int d_const_Gaussian[MASK_WIDTH*MASK_WIDTH]; //常量

static __global__ void kernel_GaussianFilt(int width, int height, int byte_per_pixel, unsigned char *d_src_imgbuf, unsigned char *d_guassian_imgbuf);
int parseInt(int , char* );
int read(FILE*, int, int);
int** parse_bmp(const char* filepath, int* width, int* height);
void write_buffer(int value, FILE* file, int length);
void write_file(const char* filepath, int width, int height, int** data);
unsigned char * transformToUCharVector(int ** data, int width, int height, int byte_per_pixel);
int ** transformToIntMatrix(unsigned char * data, int width, int height, int byte_per_pixel);

unsigned long GetTickCount()
{
    struct timespec ts;

    clock_gettime(CLOCK_MONOTONIC, &ts);

    return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);

}


int main(int argc, char **argv)
{
	char* input_path;
	char* output_path;
	if (argc != 3) {
		input_path = "/home/cloud/workspace/hand/test1.bmp";
		output_path = "/home/cloud/workspace/hand/result.bmp";
	} else {
		input_path = argv[1];
		output_path = argv[2];
	}

	// char * input_path = "C:\\Users\\congj\\Desktop\\result.bmp";
	// char * output_path = "C:\\Users\\congj\\Desktop\\gs.bmp";
	printf("input_path: %s\n", input_path);
	printf("output_path: %s\n", output_path);
	
	struct cudaDeviceProp pror;
	cudaGetDeviceProperties(&pror, 0);
	cout << "maxThreadsPerBlock=" << pror.maxThreadsPerBlock << endl;

	long start, end;
	long time = 0;

	start = GetTickCount();
	cudaEvent_t startt, stop; 
	cudaEventCreate(&startt);
	cudaEventCreate(&stop);
	cudaEventRecord(startt, 0);

	unsigned char *h_src_imgbuf;
	int width, height, byte_per_pixel = 3;

	int **d = parse_bmp(input_path, &width, &height);
	h_src_imgbuf = transformToUCharVector(d, width, height, byte_per_pixel);

	printf("width: %d, height: %d, byte_per_pixel: %d\n", width, height, byte_per_pixel);

	int size1 = width * height *byte_per_pixel * sizeof(unsigned char);

	//host memory
	unsigned char *h_guassian_imgbuf = new unsigned char[width*height*byte_per_pixel];

	//device memory
	unsigned char *d_src_imgbuf;
	unsigned char *d_guassian_imgbuf;

	cudaMalloc((void**)&d_src_imgbuf, size1);
	cudaMalloc((void**)&d_guassian_imgbuf, size1);

	//copy data from host to device
	cudaMemcpy(d_src_imgbuf, h_src_imgbuf, size1, cudaMemcpyHostToDevice);

	//gaussian matrix constant memory
	int Gaussian[25] = { 1,4,7,4,1,
						4,16,26,16,4,
						7,26,41,26,7,
						4,16,26,16,4,
						1,4,7,4,1 };//sum is 273
	cudaMemcpyToSymbol(d_const_Gaussian, Gaussian, 25 * sizeof(int));

	int bx = ceil((double)width / BLOCKDIM_X); // 40
	int by = ceil((double)height / BLOCKDIM_Y); //26

	if (bx > GRIDDIM_X) bx = GRIDDIM_X;
	if (by > GRIDDIM_Y) by = GRIDDIM_Y;
	//suppose width=638, height=411

	dim3 grid(bx, by); //40,26
	dim3 block(BLOCKDIM_X, BLOCKDIM_Y); //16,16

	//kernel
	kernel_GaussianFilt<<<grid, block>>>(width, height, byte_per_pixel, d_src_imgbuf, d_guassian_imgbuf);
	cudaMemcpy(h_guassian_imgbuf, d_guassian_imgbuf, size1, cudaMemcpyDeviceToHost);

	// saveBmp(output_path, h_guassian_imgbuf, width, height, byte_per_pixel);
	write_file(output_path, width, height, transformToIntMatrix(h_guassian_imgbuf, width, height, byte_per_pixel));
	//
	cudaFree(d_src_imgbuf);
	cudaFree(d_guassian_imgbuf);

	delete[]h_src_imgbuf;
	delete[]h_guassian_imgbuf;

	end = GetTickCount();
	//InterlockedExchangeAdd(&time, end - start); //window api
	__sync_fetch_and_add(&time, end - start); // linux api
	cout << "Total time GPU:";
	cout << time << endl;

	return 0;
}

static __global__ void kernel_GaussianFilt(int width, int height, int byte_per_pixel, unsigned char *d_src_imgbuf, unsigned char *d_dst_imgbuf)
{
	const int tix = blockDim.x * blockIdx.x + threadIdx.x;
	const int tiy = blockDim.y * blockIdx.y + threadIdx.y;
	/*cout << threadIdx.x << endl;
	cout << threadIdx.y << endl;*/
	const int threadTotalX = blockDim.x * gridDim.x;
	const int threadTotalY = blockDim.y * gridDim.y;

	for (int ix = tix; ix < height; ix += threadTotalX)
		for (int iy = tiy; iy < width; iy += threadTotalY)
		{
			for (int k = 0; k < byte_per_pixel; k++)
			{
				int sum = 0;
				int tempPixelValue = 0;
				for (int m = -2; m <= 2; m++)
				{
					for (int n = -2; n <= 2; n++)
					{
						if (ix + m < 0 || iy + n < 0 || ix + m >= height || iy + n >= width)
							tempPixelValue = 0;
						else
							tempPixelValue = *(d_src_imgbuf + (ix + m)*width*byte_per_pixel + (iy + n)*byte_per_pixel + k);
						sum += tempPixelValue * d_const_Gaussian[(m + 2) * 5 + n + 2];
					}
				}

				if (sum / 273 < 0)
					*(d_dst_imgbuf + (ix)*width*byte_per_pixel + (iy)*byte_per_pixel + k) = 0;
				else if (sum / 273 > 255)
					*(d_dst_imgbuf + (ix)*width*byte_per_pixel + (iy)*byte_per_pixel + k) = 255;
				else
					*(d_dst_imgbuf + (ix)*width*byte_per_pixel + (iy)*byte_per_pixel + k) = sum / 273;
			}
		}
}

int parseInt(int length, char* s)
{
	int result = 0;
	int shift = 0;
	for (int i = 0; i < length; i++)
	{
		//cout << hex << (int)(s[i] & 0x000000ff) << endl;
		result += (s[i]& 0x000000ff) << shift;
		shift += 8;
	}
	return result;
}

int read(FILE* file, int offset, int length)
{
	static char buff[4];
	fseek(file, offset, 0);
	fread(buff, sizeof(char), length, file);
	//current = offset + length;

	//cout << "current: " << ftell(file) << endl;
	return parseInt(length, buff);
}

int** parse_bmp(const char* filepath, int* width, int* height)
{
	FILE * file = fopen(filepath, "rb");
	if (!file) 
	{
		cerr << "文件打开失败。" << endl;
		exit(-1);
	}
	fseek(file, 0x0A, 0);

	int content_offset = read(file, 0x0A, 4);
	*width = read(file, 0x12, 4);
	*height = read(file, 0x16, 4);

	int** result;
	result = (int**)malloc(sizeof(int*) * 3);
	for (int i = 0; i < 3; i++)
	{
		result[i] = (int*)malloc(sizeof(int) * (*width) * (*height));
	}

	fseek(file, content_offset, 0);

	int pixel_acount = (*width) * (*height);

	int byte_in_row = *width * 24/8;
	int actual_byte_in_row = byte_in_row + 4 - byte_in_row % 4;

	cout << byte_in_row << endl;
	cout << actual_byte_in_row << endl;

	char* buffer;
	buffer = (char *)malloc(sizeof(char) * actual_byte_in_row);
	for (int i = 0; i < *height; i++) {
		fread(buffer, sizeof(char), actual_byte_in_row, file);
		for (int j = 0; j < *width; j++) {
			result[0][i* *width + j] = buffer[3 * j] & 0x000000ff;
			result[1][i* *width + j] = buffer[3 * j + 1] & 0x000000ff;
			result[2][i* *width + j] = buffer[3 * j + 2] & 0x000000ff;
		}
	}
	

	fclose(file);
	return result;
}

void write_buffer(int value, FILE* file, int length)
{
	static char buffer[4];
	for (int i = 0; i < length; i++)
	{
		char v_low8 = value & 0x000000ff;
		//cout << hex << int(v_low8) << endl;
		value = value >> 8;
		buffer[i] = v_low8;
	}
	for (int i = length - 1; i >= 0; i--)
		fwrite(buffer+length-1-i, sizeof(char), 1, file);
}

void write_file(const char* filepath, int width, int height, int** data)
{
	FILE *file = fopen(filepath, "wb");
	if (!file)
	{
		cerr << "文件打开错误" << endl;
		exit(-1);
	}
	char buffer[4];
	buffer[0] = 0x42;
	buffer[1] = 0x4D;
	fwrite(buffer, sizeof(char), 2, file); //写入BM

	int byte_in_row = width * 24 / 8;
	int actual_byte_in_row = byte_in_row + 4 - byte_in_row % 4;

	int size = 54 + actual_byte_in_row*height;
	write_buffer(size, file, 4); //写入文件大小的字节数
	write_buffer(0, file, 2); //写入保留字节 2个字节
	write_buffer(0, file, 2); //写入保留字节 2个字节
	write_buffer(54, file, 4); //写入偏移量，4个字节
	write_buffer(40, file, 4); //写入头部长度
	write_buffer(width, file, 4); //写入宽度
	write_buffer(height, file, 4); //写入高度
	write_buffer(1, file, 2); //平面数，总是被设置为1
	write_buffer(24, file, 2); //每像素位数
	write_buffer(0, file, 4); //不压缩
	write_buffer(height*actual_byte_in_row, file, 4); //图像字节数
	write_buffer(0, file, 4); //图像字节数
	write_buffer(0, file, 4); //图像字节数
	write_buffer(0, file, 4); //图像字节数
	write_buffer(0, file, 4); //图像字节数

	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++)
		{
			write_buffer(data[0][i*width + j], file, 1);
			write_buffer(data[1][i*width + j], file, 1);
			write_buffer(data[2][i*width + j], file, 1);
		}
		if (actual_byte_in_row - byte_in_row != 0)
			write_buffer(0, file, actual_byte_in_row - byte_in_row);
		cout << i << endl;
	}
	

	fclose(file);
}

unsigned char * transformToUCharVector(int ** data, int width, int height, int byte_per_pixel)
{
	unsigned char * result;
	result = (unsigned char *)malloc(sizeof(unsigned char) * width * height * byte_per_pixel);
	for (int i=0; i<width*height; i++)
	{
		for (int j=0; j<byte_per_pixel; j++)
		{
			result[i*byte_per_pixel + j] = (unsigned char)(data[j][i] & 0x000000ff);
		}
	}
	return result;
}

int ** transformToIntMatrix(unsigned char * data, int width, int height, int byte_per_pixel)
{
	int ** result;
	result = (int**)malloc(sizeof(int *)*byte_per_pixel);
	
	for (int i=0; i<byte_per_pixel; i++)
		result[i] = (int *)malloc(sizeof(int)*width*height);
	
	for (int i=0; i<width*height; i++)
		for (int j=0; j<byte_per_pixel; j++) 
			result[j][i] = data[i*byte_per_pixel+j] & 0x000000ff;
	
	return result;
}

	.file	"tmpxft_00396d31_00000000-6_gf.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3646:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3646:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_ZL44__device_stub__Z19kernel_GaussianFiltiiiPhS_iiiPhS_, @function
_ZL44__device_stub__Z19kernel_GaussianFiltiiiPhS_iiiPhS_:
.LFB3668:
	.cfi_startproc
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	48(%rsp), %rdi
	movl	%esi, 24(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 20(%rsp)
	leaq	32(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	20(%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	.L2
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_ZL19kernel_GaussianFiltiiiPhS_(%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
.L2:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3668:
	.size	_ZL44__device_stub__Z19kernel_GaussianFiltiiiPhS_iiiPhS_, .-_ZL44__device_stub__Z19kernel_GaussianFiltiiiPhS_iiiPhS_
	.type	_ZL19kernel_GaussianFiltiiiPhS_, @function
_ZL19kernel_GaussianFiltiiiPhS_:
.LFB3669:
	.cfi_startproc
	endbr64
	jmp	_ZL44__device_stub__Z19kernel_GaussianFiltiiiPhS_iiiPhS_
	.cfi_endproc
.LFE3669:
	.size	_ZL19kernel_GaussianFiltiiiPhS_, .-_ZL19kernel_GaussianFiltiiiPhS_
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4304:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4304:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.globl	_Z12GetTickCountv
	.type	_Z12GetTickCountv, @function
_Z12GetTickCountv:
.LFB3635:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movl	$1, %edi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	call	clock_gettime@PLT
	movq	16(%rsp), %rax
	movl	$1000000, %esi
	imulq	$1000, 8(%rsp), %rcx
	cqto
	idivq	%rsi
	addq	%rcx, %rax
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z12GetTickCountv, .-_Z12GetTickCountv
	.globl	_Z8parseIntiPc
	.type	_Z8parseIntiPc, @function
_Z8parseIntiPc:
.LFB3637:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	xorl	%edx, %edx
.L13:
	leal	0(,%rax,8), %ecx
	cmpl	%eax, %edi
	jle	.L15
	movzbl	(%rsi,%rax), %r8d
	incq	%rax
	sall	%cl, %r8d
	addl	%r8d, %edx
	jmp	.L13
.L15:
	movl	%edx, %eax
	ret
	.cfi_endproc
.LFE3637:
	.size	_Z8parseIntiPc, .-_Z8parseIntiPc
	.globl	_Z4readP8_IO_FILEii
	.type	_Z4readP8_IO_FILEii, @function
_Z4readP8_IO_FILEii:
.LFB3638:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movslq	%esi, %rsi
	leaq	_ZZ4readP8_IO_FILEiiE4buff(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edx, %ebx
	xorl	%edx, %edx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	%rdi, 8(%rsp)
	call	fseek@PLT
	movq	8(%rsp), %r8
	movq	%rbp, %rdi
	movslq	%ebx, %rcx
	movl	$4, %esi
	movl	$1, %edx
	call	__fread_chk@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	movq	%rbp, %rsi
	movl	%ebx, %edi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z8parseIntiPc
	.cfi_endproc
.LFE3638:
	.size	_Z4readP8_IO_FILEii, .-_Z4readP8_IO_FILEii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"rb"
.LC2:
	.string	"\346\226\207\344\273\266\346\211\223\345\274\200\345\244\261\350\264\245\343\200\202"
	.text
	.globl	_Z9parse_bmpPKcPiS1_
	.type	_Z9parse_bmpPKcPiS1_, @function
_Z9parse_bmpPKcPiS1_:
.LFB3639:
	.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	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	leaq	.LC1(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L19
	leaq	.LC2(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	orl	$-1, %edi
	call	exit@PLT
.L19:
	movq	%rax, %rbx
	xorl	%edx, %edx
	movl	$10, %esi
	movq	%rax, %rdi
	call	fseek@PLT
	movl	$4, %edx
	movq	%rbx, %rdi
	xorl	%r14d, %r14d
	movl	$10, %esi
	call	_Z4readP8_IO_FILEii
	movl	$4, %edx
	movl	$18, %esi
	movq	%rbx, %rdi
	movl	%eax, %ebp
	call	_Z4readP8_IO_FILEii
	movl	$4, %edx
	movl	$22, %esi
	movq	%rbx, %rdi
	movl	%eax, (%r12)
	call	_Z4readP8_IO_FILEii
	movl	$24, %edi
	movl	%eax, 0(%r13)
	call	malloc@PLT
	movq	%rax, %r15
.L20:
	movslq	(%r12), %rdi
	movslq	0(%r13), %rax
	imulq	%rax, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, (%r15,%r14,8)
	incq	%r14
	cmpq	$3, %r14
	jne	.L20
	movslq	%ebp, %rsi
	xorl	%edx, %edx
	leaq	_ZSt4cout(%rip), %r14
	movq	%rbx, %rdi
	call	fseek@PLT
	imull	$3, (%r12), %esi
	movl	$4, %ecx
	movq	%r14, %rdi
	movl	%esi, %eax
	leal	4(%rsi), %ebp
	cltd
	idivl	%ecx
	subl	%edx, %ebp
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	%ebp, %esi
	movq	%r14, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movslq	%ebp, %rax
	xorl	%ebp, %ebp
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%rax, %r14
.L21:
	cmpl	%ebp, 0(%r13)
	jle	.L27
	movq	8(%rsp), %rcx
	movl	$1, %edx
	movq	%rbx, %r8
	movq	%r14, %rdi
	movq	%rcx, %rsi
	call	__fread_chk@PLT
	movl	(%r12), %esi
	movq	%r14, %rcx
	xorl	%edx, %edx
	movl	%esi, %eax
	imull	%ebp, %eax
	cltq
	salq	$2, %rax
.L22:
	cmpl	%edx, %esi
	jle	.L28
	movzbl	(%rcx), %r8d
	movq	(%r15), %rdi
	incl	%edx
	addq	$3, %rcx
	movl	%r8d, (%rdi,%rax)
	movzbl	-2(%rcx), %r8d
	movq	8(%r15), %rdi
	movl	%r8d, (%rdi,%rax)
	movzbl	-1(%rcx), %r8d
	movq	16(%r15), %rdi
	movl	%r8d, (%rdi,%rax)
	addq	$4, %rax
	jmp	.L22
.L28:
	incl	%ebp
	jmp	.L21
.L27:
	movq	%rbx, %rdi
	call	fclose@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	movq	%r15, %rax
	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
.LFE3639:
	.size	_Z9parse_bmpPKcPiS1_, .-_Z9parse_bmpPKcPiS1_
	.globl	_Z12write_bufferiP8_IO_FILEi
	.type	_Z12write_bufferiP8_IO_FILEi, @function
_Z12write_bufferiP8_IO_FILEi:
.LFB3640:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%eax, %eax
	leaq	_ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip), %rcx
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
.L30:
	cmpl	%eax, %edx
	jle	.L35
	movl	%edi, %esi
	sarl	$8, %edi
	movb	%sil, (%rcx,%rax)
	incq	%rax
	jmp	.L30
.L35:
	leal	-1(%rdx), %ebx
	leaq	_ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip), %r12
.L32:
	testl	%ebx, %ebx
	js	.L36
	movq	%r12, %rdi
	movq	%rbp, %rcx
	movl	$1, %edx
	movl	$1, %esi
	call	fwrite@PLT
	decl	%ebx
	incq	%r12
	jmp	.L32
.L36:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3640:
	.size	_Z12write_bufferiP8_IO_FILEi, .-_Z12write_bufferiP8_IO_FILEi
	.section	.rodata.str1.1
.LC3:
	.string	"wb"
.LC4:
	.string	"\346\226\207\344\273\266\346\211\223\345\274\200\351\224\231\350\257\257"
	.text
	.globl	_Z10write_filePKciiPPi
	.type	_Z10write_filePKciiPPi, @function
_Z10write_filePKciiPPi:
.LFB3641:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rcx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%edx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	leaq	.LC3(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	movq	%rax, 8(%rsp)
	testq	%rax, %rax
	jne	.L38
	leaq	.LC4(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	orl	$-1, %edi
	call	exit@PLT
.L38:
	movq	8(%rsp), %rcx
	leaq	36(%rsp), %rdi
	movl	$2, %edx
	movl	$1, %esi
	leal	0(%rbp,%rbp,2), %r12d
	movw	$19778, 36(%rsp)
	call	fwrite@PLT
	movl	%r12d, %eax
	movl	$4, %ecx
	leal	4(%r12), %r13d
	cltd
	movq	8(%rsp), %rsi
	idivl	%ecx
	subl	%edx, %r13d
	movl	$4, %edx
	movl	%r13d, %ebx
	imull	%r14d, %ebx
	leal	54(%rbx), %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$2, %edx
	xorl	%edi, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$2, %edx
	xorl	%edi, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	movl	$54, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	movl	$40, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	movl	%ebp, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	movl	%r14d, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$2, %edx
	movl	$1, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$2, %edx
	movl	$24, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	xorl	%edi, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	movl	%ebx, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	xorl	%edi, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	xorl	%edi, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	xorl	%edi, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%rsp), %rsi
	movl	$4, %edx
	xorl	%edi, %edi
	call	_Z12write_bufferiP8_IO_FILEi
	xorl	%eax, %eax
	movl	%eax, 24(%rsp)
	movl	%eax, 20(%rsp)
.L39:
	cmpl	%r14d, 20(%rsp)
	jge	.L42
	movslq	24(%rsp), %rbx
	xorl	%eax, %eax
	salq	$2, %rbx
.L43:
	cmpl	%ebp, %eax
	jge	.L46
	movq	(%r15), %rdx
	movq	8(%rsp), %rsi
	movl	%eax, 28(%rsp)
	movl	(%rdx,%rbx), %edi
	movl	$1, %edx
	call	_Z12write_bufferiP8_IO_FILEi
	movq	8(%r15), %rdx
	movq	8(%rsp), %rsi
	movl	(%rdx,%rbx), %edi
	movl	$1, %edx
	call	_Z12write_bufferiP8_IO_FILEi
	movq	16(%r15), %rdx
	movq	8(%rsp), %rsi
	movl	(%rdx,%rbx), %edi
	movl	$1, %edx
	addq	$4, %rbx
	call	_Z12write_bufferiP8_IO_FILEi
	movl	28(%rsp), %eax
	incl	%eax
	jmp	.L43
.L46:
	cmpl	%r13d, %r12d
	je	.L41
	movl	%r13d, %edx
	movq	8(%rsp), %rsi
	xorl	%edi, %edi
	subl	%r12d, %edx
	call	_Z12write_bufferiP8_IO_FILEi
.L41:
	movl	20(%rsp), %esi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	incl	20(%rsp)
	addl	%ebp, 24(%rsp)
	jmp	.L39
.L42:
	movq	8(%rsp), %rdi
	call	fclose@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3641:
	.size	_Z10write_filePKciiPPi, .-_Z10write_filePKciiPPi
	.globl	_Z22transformToUCharVectorPPiiii
	.type	_Z22transformToUCharVectorPPiiii, @function
_Z22transformToUCharVectorPPiiii:
.LFB3642:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movslq	%ecx, %rax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rax, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdi, %rbp
	movslq	%edx, %rdi
	movq	%rdi, %r13
	imulq	%rax, %rdi
	movslq	%esi, %rax
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%esi, %ebx
	pushq	%r8
	.cfi_def_cfa_offset 48
	imull	%r13d, %ebx
	imulq	%rax, %rdi
	call	malloc@PLT
	xorl	%edi, %edi
	xorl	%esi, %esi
.L48:
	cmpl	%esi, %ebx
	jle	.L47
	movslq	%edi, %rdx
	leaq	0(,%rsi,4), %r8
	xorl	%ecx, %ecx
	addq	%rax, %rdx
.L51:
	cmpl	%ecx, %r12d
	jle	.L53
	movq	0(%rbp,%rcx,8), %r9
	movl	(%r9,%r8), %r9d
	movb	%r9b, (%rdx,%rcx)
	incq	%rcx
	jmp	.L51
.L53:
	incq	%rsi
	addl	%r12d, %edi
	jmp	.L48
.L47:
	popq	%rdx
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3642:
	.size	_Z22transformToUCharVectorPPiiii, .-_Z22transformToUCharVectorPPiiii
	.globl	_Z20transformToIntMatrixPhiii
	.type	_Z20transformToIntMatrixPhiii, @function
_Z20transformToIntMatrixPhiii:
.LFB3643:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edx, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	movslq	%ecx, %rdi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movslq	%esi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	salq	$3, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r13, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	malloc@PLT
	movq	%rax, %r12
	movslq	%r15d, %rax
	imulq	%rax, %r13
	leaq	0(,%r13,4), %rax
	xorl	%r13d, %r13d
	movq	%rax, 8(%rsp)
.L55:
	cmpl	%r13d, %ebp
	jle	.L62
	movq	8(%rsp), %rdi
	call	malloc@PLT
	movq	%rax, (%r12,%r13,8)
	incq	%r13
	jmp	.L55
.L62:
	imull	%r15d, %ebx
	xorl	%esi, %esi
	xorl	%edx, %edx
.L57:
	cmpl	%edx, %ebx
	jle	.L54
	movslq	%esi, %rcx
	leaq	0(,%rdx,4), %rdi
	xorl	%eax, %eax
	addq	%r14, %rcx
.L60:
	cmpl	%eax, %ebp
	jle	.L63
	movq	(%r12,%rax,8), %r8
	movzbl	(%rcx,%rax), %r9d
	incq	%rax
	movl	%r9d, (%r8,%rdi)
	jmp	.L60
.L63:
	incq	%rdx
	addl	%ebp, %esi
	jmp	.L57
.L54:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	movq	%r12, %rax
	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
.LFE3643:
	.size	_Z20transformToIntMatrixPhiii, .-_Z20transformToIntMatrixPhiii
	.section	.rodata.str1.1
.LC5:
	.string	"/home/cloud/workspace/hand/result.bmp"
.LC6:
	.string	"/home/cloud/workspace/hand/test1.bmp"
.LC7:
	.string	"input_path: %s\n"
.LC8:
	.string	"output_path: %s\n"
.LC9:
	.string	"maxThreadsPerBlock="
.LC10:
	.string	"width: %d, height: %d, byte_per_pixel: %d\n"
.LC12:
	.string	"Total time GPU:"
	.section	.rodata
	.align 32
.LC0:
	.long	1
	.long	4
	.long	7
	.long	4
	.long	1
	.long	4
	.long	16
	.long	26
	.long	16
	.long	4
	.long	7
	.long	26
	.long	41
	.long	26
	.long	7
	.long	4
	.long	16
	.long	26
	.long	16
	.long	4
	.long	1
	.long	4
	.long	7
	.long	4
	.long	1
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC5(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC6(%rip), %rbx
	subq	$1240, %rsp
	.cfi_def_cfa_offset 1296
	movq	%fs:40, %rax
	movq	%rax, 1224(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	jne	.L65
	movq	8(%rsi), %rbx
	movq	16(%rsi), %r15
.L65:
	movq	%rbx, %rdx
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r15, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rsi
	call	__printf_chk@PLT
	xorl	%esi, %esi
	leaq	192(%rsp), %rdi
	call	cudaGetDeviceProperties_v2@PLT
	leaq	.LC9(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	512(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	xorl	%eax, %eax
	movq	%rax, 24(%rsp)
	call	_Z12GetTickCountv
	leaq	32(%rsp), %rdi
	movq	%rax, %r14
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	%rbx, %rdi
	leaq	20(%rsp), %rdx
	leaq	16(%rsp), %rsi
	call	_Z9parse_bmpPKcPiS1_
	movl	20(%rsp), %r12d
	movl	16(%rsp), %ebp
	movl	$3, %ecx
	movq	%rax, %rdi
	movl	%r12d, %ebx
	movl	%r12d, %edx
	movl	%ebp, %esi
	call	_Z22transformToUCharVectorPPiiii
	imull	%ebp, %ebx
	movl	$3, %r8d
	movl	%ebp, %edx
	movl	%r12d, %ecx
	leaq	.LC10(%rip), %rsi
	movq	%rax, %r13
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leal	(%rbx,%rbx,2), %ebx
	movslq	%ebx, %rbx
	movq	%rbx, %rdi
	call	_Znam@PLT
	leaq	48(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rax, (%rsp)
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	48(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	92(%rsp), %rdi
	movl	$25, %ecx
	leaq	.LC0(%rip), %rsi
	rep movsl
	movl	$1, %r8d
	leaq	92(%rsp), %rsi
	movl	$100, %edx
	leaq	_ZL16d_const_Gaussian(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	cvtsi2sdl	%ebp, %xmm0
	mulsd	.LC11(%rip), %xmm0
	call	ceil@PLT
	movsd	%xmm0, 8(%rsp)
	cvtsi2sdl	%r12d, %xmm0
	mulsd	.LC11(%rip), %xmm0
	call	ceil@PLT
	movsd	8(%rsp), %xmm1
	movl	$256, %edx
	movl	$1, %ecx
	movl	$1, %esi
	movl	$1, 76(%rsp)
	cvttsd2sil	%xmm1, %eax
	movl	$1, 88(%rsp)
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	movl	%eax, 68(%rsp)
	cvttsd2sil	%xmm0, %eax
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$68719476752, %rdx
	movq	%rdx, 80(%rsp)
	movl	%eax, 72(%rsp)
	movq	68(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L66
	movq	56(%rsp), %r8
	movq	48(%rsp), %rcx
	movl	%r12d, %esi
	movl	%ebp, %edi
	movl	$3, %edx
	call	_ZL44__device_stub__Z19kernel_GaussianFiltiiiPhS_iiiPhS_
.L66:
	movq	56(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	$2, %ecx
	movq	%rbx, %rdx
	call	cudaMemcpy@PLT
	movq	(%rsp), %rdi
	movl	$3, %ecx
	movl	%ebp, %esi
	movl	%r12d, %edx
	call	_Z20transformToIntMatrixPhiii
	movl	%r12d, %edx
	movl	%ebp, %esi
	movq	%r15, %rdi
	movq	%rax, %rcx
	call	_Z10write_filePKciiPPi
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	testq	%r13, %r13
	je	.L67
	movq	%r13, %rdi
	call	_ZdaPv@PLT
.L67:
	movq	(%rsp), %rdi
	call	_ZdaPv@PLT
	call	_Z12GetTickCountv
	subq	%r14, %rax
	lock addq	%rax, 24(%rsp)
	leaq	.LC12(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	24(%rsp), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZNSo9_M_insertIlEERSoT_@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	1224(%rsp), %rax
	subq	%fs:40, %rax
	je	.L68
	call	__stack_chk_fail@PLT
.L68:
	addq	$1240, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.LFE3636:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z19kernel_GaussianFiltiiiPhS_"
.LC15:
	.string	"d_const_Gaussian"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3671:
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_ZL19kernel_GaussianFiltiiiPhS_(%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	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC15(%rip), %rdx
	movl	$100, %r9d
	leaq	_ZL16d_const_Gaussian(%rip), %rsi
	pushq	$1
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3671:
	.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	_ZZ12write_bufferiP8_IO_FILEiE6buffer
	.comm	_ZZ12write_bufferiP8_IO_FILEiE6buffer,4,1
	.local	_ZZ4readP8_IO_FILEiiE4buff
	.comm	_ZZ4readP8_IO_FILEiiE4buff,4,1
	.local	_ZL16d_const_Gaussian
	.comm	_ZL16d_const_Gaussian,100,32
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC11:
	.long	0
	.long	1068498944
	.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>
#include <math.h>
#include <iostream>

using namespace std;

#define BLOCKDIM_X		16
#define BLOCKDIM_Y		16

#define GRIDDIM_X		256
#define GRIDDIM_Y		256
#define MASK_WIDTH		5

__constant__ int d_const_Gaussian[MASK_WIDTH*MASK_WIDTH]; //常量

static __global__ void kernel_GaussianFilt(int width, int height, int byte_per_pixel, unsigned char *d_src_imgbuf, unsigned char *d_guassian_imgbuf);
int parseInt(int , char* );
int read(FILE*, int, int);
int** parse_bmp(const char* filepath, int* width, int* height);
void write_buffer(int value, FILE* file, int length);
void write_file(const char* filepath, int width, int height, int** data);
unsigned char * transformToUCharVector(int ** data, int width, int height, int byte_per_pixel);
int ** transformToIntMatrix(unsigned char * data, int width, int height, int byte_per_pixel);

unsigned long GetTickCount()
{
    struct timespec ts;

    clock_gettime(CLOCK_MONOTONIC, &ts);

    return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);

}


int main(int argc, char **argv)
{
	char* input_path;
	char* output_path;
	if (argc != 3) {
		input_path = "/home/cloud/workspace/hand/test1.bmp";
		output_path = "/home/cloud/workspace/hand/result.bmp";
	} else {
		input_path = argv[1];
		output_path = argv[2];
	}

	// char * input_path = "C:\\Users\\congj\\Desktop\\result.bmp";
	// char * output_path = "C:\\Users\\congj\\Desktop\\gs.bmp";
	printf("input_path: %s\n", input_path);
	printf("output_path: %s\n", output_path);
	
	struct hipDeviceProp_t pror;
	hipGetDeviceProperties(&pror, 0);
	cout << "maxThreadsPerBlock=" << pror.maxThreadsPerBlock << endl;

	long start, end;
	long time = 0;

	start = GetTickCount();
	hipEvent_t startt, stop; 
	hipEventCreate(&startt);
	hipEventCreate(&stop);
	hipEventRecord(startt, 0);

	unsigned char *h_src_imgbuf;
	int width, height, byte_per_pixel = 3;

	int **d = parse_bmp(input_path, &width, &height);
	h_src_imgbuf = transformToUCharVector(d, width, height, byte_per_pixel);

	printf("width: %d, height: %d, byte_per_pixel: %d\n", width, height, byte_per_pixel);

	int size1 = width * height *byte_per_pixel * sizeof(unsigned char);

	//host memory
	unsigned char *h_guassian_imgbuf = new unsigned char[width*height*byte_per_pixel];

	//device memory
	unsigned char *d_src_imgbuf;
	unsigned char *d_guassian_imgbuf;

	hipMalloc((void**)&d_src_imgbuf, size1);
	hipMalloc((void**)&d_guassian_imgbuf, size1);

	//copy data from host to device
	hipMemcpy(d_src_imgbuf, h_src_imgbuf, size1, hipMemcpyHostToDevice);

	//gaussian matrix constant memory
	int Gaussian[25] = { 1,4,7,4,1,
						4,16,26,16,4,
						7,26,41,26,7,
						4,16,26,16,4,
						1,4,7,4,1 };//sum is 273
	hipMemcpyToSymbol(HIP_SYMBOL(d_const_Gaussian), Gaussian, 25 * sizeof(int));

	int bx = ceil((double)width / BLOCKDIM_X); // 40
	int by = ceil((double)height / BLOCKDIM_Y); //26

	if (bx > GRIDDIM_X) bx = GRIDDIM_X;
	if (by > GRIDDIM_Y) by = GRIDDIM_Y;
	//suppose width=638, height=411

	dim3 grid(bx, by); //40,26
	dim3 block(BLOCKDIM_X, BLOCKDIM_Y); //16,16

	//kernel
	kernel_GaussianFilt<<<grid, block>>>(width, height, byte_per_pixel, d_src_imgbuf, d_guassian_imgbuf);
	hipMemcpy(h_guassian_imgbuf, d_guassian_imgbuf, size1, hipMemcpyDeviceToHost);

	// saveBmp(output_path, h_guassian_imgbuf, width, height, byte_per_pixel);
	write_file(output_path, width, height, transformToIntMatrix(h_guassian_imgbuf, width, height, byte_per_pixel));
	//
	hipFree(d_src_imgbuf);
	hipFree(d_guassian_imgbuf);

	delete[]h_src_imgbuf;
	delete[]h_guassian_imgbuf;

	end = GetTickCount();
	//InterlockedExchangeAdd(&time, end - start); //window api
	__sync_fetch_and_add(&time, end - start); // linux api
	cout << "Total time GPU:";
	cout << time << endl;

	return 0;
}

static __global__ void kernel_GaussianFilt(int width, int height, int byte_per_pixel, unsigned char *d_src_imgbuf, unsigned char *d_dst_imgbuf)
{
	const int tix = blockDim.x * blockIdx.x + threadIdx.x;
	const int tiy = blockDim.y * blockIdx.y + threadIdx.y;
	/*cout << threadIdx.x << endl;
	cout << threadIdx.y << endl;*/
	const int threadTotalX = blockDim.x * gridDim.x;
	const int threadTotalY = blockDim.y * gridDim.y;

	for (int ix = tix; ix < height; ix += threadTotalX)
		for (int iy = tiy; iy < width; iy += threadTotalY)
		{
			for (int k = 0; k < byte_per_pixel; k++)
			{
				int sum = 0;
				int tempPixelValue = 0;
				for (int m = -2; m <= 2; m++)
				{
					for (int n = -2; n <= 2; n++)
					{
						if (ix + m < 0 || iy + n < 0 || ix + m >= height || iy + n >= width)
							tempPixelValue = 0;
						else
							tempPixelValue = *(d_src_imgbuf + (ix + m)*width*byte_per_pixel + (iy + n)*byte_per_pixel + k);
						sum += tempPixelValue * d_const_Gaussian[(m + 2) * 5 + n + 2];
					}
				}

				if (sum / 273 < 0)
					*(d_dst_imgbuf + (ix)*width*byte_per_pixel + (iy)*byte_per_pixel + k) = 0;
				else if (sum / 273 > 255)
					*(d_dst_imgbuf + (ix)*width*byte_per_pixel + (iy)*byte_per_pixel + k) = 255;
				else
					*(d_dst_imgbuf + (ix)*width*byte_per_pixel + (iy)*byte_per_pixel + k) = sum / 273;
			}
		}
}

int parseInt(int length, char* s)
{
	int result = 0;
	int shift = 0;
	for (int i = 0; i < length; i++)
	{
		//cout << hex << (int)(s[i] & 0x000000ff) << endl;
		result += (s[i]& 0x000000ff) << shift;
		shift += 8;
	}
	return result;
}

int read(FILE* file, int offset, int length)
{
	static char buff[4];
	fseek(file, offset, 0);
	fread(buff, sizeof(char), length, file);
	//current = offset + length;

	//cout << "current: " << ftell(file) << endl;
	return parseInt(length, buff);
}

int** parse_bmp(const char* filepath, int* width, int* height)
{
	FILE * file = fopen(filepath, "rb");
	if (!file) 
	{
		cerr << "文件打开失败。" << endl;
		exit(-1);
	}
	fseek(file, 0x0A, 0);

	int content_offset = read(file, 0x0A, 4);
	*width = read(file, 0x12, 4);
	*height = read(file, 0x16, 4);

	int** result;
	result = (int**)malloc(sizeof(int*) * 3);
	for (int i = 0; i < 3; i++)
	{
		result[i] = (int*)malloc(sizeof(int) * (*width) * (*height));
	}

	fseek(file, content_offset, 0);

	int pixel_acount = (*width) * (*height);

	int byte_in_row = *width * 24/8;
	int actual_byte_in_row = byte_in_row + 4 - byte_in_row % 4;

	cout << byte_in_row << endl;
	cout << actual_byte_in_row << endl;

	char* buffer;
	buffer = (char *)malloc(sizeof(char) * actual_byte_in_row);
	for (int i = 0; i < *height; i++) {
		fread(buffer, sizeof(char), actual_byte_in_row, file);
		for (int j = 0; j < *width; j++) {
			result[0][i* *width + j] = buffer[3 * j] & 0x000000ff;
			result[1][i* *width + j] = buffer[3 * j + 1] & 0x000000ff;
			result[2][i* *width + j] = buffer[3 * j + 2] & 0x000000ff;
		}
	}
	

	fclose(file);
	return result;
}

void write_buffer(int value, FILE* file, int length)
{
	static char buffer[4];
	for (int i = 0; i < length; i++)
	{
		char v_low8 = value & 0x000000ff;
		//cout << hex << int(v_low8) << endl;
		value = value >> 8;
		buffer[i] = v_low8;
	}
	for (int i = length - 1; i >= 0; i--)
		fwrite(buffer+length-1-i, sizeof(char), 1, file);
}

void write_file(const char* filepath, int width, int height, int** data)
{
	FILE *file = fopen(filepath, "wb");
	if (!file)
	{
		cerr << "文件打开错误" << endl;
		exit(-1);
	}
	char buffer[4];
	buffer[0] = 0x42;
	buffer[1] = 0x4D;
	fwrite(buffer, sizeof(char), 2, file); //写入BM

	int byte_in_row = width * 24 / 8;
	int actual_byte_in_row = byte_in_row + 4 - byte_in_row % 4;

	int size = 54 + actual_byte_in_row*height;
	write_buffer(size, file, 4); //写入文件大小的字节数
	write_buffer(0, file, 2); //写入保留字节 2个字节
	write_buffer(0, file, 2); //写入保留字节 2个字节
	write_buffer(54, file, 4); //写入偏移量，4个字节
	write_buffer(40, file, 4); //写入头部长度
	write_buffer(width, file, 4); //写入宽度
	write_buffer(height, file, 4); //写入高度
	write_buffer(1, file, 2); //平面数，总是被设置为1
	write_buffer(24, file, 2); //每像素位数
	write_buffer(0, file, 4); //不压缩
	write_buffer(height*actual_byte_in_row, file, 4); //图像字节数
	write_buffer(0, file, 4); //图像字节数
	write_buffer(0, file, 4); //图像字节数
	write_buffer(0, file, 4); //图像字节数
	write_buffer(0, file, 4); //图像字节数

	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++)
		{
			write_buffer(data[0][i*width + j], file, 1);
			write_buffer(data[1][i*width + j], file, 1);
			write_buffer(data[2][i*width + j], file, 1);
		}
		if (actual_byte_in_row - byte_in_row != 0)
			write_buffer(0, file, actual_byte_in_row - byte_in_row);
		cout << i << endl;
	}
	

	fclose(file);
}

unsigned char * transformToUCharVector(int ** data, int width, int height, int byte_per_pixel)
{
	unsigned char * result;
	result = (unsigned char *)malloc(sizeof(unsigned char) * width * height * byte_per_pixel);
	for (int i=0; i<width*height; i++)
	{
		for (int j=0; j<byte_per_pixel; j++)
		{
			result[i*byte_per_pixel + j] = (unsigned char)(data[j][i] & 0x000000ff);
		}
	}
	return result;
}

int ** transformToIntMatrix(unsigned char * data, int width, int height, int byte_per_pixel)
{
	int ** result;
	result = (int**)malloc(sizeof(int *)*byte_per_pixel);
	
	for (int i=0; i<byte_per_pixel; i++)
		result[i] = (int *)malloc(sizeof(int)*width*height);
	
	for (int i=0; i<width*height; i++)
		for (int j=0; j<byte_per_pixel; j++) 
			result[j][i] = data[i*byte_per_pixel+j] & 0x000000ff;
	
	return result;
}

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

                                        # End of file scope inline assembly
	.globl	_Z12GetTickCountv               # -- Begin function _Z12GetTickCountv
	.type	_Z12GetTickCountv,@function
_Z12GetTickCountv:                      # @_Z12GetTickCountv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movl	$1, %edi
	movq	%rbx, %rsi
	callq	clock_gettime
	imulq	$1000, (%rbx), %rcx             # imm = 0x3E8
	movabsq	$4835703278458516699, %rax      # imm = 0x431BDE82D7B634DB
	imulq	8(%rbx)
	movq	%rdx, %rax
	shrq	$63, %rax
	sarq	$18, %rdx
	addq	%rdx, %rax
	addq	%rcx, %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z12GetTickCountv, .Lfunc_end0-_Z12GetTickCountv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI1_0:
	.quad	0x3fb0000000000000              # double 0.0625
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$1672, %rsp                     # imm = 0x688
	.cfi_def_cfa_offset 1728
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$3, %edi
	jne	.LBB1_1
# %bb.2:
	movq	8(%rsi), %r14
	movq	16(%rsi), %rbx
	jmp	.LBB1_3
.LBB1_1:
	movl	$.L.str, %r14d
	movl	$.L.str.1, %ebx
.LBB1_3:
	movq	%rbx, 32(%rsp)                  # 8-byte Spill
	movl	$.L.str.2, %edi
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.3, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	leaq	200(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$19, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	320(%r15), %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r15, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	$0, 24(%rsp)
	leaq	96(%rsp), %r15
	movl	$1, %edi
	movq	%r15, %rsi
	callq	clock_gettime
	movq	(%r15), %rax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movq	8(%r15), %rax
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	leaq	72(%rsp), %r15
	movq	%r15, %rdi
	callq	hipEventCreate
	leaq	64(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r15), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	leaq	60(%rsp), %r15
	leaq	56(%rsp), %r12
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	callq	_Z9parse_bmpPKcPiS1_
	movl	(%r15), %ebp
	movl	(%r12), %r13d
	movq	%rax, %rdi
	movl	%ebp, %esi
	movl	%r13d, %edx
	movl	$3, %ecx
	callq	_Z22transformToUCharVectorPPiiii
	movq	%rax, %r15
	movl	$.L.str.5, %edi
	movl	%ebp, %esi
	movl	%r13d, %edx
	movl	$3, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %eax
	imull	%r13d, %eax
	leal	(%rax,%rax,2), %eax
	movslq	%eax, %r14
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, %r12
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	96(%rsp), %rax
	movl	$12, %ecx
	movl	$.L__const.main.Gaussian, %esi
	movq	%rax, %rdi
	rep;movsq (%rsi), %es:(%rdi)
	movl	$1, 96(%rax)
	movl	$d_const_Gaussian, %edi
	movl	$100, %edx
	movq	%rax, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	cvtsi2sd	%ebp, %xmm0
	mulsd	.LCPI1_0(%rip), %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %ebx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r13d, %xmm0
	mulsd	.LCPI1_0(%rip), %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %eax
	movl	$256, %edi                      # imm = 0x100
	cmpl	%edi, %ebx
	cmovgel	%edi, %ebx
	cmpl	%edi, %eax
	cmovll	%eax, %edi
	shlq	$32, %rdi
	orq	%rbx, %rdi
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_5
# %bb.4:
	movq	16(%rsp), %rcx
	movq	8(%rsp), %r8
	movl	%ebp, %edi
	movl	%r13d, %esi
	movl	$3, %edx
	callq	_ZL34__device_stub__kernel_GaussianFiltiiiPhS_
.LBB1_5:
	movq	8(%rsp), %rsi
	movq	%r12, %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%r12, %rdi
	movl	%ebp, %esi
	movl	%r13d, %edx
	movl	$3, %ecx
	callq	_Z20transformToIntMatrixPhiii
	movq	32(%rsp), %rdi                  # 8-byte Reload
	movl	%ebp, %esi
	movl	%r13d, %edx
	movq	%rax, %rcx
	callq	_Z10write_filePKciiPPi
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	testq	%r15, %r15
	je	.LBB1_7
# %bb.6:
	movq	%r15, %rdi
	callq	_ZdaPv
.LBB1_7:
	movabsq	$-4835703278458516699, %rcx     # imm = 0xBCE4217D2849CB25
	movq	40(%rsp), %rax                  # 8-byte Reload
	imulq	%rcx
	movq	%rdx, %rbx
	movq	%rdx, %rax
	shrq	$63, %rax
	sarq	$18, %rbx
	addq	%rax, %rbx
	movq	%r12, %rdi
	callq	_ZdaPv
	leaq	80(%rsp), %r14
	movl	$1, %edi
	movq	%r14, %rsi
	callq	clock_gettime
	movabsq	$4835703278458516699, %rax      # imm = 0x431BDE82D7B634DB
	imulq	8(%r14)
	movq	(%r14), %rax
	subq	48(%rsp), %rax                  # 8-byte Folded Reload
	movq	%rdx, %rcx
	shrq	$63, %rcx
	sarq	$18, %rdx
	addq	%rcx, %rdx
	addq	%rbx, %rdx
	imulq	$1000, %rax, %rax               # imm = 0x3E8
	addq	%rdx, %rax
	lock		addq	%rax, 24(%rsp)
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$15, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	24(%rsp), %rsi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIlEERSoT_
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	addq	$1672, %rsp                     # imm = 0x688
	.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_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z9parse_bmpPKcPiS1_            # -- Begin function _Z9parse_bmpPKcPiS1_
	.type	_Z9parse_bmpPKcPiS1_,@function
_Z9parse_bmpPKcPiS1_:                   # @_Z9parse_bmpPKcPiS1_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %r12
	movq	%rsi, %r14
	movl	$.L.str.7, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB2_10
# %bb.1:
	movq	%rax, %r15
	xorl	%ebx, %ebx
	movl	$10, %esi
	movq	%rax, %rdi
	xorl	%edx, %edx
	callq	fseek
	movq	%r15, %rdi
	movl	$10, %esi
	movl	$4, %edx
	callq	_Z4readP8_IO_FILEii
	movl	%eax, %ebp
	movq	%r15, %rdi
	movl	$18, %esi
	movl	$4, %edx
	callq	_Z4readP8_IO_FILEii
	movl	%eax, (%r14)
	movq	%r15, %rdi
	movl	$22, %esi
	movl	$4, %edx
	callq	_Z4readP8_IO_FILEii
	movl	%eax, %r13d
	movq	%r12, 8(%rsp)                   # 8-byte Spill
	movl	%eax, (%r12)
	movl	$24, %edi
	callq	malloc
	movq	%rax, %r12
	movslq	(%r14), %rax
	movslq	%r13d, %r13
	imulq	%rax, %r13
	shlq	$2, %r13
.LBB2_2:                                # =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, (%r12,%rbx,8)
	incq	%rbx
	cmpq	$3, %rbx
	jne	.LBB2_2
# %bb.3:
	movslq	%ebp, %rsi
	xorl	%ebx, %ebx
	movq	%r15, (%rsp)                    # 8-byte Spill
	movq	%r15, %rdi
	xorl	%edx, %edx
	callq	fseek
	movl	(%r14), %eax
	leal	(%rax,%rax,2), %esi
	leal	(%rax,%rax,2), %ebp
	addl	$3, %ebp
	testl	%esi, %esi
	cmovnsl	%esi, %ebp
	andl	$-4, %ebp
	addl	$4, %ebp
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
	movq	%rax, %r13
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r13, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	%ebp, %esi
	callq	_ZNSolsEi
	movq	%rax, %r13
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r13, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movslq	%ebp, %r13
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %rbp
	movq	8(%rsp), %rax                   # 8-byte Reload
	cmpl	$0, (%rax)
	jle	.LBB2_9
# %bb.4:                                # %.lr.ph60
	movq	%rax, %r15
	movq	%rbp, %rax
	addq	$2, %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
.LBB2_5:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_7 Depth 2
	movl	$1, %esi
	movq	%rbp, %rdi
	movq	%r13, %rdx
	movq	(%rsp), %rcx                    # 8-byte Reload
	callq	fread
	movl	(%r14), %r9d
	testl	%r9d, %r9d
	jle	.LBB2_8
# %bb.6:                                # %.lr.ph
                                        #   in Loop: Header=BB2_5 Depth=1
	movq	(%r12), %rax
	movq	8(%r12), %rcx
	movq	16(%r12), %rdx
	movslq	%ebx, %rsi
	movq	16(%rsp), %rdi                  # 8-byte Reload
	xorl	%r8d, %r8d
.LBB2_7:                                #   Parent Loop BB2_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	-2(%rdi), %r10d
	imull	%ebx, %r9d
	movslq	%r9d, %r9
	addq	%r8, %r9
	movl	%r10d, (%rax,%r9,4)
	movzbl	-1(%rdi), %r9d
	movslq	(%r14), %r10
	imulq	%rsi, %r10
	addq	%r8, %r10
	movl	%r9d, (%rcx,%r10,4)
	movzbl	(%rdi), %r9d
	movslq	(%r14), %r10
	imulq	%rsi, %r10
	addq	%r8, %r10
	movl	%r9d, (%rdx,%r10,4)
	incq	%r8
	movslq	(%r14), %r9
	addq	$3, %rdi
	cmpq	%r9, %r8
	jl	.LBB2_7
.LBB2_8:                                # %._crit_edge
                                        #   in Loop: Header=BB2_5 Depth=1
	incl	%ebx
	cmpl	(%r15), %ebx
	jl	.LBB2_5
.LBB2_9:                                # %._crit_edge61
	movq	(%rsp), %rdi                    # 8-byte Reload
	callq	fclose
	movq	%r12, %rax
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_10:
	.cfi_def_cfa_offset 80
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.8, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$-1, %edi
	callq	exit
.Lfunc_end2:
	.size	_Z9parse_bmpPKcPiS1_, .Lfunc_end2-_Z9parse_bmpPKcPiS1_
	.cfi_endproc
                                        # -- End function
	.globl	_Z22transformToUCharVectorPPiiii # -- Begin function _Z22transformToUCharVectorPPiiii
	.type	_Z22transformToUCharVectorPPiiii,@function
_Z22transformToUCharVectorPPiiii:       # @_Z22transformToUCharVectorPPiiii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%ecx, %ebx
	movq	%rdi, %r14
	movslq	%esi, %r12
	movslq	%edx, %r15
	movq	%r15, %rax
	imulq	%r12, %rax
	movslq	%ecx, %rdi
	imulq	%rax, %rdi
	callq	malloc
	imull	%r12d, %r15d
	testl	%r15d, %r15d
	jle	.LBB3_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%r15d, %ecx
	movl	%ebx, %edx
	xorl	%esi, %esi
	xorl	%edi, %edi
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB3_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	%esi, %r8d
	addq	%rax, %r8
	xorl	%r9d, %r9d
.LBB3_4:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%r14,%r9,8), %r10
	movb	(%r10,%rdi,4), %r10b
	movb	%r10b, (%r8,%r9)
	incq	%r9
	cmpq	%r9, %rdx
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	incq	%rdi
	addl	%ebx, %esi
	cmpq	%rcx, %rdi
	jne	.LBB3_2
.LBB3_6:                                # %._crit_edge21
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z22transformToUCharVectorPPiiii, .Lfunc_end3-_Z22transformToUCharVectorPPiiii
	.cfi_endproc
                                        # -- End function
	.type	_ZL34__device_stub__kernel_GaussianFiltiiiPhS_,@function # -- Begin function _ZL34__device_stub__kernel_GaussianFiltiiiPhS_
_ZL34__device_stub__kernel_GaussianFiltiiiPhS_: # @_ZL34__device_stub__kernel_GaussianFiltiiiPhS_
	.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	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	8(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	4(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	32(%rsp), %rcx
	movq	%r8, (%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	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	$_ZL19kernel_GaussianFiltiiiPhS_, %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_end4:
	.size	_ZL34__device_stub__kernel_GaussianFiltiiiPhS_, .Lfunc_end4-_ZL34__device_stub__kernel_GaussianFiltiiiPhS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z10write_filePKciiPPi          # -- Begin function _Z10write_filePKciiPPi
	.type	_Z10write_filePKciiPPi,@function
_Z10write_filePKciiPPi:                 # @_Z10write_filePKciiPPi
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, %rbx
	movl	%edx, %ebp
	movl	%esi, %r14d
	movl	$.L.str.9, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB5_50
# %bb.1:
	movq	%rax, %r15
	leaq	52(%rsp), %rdi
	movw	$19778, (%rdi)                  # imm = 0x4D42
	movl	$1, %esi
	movl	$2, %edx
	movq	%rax, %rcx
	callq	fwrite
	leal	(%r14,%r14,2), %eax
	movq	%r14, 16(%rsp)                  # 8-byte Spill
	leal	(%r14,%r14,2), %ecx
	addl	$3, %ecx
	testl	%eax, %eax
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	cmovnsl	%eax, %ecx
	andl	$-4, %ecx
	addl	$4, %ecx
	movl	%ecx, 8(%rsp)                   # 4-byte Spill
	movl	%ecx, %r12d
	imull	%ebp, %r12d
	leal	54(%r12), %edx
	movq	$-4, %rax
	movl	%edx, %ecx
.LBB5_2:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	sarl	$8, %ecx
	movb	%dl, _ZZ12write_bufferiP8_IO_FILEiE6buffer+4(%rax)
	movl	%ecx, %edx
	incq	%rax
	jne	.LBB5_2
# %bb.3:                                # %.preheader.i.preheader
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r13d
.LBB5_4:                                # %.preheader.i
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r13), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r13
	cmpq	$1, %r14
	ja	.LBB5_4
# %bb.5:                                # %.lr.ph.i60.preheader
	movw	$0, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$3, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r13d
.LBB5_6:                                # %.preheader.i65
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r13), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r13
	cmpq	$1, %r14
	ja	.LBB5_6
# %bb.7:                                # %.lr.ph.i72.preheader
	movw	$0, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$3, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r13d
.LBB5_8:                                # %.preheader.i77
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r13), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r13
	cmpq	$1, %r14
	ja	.LBB5_8
# %bb.9:                                # %.lr.ph.i84.preheader
	movb	$54, %al
	movq	$-4, %rcx
.LBB5_10:                               # %.lr.ph.i84
                                        # =>This Inner Loop Header: Depth=1
	movb	%al, _ZZ12write_bufferiP8_IO_FILEiE6buffer+4(%rcx)
	xorl	%eax, %eax
	incq	%rcx
	jne	.LBB5_10
# %bb.11:                               # %.preheader.i89.preheader
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r13d
.LBB5_12:                               # %.preheader.i89
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r13), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r13
	cmpq	$1, %r14
	ja	.LBB5_12
# %bb.13:                               # %.lr.ph.i96.preheader
	movb	$40, %al
	movq	$-4, %rcx
.LBB5_14:                               # %.lr.ph.i96
                                        # =>This Inner Loop Header: Depth=1
	movb	%al, _ZZ12write_bufferiP8_IO_FILEiE6buffer+4(%rcx)
	xorl	%eax, %eax
	incq	%rcx
	jne	.LBB5_14
# %bb.15:                               # %.preheader.i101.preheader
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r13d
.LBB5_16:                               # %.preheader.i101
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r13), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r13
	cmpq	$1, %r14
	ja	.LBB5_16
# %bb.17:                               # %.lr.ph.i108.preheader
	movq	$-4, %rax
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movl	%ecx, %edx
.LBB5_18:                               # %.lr.ph.i108
                                        # =>This Inner Loop Header: Depth=1
	sarl	$8, %ecx
	movb	%dl, _ZZ12write_bufferiP8_IO_FILEiE6buffer+4(%rax)
	movl	%ecx, %edx
	incq	%rax
	jne	.LBB5_18
# %bb.19:                               # %.preheader.i113.preheader
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r13d
.LBB5_20:                               # %.preheader.i113
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r13), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r13
	cmpq	$1, %r14
	ja	.LBB5_20
# %bb.21:                               # %.lr.ph.i120.preheader
	movq	$-4, %rax
	movl	%ebp, %edx
	movl	%ebp, %ecx
.LBB5_22:                               # %.lr.ph.i120
                                        # =>This Inner Loop Header: Depth=1
	sarl	$8, %ecx
	movb	%dl, _ZZ12write_bufferiP8_IO_FILEiE6buffer+4(%rax)
	movl	%ecx, %edx
	incq	%rax
	jne	.LBB5_22
# %bb.23:                               # %.preheader.i125.preheader
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r13d
.LBB5_24:                               # %.preheader.i125
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r13), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r13
	cmpq	$1, %r14
	ja	.LBB5_24
# %bb.25:                               # %.lr.ph.i132.preheader
	movw	$1, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r14d
	movl	$3, %r13d
.LBB5_26:                               # %.preheader.i137
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r14), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r13
	incq	%r14
	cmpq	$1, %r13
	ja	.LBB5_26
# %bb.27:                               # %.lr.ph.i144.preheader
	movw	$24, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r14d
	movl	$3, %r13d
.LBB5_28:                               # %.preheader.i149
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r14), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r13
	incq	%r14
	cmpq	$1, %r13
	ja	.LBB5_28
# %bb.29:                               # %.lr.ph.i156.preheader
	movl	$0, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r13d
.LBB5_30:                               # %.preheader.i161
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r13), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r13
	cmpq	$1, %r14
	ja	.LBB5_30
# %bb.31:                               # %.lr.ph.i168.preheader
	movq	$-4, %rax
	movl	%r12d, %ecx
.LBB5_32:                               # %.lr.ph.i168
                                        # =>This Inner Loop Header: Depth=1
	sarl	$8, %ecx
	movb	%r12b, _ZZ12write_bufferiP8_IO_FILEiE6buffer+4(%rax)
	movl	%ecx, %r12d
	incq	%rax
	jne	.LBB5_32
# %bb.33:                               # %.preheader.i173.preheader
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r12d
.LBB5_34:                               # %.preheader.i173
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r12), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r12
	cmpq	$1, %r14
	ja	.LBB5_34
# %bb.35:                               # %.lr.ph.i180.preheader
	movl	$0, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r12d
.LBB5_36:                               # %.preheader.i185
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r12), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r12
	cmpq	$1, %r14
	ja	.LBB5_36
# %bb.37:                               # %.lr.ph.i192.preheader
	movl	$0, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r12d
.LBB5_38:                               # %.preheader.i197
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r12), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r12
	cmpq	$1, %r14
	ja	.LBB5_38
# %bb.39:                               # %.lr.ph.i204.preheader
	movl	$0, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r12d
.LBB5_40:                               # %.preheader.i209
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r12), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r12
	cmpq	$1, %r14
	ja	.LBB5_40
# %bb.41:                               # %.lr.ph.i216.preheader
	movl	$0, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movl	$5, %r14d
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r12d
.LBB5_42:                               # %.preheader.i221
                                        # =>This Inner Loop Header: Depth=1
	movsbl	(%r12), %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	decq	%r14
	incq	%r12
	cmpq	$1, %r14
	ja	.LBB5_42
# %bb.43:                               # %_Z12write_bufferiP8_IO_FILEi.exit227.preheader
	testl	%ebp, %ebp
	movq	16(%rsp), %rax                  # 8-byte Reload
	jle	.LBB5_49
# %bb.44:                               # %.preheader.lr.ph
	movl	8(%rsp), %ecx                   # 4-byte Reload
	subl	12(%rsp), %ecx                  # 4-byte Folded Reload
	movl	%ecx, 28(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	movq	%rcx, 40(%rsp)                  # 8-byte Spill
	movl	%eax, %ecx
	movq	%rcx, 32(%rsp)                  # 8-byte Spill
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
.LBB5_45:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_51 Depth 2
	movl	%r12d, %r12d
	movq	32(%rsp), %rbp                  # 8-byte Reload
	movq	%r12, %r14
	testl	%eax, %eax
	jle	.LBB5_46
.LBB5_51:                               # %.lr.ph.i228
                                        #   Parent Loop BB5_45 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rbx), %rax
	movl	(%rax,%r14,4), %eax
	movb	%al, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movsbl	%al, %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	movq	8(%rbx), %rax
	movl	(%rax,%r14,4), %eax
	movb	%al, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movsbl	%al, %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	movq	16(%rbx), %rax
	movl	(%rax,%r14,4), %eax
	movb	%al, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rip)
	movsbl	%al, %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	incq	%r14
	decq	%rbp
	jne	.LBB5_51
.LBB5_46:                               # %._crit_edge
                                        #   in Loop: Header=BB5_45 Depth=1
	movl	8(%rsp), %eax                   # 4-byte Reload
	cmpl	12(%rsp), %eax                  # 4-byte Folded Reload
	je	.LBB5_48
# %bb.47:                               #   in Loop: Header=BB5_45 Depth=1
	xorl	%edi, %edi
	movq	%r15, %rsi
	movl	28(%rsp), %edx                  # 4-byte Reload
	callq	_Z12write_bufferiP8_IO_FILEi
.LBB5_48:                               # %_Z12write_bufferiP8_IO_FILEi.exit227
                                        #   in Loop: Header=BB5_45 Depth=1
	movl	$_ZSt4cout, %edi
	movl	%r13d, %esi
	callq	_ZNSolsEi
	movq	%rax, %rbp
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbp, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbp, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r13
	movq	16(%rsp), %rax                  # 8-byte Reload
	addl	%eax, %r12d
	cmpq	40(%rsp), %r13                  # 8-byte Folded Reload
	jne	.LBB5_45
.LBB5_49:                               # %_Z12write_bufferiP8_IO_FILEi.exit227._crit_edge
	movq	%r15, %rdi
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.LBB5_50:
	.cfi_def_cfa_offset 112
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.10, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$-1, %edi
	callq	exit
.Lfunc_end5:
	.size	_Z10write_filePKciiPPi, .Lfunc_end5-_Z10write_filePKciiPPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z20transformToIntMatrixPhiii   # -- Begin function _Z20transformToIntMatrixPhiii
	.type	_Z20transformToIntMatrixPhiii,@function
_Z20transformToIntMatrixPhiii:          # @_Z20transformToIntMatrixPhiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebx
	movl	%edx, 4(%rsp)                   # 4-byte Spill
	movl	%esi, (%rsp)                    # 4-byte Spill
	movq	%rdi, %r14
	movslq	%ecx, %r13
	leaq	(,%r13,8), %rdi
	callq	malloc
	movq	%rax, %r15
	movl	%ebx, %r12d
	testl	%r13d, %r13d
	jle	.LBB6_3
# %bb.1:                                # %.lr.ph
	movslq	(%rsp), %rax                    # 4-byte Folded Reload
	movslq	4(%rsp), %r13                   # 4-byte Folded Reload
	imulq	%rax, %r13
	shlq	$2, %r13
	xorl	%ebp, %ebp
.LBB6_2:                                # =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, (%r15,%rbp,8)
	incq	%rbp
	cmpq	%rbp, %r12
	jne	.LBB6_2
.LBB6_3:                                # %.preheader25
	movl	4(%rsp), %eax                   # 4-byte Reload
	imull	(%rsp), %eax                    # 4-byte Folded Reload
	testl	%eax, %eax
	jle	.LBB6_9
# %bb.4:                                # %.preheader.lr.ph
	movl	%eax, %eax
	xorl	%ecx, %ecx
	xorl	%edx, %edx
.LBB6_5:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_7 Depth 2
	testl	%ebx, %ebx
	jle	.LBB6_8
# %bb.6:                                # %.lr.ph28
                                        #   in Loop: Header=BB6_5 Depth=1
	movl	%ecx, %esi
	addq	%r14, %rsi
	xorl	%edi, %edi
.LBB6_7:                                #   Parent Loop BB6_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	(%rsi,%rdi), %r8d
	movq	(%r15,%rdi,8), %r9
	movl	%r8d, (%r9,%rdx,4)
	incq	%rdi
	cmpq	%rdi, %r12
	jne	.LBB6_7
.LBB6_8:                                # %._crit_edge
                                        #   in Loop: Header=BB6_5 Depth=1
	incq	%rdx
	addl	%ebx, %ecx
	cmpq	%rax, %rdx
	jne	.LBB6_5
.LBB6_9:                                # %._crit_edge30
	movq	%r15, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z20transformToIntMatrixPhiii, .Lfunc_end6-_Z20transformToIntMatrixPhiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8parseIntiPc                  # -- Begin function _Z8parseIntiPc
	.type	_Z8parseIntiPc,@function
_Z8parseIntiPc:                         # @_Z8parseIntiPc
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jle	.LBB7_1
# %bb.3:                                # %.lr.ph.preheader
	movl	%edi, %edx
	shlq	$3, %rdx
	xorl	%ecx, %ecx
	xorl	%eax, %eax
.LBB7_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movzbl	(%rsi), %edi
	shll	%cl, %edi
	addl	%edi, %eax
	incq	%rsi
	addq	$8, %rcx
	cmpq	%rcx, %rdx
	jne	.LBB7_4
# %bb.2:                                # %._crit_edge
	retq
.LBB7_1:
	xorl	%eax, %eax
	retq
.Lfunc_end7:
	.size	_Z8parseIntiPc, .Lfunc_end7-_Z8parseIntiPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z4readP8_IO_FILEii             # -- Begin function _Z4readP8_IO_FILEii
	.type	_Z4readP8_IO_FILEii,@function
_Z4readP8_IO_FILEii:                    # @_Z4readP8_IO_FILEii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movq	%rdi, %r14
	movslq	%esi, %rsi
	xorl	%ebx, %ebx
	xorl	%edx, %edx
	callq	fseek
	movslq	%ebp, %r15
	movl	$_ZZ4readP8_IO_FILEiiE4buff, %r12d
	movl	$_ZZ4readP8_IO_FILEiiE4buff, %edi
	movl	$1, %esi
	movq	%r15, %rdx
	movq	%r14, %rcx
	callq	fread
	testl	%r15d, %r15d
	jle	.LBB8_3
# %bb.1:                                # %.lr.ph.preheader.i
	movl	%ebp, %eax
	shlq	$3, %rax
	xorl	%ecx, %ecx
	xorl	%ebx, %ebx
.LBB8_2:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movzbl	(%r12), %edx
	shll	%cl, %edx
	addl	%edx, %ebx
	addq	$8, %rcx
	incq	%r12
	cmpq	%rcx, %rax
	jne	.LBB8_2
.LBB8_3:                                # %_Z8parseIntiPc.exit
	movl	%ebx, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z4readP8_IO_FILEii, .Lfunc_end8-_Z4readP8_IO_FILEii
	.cfi_endproc
                                        # -- End function
	.globl	_Z12write_bufferiP8_IO_FILEi    # -- Begin function _Z12write_bufferiP8_IO_FILEi
	.type	_Z12write_bufferiP8_IO_FILEi,@function
_Z12write_bufferiP8_IO_FILEi:           # @_Z12write_bufferiP8_IO_FILEi
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB9_7
# %bb.1:                                # %.lr.ph.preheader
	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
	movl	%edx, %r14d
	xorl	%eax, %eax
	movl	%edi, %ecx
.LBB9_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	sarl	$8, %ecx
	movb	%dil, _ZZ12write_bufferiP8_IO_FILEiE6buffer(%rax)
	incq	%rax
	movl	%ecx, %edi
	cmpq	%rax, %r14
	jne	.LBB9_2
# %bb.3:                                # %.preheader
	testl	%edx, %edx
	jle	.LBB9_6
# %bb.4:                                # %.lr.ph18
	incq	%r14
	movl	$_ZZ12write_bufferiP8_IO_FILEiE6buffer, %r15d
.LBB9_5:                                # =>This Inner Loop Header: Depth=1
	movsbl	(%r15), %edi
	movq	%rbx, %rsi
	callq	fputc@PLT
	incq	%r15
	decq	%r14
	cmpq	$1, %r14
	ja	.LBB9_5
.LBB9_6:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB9_7:                                # %._crit_edge
	retq
.Lfunc_end9:
	.size	_Z12write_bufferiP8_IO_FILEi, .Lfunc_end9-_Z12write_bufferiP8_IO_FILEi
	.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	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_ZL19kernel_GaussianFiltiiiPhS_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$1, (%rsp)
	movl	$d_const_Gaussian, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movl	$100, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	d_const_Gaussian,@object        # @d_const_Gaussian
	.local	d_const_Gaussian
	.comm	d_const_Gaussian,100,16
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"/home/cloud/workspace/hand/test1.bmp"
	.size	.L.str, 37

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"/home/cloud/workspace/hand/result.bmp"
	.size	.L.str.1, 38

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"input_path: %s\n"
	.size	.L.str.2, 16

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"output_path: %s\n"
	.size	.L.str.3, 17

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"maxThreadsPerBlock="
	.size	.L.str.4, 20

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"width: %d, height: %d, byte_per_pixel: %d\n"
	.size	.L.str.5, 43

	.type	.L__const.main.Gaussian,@object # @__const.main.Gaussian
	.section	.rodata,"a",@progbits
	.p2align	4, 0x0
.L__const.main.Gaussian:
	.long	1                               # 0x1
	.long	4                               # 0x4
	.long	7                               # 0x7
	.long	4                               # 0x4
	.long	1                               # 0x1
	.long	4                               # 0x4
	.long	16                              # 0x10
	.long	26                              # 0x1a
	.long	16                              # 0x10
	.long	4                               # 0x4
	.long	7                               # 0x7
	.long	26                              # 0x1a
	.long	41                              # 0x29
	.long	26                              # 0x1a
	.long	7                               # 0x7
	.long	4                               # 0x4
	.long	16                              # 0x10
	.long	26                              # 0x1a
	.long	16                              # 0x10
	.long	4                               # 0x4
	.long	1                               # 0x1
	.long	4                               # 0x4
	.long	7                               # 0x7
	.long	4                               # 0x4
	.long	1                               # 0x1
	.size	.L__const.main.Gaussian, 100

	.type	_ZL19kernel_GaussianFiltiiiPhS_,@object # @_ZL19kernel_GaussianFiltiiiPhS_
	.p2align	3, 0x0
_ZL19kernel_GaussianFiltiiiPhS_:
	.quad	_ZL34__device_stub__kernel_GaussianFiltiiiPhS_
	.size	_ZL19kernel_GaussianFiltiiiPhS_, 8

	.type	.L.str.6,@object                # @.str.6
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.6:
	.asciz	"Total time GPU:"
	.size	.L.str.6, 16

	.type	_ZZ4readP8_IO_FILEiiE4buff,@object # @_ZZ4readP8_IO_FILEiiE4buff
	.local	_ZZ4readP8_IO_FILEiiE4buff
	.comm	_ZZ4readP8_IO_FILEiiE4buff,4,1
	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"rb"
	.size	.L.str.7, 3

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"\346\226\207\344\273\266\346\211\223\345\274\200\345\244\261\350\264\245\343\200\202"
	.size	.L.str.8, 22

	.type	_ZZ12write_bufferiP8_IO_FILEiE6buffer,@object # @_ZZ12write_bufferiP8_IO_FILEiE6buffer
	.local	_ZZ12write_bufferiP8_IO_FILEiE6buffer
	.comm	_ZZ12write_bufferiP8_IO_FILEiE6buffer,4,4
	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"wb"
	.size	.L.str.9, 3

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"\346\226\207\344\273\266\346\211\223\345\274\200\351\224\231\350\257\257"
	.size	.L.str.10, 19

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_ZL19kernel_GaussianFiltiiiPhS_"
	.size	.L__unnamed_1, 32

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

	.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 _ZL34__device_stub__kernel_GaussianFiltiiiPhS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym d_const_Gaussian
	.addrsig_sym _ZSt4cout
	.addrsig_sym _ZL19kernel_GaussianFiltiiiPhS_
	.addrsig_sym _ZZ4readP8_IO_FILEiiE4buff
	.addrsig_sym _ZSt4cerr
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.section	.text._ZL19kernel_GaussianFiltiiiPhS_,"axG",@progbits,_ZL19kernel_GaussianFiltiiiPhS_,comdat
	.globl	_ZL19kernel_GaussianFiltiiiPhS_ ; -- Begin function _ZL19kernel_GaussianFiltiiiPhS_
	.p2align	8
	.type	_ZL19kernel_GaussianFiltiiiPhS_,@function
_ZL19kernel_GaussianFiltiiiPhS_:        ; @_ZL19kernel_GaussianFiltiiiPhS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s8, s[0:1], 0x2c
	s_load_b128 s[4:7], s[0:1], 0x0
	v_and_b32_e32 v3, 0x3ff, v0
	s_add_u32 s2, s0, 32
	s_addc_u32 s3, s1, 0
	s_mov_b32 s9, exec_lo
	s_waitcnt lgkmcnt(0)
	s_and_b32 s7, s8, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s14, s7, v[3:4]
	v_cmpx_gt_i32_e64 s5, v1
	s_cbranch_execz .LBB0_17
; %bb.1:                                ; %.preheader86.lr.ph
	v_bfe_u32 v0, v0, 10, 10
	s_load_b64 s[2:3], s[2:3], 0x0
	s_lshr_b32 s12, s8, 16
	s_load_b128 s[8:11], s[0:1], 0x10
	s_cmp_gt_i32 s6, 0
	v_mad_u64_u32 v[2:3], null, s15, s12, v[0:1]
	s_cselect_b32 s17, -1, 0
	s_mov_b32 s18, 0
	s_mul_i32 s19, s6, s4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v0, -2, v2
	v_cmp_gt_i32_e64 s0, s4, v2
	v_mul_lo_u32 v0, s6, v0
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s16, s3, s12
	s_mul_i32 s7, s2, s7
	s_mul_i32 s20, s16, s6
.LBB0_2:                                ; %.preheader86
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
                                        ;       Child Loop BB0_6 Depth 3
                                        ;         Child Loop BB0_7 Depth 4
                                        ;           Child Loop BB0_8 Depth 5
	s_and_saveexec_b32 s21, s0
	s_cbranch_execz .LBB0_16
; %bb.3:                                ; %.preheader85.lr.ph
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_mul_lo_u32 v3, s19, v1
	v_dual_mov_b32 v5, v0 :: v_dual_mov_b32 v8, v2
	s_mov_b32 s22, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v4, 31, v3
	v_add_co_u32 v6, vcc_lo, s10, v3
	v_add_co_ci_u32_e32 v7, vcc_lo, s11, v4, vcc_lo
.LBB0_4:                                ; %.preheader85
                                        ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_6 Depth 3
                                        ;         Child Loop BB0_7 Depth 4
                                        ;           Child Loop BB0_8 Depth 5
	s_and_not1_b32 vcc_lo, exec_lo, s17
	s_cbranch_vccnz .LBB0_15
; %bb.5:                                ; %.preheader84.lr.ph
                                        ;   in Loop: Header=BB0_4 Depth=2
	v_mul_lo_u32 v3, v8, s6
	s_mov_b32 s23, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v4, 31, v3
	v_add_co_u32 v9, vcc_lo, v6, v3
	v_add_co_ci_u32_e32 v10, vcc_lo, v7, v4, vcc_lo
.LBB0_6:                                ; %.preheader84
                                        ;   Parent Loop BB0_2 Depth=1
                                        ;     Parent Loop BB0_4 Depth=2
                                        ; =>    This Loop Header: Depth=3
                                        ;         Child Loop BB0_7 Depth 4
                                        ;           Child Loop BB0_8 Depth 5
	v_mov_b32_e32 v3, 0
	s_add_u32 s24, s8, s23
	s_addc_u32 s25, s9, 0
	s_mov_b32 s26, -2
	s_getpc_b64 s[12:13]
	s_add_u32 s12, s12, d_const_Gaussian@rel32@lo+4
	s_addc_u32 s13, s13, d_const_Gaussian@rel32@hi+12
.LBB0_7:                                ; %.preheader
                                        ;   Parent Loop BB0_2 Depth=1
                                        ;     Parent Loop BB0_4 Depth=2
                                        ;       Parent Loop BB0_6 Depth=3
                                        ; =>      This Loop Header: Depth=4
                                        ;           Child Loop BB0_8 Depth 5
	v_dual_mov_b32 v13, v5 :: v_dual_add_nc_u32 v4, s26, v1
	s_mov_b64 s[14:15], s[12:13]
	s_mov_b32 s27, -2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_mul_lo_u32 v11, s19, v4
	v_cmp_lt_i32_e32 vcc_lo, -1, v4
	v_cmp_gt_i32_e64 s1, s5, v4
	v_ashrrev_i32_e32 v12, 31, v11
	v_add_co_u32 v11, s2, s24, v11
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v12, s2, s25, v12, s2
.LBB0_8:                                ;   Parent Loop BB0_2 Depth=1
                                        ;     Parent Loop BB0_4 Depth=2
                                        ;       Parent Loop BB0_6 Depth=3
                                        ;         Parent Loop BB0_7 Depth=4
                                        ; =>        This Inner Loop Header: Depth=5
	v_mov_b32_e32 v14, 0
	s_and_saveexec_b32 s28, vcc_lo
	s_cbranch_execz .LBB0_12
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=5
	v_add_nc_u32_e32 v4, s27, v8
	v_mov_b32_e32 v14, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cmp_lt_i32_e64 s2, -1, v4
	v_cmp_gt_i32_e64 s3, s4, v4
	s_and_b32 s2, s1, s2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s3, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_11
; %bb.10:                               ;   in Loop: Header=BB0_8 Depth=5
	v_ashrrev_i32_e32 v4, 31, v13
	v_add_co_u32 v14, s2, v11, v13
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v15, s2, v12, v4, s2
	global_load_u8 v14, v[14:15], off
.LBB0_11:                               ; %Flow
                                        ;   in Loop: Header=BB0_8 Depth=5
	s_or_b32 exec_lo, exec_lo, s3
.LBB0_12:                               ;   in Loop: Header=BB0_8 Depth=5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	s_or_b32 exec_lo, exec_lo, s28
	s_load_b32 s2, s[14:15], 0x0
	v_mov_b32_e32 v15, v3
	s_add_i32 s27, s27, 1
	v_add_nc_u32_e32 v13, s6, v13
	s_add_u32 s14, s14, 4
	s_addc_u32 s15, s15, 0
	s_cmp_eq_u32 s27, 3
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_mad_u64_u32 v[3:4], null, s2, v14, v[15:16]
	s_cbranch_scc0 .LBB0_8
; %bb.13:                               ;   in Loop: Header=BB0_7 Depth=4
	s_add_i32 s26, s26, 1
	s_add_u32 s12, s12, 20
	s_addc_u32 s13, s13, 0
	s_cmp_eq_u32 s26, 3
	s_cbranch_scc0 .LBB0_7
; %bb.14:                               ;   in Loop: Header=BB0_6 Depth=3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_hi_i32 v4, 0xf00f00f1, v3
	v_cmp_gt_i32_e32 vcc_lo, 0x11100, v3
	v_add_nc_u32_e32 v4, v4, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshrrev_b32_e32 v11, 31, v4
	v_lshrrev_b32_e32 v4, 8, v4
	v_add_nc_u32_e32 v4, v4, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v4, -1, v4, vcc_lo
	v_cmp_lt_i32_e32 vcc_lo, 0xfffffeef, v3
	v_cndmask_b32_e32 v11, 0, v4, vcc_lo
	v_add_co_u32 v3, vcc_lo, v9, s23
	v_add_co_ci_u32_e32 v4, vcc_lo, 0, v10, vcc_lo
	s_add_i32 s23, s23, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s23, s6
	global_store_b8 v[3:4], v11, off
	s_cbranch_scc0 .LBB0_6
.LBB0_15:                               ; %._crit_edge
                                        ;   in Loop: Header=BB0_4 Depth=2
	v_add_nc_u32_e32 v8, s16, v8
	v_add_nc_u32_e32 v5, s20, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_le_i32_e32 vcc_lo, s4, v8
	s_or_b32 s22, vcc_lo, s22
	s_and_not1_b32 exec_lo, exec_lo, s22
	s_cbranch_execnz .LBB0_4
.LBB0_16:                               ; %Flow130
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s21
	v_add_nc_u32_e32 v1, s7, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_le_i32_e32 vcc_lo, s5, v1
	s_or_b32 s18, vcc_lo, s18
	s_and_not1_b32 exec_lo, exec_lo, s18
	s_cbranch_execnz .LBB0_2
.LBB0_17:                               ; %._crit_edge97
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _ZL19kernel_GaussianFiltiiiPhS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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 17
		.amdhsa_next_free_sgpr 29
		.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
	.section	.text._ZL19kernel_GaussianFiltiiiPhS_,"axG",@progbits,_ZL19kernel_GaussianFiltiiiPhS_,comdat
.Lfunc_end0:
	.size	_ZL19kernel_GaussianFiltiiiPhS_, .Lfunc_end0-_ZL19kernel_GaussianFiltiiiPhS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 700
; NumSgprs: 31
; NumVgprs: 17
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 31
; NumVGPRsForWavesPerEU: 17
; 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
	.protected	d_const_Gaussian        ; @d_const_Gaussian
	.type	d_const_Gaussian,@object
	.section	.bss,"aw",@nobits
	.globl	d_const_Gaussian
	.p2align	4, 0x0
d_const_Gaussian:
	.zero	100
	.size	d_const_Gaussian, 100

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym d_const_Gaussian
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .offset:         8
        .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
      - .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:           _ZL19kernel_GaussianFiltiiiPhS_
    .private_segment_fixed_size: 0
    .sgpr_count:     31
    .sgpr_spill_count: 0
    .symbol:         _ZL19kernel_GaussianFiltiiiPhS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     17
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
