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

typedef struct {
     unsigned char red,green,blue;
} PPMPixel;

typedef struct {
     int x, y;
     PPMPixel *data;
} PPMImage;

#define CREATOR "COMP3231"
#define RGB_COMPONENT_COLOR 255


static PPMImage *readPPM(const char *filename)
{
         char buff[16];
         PPMImage *img;
         FILE *fp;
         int c, rgb_comp_color;
         //open PPM file for reading
         fp = fopen(filename, "rb");
         if (!fp) {
              fprintf(stderr, "Unable to open file '%s'\n", filename);
              exit(1);
         }

         //read image format
         if (!fgets(buff, sizeof(buff), fp)) {
              perror(filename);
              exit(1);
         }

    //check the image format
    if (buff[0] != 'P' || buff[1] != '6') {
         fprintf(stderr, "Invalid image format (must be 'P6')\n");
         exit(1);
    }

    //alloc memory form image
    img = (PPMImage *)malloc(sizeof(PPMImage));
    if (!img) {
         fprintf(stderr, "Unable to allocate memory\n");
         exit(1);
    }

    //check for comments
    c = getc(fp);
    while (c == '#') {
    while (getc(fp) != '\n') ;
         c = getc(fp);
    }

    ungetc(c, fp);
    //read image size information
    if (fscanf(fp, "%d %d", &img->x, &img->y) != 2) {
         fprintf(stderr, "Invalid image size (error loading '%s')\n", filename);
         exit(1);
    }

    //read rgb component
    if (fscanf(fp, "%d", &rgb_comp_color) != 1) {
         fprintf(stderr, "Invalid rgb component (error loading '%s')\n", filename);
         exit(1);
    }

    //check rgb component depth
    if (rgb_comp_color!= RGB_COMPONENT_COLOR) {
         fprintf(stderr, "'%s' does not have 8-bits components\n", filename);
         exit(1);
    }

    while (fgetc(fp) != '\n') ;
    //memory allocation for pixel data
    img->data = (PPMPixel*)malloc(img->x * img->y * sizeof(PPMPixel));

    if (!img) {
         fprintf(stderr, "Unable to allocate memory\n");
         exit(1);
    }

    //read pixel data from file
    if (fread(img->data, 3 * img->x, img->y, fp) != img->y) {
         fprintf(stderr, "Error loading image '%s'\n", filename);
         exit(1);
    }

    fclose(fp);
    return img;
}

void writePPM(const char *filename, PPMImage *img)
{
    FILE *fp;
    //open file for output
    fp = fopen(filename, "wb");
    if (!fp) {
         fprintf(stderr, "Unable to open file '%s'\n", filename);
         exit(1);
    }

    //write the header file
    //image format
    fprintf(fp, "P6\n");

    //comments
    fprintf(fp, "# Created by %s\n",CREATOR);

    //image size
    fprintf(fp, "%d %d\n",img->x,img->y);

    // rgb component depth
    fprintf(fp, "%d\n",RGB_COMPONENT_COLOR);

    // pixel data
    fwrite(img->data, 3 * img->x, img->y, fp);
    fclose(fp);
}


__global__ void blur_kernel() {

    //kernel code

}

void your_gaussian_blur_func(PPMImage *img) {
    
    //host code 

}

int main(){
    PPMImage *image;
    image = readPPM("input.ppm");

    your_gaussian_blur_func(image);

    writePPM("output.ppm",image);

}
	.file	"tmpxft_003b77a8_00000000-6_blur.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"wb"
.LC1:
	.string	"Unable to open file '%s'\n"
.LC2:
	.string	"P6\n"
.LC3:
	.string	"COMP3231"
.LC4:
	.string	"# Created by %s\n"
.LC5:
	.string	"%d %d\n"
.LC6:
	.string	"%d\n"
	.text
	.globl	_Z8writePPMPKcP8PPMImage
	.type	_Z8writePPMPKcP8PPMImage, @function
