#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <cuda.h>

#ifdef A
    #define DATASET 1
    #define SIZE 600
    #define DIMENSIONS 2
#else
    #define DATASET 2
    #define SIZE 210
    #define DIMENSIONS 7
#endif

__global__ void mean_shift(double *y, double *x, double *h, double *kernel, double *i_vectors, double *norm)
{
  //Thread scoped variables.
  int basic_index = blockIdx.x * (DIMENSIONS);
  int index = threadIdx.x * (DIMENSIONS);
  double e = 0.000001;
  double factor;

  //Initializing the norm.
  norm[blockIdx.x] = 1.0;

  //Main loop.
  while (norm[blockIdx.x] > e) {

    factor = 0.0;
    //Calculating factor.
    for (int i = 0; i < (DIMENSIONS); i++)
    {
        factor += (y[basic_index + i] - x[index + i])*(y[basic_index + i] - x[index + i]);
    }

    if (factor > *h*(*h))
    {
      kernel[blockIdx.x * SIZE + threadIdx.x] = 0.0;
      for (int i = 0; i < (DIMENSIONS); i++)
      {
        i_vectors[blockIdx.x * SIZE * DIMENSIONS + index+i] = 0.0;
      }
    }
    else
    {
      factor = exp(-(factor)/(2 * (*h)));

      kernel[blockIdx.x * SIZE + threadIdx.x] = factor;

      //Storing the 'y' vectors before normalization.
      for (int i = 0; i < (DIMENSIONS); i++)
      {
        i_vectors[blockIdx.x * SIZE * DIMENSIONS + index+i] = factor * x[index + i];
      }
    }

    __syncthreads();

    //Only the first thread of each block will calculate
    //the final vectors.
    if (threadIdx.x == 0)
    {
      double y_new[DIMENSIONS];
      for (int i = 0; i < (DIMENSIONS); i++)
      {
	       y_new[i] = 0.0;
      }

      double sum = 0.0;

      for (int i = 0; i < (SIZE) * (DIMENSIONS); i += (DIMENSIONS))
      {
      	for (int j = 0; j < (DIMENSIONS); j++)
      	{
      	  y_new[j] += i_vectors[blockIdx.x * SIZE * DIMENSIONS + i + j];
      	}
      }

      //Calculating the sum of each row of the kernel_matrix.
      for (int i = 0; i < (SIZE); i++)
      {
        sum += kernel[blockIdx.x * SIZE + i];
      }

      //Normalizing and updating the 'y' vector.
      for (int i = 0; i < (DIMENSIONS); i++)
      {
        y_new[i] = y_new[i] / sum;
      }


      //Re-initializing norm.
      norm[blockIdx.x] = 0.0;

      //Calculating the norm of the vector
      //and updating the 'y' vector
      for (int i = 0; i < (DIMENSIONS); i++)
      {

        norm[blockIdx.x] += (y_new[i]-y[basic_index + i])*(y_new[i]-y[basic_index + i]);
        y[basic_index + i] = y_new[i];

      }

      norm[blockIdx.x] = sqrt(norm[blockIdx.x]);

    }

    __syncthreads();

  }

}

int main(int argc, char **argv)
{
    FILE *file;
    char data_file_name[64], results_file_name[64];
    double *y, *x, *z, h, *kernel, *i_vectors, *norm;
    double *d_y, *d_x, *d_h, *d_kernel, *d_i_vectors, *d_norm;
    int size_double = SIZE * DIMENSIONS * sizeof(double);

	if (argc == 2)
	{
		h = atof(argv[1]);
	}
	else
	{
		if (DATASET == 1)
		{
			h = 1.0;
		}
		else
		{
			h = 2.125;
		}
	}

    if (DATASET == 1)
    {
        sprintf(data_file_name, "data_cuda.bin");
        sprintf(results_file_name, "results_global.bin");
    }
    else
    {
        sprintf(data_file_name, "data_cuda_seeds.bin");
        sprintf(results_file_name, "results_global_seeds.bin");
    }

    y = (double *)malloc(size_double);
    x = (double *)malloc(size_double);
    z = (double *)malloc(size_double);

    kernel = (double *)malloc(SIZE * SIZE * sizeof(double));
    i_vectors = (double *)malloc(SIZE * DIMENSIONS * SIZE * sizeof(double));
    norm = (double *)malloc(SIZE * sizeof(double));

    file = fopen(data_file_name, "rb");
    if (file == NULL)
    {
        printf("Could not open file\n");
        exit(1);
    }

    if(fread(y, sizeof(double), SIZE * DIMENSIONS, file) != SIZE*DIMENSIONS){
        printf("Error at reading file\n");
        exit(1);
    }

    fclose(file);

    for(int i = 0; i < SIZE * DIMENSIONS; i++)
    {
        x[i] = y[i];
    }

    cudaMalloc((void **)&d_y, size_double);
    cudaMalloc((void **)&d_x, size_double);
    cudaMalloc((void **)&d_h, sizeof(double));
    cudaMalloc((void **)&d_kernel, SIZE * SIZE * sizeof(double));
    cudaMalloc((void **)&d_i_vectors, SIZE * DIMENSIONS * SIZE * sizeof(double));
    cudaMalloc((void **)&d_norm, SIZE * sizeof(double));

    cudaMemcpy(d_y, y, size_double, cudaMemcpyHostToDevice);
    cudaMemcpy(d_x, x, size_double, cudaMemcpyHostToDevice);
    cudaMemcpy(d_h, &h, sizeof(double), cudaMemcpyHostToDevice);
    cudaMemcpy(d_kernel, kernel, SIZE * SIZE * sizeof(double), cudaMemcpyHostToDevice);
    cudaMemcpy(d_i_vectors, i_vectors, SIZE * DIMENSIONS * SIZE * sizeof(double), cudaMemcpyHostToDevice);
    cudaMemcpy(d_norm, norm, SIZE * sizeof(double), cudaMemcpyHostToDevice);

    //Time variables.
    struct timeval startwtime, endwtime;

    gettimeofday (&startwtime, NULL);

    mean_shift<<<SIZE,SIZE>>>(d_y, d_x, d_h, d_kernel, d_i_vectors, d_norm);

    cudaDeviceSynchronize();

    gettimeofday (&endwtime, NULL);

    cudaMemcpy(z, d_y, size_double, cudaMemcpyDeviceToHost);

    double exec_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6
    + endwtime.tv_sec - startwtime.tv_sec);
    printf("Runtime: %.14f \n", exec_time);

    file = fopen(results_file_name, "wb");
    if (file == NULL)
    {
        printf("Could not open file\n");
        exit(1);
    }

    fwrite(z, sizeof(double), SIZE * DIMENSIONS, file);

    fclose(file);

    cudaFree(d_y);
    cudaFree(d_x);
    cudaFree(d_h);
    cudaFree(d_kernel);
    cudaFree(d_i_vectors);
    cudaFree(d_norm);

    free(y);
    free(x);
    free(z);
    free(kernel);
    free(i_vectors);
    free(norm);

    return 0;
}

	.file	"tmpxft_00232206_00000000-6_mean_shift_global.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z40__device_stub__Z10mean_shiftPdS_S_S_S_S_PdS_S_S_S_S_
	.type	_Z40__device_stub__Z10mean_shiftPdS_S_S_S_S_PdS_S_S_S_S_, @function
