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

#define BLOCK_W 16 
#define BLOCK_H 16

//--------------------------------------------------------------------------------------------------------------------
__global__ void median_filter(const unsigned char *in, unsigned char *out, const unsigned int w, const unsigned int h) {

    __shared__ unsigned short surround[BLOCK_W*BLOCK_H][9];

    const int x = blockDim.x * blockIdx.x + threadIdx.x;
    const int y = blockDim.y * blockIdx.y + threadIdx.y;
    const int tid = threadIdx.y * blockDim.x + threadIdx.x;   

    if( (x >= (w - 1)) || (y >= h - 1) || (x == 0) || (y == 0)) return;

    // Fill shared memory
    int iter = 0;
    for (int r = x - 1; r <= x + 1; r++) 
    {
        for (int c = y - 1; c <= y + 1; c++) 
        {
            surround[tid][iter] = in[c * w + r];
            iter++;
        }
    }

    // Sort shared memory to find the median using Bubble Short
    for (int i = 0; i < 5; i++) 
    {

        // Find the position of the minimum element
        int minval = i;
        for (int l = i+1; l<9; l++) if (surround[tid][l] < surround[tid][minval]) minval = l;

        // Put found minimum element in its place
        unsigned short temp = surround[tid][i];
        surround[tid][i] = surround[tid][minval];
        surround[tid][minval]=temp;
    }

    // Pick the middle one
    out[(y*w)+x] = surround[tid][4]; 

    __syncthreads();

}
//--------------------------------------------------------------------------------------------------------------------
const unsigned int imgw = 100;
const unsigned int imgh = 100;
void loadImg(unsigned char **data, unsigned int *w, unsigned int *h, unsigned int *ch){
  *w = imgw;
  *h = imgh;
  *ch = 1;
  *data = (unsigned char *)malloc(imgw*imgh*sizeof(unsigned char));
  for (int i = 0; i < imgw*imgh; i++) (*data)[i] = i%9;
  }
//--------------------------------------------------------------------------------------------------------------------
int main()
{
    unsigned char *data = NULL, *d_idata = NULL, *d_odata = NULL;
    unsigned int w, h, channels;

    unsigned int numElements;
    size_t datasize;

    loadImg(&data, &w, &h, &channels);
    printf("Loaded input file with   w:%d   h:%d   channels:%d \n",w, h, channels);
    
    printf("input:\n");
    for (int i = 0; i < BLOCK_W; i++)
    {
      for (int j = 0; j < BLOCK_H; j++) printf("%d ", data[i*w+j]);
      printf("\n");
    }

    numElements = w*h*channels;
    datasize = numElements * sizeof(unsigned char);
    
    cudaMalloc(&d_idata, datasize);
    cudaMalloc(&d_odata, datasize);
    printf("Allocate Devicememory for data\n");

    cudaMemcpy(d_idata, data, datasize, cudaMemcpyHostToDevice);
    printf("Copy input data from the host memory to the CUDA device\n");

    dim3 threadsPerBlock(BLOCK_W, BLOCK_H);
    dim3 blocksPerGrid((w+threadsPerBlock.x-1)/threadsPerBlock.x, (h+threadsPerBlock.y-1)/threadsPerBlock.y);
    printf("CUDA kernel launch with [%d %d] blocks of [%d %d] threads\n", blocksPerGrid.x, blocksPerGrid.y,  
                                                                          threadsPerBlock.x, threadsPerBlock.y);
   
    median_filter<<<blocksPerGrid, threadsPerBlock>>>(d_idata, d_odata, w, h);

    cudaMemcpy(data, d_odata, datasize, cudaMemcpyDeviceToHost);
    printf("Copy output data from the CUDA device to the host memory\n");

    printf("output:\n");
    for (int i = 0; i < BLOCK_W; i++)
    {
      for (int j = 0; j < BLOCK_H; j++) printf("%d ", data[i*w+j]);
      printf("\n");
    }

    free(data);
    cudaFree(d_idata);
    cudaFree(d_odata);
    printf("Free device and host memory\n");

}

	.file	"tmpxft_002ad428_00000000-6_task2_2.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3770:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3770:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z7loadImgPPhPjS1_S1_
	.type	_Z7loadImgPPhPjS1_S1_, @function