_Z8writePPMPKcP8PPMImage:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rsi, %rbp
	leaq	.LC0(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L3
	movq	stderr(%rip), %rdi
	movq	%r12, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L3:
	movq	%rax, %rbx
	movq	%rax, %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC3(%rip), %rcx
	leaq	.LC4(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	4(%rbp), %r8d
	movl	0(%rbp), %ecx
	movq	%rbx, %rdi
	leaq	.LC5(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	%rbx, %rdi
	movl	$255, %ecx
	xorl	%eax, %eax
	leaq	.LC6(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	imull	$3, 0(%rbp), %esi
	movq	8(%rbp), %rdi
	movq	%rbx, %rcx
	movslq	4(%rbp), %rdx
	movslq	%esi, %rsi
	call	fwrite@PLT
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z8writePPMPKcP8PPMImage, .-_Z8writePPMPKcP8PPMImage
	.globl	_Z23your_gaussian_blur_funcP8PPMImage
	.type	_Z23your_gaussian_blur_funcP8PPMImage, @function
_Z23your_gaussian_blur_funcP8PPMImage:
.LFB2029:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z23your_gaussian_blur_funcP8PPMImage, .-_Z23your_gaussian_blur_funcP8PPMImage
	.section	.rodata.str1.1
.LC7:
	.string	"rb"
.LC8:
	.string	"input.ppm"
.LC9:
	.string	"Invalid image format (must be 'P6')\n"
.LC10:
	.string	"Unable to allocate memory\n"
.LC11:
	.string	"%d %d"
.LC12:
	.string	"Invalid image size (error loading '%s')\n"
.LC13:
	.string	"%d"
.LC14:
	.string	"Invalid rgb component (error loading '%s')\n"
.LC15:
	.string	"'%s' does not have 8-bits components\n"
.LC16:
	.string	"Error loading image '%s'\n"
.LC17:
	.string	"output.ppm"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC7(%rip), %rsi
	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
	leaq	.LC8(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	movq	%r12, %rcx
	leaq	.LC1(%rip), %rdx
	testq	%rax, %rax
	je	.L28
	leaq	8(%rsp), %rdi
	movq	%rax, %rcx
	movl	$16, %edx
	movq	%rax, %rbx
	movl	$16, %esi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	jne	.L9
	movq	%r12, %rdi
	call	perror@PLT
.L27:
	movl	$1, %edi
	call	exit@PLT
.L9:
	cmpb	$80, 8(%rsp)
	jne	.L10
	cmpb	$54, 9(%rsp)
	je	.L11
.L10:
	leaq	.LC9(%rip), %rdx
	jmp	.L29
.L11:
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	jne	.L26
	leaq	.LC10(%rip), %rdx
.L29:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L27
.L14:
	movq	%rbx, %rdi
	call	getc@PLT
	cmpl	$10, %eax
	jne	.L14
.L26:
	movq	%rbx, %rdi
	call	getc@PLT
	cmpl	$35, %eax
	je	.L14
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	ungetc@PLT
	leaq	4(%rbp), %rcx
	movq	%rbp, %rdx
	movq	%rbx, %rdi
	leaq	.LC11(%rip), %rsi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	%r12, %rcx
	leaq	.LC12(%rip), %rdx
	cmpl	$2, %eax
	jne	.L28
	leaq	4(%rsp), %rdx
	xorl	%eax, %eax
	leaq	.LC13(%rip), %rsi
	movq	%rbx, %rdi
	call	__isoc23_fscanf@PLT
	movq	%r12, %rcx
	leaq	.LC14(%rip), %rdx
	decl	%eax
	jne	.L28
	cmpl	$255, 4(%rsp)
	leaq	.LC15(%rip), %rdx
	jne	.L28
.L17:
	movq	%rbx, %rdi
	call	fgetc@PLT
	cmpl	$10, %eax
	jne	.L17
	movl	0(%rbp), %r14d
	movl	4(%rbp), %r15d
	movl	%r14d, %r13d
	imull	%r15d, %r13d
	movslq	%r13d, %r13
	leaq	0(%r13,%r13,2), %r13
	movq	%r13, %rdi
	call	malloc@PLT
	leal	(%r14,%r14,2), %edx
	movslq	%r15d, %rcx
	movq	%rbx, %r8
	movq	%rax, 8(%rbp)
	movslq	%edx, %rdx
	movq	%rax, %rdi
	movq	%r13, %rsi
	call	__fread_chk@PLT
	movq	%rax, %rdx
	movslq	4(%rbp), %rax
	cmpq	%rax, %rdx
	je	.L18
	movq	%r12, %rcx
	leaq	.LC16(%rip), %rdx
.L28:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L27
.L18:
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	%rbp, %rsi
	leaq	.LC17(%rip), %rdi
	call	_Z8writePPMPKcP8PPMImage
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	addq	$40, %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
.LFE2030:
	.size	main, .-main
	.text
	.globl	_Z30__device_stub__Z11blur_kernelvv
	.type	_Z30__device_stub__Z11blur_kernelvv, @function
_Z30__device_stub__Z11blur_kernelvv:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$88, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	movabsq	$4294967297, %rax
	leaq	8(%rsp), %rcx
	movq	%rsp, %rdx
	leaq	28(%rsp), %rsi
	leaq	16(%rsp), %rdi
	movl	$1, 24(%rsp)
	movl	$1, 36(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 28(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	pushq	8(%rsp)
	.cfi_def_cfa_offset 104
	leaq	_Z11blur_kernelv(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 112
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 104
	popq	%rdx
	.cfi_def_cfa_offset 96
.L30:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$88, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z30__device_stub__Z11blur_kernelvv, .-_Z30__device_stub__Z11blur_kernelvv
	.globl	_Z11blur_kernelv
	.type	_Z11blur_kernelv, @function
_Z11blur_kernelv:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z11blur_kernelvv
	.cfi_endproc
.LFE2056:
	.size	_Z11blur_kernelv, .-_Z11blur_kernelv
	.section	.rodata.str1.1
.LC18:
	.string	"_Z11blur_kernelv"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2058:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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
	leaq	_Z11blur_kernelv(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	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	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2058:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


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

typedef struct {
     unsigned char red,green,blue;
} PPMPixel;

typedef struct {
     int x, y;
     PPMPixel *data;
} PPMImage;

#define CREATOR "COMP3231"
#define RGB_COMPONENT_COLOR 255


static PPMImage *readPPM(const char *filename)
{
         char buff[16];
         PPMImage *img;
         FILE *fp;
         int c, rgb_comp_color;
         //open PPM file for reading
         fp = fopen(filename, "rb");
         if (!fp) {
              fprintf(stderr, "Unable to open file '%s'\n", filename);
              exit(1);
         }

         //read image format
         if (!fgets(buff, sizeof(buff), fp)) {
              perror(filename);
              exit(1);
         }

    //check the image format
    if (buff[0] != 'P' || buff[1] != '6') {
         fprintf(stderr, "Invalid image format (must be 'P6')\n");
         exit(1);
    }

    //alloc memory form image
    img = (PPMImage *)malloc(sizeof(PPMImage));
    if (!img) {
         fprintf(stderr, "Unable to allocate memory\n");
         exit(1);
    }

    //check for comments
    c = getc(fp);
    while (c == '#') {
    while (getc(fp) != '\n') ;
         c = getc(fp);
    }

    ungetc(c, fp);
    //read image size information
    if (fscanf(fp, "%d %d", &img->x, &img->y) != 2) {
         fprintf(stderr, "Invalid image size (error loading '%s')\n", filename);
         exit(1);
    }

    //read rgb component
    if (fscanf(fp, "%d", &rgb_comp_color) != 1) {
         fprintf(stderr, "Invalid rgb component (error loading '%s')\n", filename);
         exit(1);
    }

    //check rgb component depth
    if (rgb_comp_color!= RGB_COMPONENT_COLOR) {
         fprintf(stderr, "'%s' does not have 8-bits components\n", filename);
         exit(1);
    }

    while (fgetc(fp) != '\n') ;
    //memory allocation for pixel data
    img->data = (PPMPixel*)malloc(img->x * img->y * sizeof(PPMPixel));

    if (!img) {
         fprintf(stderr, "Unable to allocate memory\n");
         exit(1);
    }

    //read pixel data from file
    if (fread(img->data, 3 * img->x, img->y, fp) != img->y) {
         fprintf(stderr, "Error loading image '%s'\n", filename);
         exit(1);
    }

    fclose(fp);
    return img;
}

void writePPM(const char *filename, PPMImage *img)
{
    FILE *fp;
    //open file for output
    fp = fopen(filename, "wb");
    if (!fp) {
         fprintf(stderr, "Unable to open file '%s'\n", filename);
         exit(1);
    }

    //write the header file
    //image format
    fprintf(fp, "P6\n");

    //comments
    fprintf(fp, "# Created by %s\n",CREATOR);

    //image size
    fprintf(fp, "%d %d\n",img->x,img->y);

    // rgb component depth
    fprintf(fp, "%d\n",RGB_COMPONENT_COLOR);

    // pixel data
    fwrite(img->data, 3 * img->x, img->y, fp);
    fclose(fp);
}


__global__ void blur_kernel() {

    //kernel code

}

void your_gaussian_blur_func(PPMImage *img) {
    
    //host code 

}

int main(){
    PPMImage *image;
    image = readPPM("input.ppm");

    your_gaussian_blur_func(image);

    writePPM("output.ppm",image);

}
	.text
	.file	"blur.hip"
	.globl	_Z8writePPMPKcP8PPMImage        # -- Begin function _Z8writePPMPKcP8PPMImage
	.type	_Z8writePPMPKcP8PPMImage,@function
_Z8writePPMPKcP8PPMImage:               # @_Z8writePPMPKcP8PPMImage
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r15
	movl	$.L.str, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB0_1
# %bb.2:
	movq	%rax, %r14
	movl	$.L.str.2, %edi
	movl	$3, %esi
	movl	$1, %edx
	movq	%rax, %rcx
	callq	fwrite
	movl	$.L.str.3, %esi
	movl	$.L.str.4, %edx
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	fprintf
	movl	(%rbx), %edx
	movl	4(%rbx), %ecx
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	fprintf
	movl	$.L.str.6, %esi
	movq	%r14, %rdi
	movl	$255, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	8(%rbx), %rdi
	movslq	(%rbx), %rax
	leaq	(%rax,%rax,2), %rsi
	movslq	4(%rbx), %rdx
	movq	%r14, %rcx
	callq	fwrite
	movq	%r14, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.LBB0_1:
	.cfi_def_cfa_offset 32
	movq	stderr(%rip), %rdi
	movl	$.L.str.1, %esi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z8writePPMPKcP8PPMImage, .Lfunc_end0-_Z8writePPMPKcP8PPMImage
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__blur_kernelv # -- Begin function _Z26__device_stub__blur_kernelv
	.type	_Z26__device_stub__blur_kernelv,@function
_Z26__device_stub__blur_kernelv:        # @_Z26__device_stub__blur_kernelv
	.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
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rbx
	leaq	24(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	__hipPopCallConfiguration
	movq	(%rbx), %rsi
	movl	8(%rbx), %edx
	movq	(%r14), %rcx
	movl	8(%r14), %r8d
	movq	%rsp, %r9
	movl	$_Z11blur_kernelv, %edi
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	pushq	(%r15)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$72, %rsp
	.cfi_adjust_cfa_offset -72
	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_end1:
	.size	_Z26__device_stub__blur_kernelv, .Lfunc_end1-_Z26__device_stub__blur_kernelv
	.cfi_endproc
                                        # -- End function
	.globl	_Z23your_gaussian_blur_funcP8PPMImage # -- Begin function _Z23your_gaussian_blur_funcP8PPMImage
	.type	_Z23your_gaussian_blur_funcP8PPMImage,@function
_Z23your_gaussian_blur_funcP8PPMImage:  # @_Z23your_gaussian_blur_funcP8PPMImage
	.cfi_startproc
# %bb.0:
	retq
.Lfunc_end2:
	.size	_Z23your_gaussian_blur_funcP8PPMImage, .Lfunc_end2-_Z23your_gaussian_blur_funcP8PPMImage
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$.L.str.7, %edi
	movl	$.L.str.9, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB3_14
# %bb.1:
	movq	%rax, %rbx
	leaq	16(%rsp), %rdi
	movl	$16, %esi
	movq	%rax, %rdx
	callq	fgets
	testq	%rax, %rax
	je	.LBB3_15
# %bb.2:
	cmpb	$80, 16(%rsp)
	jne	.LBB3_16
# %bb.3:
	cmpb	$54, 17(%rsp)
	jne	.LBB3_16
# %bb.4:
	movl	$16, %edi
	callq	malloc
	testq	%rax, %rax
	je	.LBB3_17
# %bb.5:
	movq	%rax, %r14
.LBB3_6:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_7 Depth 2
	movq	%rbx, %rdi
	callq	getc
	cmpl	$35, %eax
	jne	.LBB3_8
.LBB3_7:                                # %.preheader44.i
                                        #   Parent Loop BB3_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%rbx, %rdi
	callq	getc
	cmpl	$10, %eax
	jne	.LBB3_7
	jmp	.LBB3_6
.LBB3_8:                                # %._crit_edge.i
	movl	%eax, %edi
	movq	%rbx, %rsi
	callq	ungetc
	movq	%r14, %rcx
	addq	$4, %rcx
	movl	$.L.str.12, %esi
	movq	%rbx, %rdi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$2, %eax
	jne	.LBB3_20
# %bb.9:
	leaq	12(%rsp), %rdx
	movl	$.L.str.14, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$1, %eax
	jne	.LBB3_21
# %bb.10:
	cmpl	$255, 12(%rsp)
	jne	.LBB3_22
.LBB3_11:                               # %.preheader.i
                                        # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	callq	fgetc
	cmpl	$10, %eax
	jne	.LBB3_11
# %bb.12:
	movslq	(%r14), %rax
	movslq	4(%r14), %r15
	leaq	(%rax,%rax,2), %r12
	movq	%r12, %rdi
	imulq	%r15, %rdi
	callq	malloc
	movq	%rax, 8(%r14)
	movq	%rax, %rdi
	movq	%r12, %rsi
	movq	%r15, %rdx
	movq	%rbx, %rcx
	callq	fread
	movslq	4(%r14), %rcx
	cmpq	%rcx, %rax
	jne	.LBB3_23
# %bb.13:                               # %_ZL7readPPMPKc.exit
	movq	%rbx, %rdi
	callq	fclose
	movl	$.L.str.8, %edi
	movq	%r14, %rsi
	callq	_Z8writePPMPKcP8PPMImage
	xorl	%eax, %eax
	addq	$40, %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
.LBB3_14:
	.cfi_def_cfa_offset 80
	movq	stderr(%rip), %rdi
	movl	$.L.str.1, %esi
	jmp	.LBB3_24
.LBB3_15:
	movl	$.L.str.7, %edi
	callq	perror
	jmp	.LBB3_19
.LBB3_16:
	movq	stderr(%rip), %rcx
	movl	$.L.str.10, %edi
	movl	$36, %esi
	jmp	.LBB3_18
.LBB3_17:
	movq	stderr(%rip), %rcx
	movl	$.L.str.11, %edi
	movl	$26, %esi
.LBB3_18:
	movl	$1, %edx
	callq	fwrite
	jmp	.LBB3_19
.LBB3_20:
	movq	stderr(%rip), %rdi
	movl	$.L.str.13, %esi
	jmp	.LBB3_24
.LBB3_21:
	movq	stderr(%rip), %rdi
	movl	$.L.str.15, %esi
	jmp	.LBB3_24
.LBB3_22:
	movq	stderr(%rip), %rdi
	movl	$.L.str.16, %esi
	jmp	.LBB3_24
.LBB3_23:
	movq	stderr(%rip), %rdi
	movl	$.L.str.17, %esi
.LBB3_24:
	movl	$.L.str.7, %edx
	xorl	%eax, %eax
	callq	fprintf
.LBB3_19:
	movl	$1, %edi
	callq	exit
.Lfunc_end3:
	.size	main, .Lfunc_end3-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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11blur_kernelv, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"wb"
	.size	.L.str, 3

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Unable to open file '%s'\n"
	.size	.L.str.1, 26

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"P6\n"
	.size	.L.str.2, 4

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"COMP3231"
	.size	.L.str.4, 9

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%d %d\n"
	.size	.L.str.5, 7

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%d\n"
	.size	.L.str.6, 4

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

	.type	.L.str.7,@object                # @.str.7
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.7:
	.asciz	"input.ppm"
	.size	.L.str.7, 10

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"output.ppm"
	.size	.L.str.8, 11

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

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Invalid image format (must be 'P6')\n"
	.size	.L.str.10, 37

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Unable to allocate memory\n"
	.size	.L.str.11, 27

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"%d %d"
	.size	.L.str.12, 6

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Invalid image size (error loading '%s')\n"
	.size	.L.str.13, 41

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"%d"
	.size	.L.str.14, 3

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Invalid rgb component (error loading '%s')\n"
	.size	.L.str.15, 44

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"'%s' does not have 8-bits components\n"
	.size	.L.str.16, 38

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Error loading image '%s'\n"
	.size	.L.str.17, 26

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11blur_kernelv"
	.size	.L__unnamed_1, 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 _Z26__device_stub__blur_kernelv
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11blur_kernelv
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11blur_kernelv        ; -- Begin function _Z11blur_kernelv
	.globl	_Z11blur_kernelv
	.p2align	8
	.type	_Z11blur_kernelv,@function
_Z11blur_kernelv:                       ; @_Z11blur_kernelv
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11blur_kernelv
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 0
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 0
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z11blur_kernelv, .Lfunc_end0-_Z11blur_kernelv
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:           []
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 4
    .kernarg_segment_size: 0
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11blur_kernelv
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z11blur_kernelv.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
