#include<iostream>
#include<stdlib.h>
#include <cuda.h>
#include <math.h>

#define RADIUS 3

int checkResults(int startElem, int endElem, float* cudaRes, float* res)
{
    int nDiffs=0;
    const float smallVal = 0.0001f;
    for(int i=startElem; i<endElem; i++)
        if(fabs(cudaRes[i]-res[i])>smallVal)
            nDiffs++;
    return nDiffs;
}

void initializeWeights(float* weights, int rad)
{
    // for now hardcoded for RADIUS=3
    weights[0] = 0.50f;
    weights[1] = 0.75f;
    weights[2] = 1.25f;
    weights[3] = 2.00f;
    weights[4] = 1.25f;
    weights[5] = 0.75f;
    weights[6] = 0.50f;
}

void initializeArray(FILE* fp,float* arr, int nElements)
{
    for( int i=0; i<nElements; i++){
        	int r=fscanf(fp,"%f",&arr[i]);
		if(r == EOF){
		  rewind(fp);
		}
    }
}

void applyStencil1D_SEQ(int sIdx, int eIdx, const float *weights, float *in, float *out) {
  
  for (int i = sIdx; i < eIdx; i++) {   
    out[i] = 0;
    //loop over all elements in the stencil
    for (int j = -RADIUS; j <= RADIUS; j++) {
      out[i] += weights[j + RADIUS] * in[i + j]; 
    }
    out[i] = out[i] / (2 * RADIUS + 1);
  }
}

__global__ void applyStencil1D(int sIdx, int eIdx, const float *weights, float *in, float *out) {
    int i = sIdx + blockIdx.x*blockDim.x + threadIdx.x;
    if( i < eIdx ) {
        float result = 0.f;
        result += weights[0]*in[i-3];
        result += weights[1]*in[i-2];
        result += weights[2]*in[i-1];
        result += weights[3]*in[i];
        result += weights[4]*in[i+1];
        result += weights[5]*in[i+2];
        result += weights[6]*in[i+3];
        result /=7.f;
        out[i] = result;
    }
}

int main(int argc, char* argv[]) {
  if(argc!=2){
	printf("Usage %s N\n",argv[0]);
	return 1;
  }
  int N=atoi(argv[1]);
  FILE *fp = fopen("problem1.inp","r");
  int size = N * sizeof(float); 
  int wsize = (2 * RADIUS + 1) * sizeof(float); 
  //allocate resources
  float *weights = (float *)malloc(wsize);
  float *in      = (float *)malloc(size);
  float *out     = (float *)malloc(size); 
  float *cuda_out= (float *)malloc(size);
  float time = 0.f;
  initializeWeights(weights, RADIUS);
  initializeArray(fp,in, N);
  float *d_weights;  cudaMalloc(&d_weights, wsize);
  float *d_in;       cudaMalloc(&d_in, size);
  float *d_out;      cudaMalloc(&d_out, size);
  
  cudaMemcpy(d_weights,weights,wsize,cudaMemcpyHostToDevice);
  cudaMemcpy(d_in, in, size, cudaMemcpyHostToDevice);
  applyStencil1D<<<(N+511)/512, 512>>>(RADIUS, N-RADIUS, d_weights, d_in, d_out);
  cudaMemcpy(cuda_out, d_out, size, cudaMemcpyDeviceToHost);

  applyStencil1D_SEQ(RADIUS, N-RADIUS, weights, in, out);
  int nDiffs = checkResults(RADIUS, N-RADIUS, cuda_out, out);

  if(nDiffs)printf("Test Failed\n"); // This should never print
  printf("%f\n%f\n",cuda_out[N-RADIUS-1],time);

  
  //free resources 
  free(weights); free(in); free(out); free(cuda_out);
  cudaFree(d_weights);  cudaFree(d_in);  cudaFree(d_out);
  return 0;
}

	.file	"tmpxft_0035b8ad_00000000-6_problem1a.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3642:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3642:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z12checkResultsiiPfS_
	.type	_Z12checkResultsiiPfS_, @function
