#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define MASK_WIDTH 5

#define COMMENT "Histogram_GPU"
#define RGB_COMPONENT_COLOR 255

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

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

double rtclock()
{
  struct timezone Tzp;
  struct timeval Tp;
  int stat;
  stat = gettimeofday (&Tp, &Tzp);
  if (stat != 0) printf("Error return from gettimeofday: %d",stat);
  return(Tp.tv_sec + Tp.tv_usec*1.0e-6);
}


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

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

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

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

  c = getc(fp);
  while (c == '#') {
    while (getc(fp) != '\n')
      ;
    c = getc(fp);
  }

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

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

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

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

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

  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(PPMImage *img) {
  fprintf(stdout, "P6\n");
  fprintf(stdout, "# %s\n", COMMENT);
  fprintf(stdout, "%d %d\n", img->x, img->y);
  fprintf(stdout, "%d\n", RGB_COMPONENT_COLOR);
  fwrite(img->data, 3 * img->x, img->y, stdout);
  fclose(stdout);
}


void Smoothing_CPU_Serial(PPMImage *image, PPMImage *image_copy) {
  int i, j, y, x;
  int total_red, total_blue, total_green;

  for (i = 0; i < image->y; i++) {
    for (j = 0; j < image->x; j++) {
      total_red = total_blue = total_green = 0;
      for (y = i - ((MASK_WIDTH-1)/2); y <= (i + ((MASK_WIDTH-1)/2)); y++) {
        for (x = j - ((MASK_WIDTH-1)/2); x <= (j + ((MASK_WIDTH-1)/2)); x++) {
          if (x >= 0 && y >= 0 && y < image->y && x < image->x) {
            total_red += image_copy->data[(y * image->x) + x].red;
            total_blue += image_copy->data[(y * image->x) + x].blue;
            total_green += image_copy->data[(y * image->x) + x].green;
          }
        }
      }
      image->data[(i * image->x) + j].red = total_red / (MASK_WIDTH*MASK_WIDTH);
      image->data[(i * image->x) + j].blue = total_blue / (MASK_WIDTH*MASK_WIDTH);
      image->data[(i * image->x) + j].green = total_green / (MASK_WIDTH*MASK_WIDTH);
    }
  }
}

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

  if( argc != 2 ) {
    printf("Too many or no one arguments supplied.\n");
  }

  double t_start, t_end;
  char *filename = argv[1];
  float milliseconds = 0;

  cudaEvent_t start, stop;
  cudaEventCreate(&start);
  cudaEventCreate(&stop);

  PPMImage *image = readPPM(filename);
  PPMImage *image_output = readPPM(filename);

  //t_start = rtclock();
  cudaEventRecord(start);
  Smoothing_CPU_Serial(image_output, image);
  cudaEventRecord(stop);
  cudaEventSynchronize(stop);
  cudaEventElapsedTime(&milliseconds, start, stop);
  //t_end = rtclock();

  //writePPM(image_output);

  printf("Tempo: %0.3f\n",milliseconds);
  // fprintf(stdout, "\n%0.6lfs\n", t_end - t_start);  
  free(image);
  free(image_output);
  return 0;
}

	.file	"tmpxft_003a21b4_00000000-6_serial.cudafe1.cpp"
	.text
#APP

	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"rb"
.LC1:
	.string	"Unable to open file '%s'\n"
.LC2:
	.string	"Invalid image format (must be 'P6')\n"
.LC3:
	.string	"Unable to allocate memory\n"
.LC4:
	.string	"%d %d"
.LC5:
	.string	"Invalid image size (error loading '%s')\n"
.LC6:
	.string	"%d"
.LC7:
	.string	"Invalid rgb component (error loading '%s')\n"
.LC8:
	.string	"'%s' does not have 8-bits components\n"
.LC9:
	.string	"Error loading image '%s'\n"
#NO_APP
	.text
	.type	_ZL7readPPMPKc, @function
