#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <complex.h>
#include <math.h>
#include <sys/mman.h>

#define DIV_ROUND_UP(n, d)  (((n) + (d) - 1) / (d))

#define cuda_check(ret) _cuda_check((ret), __FILE__, __LINE__)
inline void _cuda_check(cudaError_t ret, const char *file, int line)
{
	if (ret != cudaSuccess) {
		fprintf(stderr, "CudaErr: %s (%s:%d)\n", cudaGetErrorString(ret), file, line);
		exit(1);
	}
}

void read_image(char **Input, size_t *width, size_t *height, size_t *max, unsigned char **pixels)
{
    FILE *input_fd = fopen(*Input, "r+");
    if (!input_fd)
    {
        fprintf(stderr, "file does not exist");
        exit(1);
    }
    fseek(input_fd, 3, SEEK_CUR); //skip P5\n
    //printf("current line pos: %lu\n", ftell(input_fd));
    char c;
    if (fscanf(input_fd, " %lu %lu %lu%c", width, height, max, &c) != 4)
    {
        fprintf(stderr, "Info reading error\n");
        exit(1);
    }
    //printf("current line pos: %lu\n", ftell(input_fd));
    // fprintf(stdout, "width %lu, height %lu, max %lu, c%d\n", *width, *height, *max, c == '\n');

    //read the image into memory
    *pixels = (unsigned char*)calloc((*width) * (*height), sizeof(unsigned char));
    if (fread(*pixels, sizeof(unsigned char), (*width) * (*height), input_fd) != (*width) * (*height))
    {
        fprintf(stderr, "Image reading error\n");
        exit(1);
    }

    fclose(input_fd);
}

// Write pgm format
void write_image(unsigned char *g_map, size_t width, size_t height, size_t max, char *Output)
{
    char *info = (char*)calloc(100, sizeof(char));
    sprintf(info, "P5\n%lu %lu\n%lu\n", width, height, max);
    FILE *output_fd = fopen(Output, "w");
    fwrite(info, sizeof(char), strlen(info), output_fd);
    fwrite(g_map, sizeof(unsigned char), width * height, output_fd);
    fprintf(output_fd, "\n");
    fclose(output_fd);
}

float *gaussian_blur_matrix(size_t order, size_t sigma)
{

    float *matrix = (float*)calloc(order * order, sizeof(float));
    size_t x_0, y_0;
    x_0 = order / 2;
    y_0 = x_0;
    for (size_t y = 0; y < order; y++)
    {
        for (size_t x = 0; x < order; x++)
        {
            float x_dis = (float)x_0 - (float)x;
            float y_dis = (float)y_0 - (float)y;
            //printf("x_dis %f 7_dis %f\n", x_dis, y_dis);
            matrix[y * order + x] = expf((-1) * (x_dis * x_dis + y_dis * y_dis) / (2 * sigma * sigma));
        }
    }
    return matrix;
}

//__shared__ width, height, order

__device__ float blur_kernel_old(unsigned char* pixels, long width, long height, long x, long y, long order, float* mat){
    long start_x = x - order / 2;
    long start_y = y - order / 2;
    long curr_x, curr_y;
    float val = 0;
    for (long j = 0; j < order; j++)
    {
        curr_y = start_y + j;
        for (long i = 0; i < order; i++)
        {
            curr_x = start_x + i;

            if ((curr_x < 0 || curr_x >= width) && (curr_y < 0 || curr_y >= height))
            {
                if (curr_x < 0)
                    curr_x = 0;
                else if (curr_x >= width)
                    curr_x = width - 1;
                if (curr_y < 0)
                    curr_y = 0;
                else if (curr_y >= height)
                    curr_y = height - 1;
            }
            else if (curr_x < 0 || curr_x >= width)
            {
                if (curr_x < 0)
                    curr_x = 0;
                else if (curr_x >= width)
                    curr_x = width - 1;
            }
            else if (curr_y < 0 || curr_y >= height)
            {
                if (curr_y < 0)
                    curr_y = 0;
                else if (curr_y >= height)
                    curr_y = height - 1;
            }
            val += pixels[curr_y * width + curr_x] * mat[j * order + i];
        }
    }
    return val;
}

__device__ float blur_kernel(unsigned char* pixels, long width, long height, long x, long y, long order, float* mat, float k){
    long start_x = x - order / 2;
    long start_y = y - order / 2;
    long curr_x, curr_y;
    float val = 0;
    for (long j = 0; j < order; j++)
    {
        curr_y = start_y + j;
        if (curr_y < 0)
            curr_y = 0;

        else if (curr_y >= height)
            curr_y = height - 1;

        long pixel_row = curr_y * width;
        long mat_row = j * order;

        for (long i = 0; i < order; i++)
        {
            curr_x = start_x + i;

            if (curr_x < 0)
                curr_x = 0;
                
            else if (curr_x >= width)
                curr_x = width - 1;

            val += pixels[pixel_row + curr_x] * mat[mat_row + i];
        }
    }
    val /= k;
    return val;
}

__global__ void gaussian_blur_kernel_old(unsigned char *pixels, float *mat, unsigned char *output, long width, long height, float max, long order, float k) {
    int row = blockIdx.y * blockDim.y + threadIdx.y;
    int col = blockIdx.x * blockDim.x + threadIdx.x;
    // printf("row %d, col %d\n" row, col);
    // Discard out of bound coordinates
    if(row >= height || col >= width)
        return;

    //switched row and col
    float val = blur_kernel(pixels, width, height, col, row, order, mat, k);
    output[row * width + col] = (unsigned char)(val);
}

__global__ void gaussian_blur_kernel(unsigned char *pixels, float *mat, unsigned char *output, long width, long height, float max, long order, float k) {
    int row = blockIdx.y * blockDim.y + threadIdx.y;
    int col = blockIdx.x * blockDim.x + threadIdx.x;

    // Discard out of bound coordinates
    if(row >= height || col >= width)
        return;

    long start_y = row - order / 2;
    long start_x = col - order / 2;
    long curr_x, curr_y;
    float val = 0;
    for (long j = 0; j < order; j++)
    {
        curr_y = start_y + j;
        if (curr_y < 0)
            curr_y = 0;

        else if (curr_y >= height)
            curr_y = height - 1;

        long pixel_row = curr_y * width;
        long mat_row = j * order;

        for (long i = 0; i < order; i++)
        {
            curr_x = start_x + i;

            if (curr_x < 0)
                curr_x = 0;

            else if (curr_x >= width)
                curr_x = width - 1;

            val += pixels[pixel_row + curr_x] * mat[mat_row + i];
        }
    }
    val /= k;
    output[row * width + col] = (unsigned char)(val);
}



unsigned char *gaussian_blur_apply_cuda(unsigned char *pixels, long width, long height, float sigma, float max)
{
    // long order = (sigma * 6 % 2) == 0 ? sigma * 6 + 1 : sigma * 6;

    unsigned char *out_pixels_device, *out_pixels, *pixels_device;
    float *mat_device;

    //new
    long order = (long)(ceilf(sigma * 6));
    order = order % 2 == 0 ? order + 1 : order;
    // printf("order: %long\n", order);

    // Allocate needed matrices locally
    float *mat = gaussian_blur_matrix(order, sigma); //__shared__
    out_pixels = (unsigned char*)calloc(width * height, sizeof(unsigned char));

    //new
    float k = (2 * M_PI * sigma * sigma);
    
    int image_size = width * height * sizeof(unsigned char);
    
    //  allocate memory on device for needed matrices
    cuda_check(cudaMalloc(&out_pixels_device, image_size));
    cuda_check(cudaMalloc(&pixels_device, image_size));
    cuda_check(cudaMalloc(&mat_device, order * order * sizeof(float)));

    // Copy data onto device
    cuda_check(cudaMemcpy(pixels_device, pixels, image_size, cudaMemcpyHostToDevice));
    cuda_check(cudaMemcpy(mat_device, mat, order * order * sizeof(float), cudaMemcpyHostToDevice));

    //Invoke kernel function
    dim3 block_dim(32, 32);
    dim3 grid_dim(DIV_ROUND_UP(width, block_dim.x), DIV_ROUND_UP(height, block_dim.y));
    
    //  Catch errors
    gaussian_blur_kernel_old<<<grid_dim, block_dim>>>(pixels_device, mat_device, out_pixels_device, width, height, max, order, k);
    cuda_check(cudaPeekAtLastError());      /* Catch configuration errors */
	cuda_check(cudaDeviceSynchronize());    /* Catch execution errors */

    //  Copy output from device back to host
    cuda_check(cudaMemcpy(out_pixels, out_pixels_device, image_size, cudaMemcpyDeviceToHost));

    // Free memory on device
    cuda_check(cudaFree(out_pixels_device));
	cuda_check(cudaFree(mat_device));
	cuda_check(cudaFree(pixels_device));

    // unsigned char *out_pixels = calloc(width * height, sizeof(unsigned char));

    free(mat);
    return out_pixels;
}