_Z12checkResultsiiPfS_:
.LFB3635:
	.cfi_startproc
	endbr64
	movslq	%edi, %rdi
	xorl	%eax, %eax
	movss	.LC0(%rip), %xmm1
.L3:
	cmpl	%edi, %esi
	jle	.L9
	movss	(%rdx,%rdi,4), %xmm0
	subss	(%rcx,%rdi,4), %xmm0
	andps	%xmm1, %xmm0
	comiss	.LC1(%rip), %xmm0
	jbe	.L4
	incl	%eax
.L4:
	incq	%rdi
	jmp	.L3
.L9:
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z12checkResultsiiPfS_, .-_Z12checkResultsiiPfS_
	.globl	_Z17initializeWeightsPfi
	.type	_Z17initializeWeightsPfi, @function
_Z17initializeWeightsPfi:
.LFB3636:
	.cfi_startproc
	endbr64
	movabsq	$4557642823955906560, %rax
	movl	$0x3f000000, 24(%rdi)
	movq	%rax, (%rdi)
	movabsq	$4611686019494838272, %rax
	movq	%rax, 8(%rdi)
	movabsq	$4557642823966392320, %rax
	movq	%rax, 16(%rdi)
	ret
	.cfi_endproc
.LFE3636:
	.size	_Z17initializeWeightsPfi, .-_Z17initializeWeightsPfi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"%f"
	.text
	.globl	_Z15initializeArrayP8_IO_FILEPfi
	.type	_Z15initializeArrayP8_IO_FILEPfi, @function