_ZL7readPPMPKc:
.LFB2028:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%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
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	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	.L22
	leaq	8(%rsp), %rdi
	movq	%rax, %rcx
	movl	$16, %edx
	movq	%rax, %rbx
	movl	$16, %esi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	jne	.L3
	movq	%r12, %rdi
	call	perror@PLT
.L21:
	movl	$1, %edi
	call	exit@PLT
.L3:
	cmpb	$80, 8(%rsp)
	jne	.L4
	cmpb	$54, 9(%rsp)
	je	.L5
.L4:
	leaq	.LC2(%rip), %rdx
	jmp	.L23
.L5:
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	jne	.L20
	leaq	.LC3(%rip), %rdx
.L23:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L21
.L8:
	movq	%rbx, %rdi
	call	getc@PLT
	cmpl	$10, %eax
	jne	.L8
.L20:
	movq	%rbx, %rdi
	call	getc@PLT
	cmpl	$35, %eax
	je	.L8
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	ungetc@PLT
	leaq	4(%rbp), %rcx
	movq	%rbp, %rdx
	movq	%rbx, %rdi
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	%r12, %rcx
	leaq	.LC5(%rip), %rdx
	cmpl	$2, %eax
	jne	.L22
	leaq	4(%rsp), %rdx
	xorl	%eax, %eax
	leaq	.LC6(%rip), %rsi
	movq	%rbx, %rdi
	call	__isoc23_fscanf@PLT
	movq	%r12, %rcx
	leaq	.LC7(%rip), %rdx
	decl	%eax
	jne	.L22
	cmpl	$255, 4(%rsp)
	leaq	.LC8(%rip), %rdx
	jne	.L22
.L11:
	movq	%rbx, %rdi
	call	fgetc@PLT
	cmpl	$10, %eax
	jne	.L11
	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
	movslq	4(%rbp), %rdx
	cmpq	%rax, %rdx
	je	.L12
	movq	%r12, %rcx
	leaq	.LC9(%rip), %rdx
.L22:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L21
.L12:
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	movq	%rbp, %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
.LFE2028:
	.size	_ZL7readPPMPKc, .-_ZL7readPPMPKc
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1
.LC10:
	.string	"Error return from gettimeofday: %d"
	.text
	.globl	_Z7rtclockv
	.type	_Z7rtclockv, @function
_Z7rtclockv:
.LFB2027:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	testl	%eax, %eax
	je	.L27
	movl	%eax, %edx
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L27:
	cvtsi2sdq	16(%rsp), %xmm0
	mulsd	.LC11(%rip), %xmm0
	cvtsi2sdq	8(%rsp), %xmm1
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z7rtclockv, .-_Z7rtclockv
	.section	.rodata.str1.1
.LC12:
	.string	"P6\n"
.LC13:
	.string	"Histogram_GPU"
.LC14:
	.string	"# %s\n"
.LC15:
	.string	"%d %d\n"
.LC16:
	.string	"%d\n"
	.text
	.globl	_Z8writePPMP8PPMImage
	.type	_Z8writePPMP8PPMImage, @function