_Z7loadImgPPhPjS1_S1_:
.LFB3766:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movl	$10000, %edi
	movl	$100, (%rsi)
	movl	$100, (%rdx)
	movl	$1, (%rcx)
	call	malloc@PLT
	xorl	%ecx, %ecx
	movl	$9, %esi
	movq	%rax, (%rbx)
.L3:
	movl	%ecx, %eax
	movq	(%rbx), %rdi
	cltd
	idivl	%esi
	movb	%dl, (%rdi,%rcx)
	incq	%rcx
	cmpq	$10000, %rcx
	jne	.L3
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3766:
	.size	_Z7loadImgPPhPjS1_S1_, .-_Z7loadImgPPhPjS1_S1_
	.globl	_Z38__device_stub__Z13median_filterPKhPhjjPKhPhjj
	.type	_Z38__device_stub__Z13median_filterPKhPhjjPKhPhjj, @function
_Z38__device_stub__Z13median_filterPKhPhjjPKhPhjj:
.LFB3792:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L7
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z13median_filterPKhPhjj(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L7:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3792:
	.size	_Z38__device_stub__Z13median_filterPKhPhjjPKhPhjj, .-_Z38__device_stub__Z13median_filterPKhPhjjPKhPhjj
	.globl	_Z13median_filterPKhPhjj
	.type	_Z13median_filterPKhPhjj, @function
_Z13median_filterPKhPhjj:
.LFB3793:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z13median_filterPKhPhjjPKhPhjj
	.cfi_endproc
.LFE3793:
	.size	_Z13median_filterPKhPhjj, .-_Z13median_filterPKhPhjj
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Loaded input file with   w:%d   h:%d   channels:%d \n"
.LC1:
	.string	"input:\n"
.LC2:
	.string	"%d "
.LC3:
	.string	"\n"
.LC4:
	.string	"Allocate Devicememory for data\n"
.LC5:
	.string	"Copy input data from the host memory to the CUDA device\n"
.LC6:
	.string	"CUDA kernel launch with [%d %d] blocks of [%d %d] threads\n"
.LC7:
	.string	"Copy output data from the CUDA device to the host memory\n"
.LC8:
	.string	"output:\n"
.LC9:
	.string	"Free device and host memory\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3767:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	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
	movl	$16, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rcx
	xorl	%eax, %eax
	leaq	32(%rsp), %rdx
	leaq	28(%rsp), %rsi
	leaq	40(%rsp), %rdi
	movq	%rax, 40(%rsp)
	movq	%rax, 48(%rsp)
	movq	%rax, 56(%rsp)
	call	_Z7loadImgPPhPjS1_S1_
	movl	36(%rsp), %r14d
	movl	28(%rsp), %ebx
	xorl	%eax, %eax
	movl	32(%rsp), %r13d
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movl	%r14d, %r8d
	movl	%ebx, %edx
	movl	%r13d, %ecx
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L13:
	xorl	%ecx, %ecx
.L14:
	movq	40(%rsp), %r12
	leal	(%rcx,%r15), %eax
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movl	%ecx, 8(%rsp)
	movzbl	(%r12,%rax), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	8(%rsp), %ecx
	incl	%ecx
	cmpl	$16, %ecx
	jne	.L14
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	addl	%ebx, %r15d
	call	__printf_chk@PLT
	decl	%ebp
	jne	.L13
	imull	%r13d, %r14d
	leaq	48(%rsp), %rdi
	leal	15(%rbx), %r15d
	shrl	$4, %r15d
	movl	%r14d, %eax
	leal	15(%r13), %r14d
	imull	%ebx, %eax
	shrl	$4, %r14d
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	56(%rsp), %rdi
	call	cudaMalloc@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rdx
	movq	48(%rsp), %rdi
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$16, %r9d
	movl	%r14d, %ecx
	xorl	%eax, %eax
	movl	$16, %r8d
	movl	%r15d, %edx
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movl	$1, 84(%rsp)
	call	__printf_chk@PLT
	movl	%r15d, 76(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r14d, 80(%rsp)
	movl	84(%rsp), %esi
	movl	$1, %ecx
	movabsq	$68719476752, %rdx
	movq	76(%rsp), %rdi
	movq	%rdx, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L16
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdi
	movl	%r13d, %ecx
	movl	%ebx, %edx
	call	_Z38__device_stub__Z13median_filterPKhPhjjPKhPhjj
.L16:
	movq	8(%rsp), %rdx
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	movl	$16, %r13d
	leaq	.LC3(%rip), %r14
	call	cudaMemcpy@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L17:
	xorl	%r15d, %r15d
.L18:
	leal	(%r15,%rbp), %eax
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	incl	%r15d
	movzbl	(%r12,%rax), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	$16, %r15d
	jne	.L18
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	addl	%ebx, %ebp
	call	__printf_chk@PLT
	decl	%r13d
	jne	.L17
	movq	%r12, %rdi
	call	free@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC9(%rip), %rsi
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$104, %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
.LFE3767:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z13median_filterPKhPhjj"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3795:
	.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	.LC10(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z13median_filterPKhPhjj(%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
.LFE3795:
	.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 <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#define BLOCK_W 16 
#define BLOCK_H 16

//--------------------------------------------------------------------------------------------------------------------
__global__ void median_filter(const unsigned char *in, unsigned char *out, const unsigned int w, const unsigned int h) {

    __shared__ unsigned short surround[BLOCK_W*BLOCK_H][9];

    const int x = blockDim.x * blockIdx.x + threadIdx.x;
    const int y = blockDim.y * blockIdx.y + threadIdx.y;
    const int tid = threadIdx.y * blockDim.x + threadIdx.x;   

    if( (x >= (w - 1)) || (y >= h - 1) || (x == 0) || (y == 0)) return;

    // Fill shared memory
    int iter = 0;
    for (int r = x - 1; r <= x + 1; r++) 
    {
        for (int c = y - 1; c <= y + 1; c++) 
        {
            surround[tid][iter] = in[c * w + r];
            iter++;
        }
    }

    // Sort shared memory to find the median using Bubble Short
    for (int i = 0; i < 5; i++) 
    {

        // Find the position of the minimum element
        int minval = i;
        for (int l = i+1; l<9; l++) if (surround[tid][l] < surround[tid][minval]) minval = l;

        // Put found minimum element in its place
        unsigned short temp = surround[tid][i];
        surround[tid][i] = surround[tid][minval];
        surround[tid][minval]=temp;
    }

    // Pick the middle one
    out[(y*w)+x] = surround[tid][4]; 

    __syncthreads();

}
//--------------------------------------------------------------------------------------------------------------------
const unsigned int imgw = 100;
const unsigned int imgh = 100;
void loadImg(unsigned char **data, unsigned int *w, unsigned int *h, unsigned int *ch){
  *w = imgw;
  *h = imgh;
  *ch = 1;
  *data = (unsigned char *)malloc(imgw*imgh*sizeof(unsigned char));
  for (int i = 0; i < imgw*imgh; i++) (*data)[i] = i%9;
  }
//--------------------------------------------------------------------------------------------------------------------
int main()
{
    unsigned char *data = NULL, *d_idata = NULL, *d_odata = NULL;
    unsigned int w, h, channels;

    unsigned int numElements;
    size_t datasize;

    loadImg(&data, &w, &h, &channels);
    printf("Loaded input file with   w:%d   h:%d   channels:%d \n",w, h, channels);
    
    printf("input:\n");
    for (int i = 0; i < BLOCK_W; i++)
    {
      for (int j = 0; j < BLOCK_H; j++) printf("%d ", data[i*w+j]);
      printf("\n");
    }

    numElements = w*h*channels;
    datasize = numElements * sizeof(unsigned char);
    
    hipMalloc(&d_idata, datasize);
    hipMalloc(&d_odata, datasize);
    printf("Allocate Devicememory for data\n");

    hipMemcpy(d_idata, data, datasize, hipMemcpyHostToDevice);
    printf("Copy input data from the host memory to the CUDA device\n");

    dim3 threadsPerBlock(BLOCK_W, BLOCK_H);
    dim3 blocksPerGrid((w+threadsPerBlock.x-1)/threadsPerBlock.x, (h+threadsPerBlock.y-1)/threadsPerBlock.y);
    printf("CUDA kernel launch with [%d %d] blocks of [%d %d] threads\n", blocksPerGrid.x, blocksPerGrid.y,  
                                                                          threadsPerBlock.x, threadsPerBlock.y);
   
    median_filter<<<blocksPerGrid, threadsPerBlock>>>(d_idata, d_odata, w, h);

    hipMemcpy(data, d_odata, datasize, hipMemcpyDeviceToHost);
    printf("Copy output data from the CUDA device to the host memory\n");

    printf("output:\n");
    for (int i = 0; i < BLOCK_W; i++)
    {
      for (int j = 0; j < BLOCK_H; j++) printf("%d ", data[i*w+j]);
      printf("\n");
    }

    free(data);
    hipFree(d_idata);
    hipFree(d_odata);
    printf("Free device and host memory\n");

}

	.text
	.file	"task2_2.hip"
	.globl	_Z28__device_stub__median_filterPKhPhjj # -- Begin function _Z28__device_stub__median_filterPKhPhjj
	.type	_Z28__device_stub__median_filterPKhPhjj,@function
_Z28__device_stub__median_filterPKhPhjj: # @_Z28__device_stub__median_filterPKhPhjj
	.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	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z13median_filterPKhPhjj, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	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_end0:
	.size	_Z28__device_stub__median_filterPKhPhjj, .Lfunc_end0-_Z28__device_stub__median_filterPKhPhjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z7loadImgPPhPjS1_S1_           # -- Begin function _Z7loadImgPPhPjS1_S1_
	.type	_Z7loadImgPPhPjS1_S1_,@function
_Z7loadImgPPhPjS1_S1_:                  # @_Z7loadImgPPhPjS1_S1_
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movl	$100, %eax
	movl	%eax, (%rsi)
	movl	%eax, (%rdx)
	movl	$1, (%rcx)
	movl	$10000, %edi                    # imm = 0x2710
	callq	malloc
	movq	%rax, (%rbx)
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB1_1:                                # =>This Inner Loop Header: Depth=1
	movzwl	%ax, %edx
	imull	$58255, %edx, %edx              # imm = 0xE38F
	shrl	$19, %edx
	leal	(%rdx,%rdx,8), %edx
	movl	%eax, %esi
	subb	%dl, %sil
	movq	(%rbx), %rdx
	movb	%sil, (%rdx,%rcx)
	incq	%rcx
	incl	%eax
	cmpq	$10000, %rcx                    # imm = 0x2710
	jne	.LBB1_1
# %bb.2:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z7loadImgPPhPjS1_S1_, .Lfunc_end1-_Z7loadImgPPhPjS1_S1_
	.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	$24, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	xorl	%r14d, %r14d
	movq	%r14, 16(%rsp)
	movq	%r14, 8(%rsp)
	movl	$10000, %edi                    # imm = 0x2710
	callq	malloc
	movq	%rax, %rbx
.LBB2_1:                                # =>This Inner Loop Header: Depth=1
	movzwl	%r14w, %eax
	imull	$58255, %eax, %eax              # imm = 0xE38F
	shrl	$19, %eax
	leal	(%rax,%rax,8), %eax
	movl	%r14d, %ecx
	subl	%eax, %ecx
	movb	%cl, (%rbx,%r14)
	incq	%r14
	cmpq	$10000, %r14                    # imm = 0x2710
	jne	.LBB2_1
# %bb.2:                                # %_Z7loadImgPPhPjS1_S1_.exit
	movl	$.L.str, %edi
	movl	$100, %esi
	movl	$100, %edx
	movl	$1, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	movq	%rbx, %r14
	xorl	%r15d, %r15d
.LBB2_3:                                # %.preheader57
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	xorl	%r12d, %r12d
.LBB2_4:                                #   Parent Loop BB2_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	(%r14,%r12), %esi
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r12
	cmpq	$16, %r12
	jne	.LBB2_4
# %bb.5:                                #   in Loop: Header=BB2_3 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r15
	addq	$100, %r14
	cmpq	$16, %r15
	jne	.LBB2_3
# %bb.6:
	leaq	16(%rsp), %r14
	movl	$10000, %esi                    # imm = 0x2710
	movq	%r14, %rdi
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movl	$10000, %esi                    # imm = 0x2710
	callq	hipMalloc
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movq	(%r14), %rdi
	movl	$10000, %edx                    # imm = 0x2710
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.L.str.6, %edi
	movl	$7, %esi
	movl	$7, %edx
	movl	$16, %ecx
	movl	$16, %r8d
	xorl	%eax, %eax
	callq	printf
	movabsq	$30064771079, %rdi              # imm = 0x700000007
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_8
# %bb.7:
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rsi
	movl	$100, %edx
	movl	$100, %ecx
	callq	_Z28__device_stub__median_filterPKhPhjj
.LBB2_8:
	movq	8(%rsp), %rsi
	movl	$10000, %edx                    # imm = 0x2710
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movq	%rbx, %r14
	xorl	%r15d, %r15d
.LBB2_9:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_10 Depth 2
	xorl	%r12d, %r12d
.LBB2_10:                               #   Parent Loop BB2_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	(%r14,%r12), %esi
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r12
	cmpq	$16, %r12
	jne	.LBB2_10
# %bb.11:                               #   in Loop: Header=BB2_9 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r15
	addq	$100, %r14
	cmpq	$16, %r15
	jne	.LBB2_9
# %bb.12:
	movq	%rbx, %rdi
	callq	free
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	main, .Lfunc_end2-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	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13median_filterPKhPhjj, %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_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z13median_filterPKhPhjj,@object # @_Z13median_filterPKhPhjj
	.section	.rodata,"a",@progbits
	.globl	_Z13median_filterPKhPhjj
	.p2align	3, 0x0
_Z13median_filterPKhPhjj:
	.quad	_Z28__device_stub__median_filterPKhPhjj
	.size	_Z13median_filterPKhPhjj, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Loaded input file with   w:%d   h:%d   channels:%d \n"
	.size	.L.str, 53

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%d "
	.size	.L.str.2, 4

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"CUDA kernel launch with [%d %d] blocks of [%d %d] threads\n"
	.size	.L.str.6, 59

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13median_filterPKhPhjj"
	.size	.L__unnamed_1, 25

	.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	"input:"
	.size	.Lstr, 7

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Allocate Devicememory for data"
	.size	.Lstr.1, 31

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Copy input data from the host memory to the CUDA device"
	.size	.Lstr.2, 56

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Copy output data from the CUDA device to the host memory"
	.size	.Lstr.3, 57

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"output:"
	.size	.Lstr.4, 8

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"Free device and host memory"
	.size	.Lstr.5, 28

	.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 _Z28__device_stub__median_filterPKhPhjj
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z13median_filterPKhPhjj
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13median_filterPKhPhjj ; -- Begin function _Z13median_filterPKhPhjj
	.globl	_Z13median_filterPKhPhjj
	.p2align	8
	.type	_Z13median_filterPKhPhjj,@function
_Z13median_filterPKhPhjj:               ; @_Z13median_filterPKhPhjj
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b64 s[4:5], s[0:1], 0x10
	v_and_b32_e32 v4, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s6, s2, 0xffff
	s_add_i32 s3, s4, -1
	s_mul_i32 s14, s14, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v1, s14, v4
	v_cmp_gt_u32_e32 vcc_lo, s3, v1
	s_and_saveexec_b32 s3, vcc_lo
	s_cbranch_execz .LBB0_11
; %bb.1:
	v_bfe_u32 v0, v0, 10, 10
	s_lshr_b32 s2, s2, 16
	s_add_i32 s3, s5, -1
	v_cmp_ne_u32_e32 vcc_lo, 0, v1
	s_mov_b32 s5, 0
	v_mad_u64_u32 v[2:3], null, s15, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cmp_ne_u32_e64 s2, 0, v2
	v_cmp_gt_u32_e64 s3, s3, v2
	s_and_b32 s2, vcc_lo, s2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 exec_lo, exec_lo, s2
	s_cbranch_execz .LBB0_11
; %bb.2:
	s_load_b128 s[0:3], s[0:1], 0x0
	v_add_nc_u32_e32 v3, -1, v2
	v_mad_u32_u24 v0, v0, s6, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[6:7], null, s4, v3, v[4:5]
	v_mul_lo_u32 v0, v0, 18
	v_add_nc_u32_e32 v5, -1, v1
	v_add_nc_u32_e32 v3, -2, v2
	s_delay_alu instid0(VALU_DEP_4)
	v_add3_u32 v4, v6, s14, -1
	v_mov_b32_e32 v6, 0
.LBB0_3:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshl_add_u32 v7, v6, 1, v0
	v_dual_mov_b32 v8, v4 :: v_dual_mov_b32 v9, v3
	s_mov_b32 s6, 0
.LBB0_4:                                ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_waitcnt lgkmcnt(0)
	global_load_u8 v10, v8, s[0:1]
	v_add_nc_u32_e32 v9, 1, v9
	v_add_nc_u32_e32 v6, 1, v6
	v_add_nc_u32_e32 v8, s4, v8
	s_delay_alu instid0(VALU_DEP_3)
	v_cmp_gt_i32_e32 vcc_lo, v9, v2
	s_or_b32 s6, vcc_lo, s6
	s_waitcnt vmcnt(0)
	ds_store_b16 v7, v10
	v_add_nc_u32_e32 v7, 2, v7
	s_and_not1_b32 exec_lo, exec_lo, s6
	s_cbranch_execnz .LBB0_4
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s6
	v_add_nc_u32_e32 v7, 1, v5
	v_cmp_gt_i32_e32 vcc_lo, v5, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_dual_mov_b32 v5, v7 :: v_dual_add_nc_u32 v4, 1, v4
	s_or_b32 s5, vcc_lo, s5
	s_and_not1_b32 exec_lo, exec_lo, s5
	s_cbranch_execnz .LBB0_3
; %bb.6:                                ; %.preheader.preheader
	s_or_b32 exec_lo, exec_lo, s5
	v_add_nc_u32_e32 v3, 2, v0
	s_mov_b32 s0, 0
.LBB0_7:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_8 Depth 2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_dual_mov_b32 v4, s0 :: v_dual_mov_b32 v5, v3
	s_mov_b32 s1, s0
.LBB0_8:                                ; %.lr.ph
                                        ;   Parent Loop BB0_7 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_1)
	v_lshl_add_u32 v6, v4, 1, v0
	s_add_i32 s1, s1, 1
	ds_load_u16 v7, v5
	ds_load_u16 v6, v6
	v_add_nc_u32_e32 v5, 2, v5
	s_cmp_gt_u32 s1, 7
	s_waitcnt lgkmcnt(0)
	v_cmp_lt_u16_e32 vcc_lo, v7, v6
	v_cndmask_b32_e64 v4, v4, s1, vcc_lo
	s_cbranch_scc0 .LBB0_8
; %bb.9:                                ; %._crit_edge
                                        ;   in Loop: Header=BB0_7 Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_lshl_add_u32 v4, v4, 1, v0
	v_lshl_add_u32 v5, s0, 1, v0
	v_add_nc_u32_e32 v3, 2, v3
	s_add_i32 s0, s0, 1
	ds_load_u16 v6, v4
	ds_load_u16 v7, v5
	s_cmp_eq_u32 s0, 5
	s_waitcnt lgkmcnt(1)
	ds_store_b16 v5, v6
	s_waitcnt lgkmcnt(1)
	ds_store_b16 v4, v7
	s_cbranch_scc0 .LBB0_7
; %bb.10:
	ds_load_u16 v0, v0 offset:8
	v_mad_u64_u32 v[3:4], null, v2, s4, v[1:2]
	s_waitcnt lgkmcnt(0)
	global_store_b8 v3, v0, s[2:3]
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
.LBB0_11:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13median_filterPKhPhjj
		.amdhsa_group_segment_fixed_size 4608
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 11
		.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	_Z13median_filterPKhPhjj, .Lfunc_end0-_Z13median_filterPKhPhjj
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 540
; NumSgprs: 18
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 4608 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 4608
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13median_filterPKhPhjj
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13median_filterPKhPhjj.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