int main(int argc, char *argv[])
{
    char *Input = (char*)calloc(100, sizeof(char));
    unsigned char *pixels = NULL;
    unsigned char *out_pixels = NULL;
    char *Output = (char*)calloc(100, sizeof(char));
    float sigma;

    size_t width, height, max;
    if (argc != 4)
    {
        fprintf(stderr,
                "Usage: ./mandelbrot_serial order xcenter ycenter zoom cutoff\n");
        exit(1);
    }
    sscanf(argv[1], " %s", Input);
    sscanf(argv[2], " %s ", Output);
    sscanf(argv[3], " %f ", &sigma);
    //fprintf(stdout, "%s %s %lu\n", Input, Output, sigma);
    //read in original image
    read_image(&Input, &width, &height, &max, &pixels);

    //gaussian_blur the image
    out_pixels = gaussian_blur_apply_cuda(pixels, (long)width, (long)height, sigma, (float)max);
    //write out the final image
    write_image(out_pixels, width, height, max, Output); //writes the unprocessed image

    free(Input);
    free(Output);
    free(pixels);
    return 0;
}
	.file	"tmpxft_002b8941_00000000-6_gaussian_blur_cuda.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3946:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3946:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._Z11_cuda_check9cudaErrorPKci.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CudaErr: %s (%s:%d)\n"
	.section	.text._Z11_cuda_check9cudaErrorPKci,"axG",@progbits,_Z11_cuda_check9cudaErrorPKci,comdat
	.weak	_Z11_cuda_check9cudaErrorPKci
	.type	_Z11_cuda_check9cudaErrorPKci, @function
_Z11_cuda_check9cudaErrorPKci:
.LFB3936:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	(%rsp), %r8
	leaq	.LC0(%rip), %rdx
	movl	12(%rsp), %r9d
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3936:
	.size	_Z11_cuda_check9cudaErrorPKci, .-_Z11_cuda_check9cudaErrorPKci
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"r+"
.LC2:
	.string	"file does not exist"
.LC3:
	.string	" %lu %lu %lu%c"
.LC4:
	.string	"Info reading error\n"
.LC5:
	.string	"Image reading error\n"
	.text
	.globl	_Z10read_imagePPcPmS1_S1_PPh
	.type	_Z10read_imagePPcPmS1_S1_PPh, @function