_Z15initializeArrayP8_IO_FILEPfi:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC3(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rsi, %rbx
.L12:
	cmpl	%r12d, %r13d
	jge	.L16
	xorl	%eax, %eax
	movq	%rbx, %rdx
	movq	%r14, %rsi
	movq	%rbp, %rdi
	call	__isoc23_fscanf@PLT
	incl	%eax
	jne	.L13
	movq	%rbp, %rdi
	call	rewind@PLT
.L13:
	incl	%r13d
	addq	$4, %rbx
	jmp	.L12
.L16:
	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
.LFE3637:
	.size	_Z15initializeArrayP8_IO_FILEPfi, .-_Z15initializeArrayP8_IO_FILEPfi
	.globl	_Z18applyStencil1D_SEQiiPKfPfS1_
	.type	_Z18applyStencil1D_SEQiiPKfPfS1_, @function
_Z18applyStencil1D_SEQiiPKfPfS1_:
.LFB3638:
	.cfi_startproc
	endbr64
	movss	.LC5(%rip), %xmm1
	movslq	%edi, %rdi
.L18:
	cmpl	%edi, %esi
	jle	.L22
	movl	$0x00000000, (%r8,%rdi,4)
	leaq	(%rcx,%rdi,4), %r9
	xorl	%eax, %eax
.L19:
	movss	(%rdx,%rax), %xmm0
	mulss	-12(%r9,%rax), %xmm0
	addq	$4, %rax
	addss	(%r8,%rdi,4), %xmm0
	movss	%xmm0, (%r8,%rdi,4)
	cmpq	$28, %rax
	jne	.L19
	divss	%xmm1, %xmm0
	movss	%xmm0, (%r8,%rdi,4)
	incq	%rdi
	jmp	.L18
.L22:
	ret
	.cfi_endproc
.LFE3638:
	.size	_Z18applyStencil1D_SEQiiPKfPfS1_, .-_Z18applyStencil1D_SEQiiPKfPfS1_
	.globl	_Z42__device_stub__Z14applyStencil1DiiPKfPfS1_iiPKfPfS1_
	.type	_Z42__device_stub__Z14applyStencil1DiiPKfPfS1_iiPKfPfS1_, @function
_Z42__device_stub__Z14applyStencil1DiiPKfPfS1_iiPKfPfS1_:
.LFB3664:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	48(%rsp), %rdi
	movl	%esi, 24(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 16(%rsp)
	leaq	32(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z14applyStencil1DiiPKfPfS1_(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L23:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3664:
	.size	_Z42__device_stub__Z14applyStencil1DiiPKfPfS1_iiPKfPfS1_, .-_Z42__device_stub__Z14applyStencil1DiiPKfPfS1_iiPKfPfS1_
	.globl	_Z14applyStencil1DiiPKfPfS1_
	.type	_Z14applyStencil1DiiPKfPfS1_, @function
_Z14applyStencil1DiiPKfPfS1_:
.LFB3665:
	.cfi_startproc
	endbr64
	jmp	_Z42__device_stub__Z14applyStencil1DiiPKfPfS1_iiPKfPfS1_
	.cfi_endproc
.LFE3665:
	.size	_Z14applyStencil1DiiPKfPfS1_, .-_Z14applyStencil1DiiPKfPfS1_
	.section	.rodata.str1.1
.LC6:
	.string	"Usage %s N\n"
.LC7:
	.string	"r"
.LC8:
	.string	"problem1.inp"
.LC9:
	.string	"Test Failed\n"
.LC10:
	.string	"%f\n%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3639:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	je	.L29
	movq	(%rsi), %rdx
	movl	$2, %edi
	leaq	.LC6(%rip), %rsi
	call	__printf_chk@PLT
	movl	$1, %eax
	jmp	.L28
.L29:
	movq	8(%rsi), %rdi
	call	atoi@PLT
	leaq	.LC7(%rip), %rsi
	leaq	.LC8(%rip), %rdi
	movl	%eax, %ebx
	call	fopen@PLT
	leal	0(,%rbx,4), %ebp
	movl	$28, %edi
	movslq	%ebp, %rbp
	movq	%rax, %r15
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movl	$3, %esi
	movq	%r14, %rdi
	movl	%ebx, %edx
	movq	%rax, %r12
	call	_Z17initializeWeightsPfi
	movq	%r13, %rsi
	movq	%r15, %rdi
	call	_Z15initializeArrayP8_IO_FILEPfi
	leaq	24(%rsp), %rdi
	movl	$28, %esi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movq	%rbp, %rsi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rsi
	movl	$28, %edx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$512, %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	leal	511(%rbx), %eax
	subl	$3, %ebx
	cltd
	idivl	%ecx
	movl	$8388609, %edx
	movl	$1, %ecx
	salq	$9, %rdx
	movl	%eax, 48(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	movq	40(%rsp), %r8
	movq	32(%rsp), %rcx
	movl	%ebx, %esi
	movl	$3, %edi
	movq	24(%rsp), %rdx
	call	_Z42__device_stub__Z14applyStencil1DiiPKfPfS1_iiPKfPfS1_
.L31:
	movq	40(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %r8
	movq	%r13, %rcx
	movq	%r14, %rdx
	movl	$3, %edi
	movl	%ebx, %esi
	call	_Z18applyStencil1D_SEQiiPKfPfS1_
	movq	8(%rsp), %rcx
	movq	%r12, %rdx
	movl	$3, %edi
	call	_Z12checkResultsiiPfS_
	testl	%eax, %eax
	je	.L32
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L32:
	xorps	%xmm1, %xmm1
	leaq	.LC10(%rip), %rsi
	movslq	%ebx, %rbx
	movb	$2, %al
	movl	$2, %edi
	cvtss2sd	-4(%r12,%rbx,4), %xmm0
	call	__printf_chk@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	xorl	%eax, %eax
.L28:
	movq	72(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L33
	call	__stack_chk_fail@PLT
.L33:
	addq	$88, %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
.LFE3639:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z14applyStencil1DiiPKfPfS1_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3667:
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z14applyStencil1DiiPKfPfS1_(%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
.LFE3667:
	.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
.LC0:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	953267991
	.align 4
.LC5:
	.long	1088421888
	.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<iostream>
#include<stdlib.h>
#include <hip/hip_runtime.h>
#include <math.h>

#define RADIUS 3

int checkResults(int startElem, int endElem, float* cudaRes, float* res)
{
    int nDiffs=0;
    const float smallVal = 0.0001f;
    for(int i=startElem; i<endElem; i++)
        if(fabs(cudaRes[i]-res[i])>smallVal)
            nDiffs++;
    return nDiffs;
}

void initializeWeights(float* weights, int rad)
{
    // for now hardcoded for RADIUS=3
    weights[0] = 0.50f;
    weights[1] = 0.75f;
    weights[2] = 1.25f;
    weights[3] = 2.00f;
    weights[4] = 1.25f;
    weights[5] = 0.75f;
    weights[6] = 0.50f;
}

void initializeArray(FILE* fp,float* arr, int nElements)
{
    for( int i=0; i<nElements; i++){
        	int r=fscanf(fp,"%f",&arr[i]);
		if(r == EOF){
		  rewind(fp);
		}
    }
}

void applyStencil1D_SEQ(int sIdx, int eIdx, const float *weights, float *in, float *out) {
  
  for (int i = sIdx; i < eIdx; i++) {   
    out[i] = 0;
    //loop over all elements in the stencil
    for (int j = -RADIUS; j <= RADIUS; j++) {
      out[i] += weights[j + RADIUS] * in[i + j]; 
    }
    out[i] = out[i] / (2 * RADIUS + 1);
  }
}

__global__ void applyStencil1D(int sIdx, int eIdx, const float *weights, float *in, float *out) {
    int i = sIdx + blockIdx.x*blockDim.x + threadIdx.x;
    if( i < eIdx ) {
        float result = 0.f;
        result += weights[0]*in[i-3];
        result += weights[1]*in[i-2];
        result += weights[2]*in[i-1];
        result += weights[3]*in[i];
        result += weights[4]*in[i+1];
        result += weights[5]*in[i+2];
        result += weights[6]*in[i+3];
        result /=7.f;
        out[i] = result;
    }
}

int main(int argc, char* argv[]) {
  if(argc!=2){
	printf("Usage %s N\n",argv[0]);
	return 1;
  }
  int N=atoi(argv[1]);
  FILE *fp = fopen("problem1.inp","r");
  int size = N * sizeof(float); 
  int wsize = (2 * RADIUS + 1) * sizeof(float); 
  //allocate resources
  float *weights = (float *)malloc(wsize);
  float *in      = (float *)malloc(size);
  float *out     = (float *)malloc(size); 
  float *cuda_out= (float *)malloc(size);
  float time = 0.f;
  initializeWeights(weights, RADIUS);
  initializeArray(fp,in, N);
  float *d_weights;  hipMalloc(&d_weights, wsize);
  float *d_in;       hipMalloc(&d_in, size);
  float *d_out;      hipMalloc(&d_out, size);
  
  hipMemcpy(d_weights,weights,wsize,hipMemcpyHostToDevice);
  hipMemcpy(d_in, in, size, hipMemcpyHostToDevice);
  applyStencil1D<<<(N+511)/512, 512>>>(RADIUS, N-RADIUS, d_weights, d_in, d_out);
  hipMemcpy(cuda_out, d_out, size, hipMemcpyDeviceToHost);

  applyStencil1D_SEQ(RADIUS, N-RADIUS, weights, in, out);
  int nDiffs = checkResults(RADIUS, N-RADIUS, cuda_out, out);

  if(nDiffs)printf("Test Failed\n"); // This should never print
  printf("%f\n%f\n",cuda_out[N-RADIUS-1],time);

  
  //free resources 
  free(weights); free(in); free(out); free(cuda_out);
  hipFree(d_weights);  hipFree(d_in);  hipFree(d_out);
  return 0;
}

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

                                        # End of file scope inline assembly
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z12checkResultsiiPfS_
.LCPI0_0:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI0_1:
	.long	0x38d1b717                      # float 9.99999974E-5
	.text
	.globl	_Z12checkResultsiiPfS_
	.type	_Z12checkResultsiiPfS_,@function
_Z12checkResultsiiPfS_:                 # @_Z12checkResultsiiPfS_
	.cfi_startproc
# %bb.0:
	xorl	%eax, %eax
	cmpl	%esi, %edi
	jge	.LBB0_3
# %bb.1:                                # %.lr.ph.preheader
	movslq	%edi, %rdi
	movslq	%esi, %rsi
	xorl	%eax, %eax
	movaps	.LCPI0_0(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movss	.LCPI0_1(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdx,%rdi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	(%rcx,%rdi,4), %xmm2
	andps	%xmm0, %xmm2
	xorl	%r8d, %r8d
	ucomiss	%xmm1, %xmm2
	seta	%r8b
	addl	%r8d, %eax
	incq	%rdi
	cmpq	%rdi, %rsi
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	retq
.Lfunc_end0:
	.size	_Z12checkResultsiiPfS_, .Lfunc_end0-_Z12checkResultsiiPfS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z17initializeWeightsPfi
.LCPI1_0:
	.long	0x3f000000                      # float 0.5
	.long	0x3f400000                      # float 0.75
	.long	0x3fa00000                      # float 1.25
	.long	0x40000000                      # float 2
	.text
	.globl	_Z17initializeWeightsPfi
	.type	_Z17initializeWeightsPfi,@function
_Z17initializeWeightsPfi:               # @_Z17initializeWeightsPfi
	.cfi_startproc
# %bb.0:
	movaps	.LCPI1_0(%rip), %xmm0           # xmm0 = [5.0E-1,7.5E-1,1.25E+0,2.0E+0]
	movups	%xmm0, (%rdi)
	movabsq	$4557642823966392320, %rax      # imm = 0x3F4000003FA00000
	movq	%rax, 16(%rdi)
	movl	$1056964608, 24(%rdi)           # imm = 0x3F000000
	retq
.Lfunc_end1:
	.size	_Z17initializeWeightsPfi, .Lfunc_end1-_Z17initializeWeightsPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z15initializeArrayP8_IO_FILEPfi # -- Begin function _Z15initializeArrayP8_IO_FILEPfi
	.type	_Z15initializeArrayP8_IO_FILEPfi,@function
_Z15initializeArrayP8_IO_FILEPfi:       # @_Z15initializeArrayP8_IO_FILEPfi
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB2_6
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	%edx, %r15d
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str, %esi
	movq	%r14, %rdi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$-1, %eax
	jne	.LBB2_4
# %bb.3:                                #   in Loop: Header=BB2_2 Depth=1
	movq	%r14, %rdi
	callq	rewind
.LBB2_4:                                #   in Loop: Header=BB2_2 Depth=1
	addq	$4, %rbx
	decq	%r15
	jne	.LBB2_2
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB2_6:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z15initializeArrayP8_IO_FILEPfi, .Lfunc_end2-_Z15initializeArrayP8_IO_FILEPfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z18applyStencil1D_SEQiiPKfPfS1_
.LCPI3_0:
	.long	0x40e00000                      # float 7
	.text
	.globl	_Z18applyStencil1D_SEQiiPKfPfS1_
	.type	_Z18applyStencil1D_SEQiiPKfPfS1_,@function
_Z18applyStencil1D_SEQiiPKfPfS1_:       # @_Z18applyStencil1D_SEQiiPKfPfS1_
	.cfi_startproc
# %bb.0:
	cmpl	%esi, %edi
	jge	.LBB3_5
# %bb.1:                                # %.lr.ph
	movslq	%edi, %rax
	movslq	%esi, %rsi
	leaq	(%rcx,%rax,4), %rcx
	addq	$-12, %rcx
	movss	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB3_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
	movl	$0, (%r8,%rax,4)
	xorps	%xmm1, %xmm1
	xorl	%edi, %edi
.LBB3_3:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rdx,%rdi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	mulss	(%rcx,%rdi,4), %xmm2
	addss	%xmm2, %xmm1
	movss	%xmm1, (%r8,%rax,4)
	incq	%rdi
	cmpq	$7, %rdi
	jne	.LBB3_3
# %bb.4:                                #   in Loop: Header=BB3_2 Depth=1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%r8,%rax,4)
	incq	%rax
	addq	$4, %rcx
	cmpq	%rsi, %rax
	jne	.LBB3_2
.LBB3_5:                                # %._crit_edge
	retq
.Lfunc_end3:
	.size	_Z18applyStencil1D_SEQiiPKfPfS1_, .Lfunc_end3-_Z18applyStencil1D_SEQiiPKfPfS1_
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__applyStencil1DiiPKfPfS1_ # -- Begin function _Z29__device_stub__applyStencil1DiiPKfPfS1_
	.type	_Z29__device_stub__applyStencil1DiiPKfPfS1_,@function
_Z29__device_stub__applyStencil1DiiPKfPfS1_: # @_Z29__device_stub__applyStencil1DiiPKfPfS1_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	4(%rsp), %rax
	movl	%edi, (%rax)
	movq	%rsp, %rdi
	movl	%esi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z14applyStencil1DiiPKfPfS1_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z29__device_stub__applyStencil1DiiPKfPfS1_, .Lfunc_end4-_Z29__device_stub__applyStencil1DiiPKfPfS1_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI5_0:
	.long	0x3f000000                      # float 0.5
	.long	0x3f400000                      # float 0.75
	.long	0x3fa00000                      # float 1.25
	.long	0x40000000                      # float 2
.LCPI5_2:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI5_1:
	.long	0x40e00000                      # float 7
.LCPI5_3:
	.long	0x38d1b717                      # float 9.99999974E-5
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$2, %edi
	jne	.LBB5_1
# %bb.2:
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r15d
	movl	$.L.str.2, %edi
	movl	$.L.str.3, %esi
	callq	fopen
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	leal	(,%r15,4), %ebx
	movl	$28, %edi
	callq	malloc
	movq	%rax, %r14
	movslq	%ebx, %rbp
	movq	%rbp, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%rbp, %rdi
	callq	malloc
	movq	%rax, %r12
	movq	%rbp, %rdi
	callq	malloc
	movq	%rax, %r13
	movaps	.LCPI5_0(%rip), %xmm0           # xmm0 = [5.0E-1,7.5E-1,1.25E+0,2.0E+0]
	movups	%xmm0, (%r14)
	movabsq	$4557642823966392320, %rax      # imm = 0x3F4000003FA00000
	movq	%rax, 16(%r14)
	movl	$1056964608, 24(%r14)           # imm = 0x3F000000
	movq	8(%rsp), %rdi                   # 8-byte Reload
	movq	%rbx, %rsi
	movl	%r15d, %edx
	callq	_Z15initializeArrayP8_IO_FILEPfi
	leaq	32(%rsp), %rdi
	movl	$28, %esi
	callq	hipMalloc
	leaq	24(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	leaq	32(%rsp), %rax
	movq	(%rax), %rdi
	movl	$28, %edx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	24(%rsp), %rax
	movq	(%rax), %rdi
	movq	%rbx, 8(%rsp)                   # 8-byte Spill
	movq	%rbx, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leal	511(%r15), %eax
	leal	1022(%r15), %edi
	testl	%eax, %eax
	cmovnsl	%eax, %edi
	sarl	$9, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$512, %rdx                      # imm = 0x200
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	leal	-3(%r15), %ebx
	testl	%eax, %eax
	jne	.LBB5_4
# %bb.3:
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rcx
	movq	16(%rsp), %r8
	movl	$3, %edi
	movl	%ebx, %esi
	callq	_Z29__device_stub__applyStencil1DiiPKfPfS1_
.LBB5_4:                                # %._crit_edge
	movq	16(%rsp), %rsi
	movq	%r13, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$7, %r15d
	movq	8(%rsp), %rbp                   # 8-byte Reload
	jl	.LBB5_13
# %bb.5:                                # %.lr.ph.i
	movl	%ebx, %eax
	movl	$3, %ecx
	movss	.LCPI5_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movq	%rbp, %rdx
.LBB5_6:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_7 Depth 2
	xorps	%xmm1, %xmm1
	xorl	%esi, %esi
.LBB5_7:                                #   Parent Loop BB5_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r14,%rsi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	mulss	(%rdx,%rsi,4), %xmm2
	addss	%xmm2, %xmm1
	incq	%rsi
	cmpq	$7, %rsi
	jne	.LBB5_7
# %bb.8:                                #   in Loop: Header=BB5_6 Depth=1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%r12,%rcx,4)
	incq	%rcx
	addq	$4, %rdx
	cmpq	%rax, %rcx
	jne	.LBB5_6
# %bb.9:                                # %.lr.ph.i43.preheader
	xorl	%ecx, %ecx
	movl	$3, %edx
	movaps	.LCPI5_2(%rip), %xmm0           # xmm0 = [NaN,NaN,NaN,NaN]
	movss	.LCPI5_3(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
.LBB5_10:                               # %.lr.ph.i43
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r13,%rdx,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	(%r12,%rdx,4), %xmm2
	andps	%xmm0, %xmm2
	xorl	%esi, %esi
	ucomiss	%xmm1, %xmm2
	seta	%sil
	addl	%esi, %ecx
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB5_10
# %bb.11:                               # %_Z12checkResultsiiPfS_.exit
	testl	%ecx, %ecx
	je	.LBB5_13
# %bb.12:
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB5_13:                               # %_Z12checkResultsiiPfS_.exit.thread
	movslq	%r15d, %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	-16(%r13,%rax,4), %xmm0
	movl	$.L.str.5, %edi
	xorps	%xmm1, %xmm1
	movb	$2, %al
	callq	printf
	movq	%r14, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	jmp	.LBB5_14
.LBB5_1:
	movq	(%rsi), %rsi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %eax
.LBB5_14:
	addq	$40, %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_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z14applyStencil1DiiPKfPfS1_, %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_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%f"
	.size	.L.str, 3

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Usage %s N\n"
	.size	.L.str.1, 12

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"problem1.inp"
	.size	.L.str.2, 13

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

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z14applyStencil1DiiPKfPfS1_"
	.size	.L__unnamed_1, 29

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Test Failed"
	.size	.Lstr, 12

	.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 _Z29__device_stub__applyStencil1DiiPKfPfS1_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z14applyStencil1DiiPKfPfS1_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z14applyStencil1DiiPKfPfS1_ ; -- Begin function _Z14applyStencil1DiiPKfPfS1_
	.globl	_Z14applyStencil1DiiPKfPfS1_
	.p2align	8
	.type	_Z14applyStencil1DiiPKfPfS1_,@function
_Z14applyStencil1DiiPKfPfS1_:           ; @_Z14applyStencil1DiiPKfPfS1_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x2c
	s_load_b64 s[2:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s15, s15, s4
	v_add3_u32 v0, s15, s2, v0
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s3, v0
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x8
	s_load_b64 s[8:9], s[0:1], 0x18
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[7:8], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v4, vcc_lo, s6, v7
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v8, vcc_lo
	s_clause 0x1
	global_load_b128 v[0:3], v[4:5], off offset:-12
	global_load_b96 v[4:6], v[4:5], off offset:4
	s_clause 0x1
	s_load_b128 s[0:3], s[4:5], 0x0
	s_load_b64 s[6:7], s[4:5], 0x10
	s_waitcnt vmcnt(1) lgkmcnt(0)
	v_fma_f32 v0, s0, v0, 0
	s_load_b32 s0, s[4:5], 0x18
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v0, s1, v1
	v_fmac_f32_e32 v0, s2, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v0, s3, v3
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v0, s6, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v0, s7, v5
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v0, s0, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v1, null, 0x40e00000, 0x40e00000, v0
	v_div_scale_f32 v4, vcc_lo, v0, 0x40e00000, v0
	v_rcp_f32_e32 v2, v1
	s_waitcnt_depctr 0xfff
	v_fma_f32 v3, -v1, v2, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v2, v3, v2
	v_mul_f32_e32 v3, v4, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v5, -v1, v3, v4
	v_fmac_f32_e32 v3, v5, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v1, -v1, v3, v4
	v_div_fmas_f32 v1, v1, v2, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_div_fixup_f32 v2, v1, 0x40e00000, v0
	v_add_co_u32 v0, vcc_lo, s8, v7
	v_add_co_ci_u32_e32 v1, vcc_lo, s9, v8, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14applyStencil1DiiPKfPfS1_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 9
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z14applyStencil1DiiPKfPfS1_, .Lfunc_end0-_Z14applyStencil1DiiPKfPfS1_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 368
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14applyStencil1DiiPKfPfS1_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14applyStencil1DiiPKfPfS1_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