_Z8writePPMP8PPMImage:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movq	stdout(%rip), %rdi
	movl	$2, %esi
	leaq	.LC12(%rip), %rdx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	stdout(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC13(%rip), %rcx
	leaq	.LC14(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	4(%rbx), %r8d
	movl	(%rbx), %ecx
	movl	$2, %esi
	movq	stdout(%rip), %rdi
	leaq	.LC15(%rip), %rdx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	stdout(%rip), %rdi
	movl	$255, %ecx
	xorl	%eax, %eax
	leaq	.LC16(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	imull	$3, (%rbx), %esi
	movq	8(%rbx), %rdi
	movslq	4(%rbx), %rdx
	movq	stdout(%rip), %rcx
	movslq	%esi, %rsi
	call	fwrite@PLT
	movq	stdout(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z8writePPMP8PPMImage, .-_Z8writePPMP8PPMImage
	.globl	_Z20Smoothing_CPU_SerialP8PPMImageS0_
	.type	_Z20Smoothing_CPU_SerialP8PPMImageS0_, @function
_Z20Smoothing_CPU_SerialP8PPMImageS0_:
.LFB2030:
	.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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	4(%rdi), %eax
	movl	$25, %edi
	movl	%eax, -24(%rsp)
	movq	%rsi, -16(%rsp)
	xorl	%esi, %esi
.L36:
	cmpl	%esi, -24(%rsp)
	jle	.L35
	movl	0(%rbp), %ebx
	leal	-2(%rsi), %r13d
	xorl	%r11d, %r11d
	movl	%ebx, %eax
	movl	%ebx, %ecx
	imull	%r13d, %eax
	imull	%esi, %ecx
	movl	%eax, -20(%rsp)
	leal	3(%rsi), %eax
	movl	%eax, -4(%rsp)
	movslq	%ecx, %rcx
	leaq	(%rcx,%rcx,2), %rcx
.L44:
	cmpl	%r11d, %ebx
	jle	.L52
	leal	3(%r11), %edx
	movl	-20(%rsp), %r14d
	movl	%r13d, %r12d
	xorl	%r8d, %r8d
	movl	%edx, -8(%rsp)
	xorl	%r9d, %r9d
	xorl	%eax, %eax
.L37:
	movl	-4(%rsp), %edx
	cmpl	%edx, %r12d
	je	.L53
	leal	-2(%r11), %r10d
.L38:
	movl	-8(%rsp), %edx
	cmpl	%edx, %r10d
	je	.L54
	movl	%r12d, %edx
	orl	%r10d, %edx
	notl	%edx
	shrl	$31, %edx
	cmpl	%r10d, %ebx
	setg	%r15b
	testb	%dl, %r15b
	je	.L39
	cmpl	%r12d, -24(%rsp)
	jle	.L39
	movq	-16(%rsp), %r15
	leal	(%r10,%r14), %edx
	movslq	%edx, %rdx
	leaq	(%rdx,%rdx,2), %rdx
	addq	8(%r15), %rdx
	movzbl	(%rdx), %r15d
	addl	%r15d, %eax
	movzbl	2(%rdx), %r15d
	movzbl	1(%rdx), %edx
	addl	%r15d, %r9d
	addl	%edx, %r8d
.L39:
	incl	%r10d
	jmp	.L38
.L54:
	incl	%r12d
	addl	%ebx, %r14d
	jmp	.L37
.L53:
	cltd
	movq	8(%rbp), %r10
	incl	%r11d
	idivl	%edi
	addq	%rcx, %r10
	addq	$3, %rcx
	movb	%al, (%r10)
	movl	%r9d, %eax
	cltd
	idivl	%edi
	movb	%al, 2(%r10)
	movl	%r8d, %eax
	cltd
	idivl	%edi
	movb	%al, 1(%r10)
	jmp	.L44
.L52:
	incl	%esi
	jmp	.L36
.L35:
	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	_Z20Smoothing_CPU_SerialP8PPMImageS0_, .-_Z20Smoothing_CPU_SerialP8PPMImageS0_
	.section	.rodata.str1.1
.LC17:
	.string	"Too many or no one arguments supplied.\n"
.LC19:
	.string	"Tempo: %0.3f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rsi, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	je	.L56
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
.L56:
	movq	8(%rbx), %rbx
	leaq	8(%rsp), %rdi
	movl	$0x00000000, 4(%rsp)
	call	cudaEventCreate@PLT
	leaq	16(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	%rbx, %rdi
	call	_ZL7readPPMPKc
	movq	%rbx, %rdi
	movq	%rax, %rbp
	call	_ZL7readPPMPKc
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rax, %rbx
	call	cudaEventRecord@PLT
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	_Z20Smoothing_CPU_SerialP8PPMImageS0_
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	16(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	leaq	4(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	4(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L57
	call	__stack_chk_fail@PLT
.L57:
	addq	$40, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2057:
	.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.cst8,"aM",@progbits,8
	.align 8
.LC11:
	.long	-1598689907
	.long	1051772663
	.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 <sys/time.h>
#include <math.h>
#define MASK_WIDTH 5

#define COMMENT "Histogram_GPU"
#define RGB_COMPONENT_COLOR 255

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

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

double rtclock()
{
  struct timezone Tzp;
  struct timeval Tp;
  int stat;
  stat = gettimeofday (&Tp, &Tzp);
  if (stat != 0) printf("Error return from gettimeofday: %d",stat);
  return(Tp.tv_sec + Tp.tv_usec*1.0e-6);
}


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

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

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

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

  c = getc(fp);
  while (c == '#') {
    while (getc(fp) != '\n')
      ;
    c = getc(fp);
  }

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

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

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

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

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

  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(PPMImage *img) {
  fprintf(stdout, "P6\n");
  fprintf(stdout, "# %s\n", COMMENT);
  fprintf(stdout, "%d %d\n", img->x, img->y);
  fprintf(stdout, "%d\n", RGB_COMPONENT_COLOR);
  fwrite(img->data, 3 * img->x, img->y, stdout);
  fclose(stdout);
}


void Smoothing_CPU_Serial(PPMImage *image, PPMImage *image_copy) {
  int i, j, y, x;
  int total_red, total_blue, total_green;

  for (i = 0; i < image->y; i++) {
    for (j = 0; j < image->x; j++) {
      total_red = total_blue = total_green = 0;
      for (y = i - ((MASK_WIDTH-1)/2); y <= (i + ((MASK_WIDTH-1)/2)); y++) {
        for (x = j - ((MASK_WIDTH-1)/2); x <= (j + ((MASK_WIDTH-1)/2)); x++) {
          if (x >= 0 && y >= 0 && y < image->y && x < image->x) {
            total_red += image_copy->data[(y * image->x) + x].red;
            total_blue += image_copy->data[(y * image->x) + x].blue;
            total_green += image_copy->data[(y * image->x) + x].green;
          }
        }
      }
      image->data[(i * image->x) + j].red = total_red / (MASK_WIDTH*MASK_WIDTH);
      image->data[(i * image->x) + j].blue = total_blue / (MASK_WIDTH*MASK_WIDTH);
      image->data[(i * image->x) + j].green = total_green / (MASK_WIDTH*MASK_WIDTH);
    }
  }
}

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

  if( argc != 2 ) {
    printf("Too many or no one arguments supplied.\n");
  }

  double t_start, t_end;
  char *filename = argv[1];
  float milliseconds = 0;

  hipEvent_t start, stop;
  hipEventCreate(&start);
  hipEventCreate(&stop);

  PPMImage *image = readPPM(filename);
  PPMImage *image_output = readPPM(filename);

  //t_start = rtclock();
  hipEventRecord(start);
  Smoothing_CPU_Serial(image_output, image);
  hipEventRecord(stop);
  hipEventSynchronize(stop);
  hipEventElapsedTime(&milliseconds, start, stop);
  //t_end = rtclock();

  //writePPM(image_output);

  printf("Tempo: %0.3f\n",milliseconds);
  // fprintf(stdout, "\n%0.6lfs\n", t_end - t_start);  
  free(image);
  free(image_output);
  return 0;
}

	.text
	.file	"serial.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7rtclockv
.LCPI0_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z7rtclockv
	.type	_Z7rtclockv,@function
_Z7rtclockv:                            # @_Z7rtclockv
	.cfi_startproc
# %bb.0:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movq	%rsp, %rdi
	leaq	16(%rsp), %rsi
	callq	gettimeofday
	testl	%eax, %eax
	je	.LBB0_2
# %bb.1:
	movl	$.L.str, %edi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	printf
.LBB0_2:
	cvtsi2sdq	(%rsp), %xmm1
	cvtsi2sdq	8(%rsp), %xmm0
	mulsd	.LCPI0_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z7rtclockv, .Lfunc_end0-_Z7rtclockv
	.cfi_endproc
                                        # -- End function
	.globl	_Z8writePPMP8PPMImage           # -- Begin function _Z8writePPMP8PPMImage
	.type	_Z8writePPMP8PPMImage,@function
_Z8writePPMP8PPMImage:                  # @_Z8writePPMP8PPMImage
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movq	stdout(%rip), %rcx
	movl	$.L.str.1, %edi
	movl	$3, %esi
	movl	$1, %edx
	callq	fwrite
	movq	stdout(%rip), %rdi
	movl	$.L.str.2, %esi
	movl	$.L.str.3, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stdout(%rip), %rdi
	movl	(%rbx), %edx
	movl	4(%rbx), %ecx
	movl	$.L.str.4, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stdout(%rip), %rdi
	movl	$.L.str.5, %esi
	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	stdout(%rip), %rcx
	callq	fwrite
	movq	stdout(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end1:
	.size	_Z8writePPMP8PPMImage, .Lfunc_end1-_Z8writePPMP8PPMImage
	.cfi_endproc
                                        # -- End function
	.globl	_Z20Smoothing_CPU_SerialP8PPMImageS0_ # -- Begin function _Z20Smoothing_CPU_SerialP8PPMImageS0_
	.type	_Z20Smoothing_CPU_SerialP8PPMImageS0_,@function
_Z20Smoothing_CPU_SerialP8PPMImageS0_:  # @_Z20Smoothing_CPU_SerialP8PPMImageS0_
	.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
	.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	%rdi, -72(%rsp)                 # 8-byte Spill
	movl	4(%rdi), %eax
	testl	%eax, %eax
	jle	.LBB2_14
# %bb.1:                                # %.preheader.lr.ph
	movq	-72(%rsp), %rcx                 # 8-byte Reload
	movl	(%rcx), %ecx
	movq	%rcx, -48(%rsp)                 # 8-byte Spill
	movslq	%ecx, %rdx
	leaq	(%rdx,%rdx), %rcx
	leaq	(%rcx,%rcx,2), %rcx
	movq	$-4, %rdi
	subq	%rcx, %rdi
	movq	%rdi, -64(%rsp)                 # 8-byte Spill
	leaq	(%rdx,%rdx,2), %rcx
	movq	%rcx, -40(%rsp)                 # 8-byte Spill
	movq	$-2, -56(%rsp)                  # 8-byte Folded Spill
	xorl	%ecx, %ecx
	movq	%rcx, -80(%rsp)                 # 8-byte Spill
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
                                        #       Child Loop BB2_5 Depth 3
                                        #         Child Loop BB2_6 Depth 4
	cmpl	$0, -48(%rsp)                   # 4-byte Folded Reload
	jle	.LBB2_13
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	movq	-80(%rsp), %rdi                 # 8-byte Reload
	leaq	2(%rdi), %rbx
	movq	-72(%rsp), %rcx                 # 8-byte Reload
	movq	8(%rcx), %rcx
	movq	%rcx, -24(%rsp)                 # 8-byte Spill
	imulq	%rdx, %rdi
	movq	%rdi, -32(%rsp)                 # 8-byte Spill
	movq	$-3, %r14
	movq	-64(%rsp), %rcx                 # 8-byte Reload
	xorl	%r11d, %r11d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_5 Depth 3
                                        #         Child Loop BB2_6 Depth 4
	movq	%r11, -16(%rsp)                 # 8-byte Spill
	addq	$2, %r11
	xorl	%r8d, %r8d
	movq	%rcx, -8(%rsp)                  # 8-byte Spill
	movq	-56(%rsp), %r10                 # 8-byte Reload
	xorl	%edi, %edi
	xorl	%r15d, %r15d
.LBB2_5:                                #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB2_6 Depth 4
	movq	%rcx, %r13
	movq	%r14, %r12
.LBB2_6:                                #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        #       Parent Loop BB2_5 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	incq	%r12
	cmpq	%rdx, %r12
	jge	.LBB2_10
# %bb.7:                                #   in Loop: Header=BB2_6 Depth=4
	cmpq	%rax, %r10
	jge	.LBB2_10
# %bb.8:                                #   in Loop: Header=BB2_6 Depth=4
	movl	%r12d, %ebp
	orl	%r10d, %ebp
	andl	$-2147483648, %ebp              # imm = 0x80000000
	jne	.LBB2_10
# %bb.9:                                #   in Loop: Header=BB2_6 Depth=4
	movq	8(%rsi), %rbp
	movzbl	-2(%rbp,%r13), %r9d
	addl	%r9d, %r15d
	movzbl	(%rbp,%r13), %r9d
	addl	%r9d, %edi
	movzbl	-1(%rbp,%r13), %r9d
	addl	%r9d, %r8d
.LBB2_10:                               #   in Loop: Header=BB2_6 Depth=4
	addq	$3, %r13
	cmpq	%r11, %r12
	jl	.LBB2_6
# %bb.11:                               #   in Loop: Header=BB2_5 Depth=3
	leaq	1(%r10), %r9
	addq	-40(%rsp), %rcx                 # 8-byte Folded Reload
	cmpq	%rbx, %r10
	movq	%r9, %r10
	jl	.LBB2_5
# %bb.12:                               #   in Loop: Header=BB2_4 Depth=2
	movslq	%r15d, %rcx
	imulq	$1374389535, %rcx, %rcx         # imm = 0x51EB851F
	movq	%rcx, %r9
	shrq	$63, %r9
	shrq	$35, %rcx
	addl	%r9d, %ecx
	movq	-32(%rsp), %r9                  # 8-byte Reload
	movq	-16(%rsp), %r11                 # 8-byte Reload
	addq	%r11, %r9
	leaq	(%r9,%r9,2), %r9
	movq	-24(%rsp), %r10                 # 8-byte Reload
	movb	%cl, (%r10,%r9)
	movslq	%edi, %rcx
	imulq	$1374389535, %rcx, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdi
	shrq	$63, %rdi
	shrq	$35, %rcx
	addl	%edi, %ecx
	movb	%cl, 2(%r10,%r9)
	movslq	%r8d, %rcx
	imulq	$1374389535, %rcx, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdi
	shrq	$63, %rdi
	shrq	$35, %rcx
	addl	%edi, %ecx
	movb	%cl, 1(%r10,%r9)
	incq	%r11
	incq	%r14
	movq	-8(%rsp), %rcx                  # 8-byte Reload
	addq	$3, %rcx
	cmpq	-48(%rsp), %r11                 # 8-byte Folded Reload
	jne	.LBB2_4
.LBB2_13:                               # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	movq	-80(%rsp), %rdi                 # 8-byte Reload
	incq	%rdi
	incq	-56(%rsp)                       # 8-byte Folded Spill
	movq	-40(%rsp), %rcx                 # 8-byte Reload
	addq	%rcx, -64(%rsp)                 # 8-byte Folded Spill
	movq	%rdi, %rcx
	movq	%rdi, -80(%rsp)                 # 8-byte Spill
	cmpq	%rax, %rdi
	jne	.LBB2_2
.LBB2_14:                               # %._crit_edge74
	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	_Z20Smoothing_CPU_SerialP8PPMImageS0_, .Lfunc_end2-_Z20Smoothing_CPU_SerialP8PPMImageS0_
	.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	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	cmpl	$2, %edi
	je	.LBB3_2
# %bb.1:
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB3_2:
	movq	8(%rbx), %r15
	leaq	12(%rsp), %rbx
	movl	$0, (%rbx)
	leaq	24(%rsp), %r12
	movq	%r12, %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventCreate
	movq	%r15, %rdi
	callq	_ZL7readPPMPKc
	movq	%rax, %r14
	movq	%r15, %rdi
	callq	_ZL7readPPMPKc
	movq	%rax, %r15
	movq	(%r12), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_Z20Smoothing_CPU_SerialP8PPMImageS0_
	movq	(%r13), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%r13), %rdi
	callq	hipEventSynchronize
	movq	(%r12), %rsi
	movq	(%r13), %rdx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$32, %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
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.type	_ZL7readPPMPKc,@function        # -- Begin function _ZL7readPPMPKc
_ZL7readPPMPKc:                         # @_ZL7readPPMPKc
	.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	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	$.L.str.8, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB4_14
# %bb.1:
	movq	%rax, %r14
	leaq	16(%rsp), %rdi
	movl	$16, %esi
	movq	%rax, %rdx
	callq	fgets
	testq	%rax, %rax
	je	.LBB4_15
# %bb.2:
	cmpb	$80, 16(%rsp)
	jne	.LBB4_16
# %bb.3:
	cmpb	$54, 17(%rsp)
	jne	.LBB4_16
# %bb.4:
	movl	$16, %edi
	callq	malloc
	testq	%rax, %rax
	je	.LBB4_17
# %bb.5:
	movq	%rax, %r15
.LBB4_6:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_7 Depth 2
	movq	%r14, %rdi
	callq	getc
	cmpl	$35, %eax
	jne	.LBB4_8
.LBB4_7:                                # %.preheader44
                                        #   Parent Loop BB4_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r14, %rdi
	callq	getc
	cmpl	$10, %eax
	jne	.LBB4_7
	jmp	.LBB4_6
.LBB4_8:                                # %._crit_edge
	movl	%eax, %edi
	movq	%r14, %rsi
	callq	ungetc
	movq	%r15, %rcx
	addq	$4, %rcx
	movl	$.L.str.12, %esi
	movq	%r14, %rdi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$2, %eax
	jne	.LBB4_20
# %bb.9:
	leaq	12(%rsp), %rdx
	movl	$.L.str.14, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$1, %eax
	jne	.LBB4_21
# %bb.10:
	cmpl	$255, 12(%rsp)
	jne	.LBB4_22
.LBB4_11:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	callq	fgetc
	cmpl	$10, %eax
	jne	.LBB4_11
# %bb.12:
	movslq	(%r15), %rax
	movslq	4(%r15), %r12
	leaq	(%rax,%rax,2), %r13
	movq	%r13, %rdi
	imulq	%r12, %rdi
	callq	malloc
	movq	%rax, 8(%r15)
	movq	%rax, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	movq	%r14, %rcx
	callq	fread
	movslq	4(%r15), %rcx
	cmpq	%rcx, %rax
	jne	.LBB4_23
# %bb.13:
	movq	%r14, %rdi
	callq	fclose
	movq	%r15, %rax
	addq	$32, %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
.LBB4_14:
	.cfi_def_cfa_offset 80
	movq	stderr(%rip), %rdi
	movl	$.L.str.9, %esi
	jmp	.LBB4_24
.LBB4_15:
	movq	%rbx, %rdi
	callq	perror
	jmp	.LBB4_19
.LBB4_16:
	movq	stderr(%rip), %rcx
	movl	$.L.str.10, %edi
	movl	$36, %esi
	jmp	.LBB4_18
.LBB4_17:
	movq	stderr(%rip), %rcx
	movl	$.L.str.11, %edi
	movl	$26, %esi
.LBB4_18:
	movl	$1, %edx
	callq	fwrite
	jmp	.LBB4_19
.LBB4_20:
	movq	stderr(%rip), %rdi
	movl	$.L.str.13, %esi
	jmp	.LBB4_24
.LBB4_21:
	movq	stderr(%rip), %rdi
	movl	$.L.str.15, %esi
	jmp	.LBB4_24
.LBB4_22:
	movq	stderr(%rip), %rdi
	movl	$.L.str.16, %esi
	jmp	.LBB4_24
.LBB4_23:
	movq	stderr(%rip), %rdi
	movl	$.L.str.17, %esi
.LBB4_24:
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	fprintf
.LBB4_19:
	movl	$1, %edi
	callq	exit
.Lfunc_end4:
	.size	_ZL7readPPMPKc, .Lfunc_end4-_ZL7readPPMPKc
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Error return from gettimeofday: %d"
	.size	.L.str, 35

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

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

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

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

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

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Tempo: %0.3f\n"
	.size	.L.str.7, 14

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

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

	.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	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Too many or no one arguments supplied."
	.size	.Lstr, 39

	.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_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