_Z10read_imagePPcPmS1_S1_PPh:
.LFB3937:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%r8, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	leaq	.LC1(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	(%rdi), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	leaq	.LC2(%rip), %rdx
	testq	%rax, %rax
	je	.L14
	movq	%rax, %rbx
	movl	$1, %edx
	movl	$3, %esi
	movq	%rax, %rdi
	call	fseek@PLT
	xorl	%eax, %eax
	leaq	7(%rsp), %r9
	movq	%r13, %r8
	movq	%rbp, %rcx
	movq	%r12, %rdx
	leaq	.LC3(%rip), %rsi
	movq	%rbx, %rdi
	call	__isoc23_fscanf@PLT
	cmpl	$4, %eax
	je	.L10
	leaq	.LC4(%rip), %rdx
.L14:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L10:
	movq	(%r12), %r13
	imulq	0(%rbp), %r13
	movl	$1, %esi
	movq	%r13, %rdi
	call	calloc@PLT
	movl	$1, %edx
	movq	%rbx, %r8
	movq	%r13, %rcx
	movq	%rax, (%r14)
	movq	%rax, %rdi
	movq	%r13, %rsi
	call	__fread_chk@PLT
	movq	%rax, %rdx
	movq	(%r12), %rax
	imulq	0(%rbp), %rax
	cmpq	%rdx, %rax
	je	.L11
	leaq	.LC5(%rip), %rdx
	jmp	.L14
.L11:
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3937:
	.size	_Z10read_imagePPcPmS1_S1_PPh, .-_Z10read_imagePPcPmS1_S1_PPh
	.section	.rodata.str1.1
.LC6:
	.string	"P5\n%lu %lu\n%lu\n"
.LC7:
	.string	"w"
.LC8:
	.string	"\n"
	.text
	.globl	_Z11write_imagePhmmmPc
	.type	_Z11write_imagePhmmmPc, @function
_Z11write_imagePhmmmPc:
.LFB3938:
	.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
	movq	%rdi, %r14
	movl	$100, %edi
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	movl	$1, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r8, %rbx
	pushq	%rax
	.cfi_def_cfa_offset 64
	call	calloc@PLT
	movq	%rbp, %r8
	movq	%r13, %r9
	movl	$2, %esi
	pushq	%rdx
	.cfi_def_cfa_offset 72
	movq	%rax, %r12
	movl	$100, %edx
	movq	%rax, %rdi
	pushq	%r15
	.cfi_def_cfa_offset 80
	leaq	.LC6(%rip), %rcx
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	popq	%rcx
	.cfi_def_cfa_offset 72
	movq	%rbx, %rdi
	popq	%rsi
	.cfi_def_cfa_offset 64
	leaq	.LC7(%rip), %rsi
	call	fopen@PLT
	movq	%r12, %rdi
	movq	%rax, %rbx
	call	strlen@PLT
	movq	%rbx, %rcx
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%rax, %rdx
	call	fwrite@PLT
	movq	%rbp, %rdx
	movq	%rbx, %rcx
	movq	%r14, %rdi
	imulq	%r13, %rdx
	movl	$1, %esi
	call	fwrite@PLT
	movq	%rbx, %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rdx
	call	__fprintf_chk@PLT
	popq	%r8
	.cfi_def_cfa_offset 56
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE3938:
	.size	_Z11write_imagePhmmmPc, .-_Z11write_imagePhmmmPc
	.globl	_Z20gaussian_blur_matrixmm
	.type	_Z20gaussian_blur_matrixmm, @function
_Z20gaussian_blur_matrixmm:
.LFB3939:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	imulq	%rdi, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	movl	$4, %esi
	imulq	%rbx, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	call	calloc@PLT
	addq	%rbx, %rbx
	movq	%rax, %r15
	movq	%r13, %rax
	shrq	%rax
	movq	%rax, 8(%rsp)
.L18:
	cmpq	%r13, %r12
	je	.L27
	cvtsi2ssq	8(%rsp), %xmm2
	testq	%r12, %r12
	js	.L19
	cvtsi2ssq	%r12, %xmm0
	jmp	.L20
.L19:
	movq	%r12, %rdx
	movq	%r12, %rcx
	shrq	%rdx
	andl	$1, %ecx
	orq	%rcx, %rdx
	cvtsi2ssq	%rdx, %xmm0
	addss	%xmm0, %xmm0
.L20:
	movaps	%xmm2, %xmm1
	subss	%xmm0, %xmm1
	mulss	%xmm1, %xmm1
	movss	%xmm1, 4(%rsp)
	testq	%rbx, %rbx
	js	.L21
	cvtsi2ssq	%rbx, %xmm1
	jmp	.L22
.L21:
	movq	%rbx, %rdx
	movq	%rbx, %rcx
	shrq	%rdx
	andl	$1, %ecx
	orq	%rcx, %rdx
	cvtsi2ssq	%rdx, %xmm1
	addss	%xmm1, %xmm1
.L22:
	leaq	(%r15,%rbp,4), %rdx
	xorl	%r14d, %r14d
.L23:
	cvtsi2ssq	%r14, %xmm3
	movaps	%xmm2, %xmm0
	movq	%rdx, 24(%rsp)
	movss	%xmm2, 20(%rsp)
	movss	%xmm1, 16(%rsp)
	subss	%xmm3, %xmm0
	mulss	%xmm0, %xmm0
	addss	4(%rsp), %xmm0
	xorps	.LC9(%rip), %xmm0
	divss	%xmm1, %xmm0
	call	expf@PLT
	movq	24(%rsp), %rdx
	movss	16(%rsp), %xmm1
	movss	20(%rsp), %xmm2
	movss	%xmm0, (%rdx,%r14,4)
	incq	%r14
	cmpq	%r14, %r13
	jne	.L23
	incq	%r12
	addq	%r13, %rbp
	jmp	.L18
.L27:
	addq	$40, %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
.LFE3939:
	.size	_Z20gaussian_blur_matrixmm, .-_Z20gaussian_blur_matrixmm
	.globl	_Z15blur_kernel_oldPhlllllPf
	.type	_Z15blur_kernel_oldPhlllllPf, @function
_Z15blur_kernel_oldPhlllllPf:
.LFB3940:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE3940:
	.size	_Z15blur_kernel_oldPhlllllPf, .-_Z15blur_kernel_oldPhlllllPf
	.globl	_Z11blur_kernelPhlllllPff
	.type	_Z11blur_kernelPhlllllPff, @function
_Z11blur_kernelPhlllllPff:
.LFB3941:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE3941:
	.size	_Z11blur_kernelPhlllllPff, .-_Z11blur_kernelPhlllllPff
	.globl	_Z53__device_stub__Z24gaussian_blur_kernel_oldPhPfS_llflfPhPfS_llflf
	.type	_Z53__device_stub__Z24gaussian_blur_kernel_oldPhPfS_llflfPhPfS_llflf, @function
_Z53__device_stub__Z24gaussian_blur_kernel_oldPhPfS_llflfPhPfS_llflf:
.LFB3968:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rdi, 56(%rsp)
	leaq	88(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	100(%rsp), %rsi
	movq	%rdx, 40(%rsp)
	leaq	72(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	80(%rsp), %rcx
	movq	%r8, 24(%rsp)
	movq	%r9, 8(%rsp)
	movss	%xmm0, 20(%rsp)
	movss	%xmm1, 16(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 96(%rsp)
	movq	%rax, 136(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	pushq	80(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z24gaussian_blur_kernel_oldPhPfS_llflf(%rip), %rdi
	pushq	80(%rsp)
	.cfi_def_cfa_offset 240
	movq	116(%rsp), %rcx
	movl	124(%rsp), %r8d
	movq	104(%rsp), %rsi
	movl	112(%rsp), %edx
	leaq	152(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L32:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3968:
	.size	_Z53__device_stub__Z24gaussian_blur_kernel_oldPhPfS_llflfPhPfS_llflf, .-_Z53__device_stub__Z24gaussian_blur_kernel_oldPhPfS_llflfPhPfS_llflf
	.globl	_Z24gaussian_blur_kernel_oldPhPfS_llflf
	.type	_Z24gaussian_blur_kernel_oldPhPfS_llflf, @function
_Z24gaussian_blur_kernel_oldPhPfS_llflf:
.LFB3969:
	.cfi_startproc
	endbr64
	jmp	_Z53__device_stub__Z24gaussian_blur_kernel_oldPhPfS_llflfPhPfS_llflf
	.cfi_endproc
.LFE3969:
	.size	_Z24gaussian_blur_kernel_oldPhPfS_llflf, .-_Z24gaussian_blur_kernel_oldPhPfS_llflf
	.section	.rodata.str1.1
.LC12:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/ZijianF/Gaussian-Blur/master/gaussian_blur_cuda.cu"
	.text
	.globl	_Z24gaussian_blur_apply_cudaPhllff
	.type	_Z24gaussian_blur_apply_cudaPhllff, @function
_Z24gaussian_blur_apply_cudaPhllff:
.LFB3942:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movss	%xmm1, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	movss	%xmm0, 8(%rsp)
	mulss	.LC10(%rip), %xmm0
	call	ceilf@PLT
	movss	8(%rsp), %xmm2
	cvttss2siq	%xmm0, %rbx
	movq	%rbx, %rax
	andl	$1, %eax
	cmpq	$1, %rax
	adcq	$0, %rbx
	comiss	.LC11(%rip), %xmm2
	jnb	.L39
	cvttss2siq	%xmm2, %rsi
	jmp	.L40
.L39:
	movaps	%xmm2, %xmm0
	subss	.LC11(%rip), %xmm0
	cvttss2siq	%xmm0, %rsi
	btcq	$63, %rsi
.L40:
	movq	%rbx, %rdi
	movl	%r12d, %ebp
	movss	%xmm2, 28(%rsp)
	call	_Z20gaussian_blur_matrixmm
	imull	%r13d, %ebp
	movq	%r12, %rdi
	movl	$1, %esi
	imulq	%r13, %rdi
	movq	%rax, %r14
	movslq	%ebp, %rbp
	call	calloc@PLT
	leaq	40(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rax, 16(%rsp)
	call	cudaMalloc@PLT
	movl	$238, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	leaq	48(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movl	$239, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	movq	%rbx, %rax
	leaq	56(%rsp), %rdi
	imulq	%rbx, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movl	$240, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	movq	48(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$243, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	movq	8(%rsp), %rdx
	movq	56(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$244, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	leaq	31(%r12), %rax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$32, %ecx
	cqto
	movl	$1, %esi
	idivq	%rcx
	movl	%eax, 76(%rsp)
	leaq	31(%r13), %rax
	cqto
	idivq	%rcx
	movabsq	$137438953504, %rdx
	movl	$1, %ecx
	movl	%eax, 80(%rsp)
	movq	76(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	movss	28(%rsp), %xmm2
	testl	%eax, %eax
	jne	.L41
	cvtss2sd	%xmm2, %xmm2
	movq	40(%rsp), %rdx
	movq	%rbx, %r9
	movq	%r13, %r8
	movsd	.LC13(%rip), %xmm1
	movss	24(%rsp), %xmm0
	movq	%r12, %rcx
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdi
	mulsd	%xmm2, %xmm1
	mulsd	%xmm2, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	call	_Z53__device_stub__Z24gaussian_blur_kernel_oldPhPfS_llflfPhPfS_llflf
.L41:
	call	cudaPeekAtLastError@PLT
	movl	$252, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	call	cudaDeviceSynchronize@PLT
	movl	$253, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	movq	40(%rsp), %rsi
	movq	16(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movl	$256, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	$259, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movl	$260, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movl	$261, %edx
	leaq	.LC12(%rip), %rsi
	movl	%eax, %edi
	call	_Z11_cuda_check9cudaErrorPKci
	movq	%r14, %rdi
	call	free@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	movq	16(%rsp), %rax
	addq	$104, %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
.LFE3942:
	.size	_Z24gaussian_blur_apply_cudaPhllff, .-_Z24gaussian_blur_apply_cudaPhllff
	.section	.rodata.str1.1
.LC14:
	.string	"Usage: ./mandelbrot_serial order xcenter ycenter zoom cutoff\n"
.LC15:
	.string	" %s"
.LC16:
	.string	" %s "
.LC17:
	.string	" %f "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3943:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edi, %r13d
	movl	$100, %edi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	movl	$1, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$72, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	calloc@PLT
	movl	$1, %esi
	movl	$100, %edi
	movq	%rax, 16(%rsp)
	movq	%rax, %rbp
	xorl	%eax, %eax
	movq	%rax, 24(%rsp)
	call	calloc@PLT
	cmpl	$4, %r13d
	je	.L45
	movq	stderr(%rip), %rdi
	leaq	.LC14(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L45:
	movq	8(%r12), %rdi
	movq	%rax, %rbx
	xorl	%eax, %eax
	movq	%rbp, %rdx
	leaq	.LC15(%rip), %rsi
	call	__isoc23_sscanf@PLT
	movq	16(%r12), %rdi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	leaq	.LC16(%rip), %rsi
	call	__isoc23_sscanf@PLT
	movq	24(%r12), %rdi
	leaq	12(%rsp), %rdx
	xorl	%eax, %eax
	leaq	.LC17(%rip), %rsi
	call	__isoc23_sscanf@PLT
	leaq	48(%rsp), %rcx
	leaq	40(%rsp), %rdx
	leaq	32(%rsp), %rsi
	leaq	16(%rsp), %rdi
	leaq	24(%rsp), %r8
	call	_Z10read_imagePPcPmS1_S1_PPh
	movq	48(%rsp), %rax
	movq	24(%rsp), %r12
	testq	%rax, %rax
	js	.L46
	cvtsi2ssq	%rax, %xmm1
	jmp	.L47
.L46:
	movq	%rax, %rdx
	andl	$1, %eax
	shrq	%rdx
	orq	%rax, %rdx
	cvtsi2ssq	%rdx, %xmm1
	addss	%xmm1, %xmm1
.L47:
	movss	12(%rsp), %xmm0
	movq	40(%rsp), %rdx
	movq	%r12, %rdi
	movq	32(%rsp), %rsi
	call	_Z24gaussian_blur_apply_cudaPhllff
	movq	48(%rsp), %rcx
	movq	40(%rsp), %rdx
	movq	%rbx, %r8
	movq	32(%rsp), %rsi
	movq	%rax, %rdi
	call	_Z11write_imagePhmmmPc
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$72, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
.LFE3943:
	.size	main, .-main
	.text
	.globl	_Z49__device_stub__Z20gaussian_blur_kernelPhPfS_llflfPhPfS_llflf
	.type	_Z49__device_stub__Z20gaussian_blur_kernelPhPfS_llflfPhPfS_llflf, @function
_Z49__device_stub__Z20gaussian_blur_kernelPhPfS_llflfPhPfS_llflf:
.LFB3970:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rdi, 56(%rsp)
	leaq	88(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	100(%rsp), %rsi
	movq	%rdx, 40(%rsp)
	leaq	72(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	80(%rsp), %rcx
	movq	%r8, 24(%rsp)
	movq	%r9, 8(%rsp)
	movss	%xmm0, 20(%rsp)
	movss	%xmm1, 16(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 96(%rsp)
	movq	%rax, 136(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	pushq	80(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z20gaussian_blur_kernelPhPfS_llflf(%rip), %rdi
	pushq	80(%rsp)
	.cfi_def_cfa_offset 240
	movq	116(%rsp), %rcx
	movl	124(%rsp), %r8d
	movq	104(%rsp), %rsi
	movl	112(%rsp), %edx
	leaq	152(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L50:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3970:
	.size	_Z49__device_stub__Z20gaussian_blur_kernelPhPfS_llflfPhPfS_llflf, .-_Z49__device_stub__Z20gaussian_blur_kernelPhPfS_llflfPhPfS_llflf
	.globl	_Z20gaussian_blur_kernelPhPfS_llflf
	.type	_Z20gaussian_blur_kernelPhPfS_llflf, @function
_Z20gaussian_blur_kernelPhPfS_llflf:
.LFB3971:
	.cfi_startproc
	endbr64
	jmp	_Z49__device_stub__Z20gaussian_blur_kernelPhPfS_llflfPhPfS_llflf
	.cfi_endproc
.LFE3971:
	.size	_Z20gaussian_blur_kernelPhPfS_llflf, .-_Z20gaussian_blur_kernelPhPfS_llflf
	.section	.rodata.str1.1
.LC18:
	.string	"_Z20gaussian_blur_kernelPhPfS_llflf"
.LC19:
	.string	"_Z24gaussian_blur_kernel_oldPhPfS_llflf"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3973:
	.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	.LC18(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z20gaussian_blur_kernelPhPfS_llflf(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC19(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z24gaussian_blur_kernel_oldPhPfS_llflf(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3973:
	.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
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC9:
	.long	-2147483648
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC10:
	.long	1086324736
	.align 4
.LC11:
	.long	1593835520
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC13:
	.long	1413754136
	.long	1075388923
	.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 <stdlib.h>
#include <string.h>
#include <complex.h>
#include <math.h>
#include <sys/mman.h>

#define DIV_ROUND_UP(n, d)  (((n) + (d) - 1) / (d))

#define cuda_check(ret) _cuda_check((ret), __FILE__, __LINE__)
inline void _cuda_check(hipError_t ret, const char *file, int line)
{
	if (ret != hipSuccess) {
		fprintf(stderr, "CudaErr: %s (%s:%d)\n", hipGetErrorString(ret), file, line);
		exit(1);
	}
}

void read_image(char **Input, size_t *width, size_t *height, size_t *max, unsigned char **pixels)
{
    FILE *input_fd = fopen(*Input, "r+");
    if (!input_fd)
    {
        fprintf(stderr, "file does not exist");
        exit(1);
    }
    fseek(input_fd, 3, SEEK_CUR); //skip P5\n
    //printf("current line pos: %lu\n", ftell(input_fd));
    char c;
    if (fscanf(input_fd, " %lu %lu %lu%c", width, height, max, &c) != 4)
    {
        fprintf(stderr, "Info reading error\n");
        exit(1);
    }
    //printf("current line pos: %lu\n", ftell(input_fd));
    // fprintf(stdout, "width %lu, height %lu, max %lu, c%d\n", *width, *height, *max, c == '\n');

    //read the image into memory
    *pixels = (unsigned char*)calloc((*width) * (*height), sizeof(unsigned char));
    if (fread(*pixels, sizeof(unsigned char), (*width) * (*height), input_fd) != (*width) * (*height))
    {
        fprintf(stderr, "Image reading error\n");
        exit(1);
    }

    fclose(input_fd);
}

// Write pgm format
void write_image(unsigned char *g_map, size_t width, size_t height, size_t max, char *Output)
{
    char *info = (char*)calloc(100, sizeof(char));
    sprintf(info, "P5\n%lu %lu\n%lu\n", width, height, max);
    FILE *output_fd = fopen(Output, "w");
    fwrite(info, sizeof(char), strlen(info), output_fd);
    fwrite(g_map, sizeof(unsigned char), width * height, output_fd);
    fprintf(output_fd, "\n");
    fclose(output_fd);
}

float *gaussian_blur_matrix(size_t order, size_t sigma)
{

    float *matrix = (float*)calloc(order * order, sizeof(float));
    size_t x_0, y_0;
    x_0 = order / 2;
    y_0 = x_0;
    for (size_t y = 0; y < order; y++)
    {
        for (size_t x = 0; x < order; x++)
        {
            float x_dis = (float)x_0 - (float)x;
            float y_dis = (float)y_0 - (float)y;
            //printf("x_dis %f 7_dis %f\n", x_dis, y_dis);
            matrix[y * order + x] = expf((-1) * (x_dis * x_dis + y_dis * y_dis) / (2 * sigma * sigma));
        }
    }
    return matrix;
}

//__shared__ width, height, order

__device__ float blur_kernel_old(unsigned char* pixels, long width, long height, long x, long y, long order, float* mat){
    long start_x = x - order / 2;
    long start_y = y - order / 2;
    long curr_x, curr_y;
    float val = 0;
    for (long j = 0; j < order; j++)
    {
        curr_y = start_y + j;
        for (long i = 0; i < order; i++)
        {
            curr_x = start_x + i;

            if ((curr_x < 0 || curr_x >= width) && (curr_y < 0 || curr_y >= height))
            {
                if (curr_x < 0)
                    curr_x = 0;
                else if (curr_x >= width)
                    curr_x = width - 1;
                if (curr_y < 0)
                    curr_y = 0;
                else if (curr_y >= height)
                    curr_y = height - 1;
            }
            else if (curr_x < 0 || curr_x >= width)
            {
                if (curr_x < 0)
                    curr_x = 0;
                else if (curr_x >= width)
                    curr_x = width - 1;
            }
            else if (curr_y < 0 || curr_y >= height)
            {
                if (curr_y < 0)
                    curr_y = 0;
                else if (curr_y >= height)
                    curr_y = height - 1;
            }
            val += pixels[curr_y * width + curr_x] * mat[j * order + i];
        }
    }
    return val;
}

__device__ float blur_kernel(unsigned char* pixels, long width, long height, long x, long y, long order, float* mat, float k){
    long start_x = x - order / 2;
    long start_y = y - order / 2;
    long curr_x, curr_y;
    float val = 0;
    for (long j = 0; j < order; j++)
    {
        curr_y = start_y + j;
        if (curr_y < 0)
            curr_y = 0;

        else if (curr_y >= height)
            curr_y = height - 1;

        long pixel_row = curr_y * width;
        long mat_row = j * order;

        for (long i = 0; i < order; i++)
        {
            curr_x = start_x + i;

            if (curr_x < 0)
                curr_x = 0;
                
            else if (curr_x >= width)
                curr_x = width - 1;

            val += pixels[pixel_row + curr_x] * mat[mat_row + i];
        }
    }
    val /= k;
    return val;
}

__global__ void gaussian_blur_kernel_old(unsigned char *pixels, float *mat, unsigned char *output, long width, long height, float max, long order, float k) {
    int row = blockIdx.y * blockDim.y + threadIdx.y;
    int col = blockIdx.x * blockDim.x + threadIdx.x;
    // printf("row %d, col %d\n" row, col);
    // Discard out of bound coordinates
    if(row >= height || col >= width)
        return;

    //switched row and col
    float val = blur_kernel(pixels, width, height, col, row, order, mat, k);
    output[row * width + col] = (unsigned char)(val);
}

__global__ void gaussian_blur_kernel(unsigned char *pixels, float *mat, unsigned char *output, long width, long height, float max, long order, float k) {
    int row = blockIdx.y * blockDim.y + threadIdx.y;
    int col = blockIdx.x * blockDim.x + threadIdx.x;

    // Discard out of bound coordinates
    if(row >= height || col >= width)
        return;

    long start_y = row - order / 2;
    long start_x = col - order / 2;
    long curr_x, curr_y;
    float val = 0;
    for (long j = 0; j < order; j++)
    {
        curr_y = start_y + j;
        if (curr_y < 0)
            curr_y = 0;

        else if (curr_y >= height)
            curr_y = height - 1;

        long pixel_row = curr_y * width;
        long mat_row = j * order;

        for (long i = 0; i < order; i++)
        {
            curr_x = start_x + i;

            if (curr_x < 0)
                curr_x = 0;

            else if (curr_x >= width)
                curr_x = width - 1;

            val += pixels[pixel_row + curr_x] * mat[mat_row + i];
        }
    }
    val /= k;
    output[row * width + col] = (unsigned char)(val);
}



unsigned char *gaussian_blur_apply_cuda(unsigned char *pixels, long width, long height, float sigma, float max)
{
    // long order = (sigma * 6 % 2) == 0 ? sigma * 6 + 1 : sigma * 6;

    unsigned char *out_pixels_device, *out_pixels, *pixels_device;
    float *mat_device;

    //new
    long order = (long)(ceilf(sigma * 6));
    order = order % 2 == 0 ? order + 1 : order;
    // printf("order: %long\n", order);

    // Allocate needed matrices locally
    float *mat = gaussian_blur_matrix(order, sigma); //__shared__
    out_pixels = (unsigned char*)calloc(width * height, sizeof(unsigned char));

    //new
    float k = (2 * M_PI * sigma * sigma);
    
    int image_size = width * height * sizeof(unsigned char);
    
    //  allocate memory on device for needed matrices
    cuda_check(hipMalloc(&out_pixels_device, image_size));
    cuda_check(hipMalloc(&pixels_device, image_size));
    cuda_check(hipMalloc(&mat_device, order * order * sizeof(float)));

    // Copy data onto device
    cuda_check(hipMemcpy(pixels_device, pixels, image_size, hipMemcpyHostToDevice));
    cuda_check(hipMemcpy(mat_device, mat, order * order * sizeof(float), hipMemcpyHostToDevice));

    //Invoke kernel function
    dim3 block_dim(32, 32);
    dim3 grid_dim(DIV_ROUND_UP(width, block_dim.x), DIV_ROUND_UP(height, block_dim.y));
    
    //  Catch errors
    gaussian_blur_kernel_old<<<grid_dim, block_dim>>>(pixels_device, mat_device, out_pixels_device, width, height, max, order, k);
    cuda_check(hipPeekAtLastError());      /* Catch configuration errors */
	cuda_check(hipDeviceSynchronize());    /* Catch execution errors */

    //  Copy output from device back to host
    cuda_check(hipMemcpy(out_pixels, out_pixels_device, image_size, hipMemcpyDeviceToHost));

    // Free memory on device
    cuda_check(hipFree(out_pixels_device));
	cuda_check(hipFree(mat_device));
	cuda_check(hipFree(pixels_device));

    // unsigned char *out_pixels = calloc(width * height, sizeof(unsigned char));

    free(mat);
    return out_pixels;
}


int main(int argc, char *argv[])
{
    char *Input = (char*)calloc(100, sizeof(char));
    unsigned char *pixels = NULL;
    unsigned char *out_pixels = NULL;
    char *Output = (char*)calloc(100, sizeof(char));
    float sigma;

    size_t width, height, max;
    if (argc != 4)
    {
        fprintf(stderr,
                "Usage: ./mandelbrot_serial order xcenter ycenter zoom cutoff\n");
        exit(1);
    }
    sscanf(argv[1], " %s", Input);
    sscanf(argv[2], " %s ", Output);
    sscanf(argv[3], " %f ", &sigma);
    //fprintf(stdout, "%s %s %lu\n", Input, Output, sigma);
    //read in original image
    read_image(&Input, &width, &height, &max, &pixels);

    //gaussian_blur the image
    out_pixels = gaussian_blur_apply_cuda(pixels, (long)width, (long)height, sigma, (float)max);
    //write out the final image
    write_image(out_pixels, width, height, max, Output); //writes the unprocessed image

    free(Input);
    free(Output);
    free(pixels);
    return 0;
}
	.text
	.file	"gaussian_blur_cuda.hip"
	.globl	_Z10read_imagePPcPmS1_S1_PPh    # -- Begin function _Z10read_imagePPcPmS1_S1_PPh
	.type	_Z10read_imagePPcPmS1_S1_PPh,@function
_Z10read_imagePPcPmS1_S1_PPh:           # @_Z10read_imagePPcPmS1_S1_PPh
	.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	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%r8, %r12
	movq	%rcx, %r13
	movq	%rdx, %r14
	movq	%rsi, %rbx
	movq	(%rdi), %rdi
	movl	$.L.str, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB0_1
# %bb.4:
	movq	%rax, %r15
	movl	$3, %esi
	movq	%rax, %rdi
	movl	$1, %edx
	callq	fseek
	leaq	15(%rsp), %r9
	movl	$.L.str.2, %esi
	movq	%r15, %rdi
	movq	%rbx, %rdx
	movq	%r14, %rcx
	movq	%r13, %r8
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$4, %eax
	jne	.LBB0_5
# %bb.6:
	movq	(%r14), %r13
	imulq	(%rbx), %r13
	movl	$1, %esi
	movq	%r13, %rdi
	callq	calloc
	movq	%rax, (%r12)
	movl	$1, %esi
	movq	%rax, %rdi
	movq	%r13, %rdx
	movq	%r15, %rcx
	callq	fread
	movq	(%r14), %rcx
	imulq	(%rbx), %rcx
	cmpq	%rcx, %rax
	jne	.LBB0_7
# %bb.8:
	movq	%r15, %rdi
	callq	fclose
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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
.LBB0_1:
	.cfi_def_cfa_offset 64
	movq	stderr(%rip), %rcx
	movl	$.L.str.1, %edi
	jmp	.LBB0_2
.LBB0_5:
	movq	stderr(%rip), %rcx
	movl	$.L.str.3, %edi
.LBB0_2:
	movl	$19, %esi
	jmp	.LBB0_3
.LBB0_7:
	movq	stderr(%rip), %rcx
	movl	$.L.str.4, %edi
	movl	$20, %esi
.LBB0_3:
	movl	$1, %edx
	callq	fwrite
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z10read_imagePPcPmS1_S1_PPh, .Lfunc_end0-_Z10read_imagePPcPmS1_S1_PPh
	.cfi_endproc
                                        # -- End function
	.globl	_Z11write_imagePhmmmPc          # -- Begin function _Z11write_imagePhmmmPc
	.type	_Z11write_imagePhmmmPc,@function
_Z11write_imagePhmmmPc:                 # @_Z11write_imagePhmmmPc
	.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
	movq	%r8, %r12
	movq	%rcx, %r13
	movq	%rdx, %rbx
	movq	%rsi, %r15
	movq	%rdi, %r14
	movl	$100, %edi
	movl	$1, %esi
	callq	calloc
	movq	%rax, %rbp
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	movq	%r15, %rdx
	movq	%rbx, %rcx
	movq	%r13, %r8
	xorl	%eax, %eax
	callq	sprintf
	movl	$.L.str.6, %esi
	movq	%r12, %rdi
	callq	fopen
	movq	%rax, %r12
	movq	%rbp, %rdi
	callq	strlen
	movl	$1, %esi
	movq	%rbp, %rdi
	movq	%rax, %rdx
	movq	%r12, %rcx
	callq	fwrite
	imulq	%r15, %rbx
	movl	$1, %esi
	movq	%r14, %rdi
	movq	%rbx, %rdx
	movq	%r12, %rcx
	callq	fwrite
	movl	$10, %edi
	movq	%r12, %rsi
	callq	fputc@PLT
	movq	%r12, %rdi
	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
	jmp	fclose                          # TAILCALL
.Lfunc_end1:
	.size	_Z11write_imagePhmmmPc, .Lfunc_end1-_Z11write_imagePhmmmPc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z20gaussian_blur_matrixmm
.LCPI2_0:
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.long	0x80000000                      # float -0
	.text
	.globl	_Z20gaussian_blur_matrixmm
	.type	_Z20gaussian_blur_matrixmm,@function
_Z20gaussian_blur_matrixmm:             # @_Z20gaussian_blur_matrixmm
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r15
	movq	%rdi, %rbx
	imulq	%rdi, %rdi
	movl	$4, %esi
	callq	calloc
	movq	%rax, %r14
	testq	%rbx, %rbx
	je	.LBB2_12
# %bb.1:                                # %.preheader.lr.ph
	movq	%rbx, %rax
	shrq	%rax
	imulq	%r15, %r15
	movq	%r15, %rcx
	addq	%r15, %rcx
	js	.LBB2_2
# %bb.3:                                # %.preheader.lr.ph
	cvtsi2ss	%rcx, %xmm0
	jmp	.LBB2_4
.LBB2_2:
	btrq	$63, %r15
	cvtsi2ss	%r15, %xmm0
	addss	%xmm0, %xmm0
.LBB2_4:                                # %.preheader.lr.ph
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	movss	%xmm0, 16(%rsp)                 # 4-byte Spill
	leaq	(,%rbx,4), %r15
	xorl	%r12d, %r12d
	movq	%r14, %r13
.LBB2_5:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_9 Depth 2
	testq	%r12, %r12
	js	.LBB2_6
# %bb.7:                                # %.preheader
                                        #   in Loop: Header=BB2_5 Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r12, %xmm0
	jmp	.LBB2_8
.LBB2_6:                                #   in Loop: Header=BB2_5 Depth=1
	movq	%r12, %rax
	shrq	%rax
	movl	%r12d, %ecx
	andl	$1, %ecx
	orq	%rax, %rcx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	addss	%xmm0, %xmm0
.LBB2_8:                                # %.preheader
                                        #   in Loop: Header=BB2_5 Depth=1
	movss	16(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	subss	%xmm0, %xmm1
	mulss	%xmm1, %xmm1
	movss	%xmm1, 20(%rsp)                 # 4-byte Spill
	xorl	%ebp, %ebp
.LBB2_9:                                #   Parent Loop BB2_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	testq	%rbp, %rbp
	js	.LBB2_10
# %bb.13:                               #   in Loop: Header=BB2_9 Depth=2
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rbp, %xmm1
	jmp	.LBB2_14
.LBB2_10:                               #   in Loop: Header=BB2_9 Depth=2
	movq	%rbp, %rax
	shrq	%rax
	movl	%ebp, %ecx
	andl	$1, %ecx
	orq	%rax, %rcx
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rcx, %xmm1
	addss	%xmm1, %xmm1
.LBB2_14:                               #   in Loop: Header=BB2_9 Depth=2
	movss	16(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	subss	%xmm1, %xmm0
	mulss	%xmm0, %xmm0
	addss	20(%rsp), %xmm0                 # 4-byte Folded Reload
	xorps	.LCPI2_0(%rip), %xmm0
	divss	12(%rsp), %xmm0                 # 4-byte Folded Reload
	callq	expf
	movss	%xmm0, (%r13,%rbp,4)
	incq	%rbp
	cmpq	%rbp, %rbx
	jne	.LBB2_9
# %bb.11:                               #   in Loop: Header=BB2_5 Depth=1
	incq	%r12
	addq	%r15, %r13
	cmpq	%rbx, %r12
	jne	.LBB2_5
.LBB2_12:                               # %._crit_edge
	movq	%r14, %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
.Lfunc_end2:
	.size	_Z20gaussian_blur_matrixmm, .Lfunc_end2-_Z20gaussian_blur_matrixmm
	.cfi_endproc
                                        # -- End function
	.globl	_Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf # -- Begin function _Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf
	.type	_Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf,@function
_Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf: # @_Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf
	.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	$176, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	72(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	64(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	56(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	12(%rsp), %r8
	movss	%xmm0, (%r8)
	leaq	32(%rsp), %r10
	movq	%r9, (%r10)
	leaq	8(%rsp), %r9
	movss	%xmm1, (%r9)
	leaq	112(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	movq	%r10, 48(%rbx)
	movq	%r9, 56(%rbx)
	leaq	96(%rsp), %r14
	leaq	80(%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	$_Z24gaussian_blur_kernel_oldPhPfS_llflf, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$192, %rsp
	.cfi_adjust_cfa_offset -192
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf, .Lfunc_end3-_Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf
	.cfi_endproc
                                        # -- End function
	.globl	_Z35__device_stub__gaussian_blur_kernelPhPfS_llflf # -- Begin function _Z35__device_stub__gaussian_blur_kernelPhPfS_llflf
	.type	_Z35__device_stub__gaussian_blur_kernelPhPfS_llflf,@function
_Z35__device_stub__gaussian_blur_kernelPhPfS_llflf: # @_Z35__device_stub__gaussian_blur_kernelPhPfS_llflf
	.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	$176, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	72(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	64(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	56(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	12(%rsp), %r8
	movss	%xmm0, (%r8)
	leaq	32(%rsp), %r10
	movq	%r9, (%r10)
	leaq	8(%rsp), %r9
	movss	%xmm1, (%r9)
	leaq	112(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	movq	%r10, 48(%rbx)
	movq	%r9, 56(%rbx)
	leaq	96(%rsp), %r14
	leaq	80(%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	$_Z20gaussian_blur_kernelPhPfS_llflf, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$192, %rsp
	.cfi_adjust_cfa_offset -192
	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	_Z35__device_stub__gaussian_blur_kernelPhPfS_llflf, .Lfunc_end4-_Z35__device_stub__gaussian_blur_kernelPhPfS_llflf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z24gaussian_blur_apply_cudaPhllff
.LCPI5_0:
	.long	0x40c00000                      # float 6
.LCPI5_1:
	.long	0x5f000000                      # float 9.22337203E+18
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI5_2:
	.quad	0x401921fb54442d18              # double 6.2831853071795862
	.text
	.globl	_Z24gaussian_blur_apply_cudaPhllff
	.type	_Z24gaussian_blur_apply_cudaPhllff,@function
_Z24gaussian_blur_apply_cudaPhllff:     # @_Z24gaussian_blur_apply_cudaPhllff
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movss	%xmm1, 28(%rsp)                 # 4-byte Spill
	movaps	%xmm0, %xmm1
	movaps	%xmm0, 48(%rsp)                 # 16-byte Spill
	movq	%rdx, %r15
	movq	%rsi, %r12
	movq	%rdi, 40(%rsp)                  # 8-byte Spill
	movss	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r14
	orq	$1, %r14
	movaps	48(%rsp), %xmm0                 # 16-byte Reload
	cvttss2si	%xmm0, %rax
	movq	%rax, %rcx
	sarq	$63, %rcx
	subss	.LCPI5_1(%rip), %xmm0
	cvttss2si	%xmm0, %rsi
	andq	%rcx, %rsi
	orq	%rax, %rsi
	movq	%r14, %rdi
	callq	_Z20gaussian_blur_matrixmm
	movq	%rax, %rbx
	movq	%r15, %r13
	imulq	%r12, %r13
	movl	$1, %esi
	movq	%r13, %rdi
	callq	calloc
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movslq	%r13d, %rbp
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_1
# %bb.3:                                # %_Z11_cuda_check10hipError_tPKci.exit
	leaq	8(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_4
# %bb.5:                                # %_Z11_cuda_check10hipError_tPKci.exit38
	movq	%r14, %r13
	imulq	%r14, %r13
	shlq	$2, %r13
	movq	%rsp, %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB5_6
# %bb.7:                                # %_Z11_cuda_check10hipError_tPKci.exit40
	movq	8(%rsp), %rdi
	movq	40(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_8
# %bb.9:                                # %_Z11_cuda_check10hipError_tPKci.exit42
	movq	(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_10
# %bb.11:                               # %_Z11_cuda_check10hipError_tPKci.exit44
	leaq	31(%r12), %rax
	leaq	62(%r12), %rcx
	testq	%rax, %rax
	cmovnsq	%rax, %rcx
	shrq	$5, %rcx
	leaq	31(%r15), %rax
	leaq	62(%r15), %rdi
	testq	%rax, %rax
	cmovnsq	%rax, %rdi
	movl	%ecx, %eax
	andq	$-32, %rdi
	shlq	$27, %rdi
	orq	%rax, %rdi
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_13
# %bb.12:
	cvtss2sd	48(%rsp), %xmm0                 # 16-byte Folded Reload
	movsd	.LCPI5_2(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm0, %xmm1
	mulsd	%xmm0, %xmm1
	cvtsd2ss	%xmm1, %xmm1
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	%r12, %rcx
	movq	%r15, %r8
	movss	28(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	movq	%r14, %r9
	callq	_Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf
.LBB5_13:
	callq	hipPeekAtLastError
	testl	%eax, %eax
	jne	.LBB5_14
# %bb.15:                               # %_Z11_cuda_check10hipError_tPKci.exit46
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	movq	32(%rsp), %r14                  # 8-byte Reload
	jne	.LBB5_16
# %bb.17:                               # %_Z11_cuda_check10hipError_tPKci.exit48
	movq	16(%rsp), %rsi
	movq	%r14, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB5_18
# %bb.19:                               # %_Z11_cuda_check10hipError_tPKci.exit50
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_20
# %bb.21:                               # %_Z11_cuda_check10hipError_tPKci.exit52
	movq	(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_22
# %bb.23:                               # %_Z11_cuda_check10hipError_tPKci.exit54
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB5_24
# %bb.25:                               # %_Z11_cuda_check10hipError_tPKci.exit56
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rax
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB5_1:
	.cfi_def_cfa_offset 128
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$240, %r8d
	jmp	.LBB5_2
.LBB5_4:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$241, %r8d
	jmp	.LBB5_2
.LBB5_6:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$242, %r8d
	jmp	.LBB5_2
.LBB5_8:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$245, %r8d
	jmp	.LBB5_2
.LBB5_10:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$246, %r8d
	jmp	.LBB5_2
.LBB5_14:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$254, %r8d
	jmp	.LBB5_2
.LBB5_16:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$255, %r8d
	jmp	.LBB5_2
.LBB5_18:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$258, %r8d                      # imm = 0x102
	jmp	.LBB5_2
.LBB5_20:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$261, %r8d                      # imm = 0x105
	jmp	.LBB5_2
.LBB5_22:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$262, %r8d                      # imm = 0x106
	jmp	.LBB5_2
.LBB5_24:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movl	$.L.str.8, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$263, %r8d                      # imm = 0x107
.LBB5_2:
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end5:
	.size	_Z24gaussian_blur_apply_cudaPhllff, .Lfunc_end5-_Z24gaussian_blur_apply_cudaPhllff
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$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	%rsi, %r15
	movl	%edi, %ebp
	movl	$100, %edi
	movl	$1, %esi
	callq	calloc
	movq	%rax, %rbx
	movq	%rax, 40(%rsp)
	movq	$0, 32(%rsp)
	movl	$100, %edi
	movl	$1, %esi
	callq	calloc
	cmpl	$4, %ebp
	jne	.LBB6_5
# %bb.1:
	movq	%rax, %r14
	movq	8(%r15), %rdi
	movl	$.L.str.10, %esi
	movq	%rbx, (%rsp)                    # 8-byte Spill
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	16(%r15), %rdi
	movl	$.L.str.11, %esi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	24(%r15), %rdi
	leaq	52(%rsp), %r12
	movl	$.L.str.12, %esi
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	leaq	40(%rsp), %rdi
	leaq	24(%rsp), %r13
	leaq	16(%rsp), %rbp
	leaq	8(%rsp), %rbx
	leaq	32(%rsp), %r15
	movq	%r13, %rsi
	movq	%rbp, %rdx
	movq	%rbx, %rcx
	movq	%r15, %r8
	callq	_Z10read_imagePPcPmS1_S1_PPh
	movq	(%r15), %r15
	movq	(%r13), %rsi
	movq	(%rbp), %rdx
	movss	(%r12), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movq	(%rbx), %rax
	testq	%rax, %rax
	js	.LBB6_2
# %bb.3:
	cvtsi2ss	%rax, %xmm1
	jmp	.LBB6_4
.LBB6_2:
	movq	%rax, %rcx
	shrq	%rcx
	andl	$1, %eax
	orq	%rcx, %rax
	cvtsi2ss	%rax, %xmm1
	addss	%xmm1, %xmm1
.LBB6_4:
	movq	%r15, %rdi
	callq	_Z24gaussian_blur_apply_cudaPhllff
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rcx
	movq	%rax, %rdi
	movq	%r14, %r8
	callq	_Z11write_imagePhmmmPc
	movq	(%rsp), %rdi                    # 8-byte Reload
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB6_5:
	.cfi_def_cfa_offset 112
	movq	stderr(%rip), %rcx
	movl	$.L.str.9, %edi
	movl	$61, %esi
	movl	$1, %edx
	callq	fwrite
	movl	$1, %edi
	callq	exit
.Lfunc_end6:
	.size	main, .Lfunc_end6-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z24gaussian_blur_kernel_oldPhPfS_llflf, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z20gaussian_blur_kernelPhPfS_llflf, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB8_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"r+"
	.size	.L.str, 3

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"file does not exist"
	.size	.L.str.1, 20

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	" %lu %lu %lu%c"
	.size	.L.str.2, 15

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Info reading error\n"
	.size	.L.str.3, 20

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Image reading error\n"
	.size	.L.str.4, 21

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"P5\n%lu %lu\n%lu\n"
	.size	.L.str.5, 16

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"w"
	.size	.L.str.6, 2

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

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

	.type	.L.str.8,@object                # @.str.8
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.8:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/ZijianF/Gaussian-Blur/master/gaussian_blur_cuda.hip"
	.size	.L.str.8, 114

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Usage: ./mandelbrot_serial order xcenter ycenter zoom cutoff\n"
	.size	.L.str.9, 62

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	" %s"
	.size	.L.str.10, 4

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	" %s "
	.size	.L.str.11, 5

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	" %f "
	.size	.L.str.12, 5

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"CudaErr: %s (%s:%d)\n"
	.size	.L.str.13, 21

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z24gaussian_blur_kernel_oldPhPfS_llflf"
	.size	.L__unnamed_1, 40

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z20gaussian_blur_kernelPhPfS_llflf"
	.size	.L__unnamed_2, 36

	.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 _Z39__device_stub__gaussian_blur_kernel_oldPhPfS_llflf
	.addrsig_sym _Z35__device_stub__gaussian_blur_kernelPhPfS_llflf
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z24gaussian_blur_kernel_oldPhPfS_llflf
	.addrsig_sym _Z20gaussian_blur_kernelPhPfS_llflf
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z24gaussian_blur_kernel_oldPhPfS_llflf ; -- Begin function _Z24gaussian_blur_kernel_oldPhPfS_llflf
	.globl	_Z24gaussian_blur_kernel_oldPhPfS_llflf
	.p2align	8
	.type	_Z24gaussian_blur_kernel_oldPhPfS_llflf,@function
_Z24gaussian_blur_kernel_oldPhPfS_llflf: ; @_Z24gaussian_blur_kernel_oldPhPfS_llflf
; %bb.0:
	s_clause 0x1
	s_load_b32 s6, s[0:1], 0x4c
	s_load_b64 s[2:3], s[0:1], 0x20
	v_bfe_u32 v3, v0, 10, 10
	s_add_u32 s4, s0, 64
	s_addc_u32 s5, s1, 0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s6, s6, 16
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s6, v[3:4]
	s_mov_b32 s6, exec_lo
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i64_e64 s[2:3], v[1:2]
	s_cbranch_execz .LBB0_9
; %bb.1:
	s_load_b32 s12, s[4:5], 0xc
	s_load_b256 s[4:11], s[0:1], 0x0
	v_and_b32_e32 v0, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s12, s12, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[3:4], null, s14, s12, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v4, 31, v3
	v_cmp_gt_i64_e32 vcc_lo, s[10:11], v[3:4]
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_9
; %bb.2:
	s_load_b64 s[12:13], s[0:1], 0x30
	s_waitcnt lgkmcnt(0)
	v_cmp_lt_i64_e64 s14, s[12:13], 1
	s_delay_alu instid0(VALU_DEP_1)
	s_and_b32 vcc_lo, exec_lo, s14
	s_cbranch_vccnz .LBB0_7
; %bb.3:                                ; %.lr.ph51.i
	s_lshr_b32 s14, s13, 31
	v_mov_b32_e32 v0, 0
	s_add_u32 s14, s12, s14
	s_addc_u32 s15, s13, 0
	s_mov_b64 s[16:17], 0
	s_ashr_i64 s[14:15], s[14:15], 1
	s_add_u32 s22, s2, -1
	v_sub_co_u32 v7, vcc_lo, v3, s14
	v_subrev_co_ci_u32_e32 v8, vcc_lo, s15, v4, vcc_lo
	v_sub_co_u32 v9, vcc_lo, v1, s14
	v_subrev_co_ci_u32_e32 v10, vcc_lo, s15, v2, vcc_lo
	s_addc_u32 s23, s3, -1
	s_add_u32 s24, s10, -1
	s_addc_u32 s25, s11, -1
	s_lshl_b64 s[14:15], s[12:13], 2
.LBB0_4:                                ; %.lr.ph.i
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_5 Depth 2
	v_add_co_u32 v5, vcc_lo, s16, v9
	v_add_co_ci_u32_e32 v6, vcc_lo, s17, v10, vcc_lo
	s_mov_b64 s[18:19], s[6:7]
	s_mov_b64 s[20:21], 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_cmp_gt_i64_e32 vcc_lo, s[2:3], v[5:6]
	v_cndmask_b32_e32 v11, s22, v5, vcc_lo
	v_cndmask_b32_e32 v12, s23, v6, vcc_lo
	v_cmp_lt_i64_e32 vcc_lo, -1, v[5:6]
	v_cndmask_b32_e32 v5, 0, v12, vcc_lo
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v11, 0, v11, vcc_lo
	v_mul_lo_u32 v12, v5, s10
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v13, v11, s11
	v_mad_u64_u32 v[5:6], null, v11, s10, s[4:5]
	v_add3_u32 v6, v12, v6, v13
.LBB0_5:                                ;   Parent Loop BB0_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_co_u32 v11, vcc_lo, v7, s20
	v_add_co_ci_u32_e32 v12, vcc_lo, s21, v8, vcc_lo
	s_load_b32 s26, s[18:19], 0x0
	s_add_u32 s20, s20, 1
	s_addc_u32 s21, s21, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_i64_e32 vcc_lo, s[10:11], v[11:12]
	s_add_u32 s18, s18, 4
	s_addc_u32 s19, s19, 0
	s_cmp_eq_u64 s[12:13], s[20:21]
	v_cndmask_b32_e32 v13, s24, v11, vcc_lo
	v_cndmask_b32_e32 v14, s25, v12, vcc_lo
	v_cmp_lt_i64_e32 vcc_lo, -1, v[11:12]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v12, 0, v14 :: v_dual_cndmask_b32 v11, 0, v13
	v_add_co_u32 v11, vcc_lo, v5, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v12, vcc_lo, v6, v12, vcc_lo
	global_load_u8 v11, v[11:12], off
	s_waitcnt vmcnt(0)
	v_cvt_f32_ubyte0_e32 v11, v11
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v0, s26, v11
	s_cbranch_scc0 .LBB0_5
; %bb.6:                                ; %._crit_edge.i
                                        ;   in Loop: Header=BB0_4 Depth=1
	s_add_u32 s16, s16, 1
	s_addc_u32 s17, s17, 0
	s_add_u32 s6, s6, s14
	s_addc_u32 s7, s7, s15
	s_cmp_eq_u64 s[16:17], s[12:13]
	s_cbranch_scc0 .LBB0_4
	s_branch .LBB0_8
.LBB0_7:
	v_mov_b32_e32 v0, 0
.LBB0_8:                                ; %_Z11blur_kernelPhlllllPff.exit
	s_load_b32 s0, s[0:1], 0x38
	v_mul_lo_u32 v2, v2, s10
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v5, null, s0, s0, v0
	v_div_scale_f32 v8, vcc_lo, v0, s0, v0
	v_rcp_f32_e32 v6, v5
	s_waitcnt_depctr 0xfff
	v_fma_f32 v7, -v5, v6, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v7, v6
	v_mul_f32_e32 v7, v8, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v9, -v5, v7, v8
	v_fmac_f32_e32 v7, v9, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f32 v5, -v5, v7, v8
	v_mul_lo_u32 v8, v1, s11
	v_div_fmas_f32 v7, v5, v6, v7
	v_mad_u64_u32 v[5:6], null, v1, s10, s[8:9]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fixup_f32 v0, v7, s0, v0
	v_add3_u32 v1, v2, v6, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_cvt_i32_f32_e32 v2, v0
	v_add_co_u32 v0, vcc_lo, v5, v3
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v1, vcc_lo, v1, v4, vcc_lo
	global_store_b8 v[0:1], v2, off
.LBB0_9:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z24gaussian_blur_kernel_oldPhPfS_llflf
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.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 15
		.amdhsa_next_free_sgpr 27
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z24gaussian_blur_kernel_oldPhPfS_llflf, .Lfunc_end0-_Z24gaussian_blur_kernel_oldPhPfS_llflf
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 668
; NumSgprs: 29
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 29
; NumVGPRsForWavesPerEU: 15
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z20gaussian_blur_kernelPhPfS_llflf ; -- Begin function _Z20gaussian_blur_kernelPhPfS_llflf
	.globl	_Z20gaussian_blur_kernelPhPfS_llflf
	.p2align	8
	.type	_Z20gaussian_blur_kernelPhPfS_llflf,@function
_Z20gaussian_blur_kernelPhPfS_llflf:    ; @_Z20gaussian_blur_kernelPhPfS_llflf
; %bb.0:
	s_clause 0x1
	s_load_b32 s6, s[0:1], 0x4c
	s_load_b64 s[2:3], s[0:1], 0x20
	v_bfe_u32 v3, v0, 10, 10
	s_add_u32 s4, s0, 64
	s_addc_u32 s5, s1, 0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s6, s6, 16
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s6, v[3:4]
	s_mov_b32 s6, exec_lo
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i64_e64 s[2:3], v[1:2]
	s_cbranch_execz .LBB1_9
; %bb.1:
	s_load_b32 s12, s[4:5], 0xc
	s_load_b256 s[4:11], s[0:1], 0x0
	v_and_b32_e32 v0, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s12, s12, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[3:4], null, s14, s12, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v4, 31, v3
	v_cmp_gt_i64_e32 vcc_lo, s[10:11], v[3:4]
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_9
; %bb.2:
	s_load_b64 s[12:13], s[0:1], 0x30
	s_waitcnt lgkmcnt(0)
	v_cmp_lt_i64_e64 s14, s[12:13], 1
	s_delay_alu instid0(VALU_DEP_1)
	s_and_b32 vcc_lo, exec_lo, s14
	s_cbranch_vccnz .LBB1_7
; %bb.3:                                ; %.lr.ph67
	s_lshr_b32 s14, s13, 31
	v_mov_b32_e32 v0, 0
	s_add_u32 s14, s12, s14
	s_addc_u32 s15, s13, 0
	s_mov_b64 s[16:17], 0
	s_ashr_i64 s[14:15], s[14:15], 1
	s_add_u32 s22, s2, -1
	v_sub_co_u32 v7, vcc_lo, v1, s14
	v_subrev_co_ci_u32_e32 v8, vcc_lo, s15, v2, vcc_lo
	v_sub_co_u32 v9, vcc_lo, v3, s14
	v_subrev_co_ci_u32_e32 v10, vcc_lo, s15, v4, vcc_lo
	s_addc_u32 s23, s3, -1
	s_add_u32 s24, s10, -1
	s_addc_u32 s25, s11, -1
	s_lshl_b64 s[14:15], s[12:13], 2
.LBB1_4:                                ; %.lr.ph
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_5 Depth 2
	v_add_co_u32 v5, vcc_lo, s16, v7
	v_add_co_ci_u32_e32 v6, vcc_lo, s17, v8, vcc_lo
	s_mov_b64 s[18:19], s[6:7]
	s_mov_b64 s[20:21], 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_cmp_gt_i64_e32 vcc_lo, s[2:3], v[5:6]
	v_cndmask_b32_e32 v11, s22, v5, vcc_lo
	v_cndmask_b32_e32 v12, s23, v6, vcc_lo
	v_cmp_lt_i64_e32 vcc_lo, -1, v[5:6]
	v_cndmask_b32_e32 v5, 0, v12, vcc_lo
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v11, 0, v11, vcc_lo
	v_mul_lo_u32 v12, v5, s10
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v13, v11, s11
	v_mad_u64_u32 v[5:6], null, v11, s10, s[4:5]
	v_add3_u32 v6, v12, v6, v13
.LBB1_5:                                ;   Parent Loop BB1_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_co_u32 v11, vcc_lo, v9, s20
	v_add_co_ci_u32_e32 v12, vcc_lo, s21, v10, vcc_lo
	s_load_b32 s26, s[18:19], 0x0
	s_add_u32 s20, s20, 1
	s_addc_u32 s21, s21, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_i64_e32 vcc_lo, s[10:11], v[11:12]
	s_add_u32 s18, s18, 4
	s_addc_u32 s19, s19, 0
	s_cmp_eq_u64 s[12:13], s[20:21]
	v_cndmask_b32_e32 v13, s24, v11, vcc_lo
	v_cndmask_b32_e32 v14, s25, v12, vcc_lo
	v_cmp_lt_i64_e32 vcc_lo, -1, v[11:12]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v12, 0, v14 :: v_dual_cndmask_b32 v11, 0, v13
	v_add_co_u32 v11, vcc_lo, v5, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v12, vcc_lo, v6, v12, vcc_lo
	global_load_u8 v11, v[11:12], off
	s_waitcnt vmcnt(0)
	v_cvt_f32_ubyte0_e32 v11, v11
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v0, s26, v11
	s_cbranch_scc0 .LBB1_5
; %bb.6:                                ; %._crit_edge
                                        ;   in Loop: Header=BB1_4 Depth=1
	s_add_u32 s16, s16, 1
	s_addc_u32 s17, s17, 0
	s_add_u32 s6, s6, s14
	s_addc_u32 s7, s7, s15
	s_cmp_eq_u64 s[16:17], s[12:13]
	s_cbranch_scc0 .LBB1_4
	s_branch .LBB1_8
.LBB1_7:
	v_mov_b32_e32 v0, 0
.LBB1_8:                                ; %Flow91
	s_load_b32 s0, s[0:1], 0x38
	v_mul_lo_u32 v2, v2, s10
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v5, null, s0, s0, v0
	v_div_scale_f32 v8, vcc_lo, v0, s0, v0
	v_rcp_f32_e32 v6, v5
	s_waitcnt_depctr 0xfff
	v_fma_f32 v7, -v5, v6, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v6, v7, v6
	v_mul_f32_e32 v7, v8, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v9, -v5, v7, v8
	v_fmac_f32_e32 v7, v9, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f32 v5, -v5, v7, v8
	v_mul_lo_u32 v8, v1, s11
	v_div_fmas_f32 v7, v5, v6, v7
	v_mad_u64_u32 v[5:6], null, v1, s10, s[8:9]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fixup_f32 v0, v7, s0, v0
	v_add3_u32 v1, v2, v6, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_cvt_i32_f32_e32 v2, v0
	v_add_co_u32 v0, vcc_lo, v5, v3
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v1, vcc_lo, v1, v4, vcc_lo
	global_store_b8 v[0:1], v2, off
.LBB1_9:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20gaussian_blur_kernelPhPfS_llflf
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.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 15
		.amdhsa_next_free_sgpr 27
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z20gaussian_blur_kernelPhPfS_llflf, .Lfunc_end1-_Z20gaussian_blur_kernelPhPfS_llflf
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 668
; NumSgprs: 29
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 29
; NumVGPRsForWavesPerEU: 15
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           8
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           8
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z24gaussian_blur_kernel_oldPhPfS_llflf
    .private_segment_fixed_size: 0
    .sgpr_count:     29
    .sgpr_spill_count: 0
    .symbol:         _Z24gaussian_blur_kernel_oldPhPfS_llflf.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           8
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           8
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z20gaussian_blur_kernelPhPfS_llflf
    .private_segment_fixed_size: 0
    .sgpr_count:     29
    .sgpr_spill_count: 0
    .symbol:         _Z20gaussian_blur_kernelPhPfS_llflf.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