_Z40__device_stub__Z10mean_shiftPdS_S_S_S_S_PdS_S_S_S_S_:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%r9, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 152(%rsp)
	movq	%rsp, %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z10mean_shiftPdS_S_S_S_S_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L2:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z40__device_stub__Z10mean_shiftPdS_S_S_S_S_PdS_S_S_S_S_, .-_Z40__device_stub__Z10mean_shiftPdS_S_S_S_S_PdS_S_S_S_S_
	.globl	_Z10mean_shiftPdS_S_S_S_S_
	.type	_Z10mean_shiftPdS_S_S_S_S_, @function
_Z10mean_shiftPdS_S_S_S_S_:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z10mean_shiftPdS_S_S_S_S_PdS_S_S_S_S_
	.cfi_endproc
.LFE2053:
	.size	_Z10mean_shiftPdS_S_S_S_S_, .-_Z10mean_shiftPdS_S_S_S_S_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"data_cuda_seeds.bin"
.LC2:
	.string	"results_global_seeds.bin"
.LC3:
	.string	"rb"
.LC4:
	.string	"Could not open file\n"
.LC5:
	.string	"Error at reading file\n"
.LC7:
	.string	"Runtime: %.14f \n"
.LC8:
	.string	"wb"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.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	$264, %rsp
	.cfi_def_cfa_offset 320
	movsd	.LC0(%rip), %xmm0
	movq	%fs:40, %rax
	movq	%rax, 248(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	jne	.L9
	movq	8(%rsi), %rdi
	call	atof@PLT
.L9:
	leaq	120(%rsp), %r15
	leaq	.LC1(%rip), %rsi
	movsd	%xmm0, 16(%rsp)
	movq	%r15, %rdi
	leaq	184(%rsp), %r14
	call	strcpy@PLT
	leaq	.LC2(%rip), %rsi
	movq	%r14, %rdi
	call	strcpy@PLT
	movl	$11760, %edi
	call	malloc@PLT
	movl	$11760, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$11760, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movl	$352800, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$2469600, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$1680, %edi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	%r15, %rdi
	leaq	.LC3(%rip), %rsi
	movq	%rax, 8(%rsp)
	call	fopen@PLT
	movq	%rax, %r15
	testq	%rax, %rax
	jne	.L10
.L13:
	leaq	.LC4(%rip), %rsi
	jmp	.L20
.L10:
	movq	%rax, %r8
	movl	$1470, %ecx
	movl	$8, %edx
	movq	%rbx, %rdi
	movl	$11760, %esi
	call	__fread_chk@PLT
	cmpq	$1470, %rax
	je	.L11
	leaq	.LC5(%rip), %rsi
.L20:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L11:
	movq	%r15, %rdi
	call	fclose@PLT
	movl	$2940, %ecx
	movq	%rbp, %rdi
	movq	%rbx, %rsi
	rep movsl
	leaq	24(%rsp), %rdi
	movl	$11760, %esi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movl	$11760, %esi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movl	$8, %esi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$352800, %esi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movl	$2469600, %esi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movl	$1680, %esi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$11760, %edx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$11760, %edx
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	leaq	16(%rsp), %rsi
	movl	$1, %ecx
	movl	$8, %edx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rsi
	movl	$352800, %edx
	call	cudaMemcpy@PLT
	movq	(%rsp), %rsi
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movl	$2469600, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movl	$1680, %edx
	call	cudaMemcpy@PLT
	xorl	%esi, %esi
	leaq	88(%rsp), %rdi
	call	gettimeofday@PLT
	movl	$2147483753, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	addq	%rdi, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movl	$1, 112(%rsp)
	movq	%rdi, %rdx
	movq	%rdi, 104(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L12
	movq	64(%rsp), %r9
	movq	56(%rsp), %r8
	movq	48(%rsp), %rcx
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z40__device_stub__Z10mean_shiftPdS_S_S_S_S_PdS_S_S_S_S_
.L12:
	call	cudaDeviceSynchronize@PLT
	leaq	104(%rsp), %rdi
	xorl	%esi, %esi
	call	gettimeofday@PLT
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdi
	movl	$11760, %edx
	call	cudaMemcpy@PLT
	movq	112(%rsp), %rax
	subq	96(%rsp), %rax
	leaq	.LC7(%rip), %rsi
	cvtsi2sdq	104(%rsp), %xmm1
	movl	$2, %edi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC6(%rip), %xmm0
	movb	$1, %al
	addsd	%xmm1, %xmm0
	cvtsi2sdq	88(%rsp), %xmm1
	subsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	movq	%r14, %rdi
	leaq	.LC8(%rip), %rsi
	call	fopen@PLT
	movq	%rax, %r14
	testq	%rax, %rax
	je	.L13
	movq	%rax, %rcx
	movl	$1470, %edx
	movl	$8, %esi
	movq	%r12, %rdi
	call	fwrite@PLT
	movq	%r14, %rdi
	call	fclose@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	248(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$264, %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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z10mean_shiftPdS_S_S_S_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z10mean_shiftPdS_S_S_S_S_(%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
.LFE2055:
	.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
.LC0:
	.long	0
	.long	1073807360
	.align 8
.LC6:
	.long	0
	.long	1093567616
	.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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <hip/hip_runtime.h>

#ifdef A
    #define DATASET 1
    #define SIZE 600
    #define DIMENSIONS 2
#else
    #define DATASET 2
    #define SIZE 210
    #define DIMENSIONS 7
#endif

__global__ void mean_shift(double *y, double *x, double *h, double *kernel, double *i_vectors, double *norm)
{
  //Thread scoped variables.
  int basic_index = blockIdx.x * (DIMENSIONS);
  int index = threadIdx.x * (DIMENSIONS);
  double e = 0.000001;
  double factor;

  //Initializing the norm.
  norm[blockIdx.x] = 1.0;

  //Main loop.
  while (norm[blockIdx.x] > e) {

    factor = 0.0;
    //Calculating factor.
    for (int i = 0; i < (DIMENSIONS); i++)
    {
        factor += (y[basic_index + i] - x[index + i])*(y[basic_index + i] - x[index + i]);
    }

    if (factor > *h*(*h))
    {
      kernel[blockIdx.x * SIZE + threadIdx.x] = 0.0;
      for (int i = 0; i < (DIMENSIONS); i++)
      {
        i_vectors[blockIdx.x * SIZE * DIMENSIONS + index+i] = 0.0;
      }
    }
    else
    {
      factor = exp(-(factor)/(2 * (*h)));

      kernel[blockIdx.x * SIZE + threadIdx.x] = factor;

      //Storing the 'y' vectors before normalization.
      for (int i = 0; i < (DIMENSIONS); i++)
      {
        i_vectors[blockIdx.x * SIZE * DIMENSIONS + index+i] = factor * x[index + i];
      }
    }

    __syncthreads();

    //Only the first thread of each block will calculate
    //the final vectors.
    if (threadIdx.x == 0)
    {
      double y_new[DIMENSIONS];
      for (int i = 0; i < (DIMENSIONS); i++)
      {
	       y_new[i] = 0.0;
      }

      double sum = 0.0;

      for (int i = 0; i < (SIZE) * (DIMENSIONS); i += (DIMENSIONS))
      {
      	for (int j = 0; j < (DIMENSIONS); j++)
      	{
      	  y_new[j] += i_vectors[blockIdx.x * SIZE * DIMENSIONS + i + j];
      	}
      }

      //Calculating the sum of each row of the kernel_matrix.
      for (int i = 0; i < (SIZE); i++)
      {
        sum += kernel[blockIdx.x * SIZE + i];
      }

      //Normalizing and updating the 'y' vector.
      for (int i = 0; i < (DIMENSIONS); i++)
      {
        y_new[i] = y_new[i] / sum;
      }


      //Re-initializing norm.
      norm[blockIdx.x] = 0.0;

      //Calculating the norm of the vector
      //and updating the 'y' vector
      for (int i = 0; i < (DIMENSIONS); i++)
      {

        norm[blockIdx.x] += (y_new[i]-y[basic_index + i])*(y_new[i]-y[basic_index + i]);
        y[basic_index + i] = y_new[i];

      }

      norm[blockIdx.x] = sqrt(norm[blockIdx.x]);

    }

    __syncthreads();

  }

}

int main(int argc, char **argv)
{
    FILE *file;
    char data_file_name[64], results_file_name[64];
    double *y, *x, *z, h, *kernel, *i_vectors, *norm;
    double *d_y, *d_x, *d_h, *d_kernel, *d_i_vectors, *d_norm;
    int size_double = SIZE * DIMENSIONS * sizeof(double);

	if (argc == 2)
	{
		h = atof(argv[1]);
	}
	else
	{
		if (DATASET == 1)
		{
			h = 1.0;
		}
		else
		{
			h = 2.125;
		}
	}

    if (DATASET == 1)
    {
        sprintf(data_file_name, "data_cuda.bin");
        sprintf(results_file_name, "results_global.bin");
    }
    else
    {
        sprintf(data_file_name, "data_cuda_seeds.bin");
        sprintf(results_file_name, "results_global_seeds.bin");
    }

    y = (double *)malloc(size_double);
    x = (double *)malloc(size_double);
    z = (double *)malloc(size_double);

    kernel = (double *)malloc(SIZE * SIZE * sizeof(double));
    i_vectors = (double *)malloc(SIZE * DIMENSIONS * SIZE * sizeof(double));
    norm = (double *)malloc(SIZE * sizeof(double));

    file = fopen(data_file_name, "rb");
    if (file == NULL)
    {
        printf("Could not open file\n");
        exit(1);
    }

    if(fread(y, sizeof(double), SIZE * DIMENSIONS, file) != SIZE*DIMENSIONS){
        printf("Error at reading file\n");
        exit(1);
    }

    fclose(file);

    for(int i = 0; i < SIZE * DIMENSIONS; i++)
    {
        x[i] = y[i];
    }

    hipMalloc((void **)&d_y, size_double);
    hipMalloc((void **)&d_x, size_double);
    hipMalloc((void **)&d_h, sizeof(double));
    hipMalloc((void **)&d_kernel, SIZE * SIZE * sizeof(double));
    hipMalloc((void **)&d_i_vectors, SIZE * DIMENSIONS * SIZE * sizeof(double));
    hipMalloc((void **)&d_norm, SIZE * sizeof(double));

    hipMemcpy(d_y, y, size_double, hipMemcpyHostToDevice);
    hipMemcpy(d_x, x, size_double, hipMemcpyHostToDevice);
    hipMemcpy(d_h, &h, sizeof(double), hipMemcpyHostToDevice);
    hipMemcpy(d_kernel, kernel, SIZE * SIZE * sizeof(double), hipMemcpyHostToDevice);
    hipMemcpy(d_i_vectors, i_vectors, SIZE * DIMENSIONS * SIZE * sizeof(double), hipMemcpyHostToDevice);
    hipMemcpy(d_norm, norm, SIZE * sizeof(double), hipMemcpyHostToDevice);

    //Time variables.
    struct timeval startwtime, endwtime;

    gettimeofday (&startwtime, NULL);

    mean_shift<<<SIZE,SIZE>>>(d_y, d_x, d_h, d_kernel, d_i_vectors, d_norm);

    hipDeviceSynchronize();

    gettimeofday (&endwtime, NULL);

    hipMemcpy(z, d_y, size_double, hipMemcpyDeviceToHost);

    double exec_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6
    + endwtime.tv_sec - startwtime.tv_sec);
    printf("Runtime: %.14f \n", exec_time);

    file = fopen(results_file_name, "wb");
    if (file == NULL)
    {
        printf("Could not open file\n");
        exit(1);
    }

    fwrite(z, sizeof(double), SIZE * DIMENSIONS, file);

    fclose(file);

    hipFree(d_y);
    hipFree(d_x);
    hipFree(d_h);
    hipFree(d_kernel);
    hipFree(d_i_vectors);
    hipFree(d_norm);

    free(y);
    free(x);
    free(z);
    free(kernel);
    free(i_vectors);
    free(norm);

    return 0;
}

	.text
	.file	"mean_shift_global.hip"
	.globl	_Z25__device_stub__mean_shiftPdS_S_S_S_S_ # -- Begin function _Z25__device_stub__mean_shiftPdS_S_S_S_S_
	.type	_Z25__device_stub__mean_shiftPdS_S_S_S_S_,@function
_Z25__device_stub__mean_shiftPdS_S_S_S_S_: # @_Z25__device_stub__mean_shiftPdS_S_S_S_S_
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z10mean_shiftPdS_S_S_S_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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	_Z25__device_stub__mean_shiftPdS_S_S_S_S_, .Lfunc_end0-_Z25__device_stub__mean_shiftPdS_S_S_S_S_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI1_0:
	.quad	0x4001000000000000              # double 2.125
.LCPI1_1:
	.quad	0x412e848000000000              # double 1.0E+6
	.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	$264, %rsp                      # imm = 0x108
	.cfi_def_cfa_offset 320
	.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	.LBB1_1
# %bb.2:
	movq	8(%rsi), %rdi
	callq	atof
	jmp	.LBB1_3
.LBB1_1:
	movsd	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB1_3:
	movsd	%xmm0, 88(%rsp)
	movaps	.L.str(%rip), %xmm0
	leaq	192(%rsp), %rbx
	movaps	%xmm0, (%rbx)
	movl	$7235938, 16(%rbx)              # imm = 0x6E6962
	movaps	.L.str.1(%rip), %xmm0
	movaps	%xmm0, 128(%rsp)
	movupd	.L.str.1+9(%rip), %xmm0
	movupd	%xmm0, 137(%rsp)
	movl	$11760, %edi                    # imm = 0x2DF0
	callq	malloc
	movq	%rax, %r14
	movl	$11760, %edi                    # imm = 0x2DF0
	callq	malloc
	movq	%rax, %r15
	movl	$11760, %edi                    # imm = 0x2DF0
	callq	malloc
	movq	%rax, %r12
	movl	$352800, %edi                   # imm = 0x56220
	callq	malloc
	movq	%rax, %r13
	movl	$2469600, %edi                  # imm = 0x25AEE0
	callq	malloc
	movq	%rax, %rbp
	movl	$1680, %edi                     # imm = 0x690
	callq	malloc
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_4
# %bb.6:
	movq	%rax, %rbx
	movq	%rbp, 56(%rsp)                  # 8-byte Spill
	movq	%r13, 64(%rsp)                  # 8-byte Spill
	movq	%r12, 72(%rsp)                  # 8-byte Spill
	movl	$8, %esi
	movl	$1470, %edx                     # imm = 0x5BE
	movq	%r14, %rdi
	movq	%rax, %rcx
	callq	fread
	cmpq	$1470, %rax                     # imm = 0x5BE
	jne	.LBB1_7
# %bb.8:
	movq	%rbx, %rdi
	callq	fclose
	movl	$11760, %edx                    # imm = 0x2DF0
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	memcpy@PLT
	leaq	16(%rsp), %rbx
	movl	$11760, %esi                    # imm = 0x2DF0
	movq	%rbx, %rdi
	callq	hipMalloc
	leaq	40(%rsp), %r13
	movl	$11760, %esi                    # imm = 0x2DF0
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	32(%rsp), %r12
	movl	$8, %esi
	movq	%r12, %rdi
	callq	hipMalloc
	leaq	24(%rsp), %rbp
	movl	$352800, %esi                   # imm = 0x56220
	movq	%rbp, %rdi
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movl	$2469600, %esi                  # imm = 0x25AEE0
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$1680, %esi                     # imm = 0x690
	callq	hipMalloc
	movq	(%rbx), %rdi
	movl	$11760, %edx                    # imm = 0x2DF0
	movq	%r14, 48(%rsp)                  # 8-byte Spill
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r13), %rdi
	movq	%r15, %r14
	movl	$11760, %edx                    # imm = 0x2DF0
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	leaq	88(%rsp), %rsi
	movl	$8, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rdi
	movl	$352800, %edx                   # imm = 0x56220
	movq	64(%rsp), %r12                  # 8-byte Reload
	movq	%r12, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	8(%rsp), %rax
	movq	(%rax), %rdi
	movl	$2469600, %edx                  # imm = 0x25AEE0
	movq	56(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rsp, %rax
	movq	(%rax), %rdi
	movl	$1680, %edx                     # imm = 0x690
	movq	80(%rsp), %rbp                  # 8-byte Reload
	movq	%rbp, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	96(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movabsq	$4294967506, %rdi               # imm = 0x1000000D2
	movl	$1, %esi
	movq	%rdi, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_10
# %bb.9:
	movq	16(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rcx
	movq	8(%rsp), %r8
	movq	(%rsp), %r9
	callq	_Z25__device_stub__mean_shiftPdS_S_S_S_S_
.LBB1_10:
	callq	hipDeviceSynchronize
	leaq	112(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	16(%rsp), %rsi
	movl	$11760, %edx                    # imm = 0x2DF0
	movq	72(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	8(%rbx), %rax
	subq	104(%rsp), %rax
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI1_1(%rip), %xmm1
	cvtsi2sdq	(%rbx), %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	96(%rsp), %xmm1
	subsd	%xmm1, %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	leaq	128(%rsp), %rdi
	movl	$.L.str.6, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_4
# %bb.11:
	movq	%rax, %rbx
	movl	$8, %esi
	movl	$1470, %edx                     # imm = 0x5BE
	movq	%r15, %rdi
	movq	%rax, %rcx
	callq	fwrite
	movq	%rbx, %rdi
	callq	fclose
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$264, %rsp                      # imm = 0x108
	.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
.LBB1_4:
	.cfi_def_cfa_offset 320
	movl	$.Lstr.2, %edi
	jmp	.LBB1_5
.LBB1_7:
	movl	$.Lstr.1, %edi
.LBB1_5:
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end1:
	.size	main, .Lfunc_end1-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	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10mean_shiftPdS_S_S_S_S_, %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_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z10mean_shiftPdS_S_S_S_S_,@object # @_Z10mean_shiftPdS_S_S_S_S_
	.section	.rodata,"a",@progbits
	.globl	_Z10mean_shiftPdS_S_S_S_S_
	.p2align	3, 0x0
_Z10mean_shiftPdS_S_S_S_S_:
	.quad	_Z25__device_stub__mean_shiftPdS_S_S_S_S_
	.size	_Z10mean_shiftPdS_S_S_S_S_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.16,"aMS",@progbits,1
	.p2align	4, 0x0
.L.str:
	.asciz	"data_cuda_seeds.bin"
	.size	.L.str, 20

	.type	.L.str.1,@object                # @.str.1
	.p2align	4, 0x0
.L.str.1:
	.asciz	"results_global_seeds.bin"
	.size	.L.str.1, 25

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"rb"
	.size	.L.str.2, 3

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"wb"
	.size	.L.str.6, 3

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z10mean_shiftPdS_S_S_S_S_"
	.size	.L__unnamed_1, 27

	.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.1,@object                 # @str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr.1:
	.asciz	"Error at reading file"
	.size	.Lstr.1, 22

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Could not open file"
	.size	.Lstr.2, 20

	.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 _Z25__device_stub__mean_shiftPdS_S_S_S_S_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z10mean_shiftPdS_S_S_S_S_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z10mean_shiftPdS_S_S_S_S_ ; -- Begin function _Z10mean_shiftPdS_S_S_S_S_
	.globl	_Z10mean_shiftPdS_S_S_S_S_
	.p2align	8
	.type	_Z10mean_shiftPdS_S_S_S_S_,@function
_Z10mean_shiftPdS_S_S_S_S_:             ; @_Z10mean_shiftPdS_S_S_S_S_
; %bb.0:                                ; %.preheader106.lr.ph
	s_mov_b32 s2, s15
	s_clause 0x1
	s_load_b128 s[12:15], s[0:1], 0x20
	s_load_b256 s[4:11], s[0:1], 0x0
	s_mul_i32 s33, s2, 0xd2
	v_dual_mov_b32 v17, 0 :: v_dual_mov_b32 v2, 0x3ff00000
	v_add_nc_u32_e32 v16, s33, v0
	v_mul_u32_u24_e32 v5, 7, v0
	s_mov_b32 s3, 0
	s_delay_alu instid0(VALU_DEP_3)
	v_mov_b32_e32 v1, v17
	s_lshl_b64 s[18:19], s[2:3], 3
	v_lshlrev_b64 v[3:4], 3, v[16:17]
	v_lshlrev_b32_e32 v5, 3, v5
	s_mul_i32 s16, s2, 7
	s_mulk_i32 s2, 0x5be
	v_cmp_eq_u32_e64 s0, 0, v0
	v_mad_u32_u24 v26, v0, 7, s2
	s_mov_b32 s20, 0xfca7ab0c
	s_mov_b32 s22, 0x6a5dcb37
	s_mov_b32 s24, 0x623fde64
	s_mov_b32 s26, 0x7c89e6b0
	s_waitcnt lgkmcnt(0)
	s_add_u32 s14, s14, s18
	v_add_co_u32 v18, vcc_lo, s10, v3
	s_addc_u32 s15, s15, s19
	s_ashr_i32 s17, s16, 31
	v_add_co_u32 v20, s1, s6, v5
	v_add_co_ci_u32_e32 v19, vcc_lo, s11, v4, vcc_lo
	v_add_co_ci_u32_e64 v21, null, s7, 0, s1
	s_lshl_b64 s[44:45], s[16:17], 3
	s_mov_b32 s6, 0x652b82fe
	s_mov_b32 s16, 0xfefa39ef
	s_mov_b32 s18, 0x3b39803f
	s_mov_b32 s28, 0x14761f6e
	s_mov_b32 s30, 0x1852b7b0
	s_mov_b32 s34, 0x11122322
	s_mov_b32 s36, 0x555502a1
	s_mov_b32 s38, 0x55555511
	s_mov_b32 s40, 11
	s_mov_b32 s42, 0xa0b5ed8d
	s_add_u32 s4, s4, s44
	s_mov_b32 s7, 0x3ff71547
	s_mov_b32 s17, 0xbfe62e42
	s_mov_b32 s19, 0xbc7abc9e
	s_mov_b32 s21, 0x3e928af3
	s_mov_b32 s23, 0x3e5ade15
	s_mov_b32 s25, 0x3ec71dee
	s_mov_b32 s27, 0x3efa0199
	s_mov_b32 s29, 0x3f2a01a0
	s_mov_b32 s31, 0x3f56c16c
	s_mov_b32 s35, 0x3f811111
	s_mov_b32 s37, 0x3fa55555
	s_mov_b32 s39, 0x3fc55555
	s_mov_b32 s41, 0x3fe00000
	s_mov_b32 s43, 0x3eb0c6f7
	s_addc_u32 s5, s5, s45
	s_mov_b64 s[44:45], s[2:3]
	global_store_b64 v17, v[1:2], s[14:15]
                                        ; implicit-def: $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7_vgpr8_vgpr9_vgpr10_vgpr11_vgpr12_vgpr13_vgpr14_vgpr15
.LBB0_1:                                ; %.preheader106
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_2 Depth 2
                                        ;     Child Loop BB0_5 Depth 2
                                        ;     Child Loop BB0_8 Depth 2
                                        ;     Child Loop BB0_11 Depth 2
                                        ;     Child Loop BB0_13 Depth 2
                                        ;       Child Loop BB0_14 Depth 3
                                        ;     Child Loop BB0_18 Depth 2
                                        ;     Child Loop BB0_20 Depth 2
                                        ;     Child Loop BB0_22 Depth 2
	v_mov_b32_e32 v22, 0
	v_mov_b32_e32 v23, 0
	s_mov_b64 s[46:47], 0
.LBB0_2:                                ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add_co_u32 v24, vcc_lo, v20, s46
	v_add_co_ci_u32_e32 v25, vcc_lo, s47, v21, vcc_lo
	s_add_u32 s48, s4, s46
	s_addc_u32 s49, s5, s47
	global_load_b64 v[27:28], v17, s[48:49]
	global_load_b64 v[24:25], v[24:25], off
	s_add_u32 s46, s46, 8
	s_addc_u32 s47, s47, 0
	s_cmp_eq_u32 s46, 56
	s_waitcnt vmcnt(0)
	v_add_f64 v[24:25], v[27:28], -v[24:25]
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f64 v[22:23], v[24:25], v[24:25], v[22:23]
	s_cbranch_scc0 .LBB0_2
; %bb.3:                                ;   in Loop: Header=BB0_1 Depth=1
	global_load_b64 v[24:25], v17, s[8:9]
	s_mov_b32 s1, exec_lo
	s_waitcnt vmcnt(0)
	v_mul_f64 v[27:28], v[24:25], v[24:25]
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_ngt_f64_e32 v[22:23], v[27:28]
	s_xor_b32 s2, exec_lo, s1
	s_cbranch_execz .LBB0_6
; %bb.4:                                ;   in Loop: Header=BB0_1 Depth=1
	v_add_f64 v[24:25], v[24:25], v[24:25]
	s_mov_b32 s46, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f64 v[27:28], null, v[24:25], v[24:25], -v[22:23]
	v_div_scale_f64 v[33:34], vcc_lo, -v[22:23], v[24:25], -v[22:23]
	v_rcp_f64_e32 v[29:30], v[27:28]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[31:32], -v[27:28], v[29:30], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[29:30], v[31:32], v[29:30]
	v_fma_f64 v[31:32], -v[27:28], v[29:30], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[29:30], v[31:32], v[29:30]
	v_mul_f64 v[31:32], v[33:34], v[29:30]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[27:28], -v[27:28], v[31:32], v[33:34]
	v_div_fmas_f64 v[27:28], v[27:28], v[29:30], v[31:32]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f64 v[22:23], v[27:28], v[24:25], -v[22:23]
	v_mul_f64 v[24:25], v[22:23], s[6:7]
	v_cmp_nlt_f64_e32 vcc_lo, 0x40900000, v[22:23]
	v_cmp_ngt_f64_e64 s1, 0xc090cc00, v[22:23]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_rndne_f64_e32 v[24:25], v[24:25]
	v_fma_f64 v[27:28], v[24:25], s[16:17], v[22:23]
	v_cvt_i32_f64_e32 v16, v[24:25]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[27:28], v[24:25], s[18:19], v[27:28]
	v_fma_f64 v[29:30], v[27:28], s[22:23], s[20:21]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[27:28], v[29:30], s[24:25]
	v_fma_f64 v[29:30], v[27:28], v[29:30], s[26:27]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[27:28], v[29:30], s[28:29]
	v_fma_f64 v[29:30], v[27:28], v[29:30], s[30:31]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[27:28], v[29:30], s[34:35]
	v_fma_f64 v[29:30], v[27:28], v[29:30], s[36:37]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[27:28], v[29:30], s[38:39]
	v_fma_f64 v[29:30], v[27:28], v[29:30], s[40:41]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[27:28], v[29:30], 1.0
	v_fma_f64 v[24:25], v[27:28], v[29:30], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[24:25], v[24:25], v16
	v_cndmask_b32_e32 v16, 0x7ff00000, v25, vcc_lo
	s_and_b32 vcc_lo, s1, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_dual_cndmask_b32 v22, 0, v24 :: v_dual_mov_b32 v25, v21
	v_cndmask_b32_e64 v23, 0, v16, s1
	v_mov_b32_e32 v24, v20
	global_store_b64 v[18:19], v[22:23], off
.LBB0_5:                                ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b64 v[27:28], v[24:25], off
	v_add_nc_u32_e32 v16, s46, v26
	v_add_co_u32 v24, vcc_lo, v24, 8
	v_add_co_ci_u32_e32 v25, vcc_lo, 0, v25, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_lshlrev_b64 v[29:30], 3, v[16:17]
	s_add_i32 s46, s46, 1
	s_cmp_lg_u32 s46, 7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v29, s1, s12, v29
	v_add_co_ci_u32_e64 v30, s1, s13, v30, s1
	s_waitcnt vmcnt(0)
	v_mul_f64 v[27:28], v[22:23], v[27:28]
	global_store_b64 v[29:30], v[27:28], off
	s_cbranch_scc1 .LBB0_5
.LBB0_6:                                ; %Flow201
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s1, s2
	s_cbranch_execz .LBB0_9
; %bb.7:                                ;   in Loop: Header=BB0_1 Depth=1
	v_mov_b32_e32 v22, v17
	v_mov_b32_e32 v23, v17
	s_mov_b32 s2, 0
	global_store_b64 v[18:19], v[22:23], off
.LBB0_8:                                ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_add_nc_u32_e32 v16, s2, v26
	s_add_i32 s2, s2, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s2, 7
	v_lshlrev_b64 v[24:25], 3, v[16:17]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v24, vcc_lo, s12, v24
	v_add_co_ci_u32_e32 v25, vcc_lo, s13, v25, vcc_lo
	global_store_b64 v[24:25], v[22:23], off
	s_cbranch_scc0 .LBB0_8
.LBB0_9:                                ; %Flow202
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_24
; %bb.10:                               ; %.preheader104.preheader
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b64 s[46:47], 0
.LBB0_11:                               ; %.preheader104
                                        ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b32 s2, s46, 1
	s_add_u32 s46, s46, 1
	s_mov_b32 m0, s2
	s_addc_u32 s47, s47, 0
	s_cmp_lg_u32 s46, 7
	v_movreld_b32_e32 v0, 0
	v_movreld_b32_e32 v1, 0
	s_cbranch_scc1 .LBB0_11
; %bb.12:                               ; %.preheader.preheader
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s50, 0
	s_mov_b64 s[46:47], s[44:45]
.LBB0_13:                               ; %.preheader
                                        ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_14 Depth 3
	s_mov_b64 s[48:49], 0
.LBB0_14:                               ;   Parent Loop BB0_1 Depth=1
                                        ;     Parent Loop BB0_13 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s46, s48
	s_lshl_b64 s[52:53], s[2:3], 3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s52, s12, s52
	s_addc_u32 s53, s13, s53
	s_lshl_b32 s2, s48, 1
	global_load_b64 v[22:23], v17, s[52:53]
	s_mov_b32 m0, s2
	s_add_u32 s48, s48, 1
	v_movrels_b32_e32 v25, v1
	v_movrels_b32_e32 v24, v0
	s_addc_u32 s49, s49, 0
	s_cmp_eq_u32 s48, 7
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[22:23], v[24:25], v[22:23]
	v_movreld_b32_e32 v0, v22
	s_delay_alu instid0(VALU_DEP_2)
	v_movreld_b32_e32 v1, v23
	s_cbranch_scc0 .LBB0_14
; %bb.15:                               ;   in Loop: Header=BB0_13 Depth=2
	s_add_i32 s2, s50, 7
	s_add_u32 s46, s46, 7
	s_addc_u32 s47, s47, 0
	s_cmpk_lt_u32 s50, 0x5b7
	s_cbranch_scc0 .LBB0_17
; %bb.16:                               ;   in Loop: Header=BB0_13 Depth=2
	s_mov_b32 s50, s2
	s_branch .LBB0_13
.LBB0_17:                               ; %.preheader102.preheader
                                        ;   in Loop: Header=BB0_1 Depth=1
	v_mov_b32_e32 v22, 0
	v_mov_b32_e32 v23, 0
	s_mov_b32 s46, 0
.LBB0_18:                               ; %.preheader102
                                        ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s33, s46
	s_lshl_b64 s[48:49], s[2:3], 3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s48, s10, s48
	s_addc_u32 s49, s11, s49
	s_add_i32 s46, s46, 1
	global_load_b64 v[24:25], v17, s[48:49]
	s_cmpk_lg_i32 s46, 0xd2
	s_waitcnt vmcnt(0)
	v_add_f64 v[22:23], v[22:23], v[24:25]
	s_cbranch_scc1 .LBB0_18
; %bb.19:                               ; %.preheader101.preheader
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b64 s[46:47], 0
.LBB0_20:                               ; %.preheader101
                                        ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b32 s2, s46, 1
	s_add_u32 s46, s46, 1
	s_mov_b32 m0, s2
	s_addc_u32 s47, s47, 0
	v_movrels_b32_e32 v25, v1
	v_movrels_b32_e32 v24, v0
	s_cmp_eq_u32 s46, 7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f64 v[27:28], null, v[22:23], v[22:23], v[24:25]
	v_div_scale_f64 v[33:34], vcc_lo, v[24:25], v[22:23], v[24:25]
	v_rcp_f64_e32 v[29:30], v[27:28]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[31:32], -v[27:28], v[29:30], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[29:30], v[31:32], v[29:30]
	v_fma_f64 v[31:32], -v[27:28], v[29:30], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[29:30], v[29:30], v[31:32], v[29:30]
	v_mul_f64 v[31:32], v[33:34], v[29:30]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[27:28], -v[27:28], v[31:32], v[33:34]
	v_div_fmas_f64 v[27:28], v[27:28], v[29:30], v[31:32]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f64 v[24:25], v[27:28], v[22:23], v[24:25]
	v_movreld_b32_e32 v0, v24
	s_delay_alu instid0(VALU_DEP_2)
	v_movreld_b32_e32 v1, v25
	s_cbranch_scc0 .LBB0_20
; %bb.21:                               ;   in Loop: Header=BB0_1 Depth=1
	v_mov_b32_e32 v16, v17
	s_mov_b64 s[46:47], 0
	s_mov_b64 s[48:49], s[4:5]
	global_store_b64 v17, v[16:17], s[14:15]
.LBB0_22:                               ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_clause 0x1
	global_load_b64 v[22:23], v17, s[48:49]
	global_load_b64 v[24:25], v17, s[14:15]
	s_lshl_b32 s2, s46, 1
	s_add_u32 s46, s46, 1
	s_mov_b32 m0, s2
	s_addc_u32 s47, s47, 0
	v_movrels_b32_e32 v28, v1
	v_movrels_b32_e32 v27, v0
	s_waitcnt vmcnt(1)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_f64 v[22:23], v[27:28], -v[22:23]
	s_waitcnt vmcnt(0)
	v_fma_f64 v[22:23], v[22:23], v[22:23], v[24:25]
	s_clause 0x1
	global_store_b64 v17, v[22:23], s[14:15]
	global_store_b64 v17, v[27:28], s[48:49]
	s_add_u32 s48, s48, 8
	s_addc_u32 s49, s49, 0
	s_cmp_eq_u32 s46, 7
	s_cbranch_scc0 .LBB0_22
; %bb.23:                               ;   in Loop: Header=BB0_1 Depth=1
	global_load_b64 v[22:23], v17, s[14:15]
	s_waitcnt vmcnt(0)
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[22:23]
	v_cndmask_b32_e64 v16, 0, 1, vcc_lo
	s_and_b32 s2, vcc_lo, exec_lo
	s_cselect_b32 s2, 0xffffff80, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v16, 8, v16
	v_ldexp_f64 v[22:23], v[22:23], v16
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_rsq_f64_e32 v[24:25], v[22:23]
	v_cmp_class_f64_e64 vcc_lo, v[22:23], 0x260
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[27:28], v[22:23], v[24:25]
	v_mul_f64 v[24:25], v[24:25], 0.5
	v_fma_f64 v[29:30], -v[24:25], v[27:28], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f64 v[27:28], v[27:28], v[29:30], v[27:28]
	v_fma_f64 v[24:25], v[24:25], v[29:30], v[24:25]
	v_fma_f64 v[29:30], -v[27:28], v[27:28], v[22:23]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[27:28], v[29:30], v[24:25], v[27:28]
	v_fma_f64 v[29:30], -v[27:28], v[27:28], v[22:23]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[24:25], v[29:30], v[24:25], v[27:28]
	v_ldexp_f64 v[24:25], v[24:25], s2
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_cndmask_b32 v23, v25, v23 :: v_dual_cndmask_b32 v22, v24, v22
	global_store_b64 v17, v[22:23], s[14:15]
.LBB0_24:                               ; %Flow
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	global_load_b64 v[22:23], v17, s[14:15]
	s_waitcnt vmcnt(0)
	v_cmp_lt_f64_e32 vcc_lo, s[42:43], v[22:23]
	s_cbranch_vccnz .LBB0_1
; %bb.25:                               ; %._crit_edge
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10mean_shiftPdS_S_S_S_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 48
		.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 35
		.amdhsa_next_free_sgpr 54
		.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	_Z10mean_shiftPdS_S_S_S_S_, .Lfunc_end0-_Z10mean_shiftPdS_S_S_S_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1828
; NumSgprs: 56
; NumVgprs: 35
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 6
; VGPRBlocks: 4
; NumSGPRsForWavesPerEU: 56
; NumVGPRsForWavesPerEU: 35
; 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:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 48
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10mean_shiftPdS_S_S_S_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     56
    .sgpr_spill_count: 0
    .symbol:         _Z10mean_shiftPdS_S_S_S_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     35
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
