#include<iostream>
#include<cstring>
#include<cstdlib>

#define GMM_MAX_COMPONT 3	
#define GMM_LEARN_ALPHA 0.005  
#define GMM_THRESHOD_SUMW 0.7
#define HEIGHT 1080
#define WIDTH 1920

using namespace std;

__global__ void trainGMM_CUDA(unsigned char *_image, unsigned char *mask, float *modelW, float *modelS, unsigned char *modelM, int height, int width)
{
  const int x = blockIdx.x * blockDim.x + threadIdx.x;
  const int y = blockIdx.y * blockDim.y + threadIdx.y;

  if (x >= height || y >= width)
    return; 
 
  unsigned char *_imageData = _image + x * width + y;
 
  float *modelWData = modelW + GMM_MAX_COMPONT * (x * width + y);
  float *modelSData = modelS + GMM_MAX_COMPONT * (x * width + y);
  unsigned char *modelMData = modelM + GMM_MAX_COMPONT * (x * width + y);

	int num_fit = 0;
	
  for (int k = 0; k < GMM_MAX_COMPONT; k++)
	{
		int delm = abs(_imageData[0] - modelMData[k]);
		long dist = delm * delm;
		if (dist < 3.0 * modelSData[k])
		{
			modelWData[k] += GMM_LEARN_ALPHA * (1 - modelWData[k]);
			modelMData[k] += (GMM_LEARN_ALPHA / modelWData[k]) * delm;
			modelSData[k] += (GMM_LEARN_ALPHA / modelWData[k]) * (dist - modelSData[k]);
		}
		else
		{
			modelWData[k] += GMM_LEARN_ALPHA * (0 - modelWData[k]);
			num_fit++;
		}
	}

	for (int kk = 0; kk < GMM_MAX_COMPONT; kk++)
	{
		for (int rr = kk; rr< GMM_MAX_COMPONT; rr++)
		{
			if (modelWData[rr] / modelSData[rr] > modelWData[kk] / modelSData[kk])
			{
				float temp_weight = modelWData[rr];
				modelWData[rr] = modelWData[kk];
				modelWData[kk] = temp_weight;
				unsigned char temp_mean = modelMData[rr];
			  modelMData[rr] = modelMData[kk];
				modelMData[kk] = temp_mean;

				float temp_sigma = modelSData[rr];
				modelSData[rr] = modelSData[kk];
				modelSData[kk] = temp_sigma;
			}
		}
	}
	
  if (num_fit == GMM_MAX_COMPONT && modelWData[GMM_MAX_COMPONT - 1] == 0)
	{
		for (int k = 0; k < GMM_MAX_COMPONT; k++)
		{
			if (0 == modelWData[k])
			{
				if (k == 0)
				  modelWData[k] = 1;
				else
				  modelWData[k] = GMM_LEARN_ALPHA;
				
        modelMData[k] = _imageData[0];
				modelSData[k] = 15.0;

				for (int q = 0; q < GMM_MAX_COMPONT && q != k; q++)
				{
					modelWData[q] *= (1 - GMM_LEARN_ALPHA);
				}
				break;
			}
		}
	}
	else if (num_fit == GMM_MAX_COMPONT && modelWData[GMM_MAX_COMPONT - 1] != 0)
	{
		modelMData[GMM_MAX_COMPONT - 1] = _imageData[0];
		modelSData[GMM_MAX_COMPONT - 1] = 15.0;
	}
}

__global__ void testGMM_CUDA(unsigned char *_image, unsigned char *mask, float *modelW, float *modelS, unsigned char *modelM, int height, int width)
{
  const int x = blockIdx.x * blockDim.x + threadIdx.x;
  const int y = blockIdx.y * blockDim.y + threadIdx.y;
  
  if (x >= height || y >= width)
    return; 
 
  unsigned char *_imageData = _image + x * width + y;
  unsigned char *maskData = mask + x * width + y;
 
  float *modelWData = modelW + GMM_MAX_COMPONT * (x * width + y);
  float *modelSData = modelS + GMM_MAX_COMPONT * (x * width + y);
  unsigned char *modelMData = modelM + GMM_MAX_COMPONT * (x * width + y);
	
	float sum_w = 0.0;
	for (unsigned char k = 0; k < GMM_MAX_COMPONT; k++)
	{
		if (abs(_imageData[0] - modelMData[k]) < (unsigned char)(2.5 * modelSData[k]))
		{
			maskData[0] = 0;
			break;
		}
			sum_w += modelWData[k];
		if (sum_w >= GMM_THRESHOD_SUMW)
		{
			maskData[0] = 255;
			break;
		}
	}
}

void trainGMM(unsigned char *_image, unsigned char *mask, float *modelW, float *modelS, unsigned char *modelM, int height, int width)
{
	/**************************** Train ******************************************/
	for (int i = 0; i < height; i++)
	{
		float *modelWData = modelW + i * width * GMM_MAX_COMPONT;
		float *modelSData = modelS + i * width * GMM_MAX_COMPONT;
		unsigned char *modelMData = modelM + i * width * GMM_MAX_COMPONT;
		const unsigned char *_imageData = _image + i * width;
		for (int j = 0; j < width; j++)
		{
			int num_fit = 0;

			/**************************** Update parameters Start ******************************************/
			for (int k = 0; k < GMM_MAX_COMPONT; k++)
			{
				int delm = abs(_imageData[j] - modelMData[k]);
				long dist = delm * delm;
				if (dist < 3.0 * modelSData[k])
				{
					modelWData[k] += GMM_LEARN_ALPHA * (1 - modelWData[k]);
					modelMData[k] += (GMM_LEARN_ALPHA / modelWData[k]) * delm;
					modelSData[k] += (GMM_LEARN_ALPHA / modelWData[k]) * (dist - modelSData[k]);
				}
				else
				{
					modelWData[k] += GMM_LEARN_ALPHA * (0 - modelWData[k]);
					num_fit++;
				}
			}
			/**************************** Update parameters End ******************************************/

			/*********************** Sort Gaussian component by 'weight / sigma' Start ****************************/
			for (int kk = 0; kk < GMM_MAX_COMPONT; kk++)
			{
				for (int rr = kk; rr< GMM_MAX_COMPONT; rr++)
				{
					if (modelWData[rr] / modelSData[rr] > modelWData[kk] / modelSData[kk])
					{
						float temp_weight = modelWData[rr];
						modelWData[rr] = modelWData[kk];
						modelWData[kk] = temp_weight;

						unsigned char temp_mean = modelMData[rr];
						modelMData[rr] = modelMData[kk];
						modelMData[kk] = temp_mean;

						float temp_sigma = modelSData[rr];
						modelSData[rr] = modelSData[kk];
						modelSData[kk] = temp_sigma;
					}
				}
			}
			/*********************** Sort Gaussian model by 'weight / sigma' End ****************************/

			/*********************** Create new Gaussian component Start ****************************/
			if (num_fit == GMM_MAX_COMPONT && modelWData[GMM_MAX_COMPONT - 1] == 0)
			{
				//if there is no exit component fit,then start a new component
				for (int k = 0; k < GMM_MAX_COMPONT; k++)
				{
					if (0 == modelWData[k])
					{
						if (k == 0)
							modelWData[k] = 1;
						else
							modelWData[k] = GMM_LEARN_ALPHA;
						
            modelMData[k] = _imageData[j];
						modelSData[k] = 15.0;

						//normalization the weight,let they sum to 1
						for (int q = 0; q < GMM_MAX_COMPONT && q != k; q++)
						{
							/****update the other unfit's weight,u and sigma remain unchanged****/
							modelWData[q] *= (1 - GMM_LEARN_ALPHA);
						}
						break;
					}
				}
			}
			else if (num_fit == GMM_MAX_COMPONT && modelWData[GMM_MAX_COMPONT - 1] != 0)
			{
				modelMData[GMM_MAX_COMPONT - 1] = _imageData[j];
				modelSData[GMM_MAX_COMPONT - 1] = 15.0;
			}
			/*********************** Create new Gaussian component End ****************************/

			modelWData += GMM_MAX_COMPONT;
			modelSData += GMM_MAX_COMPONT;
			modelMData += GMM_MAX_COMPONT;
		}
	}
}

void testGMM(unsigned char* _image, unsigned char* mask, float* modelW, float* modelS, unsigned char* modelM, int height, int width)
{
	/*********************** Predict ****************************/
	for (int i = 0; i < height; i++)
	{
		float *modelWData = modelW + i * width * GMM_MAX_COMPONT;
		float *modelSData = modelS + i * width * GMM_MAX_COMPONT;
		unsigned char *modelMData = modelM + i * width * GMM_MAX_COMPONT;
		const unsigned char *_imageData = _image + i * width;
		unsigned char *maskData = mask + i * width;
		for (int j = 0; j < width; j++)
		{
			float sum_w = 0.0;
			for (unsigned char k = 0; k < GMM_MAX_COMPONT; k++)
			{
				if (abs(_imageData[j] - modelMData[k]) < (unsigned char)(2.5 * modelSData[k]))
				{
					maskData[j] = 0;
					break;
				}
				sum_w += modelWData[k];
				if (sum_w >= GMM_THRESHOD_SUMW)
				{
					maskData[j] = 255;
					break;
				}
			}
			modelWData += GMM_MAX_COMPONT;
			modelSData += GMM_MAX_COMPONT;
			modelMData += GMM_MAX_COMPONT;
		}
	}
}

int main()
{	
  float *modelW = new float[HEIGHT * GMM_MAX_COMPONT * WIDTH];
  float *modelS = new float[HEIGHT * GMM_MAX_COMPONT * WIDTH];
  unsigned char *modelM = new unsigned char[HEIGHT * GMM_MAX_COMPONT * WIDTH];;
  unsigned char *frame = new unsigned char[HEIGHT * WIDTH];
  unsigned char *mask = new unsigned char[HEIGHT * WIDTH];
  unsigned char *mask2 = new unsigned char[HEIGHT * WIDTH];
  int height = HEIGHT;
  int width = WIDTH;  

  memset(modelW, 0, sizeof(modelW));
  memset(modelS, 0, sizeof(modelM));
  memset(modelM, 0, sizeof(modelS));
  memset(mask, 0, sizeof(mask));

  // For GPU  
  float *dev_modelW, *dev_modelS;
  unsigned char *dev_frame, *dev_mask, *dev_modelM;

  cudaMalloc((void**)&dev_modelW, (HEIGHT * GMM_MAX_COMPONT * WIDTH) * sizeof(float));
  cudaMalloc((void**)&dev_modelS, (HEIGHT * GMM_MAX_COMPONT * WIDTH) * sizeof(float));
  cudaMalloc((void**)&dev_modelM, (HEIGHT * GMM_MAX_COMPONT * WIDTH) * sizeof(unsigned char));
  cudaMalloc((void**)&dev_frame, (HEIGHT * WIDTH) * sizeof(unsigned char));
  cudaMalloc((void**)&dev_mask, (HEIGHT * WIDTH) * sizeof(unsigned char));

  cudaMemcpy(dev_modelW,
             modelW,
             HEIGHT * GMM_MAX_COMPONT * WIDTH * sizeof(float),
             cudaMemcpyHostToDevice);
  cudaMemcpy(dev_modelS,
             modelS,
             HEIGHT * GMM_MAX_COMPONT * WIDTH * sizeof(float),
             cudaMemcpyHostToDevice);
  cudaMemcpy(dev_modelM,
             modelM,
             HEIGHT * GMM_MAX_COMPONT * WIDTH * sizeof(unsigned char),
             cudaMemcpyHostToDevice);
  
  dim3 block(32,8);
  dim3 grid((HEIGHT + block.x - 1) / block.x, 
					  (WIDTH + block.y - 1) / block.y);

  clock_t start, end;
  clock_t start2, end2;
	double sum_t = 0;
	double sum_t2 = 0;
	 
  srand(unsigned(time(0)));  

  int frame_num = 100;
  for (int t = 0; t < frame_num; t++)
  {
    for (int i = 0; i < height; i++)
      for (int j = 0; j < width; j++)
        *(frame + i * width + j) = rand() % 255;
    
    start = clock();  
    trainGMM(frame, mask, modelW, modelS, modelM, height, width);
    testGMM(frame, mask, modelW, modelS, modelM, height, width);
    end = clock();
    sum_t += end - start;

    start2 = clock();
    cudaMemcpy(dev_frame,
               frame,
               HEIGHT * WIDTH * sizeof(unsigned char),
               cudaMemcpyHostToDevice);
    trainGMM_CUDA<<<grid, block>>>(dev_frame, dev_mask,  dev_modelW, dev_modelS, dev_modelM, height, width);    
    testGMM_CUDA<<<grid, block>>>(dev_frame, dev_mask,  dev_modelW, dev_modelS, dev_modelM, height, width);    
    cudaMemcpy(mask2,
               dev_mask,
               HEIGHT * WIDTH * sizeof(unsigned char),
               cudaMemcpyDeviceToHost);
    end2 = clock();
    sum_t2 += end2 - start2;
  
  // TEST
  /*
  int diff_count = 0;
  for (int i = 0; i < height * width; i++)
    if (mask[i] != mask2[i])
      diff_count++;
  
  cout <<"Diff: " << diff_count << endl;
  */
  }
	cout <<"CPU: " << (sum_t / frame_num) / CLOCKS_PER_SEC << endl;
	cout <<"GPU: " << (sum_t2 / frame_num) / CLOCKS_PER_SEC << endl;
}

	.file	"tmpxft_002a7998_00000000-6_gmm_cuda.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3640:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3640:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z8trainGMMPhS_PfS0_S_ii
	.type	_Z8trainGMMPhS_PfS0_S_ii, @function
_Z8trainGMMPhS_PfS0_S_ii:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorps	%xmm2, %xmm2
	movsd	.LC2(%rip), %xmm4
	xorl	%r11d, %r11d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movsd	.LC3(%rip), %xmm1
	movaps	%xmm2, %xmm6
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movss	.LC1(%rip), %xmm5
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	imull	$3, 56(%rsp), %r10d
	movslq	56(%rsp), %rax
	movq	%rdi, -8(%rsp)
	movslq	%r10d, %r10
	movq	%rdx, -24(%rsp)
	leaq	0(,%r10,4), %r14
	movq	%rcx, -32(%rsp)
	movq	%r8, -40(%rsp)
	movq	%rax, -16(%rsp)
.L3:
	cmpl	%r9d, %r11d
	jge	.L44
	movq	-8(%rsp), %rbx
	movq	-24(%rsp), %rax
	movq	-32(%rsp), %rdx
	movq	-40(%rsp), %rsi
	movss	.LC5(%rip), %xmm3
	leaq	(%rbx,%rbp), %r8
	xorl	%ebx, %ebx
.L4:
	cmpl	56(%rsp), %ebx
	jge	.L45
	xorl	%ecx, %ecx
	xorl	%r12d, %r12d
.L8:
	movzbl	(%r8), %edi
	movzbl	(%rsi,%rcx), %r13d
	cvtss2sd	(%rdx,%rcx,4), %xmm0
	mulsd	%xmm4, %xmm0
	movss	(%rax,%rcx,4), %xmm7
	subl	%r13d, %edi
	movl	%edi, %r15d
	cvtss2sd	%xmm7, %xmm8
	imull	%edi, %r15d
	cvtsi2sdl	%r15d, %xmm9
	comisd	%xmm9, %xmm0
	jbe	.L40
	movaps	%xmm5, %xmm0
	movl	%edi, %r13d
	subss	%xmm7, %xmm0
	negl	%r13d
	cmovs	%edi, %r13d
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm0
	cvtsi2sdl	%r13d, %xmm7
	addsd	%xmm8, %xmm0
	movaps	%xmm1, %xmm8
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%rcx,4)
	cvtss2sd	%xmm0, %xmm0
	divsd	%xmm0, %xmm8
	movzbl	(%rsi,%rcx), %edi
	mulsd	%xmm8, %xmm7
	movaps	%xmm7, %xmm0
	cvtsi2sdl	%edi, %xmm7
	addsd	%xmm7, %xmm0
	cvttsd2sil	%xmm0, %edi
	movaps	%xmm1, %xmm0
	movb	%dil, (%rsi,%rcx)
	cvtss2sd	(%rax,%rcx,4), %xmm7
	divsd	%xmm7, %xmm0
	cvtsi2ssl	%r15d, %xmm7
	movss	(%rdx,%rcx,4), %xmm8
	subss	%xmm8, %xmm7
	cvtss2sd	%xmm8, %xmm8
	cvtss2sd	%xmm7, %xmm7
	mulsd	%xmm7, %xmm0
	addsd	%xmm8, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rdx,%rcx,4)
	jmp	.L7
.L40:
	movaps	%xmm2, %xmm0
	incl	%r12d
	subss	%xmm7, %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	%xmm8, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%rcx,4)
.L7:
	incq	%rcx
	cmpq	$3, %rcx
	jne	.L8
	xorl	%ecx, %ecx
.L9:
	movq	%rcx, %rdi
.L12:
	movss	(%rax,%rdi,4), %xmm0
	movss	(%rax,%rcx,4), %xmm7
	movaps	%xmm0, %xmm9
	movaps	%xmm7, %xmm8
	divss	(%rdx,%rdi,4), %xmm9
	divss	(%rdx,%rcx,4), %xmm8
	comiss	%xmm8, %xmm9
	jbe	.L10
	movss	%xmm7, (%rax,%rdi,4)
	movss	%xmm0, (%rax,%rcx,4)
	movb	(%rsi,%rdi), %r13b
	movb	(%rsi,%rcx), %r15b
	movb	%r15b, (%rsi,%rdi)
	movb	%r13b, (%rsi,%rcx)
	movss	(%rdx,%rdi,4), %xmm0
	movss	(%rdx,%rcx,4), %xmm7
	movss	%xmm7, (%rdx,%rdi,4)
	movss	%xmm0, (%rdx,%rcx,4)
.L10:
	incq	%rdi
	cmpl	$3, %edi
	jne	.L12
	incq	%rcx
	cmpq	$3, %rcx
	jne	.L9
	cmpl	$3, %r12d
	jne	.L15
	ucomiss	8(%rax), %xmm2
	jp	.L16
	jne	.L16
	ucomiss	(%rax), %xmm6
	jp	.L33
	je	.L28
.L33:
	ucomiss	4(%rax), %xmm2
	jp	.L34
	je	.L20
.L34:
	leaq	8(%rax), %r13
	movl	$2, %ecx
	movl	$2, %edi
	movl	$8, %r12d
	jmp	.L22
.L28:
	movss	.LC1(%rip), %xmm0
	movq	%rax, %r13
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	xorl	%r12d, %r12d
.L18:
	movss	%xmm0, 0(%r13)
	movb	(%r8), %r13b
	movsd	.LC6(%rip), %xmm7
	movb	%r13b, (%rsi,%rdi)
	xorl	%edi, %edi
	movl	$0x41700000, (%rdx,%r12)
.L23:
	cmpl	$2, %edi
	jg	.L15
	cmpl	%edi, %ecx
	je	.L15
	cvtss2sd	(%rax,%rdi,4), %xmm0
	mulsd	%xmm7, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, (%rax,%rdi,4)
	incq	%rdi
	jmp	.L23
.L16:
	movb	(%r8), %cl
	movb	%cl, 2(%rsi)
	movss	%xmm3, 8(%rdx)
.L15:
	addq	$12, %rax
	addq	$12, %rdx
	addq	$3, %rsi
	incl	%ebx
	incq	%r8
	jmp	.L4
.L45:
	movq	-16(%rsp), %rax
	addq	%r14, -24(%rsp)
	incl	%r11d
	addq	%r14, -32(%rsp)
	addq	%r10, -40(%rsp)
	addq	%rax, %rbp
	jmp	.L3
.L20:
	leaq	4(%rax), %r13
	movl	$1, %ecx
	movl	$1, %edi
	movl	$4, %r12d
.L22:
	movss	.LC0(%rip), %xmm0
	jmp	.L18
.L44:
	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
.LFE3635:
	.size	_Z8trainGMMPhS_PfS0_S_ii, .-_Z8trainGMMPhS_PfS0_S_ii
	.globl	_Z7testGMMPhS_PfS0_S_ii
	.type	_Z7testGMMPhS_PfS0_S_ii, @function
_Z7testGMMPhS_PfS0_S_ii:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movsd	.LC7(%rip), %xmm2
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movsd	.LC8(%rip), %xmm3
	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
	movslq	56(%rsp), %rax
	movq	%rdi, -24(%rsp)
	imull	$3, 56(%rsp), %edi
	movq	%rdx, -40(%rsp)
	movq	%rax, -32(%rsp)
	movslq	%edi, %rdi
	movl	%r9d, -12(%rsp)
	xorl	%r9d, %r9d
	leaq	0(,%rdi,4), %r13
.L47:
	movl	-12(%rsp), %eax
	cmpl	%eax, %r15d
	jge	.L60
	movq	-24(%rsp), %rdx
	movq	-40(%rsp), %r10
	movq	%rcx, %r11
	movq	%r8, %rbx
	leaq	(%rsi,%r9), %r14
	xorl	%eax, %eax
	addq	%r9, %rdx
	movq	%rdx, -8(%rsp)
.L48:
	cmpl	%eax, 56(%rsp)
	jle	.L61
	movq	-8(%rsp), %rdx
	xorps	%xmm0, %xmm0
	movzbl	(%rdx,%rax), %edx
	movl	%edx, -16(%rsp)
	xorl	%edx, %edx
.L53:
	movzbl	(%rbx,%rdx), %r12d
	movl	-16(%rsp), %ebp
	cvtss2sd	(%r11,%rdx,4), %xmm1
	mulsd	%xmm2, %xmm1
	subl	%r12d, %ebp
	movl	%ebp, %r12d
	negl	%r12d
	cmovs	%ebp, %r12d
	cvttsd2sil	%xmm1, %ebp
	movzbl	%bpl, %ebp
	cmpl	%ebp, %r12d
	jge	.L49
	movb	$0, (%r14,%rax)
	jmp	.L50
.L49:
	addss	(%r10,%rdx,4), %xmm0
	cvtss2sd	%xmm0, %xmm1
	comisd	%xmm3, %xmm1
	jb	.L58
	movb	$-1, (%r14,%rax)
	jmp	.L50
.L58:
	incq	%rdx
	cmpq	$3, %rdx
	jne	.L53
.L50:
	addq	$12, %r10
	addq	$12, %r11
	addq	$3, %rbx
	incq	%rax
	jmp	.L48
.L61:
	movq	-32(%rsp), %rax
	addq	%r13, -40(%rsp)
	incl	%r15d
	addq	%r13, %rcx
	addq	%rdi, %r8
	addq	%rax, %r9
	jmp	.L47
.L60:
	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
.LFE3636:
	.size	_Z7testGMMPhS_PfS0_S_ii, .-_Z7testGMMPhS_PfS0_S_ii
	.globl	_Z44__device_stub__Z13trainGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii
	.type	_Z44__device_stub__Z13trainGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii, @function
_Z44__device_stub__Z13trainGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii:
.LFB3662:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movl	%r9d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L62
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z13trainGMM_CUDAPhS_PfS0_S_ii(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L62:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L64
	call	__stack_chk_fail@PLT
.L64:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3662:
	.size	_Z44__device_stub__Z13trainGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii, .-_Z44__device_stub__Z13trainGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii
	.globl	_Z13trainGMM_CUDAPhS_PfS0_S_ii
	.type	_Z13trainGMM_CUDAPhS_PfS0_S_ii, @function
_Z13trainGMM_CUDAPhS_PfS0_S_ii:
.LFB3663:
	.cfi_startproc
	endbr64
	jmp	_Z44__device_stub__Z13trainGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii
	.cfi_endproc
.LFE3663:
	.size	_Z13trainGMM_CUDAPhS_PfS0_S_ii, .-_Z13trainGMM_CUDAPhS_PfS0_S_ii
	.globl	_Z43__device_stub__Z12testGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii
	.type	_Z43__device_stub__Z12testGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii, @function
_Z43__device_stub__Z12testGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii:
.LFB3664:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movl	%r9d, 4(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L67
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z12testGMM_CUDAPhS_PfS0_S_ii(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L67:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L69
	call	__stack_chk_fail@PLT
.L69:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3664:
	.size	_Z43__device_stub__Z12testGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii, .-_Z43__device_stub__Z12testGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii
	.globl	_Z12testGMM_CUDAPhS_PfS0_S_ii
	.type	_Z12testGMM_CUDAPhS_PfS0_S_ii, @function
_Z12testGMM_CUDAPhS_PfS0_S_ii:
.LFB3665:
	.cfi_startproc
	endbr64
	jmp	_Z43__device_stub__Z12testGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii
	.cfi_endproc
.LFE3665:
	.size	_Z12testGMM_CUDAPhS_PfS0_S_ii, .-_Z12testGMM_CUDAPhS_PfS0_S_ii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC10:
	.string	"CPU: "
.LC13:
	.string	"GPU: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$24883200, %edi
	movabsq	$34359738400, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	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	$152, %rsp
	.cfi_def_cfa_offset 208
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	call	_Znam@PLT
	movl	$24883200, %edi
	movq	%rax, %rbx
	call	_Znam@PLT
	movl	$6220800, %edi
	movq	%rax, %rbp
	call	_Znam@PLT
	movl	$2073600, %edi
	movq	%rax, %r12
	call	_Znam@PLT
	movl	$2073600, %edi
	movq	%rax, %r13
	call	_Znam@PLT
	movl	$2073600, %edi
	movq	%rax, 24(%rsp)
	call	_Znam@PLT
	movq	%r14, (%rbx)
	leaq	72(%rsp), %rdi
	movl	$24883200, %esi
	movq	%r14, 0(%rbp)
	movq	%r14, (%r12)
	movq	%rax, 40(%rsp)
	call	cudaMalloc@PLT
	leaq	80(%rsp), %rdi
	movl	$24883200, %esi
	call	cudaMalloc@PLT
	leaq	104(%rsp), %rdi
	movl	$6220800, %esi
	call	cudaMalloc@PLT
	leaq	88(%rsp), %rdi
	movl	$2073600, %esi
	call	cudaMalloc@PLT
	leaq	96(%rsp), %rdi
	movl	$2073600, %esi
	call	cudaMalloc@PLT
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$24883200, %edx
	call	cudaMemcpy@PLT
	movq	80(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$24883200, %edx
	call	cudaMemcpy@PLT
	movq	104(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$6220800, %edx
	call	cudaMemcpy@PLT
	xorl	%edi, %edi
	movl	$1, 120(%rsp)
	movabsq	$1030792151074, %rax
	movq	%rax, 124(%rsp)
	movl	$1, 132(%rsp)
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	movl	$100, 36(%rsp)
	movq	$0x000000000, 16(%rsp)
	movq	$0x000000000, 8(%rsp)
.L73:
	xorl	%r14d, %r14d
.L79:
	xorl	%esi, %esi
	leaq	0(%r13,%r14), %rdi
.L74:
	movq	%rdi, 56(%rsp)
	movq	%rsi, 48(%rsp)
	call	rand@PLT
	movl	$255, %ecx
	movq	48(%rsp), %rsi
	movq	56(%rsp), %rdi
	cltd
	idivl	%ecx
	movb	%dl, (%rdi,%rsi)
	incq	%rsi
	cmpq	$1920, %rsi
	jne	.L74
	addq	$1920, %r14
	cmpq	$2073600, %r14
	jne	.L79
	call	clock@PLT
	movq	%r12, %r8
	movq	%rbp, %rcx
	movq	%rbx, %rdx
	pushq	%r9
	.cfi_def_cfa_offset 216
	movq	%r13, %rdi
	movl	$1080, %r9d
	movq	%rax, %r14
	pushq	$1920
	.cfi_def_cfa_offset 224
	movq	40(%rsp), %rsi
	call	_Z8trainGMMPhS_PfS0_S_ii
	movq	40(%rsp), %rsi
	movq	%r12, %r8
	movq	%rbp, %rcx
	movq	%rbx, %rdx
	movq	%r13, %rdi
	movl	$1920, (%rsp)
	call	_Z7testGMMPhS_PfS0_S_ii
	call	clock@PLT
	subq	%r14, %rax
	cvtsi2sdq	%rax, %xmm0
	addsd	24(%rsp), %xmm0
	movsd	%xmm0, 24(%rsp)
	call	clock@PLT
	popq	%r10
	.cfi_def_cfa_offset 216
	popq	%r11
	.cfi_def_cfa_offset 208
	movl	$1, %ecx
	movq	88(%rsp), %rdi
	movl	$2073600, %edx
	movq	%r13, %rsi
	movq	%rax, %r14
	call	cudaMemcpy@PLT
	movl	120(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	124(%rsp), %rdi
	movl	132(%rsp), %esi
	movq	%r15, %rdx
	movq	%r15, 112(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L76
	pushq	%rsi
	.cfi_def_cfa_offset 216
	movl	$1080, %r9d
	pushq	$1920
	.cfi_def_cfa_offset 224
	movq	120(%rsp), %r8
	movq	96(%rsp), %rcx
	movq	88(%rsp), %rdx
	movq	112(%rsp), %rsi
	movq	104(%rsp), %rdi
	call	_Z44__device_stub__Z13trainGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii
	popq	%rdi
	.cfi_def_cfa_offset 216
	popq	%r8
	.cfi_def_cfa_offset 208
.L76:
	movl	120(%rsp), %ecx
	movq	112(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	124(%rsp), %rdi
	movl	132(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L77
	pushq	%rax
	.cfi_def_cfa_offset 216
	movl	$1080, %r9d
	pushq	$1920
	.cfi_def_cfa_offset 224
	movq	120(%rsp), %r8
	movq	96(%rsp), %rcx
	movq	88(%rsp), %rdx
	movq	112(%rsp), %rsi
	movq	104(%rsp), %rdi
	call	_Z43__device_stub__Z12testGMM_CUDAPhS_PfS0_S_iiPhS_PfS0_S_ii
	popq	%rdx
	.cfi_def_cfa_offset 216
	popq	%rcx
	.cfi_def_cfa_offset 208
.L77:
	movq	96(%rsp), %rsi
	movq	40(%rsp), %rdi
	movl	$2, %ecx
	movl	$2073600, %edx
	call	cudaMemcpy@PLT
	call	clock@PLT
	subq	%r14, %rax
	decl	36(%rsp)
	cvtsi2sdq	%rax, %xmm0
	addsd	16(%rsp), %xmm0
	movsd	%xmm0, 16(%rsp)
	jne	.L73
	leaq	_ZSt4cout(%rip), %rbx
	leaq	.LC10(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	8(%rsp), %xmm0
	divsd	.LC11(%rip), %xmm0
	divsd	.LC12(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	.LC13(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	16(%rsp), %xmm0
	divsd	.LC11(%rip), %xmm0
	divsd	.LC12(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L80
	call	__stack_chk_fail@PLT
.L80:
	addq	$152, %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
.LFE3637:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z12testGMM_CUDAPhS_PfS0_S_ii"
.LC15:
	.string	"_Z13trainGMM_CUDAPhS_PfS0_S_ii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3667:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z12testGMM_CUDAPhS_PfS0_S_ii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC15(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z13trainGMM_CUDAPhS_PfS0_S_ii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.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.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	1000593162
	.align 4
.LC1:
	.long	1065353216
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC2:
	.long	0
	.long	1074266112
	.align 8
.LC3:
	.long	1202590843
	.long	1064598241
	.section	.rodata.cst4
	.align 4
.LC5:
	.long	1097859072
	.section	.rodata.cst8
	.align 8
.LC6:
	.long	1030792151
	.long	1072682762
	.align 8
.LC7:
	.long	0
	.long	1074003968
	.align 8
.LC8:
	.long	1717986918
	.long	1072064102
	.align 8
.LC11:
	.long	0
	.long	1079574528
	.align 8
.LC12:
	.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 <hip/hip_runtime.h>
#include<iostream>
#include<cstring>
#include<cstdlib>

#define GMM_MAX_COMPONT 3	
#define GMM_LEARN_ALPHA 0.005  
#define GMM_THRESHOD_SUMW 0.7
#define HEIGHT 1080
#define WIDTH 1920

using namespace std;

__global__ void trainGMM_CUDA(unsigned char *_image, unsigned char *mask, float *modelW, float *modelS, unsigned char *modelM, int height, int width)
{
  const int x = blockIdx.x * blockDim.x + threadIdx.x;
  const int y = blockIdx.y * blockDim.y + threadIdx.y;

  if (x >= height || y >= width)
    return; 
 
  unsigned char *_imageData = _image + x * width + y;
 
  float *modelWData = modelW + GMM_MAX_COMPONT * (x * width + y);
  float *modelSData = modelS + GMM_MAX_COMPONT * (x * width + y);
  unsigned char *modelMData = modelM + GMM_MAX_COMPONT * (x * width + y);

	int num_fit = 0;
	
  for (int k = 0; k < GMM_MAX_COMPONT; k++)
	{
		int delm = abs(_imageData[0] - modelMData[k]);
		long dist = delm * delm;
		if (dist < 3.0 * modelSData[k])
		{
			modelWData[k] += GMM_LEARN_ALPHA * (1 - modelWData[k]);
			modelMData[k] += (GMM_LEARN_ALPHA / modelWData[k]) * delm;
			modelSData[k] += (GMM_LEARN_ALPHA / modelWData[k]) * (dist - modelSData[k]);
		}
		else
		{
			modelWData[k] += GMM_LEARN_ALPHA * (0 - modelWData[k]);
			num_fit++;
		}
	}

	for (int kk = 0; kk < GMM_MAX_COMPONT; kk++)
	{
		for (int rr = kk; rr< GMM_MAX_COMPONT; rr++)
		{
			if (modelWData[rr] / modelSData[rr] > modelWData[kk] / modelSData[kk])
			{
				float temp_weight = modelWData[rr];
				modelWData[rr] = modelWData[kk];
				modelWData[kk] = temp_weight;
				unsigned char temp_mean = modelMData[rr];
			  modelMData[rr] = modelMData[kk];
				modelMData[kk] = temp_mean;

				float temp_sigma = modelSData[rr];
				modelSData[rr] = modelSData[kk];
				modelSData[kk] = temp_sigma;
			}
		}
	}
	
  if (num_fit == GMM_MAX_COMPONT && modelWData[GMM_MAX_COMPONT - 1] == 0)
	{
		for (int k = 0; k < GMM_MAX_COMPONT; k++)
		{
			if (0 == modelWData[k])
			{
				if (k == 0)
				  modelWData[k] = 1;
				else
				  modelWData[k] = GMM_LEARN_ALPHA;
				
        modelMData[k] = _imageData[0];
				modelSData[k] = 15.0;

				for (int q = 0; q < GMM_MAX_COMPONT && q != k; q++)
				{
					modelWData[q] *= (1 - GMM_LEARN_ALPHA);
				}
				break;
			}
		}
	}
	else if (num_fit == GMM_MAX_COMPONT && modelWData[GMM_MAX_COMPONT - 1] != 0)
	{
		modelMData[GMM_MAX_COMPONT - 1] = _imageData[0];
		modelSData[GMM_MAX_COMPONT - 1] = 15.0;
	}
}

__global__ void testGMM_CUDA(unsigned char *_image, unsigned char *mask, float *modelW, float *modelS, unsigned char *modelM, int height, int width)
{
  const int x = blockIdx.x * blockDim.x + threadIdx.x;
  const int y = blockIdx.y * blockDim.y + threadIdx.y;
  
  if (x >= height || y >= width)
    return; 
 
  unsigned char *_imageData = _image + x * width + y;
  unsigned char *maskData = mask + x * width + y;
 
  float *modelWData = modelW + GMM_MAX_COMPONT * (x * width + y);
  float *modelSData = modelS + GMM_MAX_COMPONT * (x * width + y);
  unsigned char *modelMData = modelM + GMM_MAX_COMPONT * (x * width + y);
	
	float sum_w = 0.0;
	for (unsigned char k = 0; k < GMM_MAX_COMPONT; k++)
	{
		if (abs(_imageData[0] - modelMData[k]) < (unsigned char)(2.5 * modelSData[k]))
		{
			maskData[0] = 0;
			break;
		}
			sum_w += modelWData[k];
		if (sum_w >= GMM_THRESHOD_SUMW)
		{
			maskData[0] = 255;
			break;
		}
	}
}

void trainGMM(unsigned char *_image, unsigned char *mask, float *modelW, float *modelS, unsigned char *modelM, int height, int width)
{
	/**************************** Train ******************************************/
	for (int i = 0; i < height; i++)
	{
		float *modelWData = modelW + i * width * GMM_MAX_COMPONT;
		float *modelSData = modelS + i * width * GMM_MAX_COMPONT;
		unsigned char *modelMData = modelM + i * width * GMM_MAX_COMPONT;
		const unsigned char *_imageData = _image + i * width;
		for (int j = 0; j < width; j++)
		{
			int num_fit = 0;

			/**************************** Update parameters Start ******************************************/
			for (int k = 0; k < GMM_MAX_COMPONT; k++)
			{
				int delm = abs(_imageData[j] - modelMData[k]);
				long dist = delm * delm;
				if (dist < 3.0 * modelSData[k])
				{
					modelWData[k] += GMM_LEARN_ALPHA * (1 - modelWData[k]);
					modelMData[k] += (GMM_LEARN_ALPHA / modelWData[k]) * delm;
					modelSData[k] += (GMM_LEARN_ALPHA / modelWData[k]) * (dist - modelSData[k]);
				}
				else
				{
					modelWData[k] += GMM_LEARN_ALPHA * (0 - modelWData[k]);
					num_fit++;
				}
			}
			/**************************** Update parameters End ******************************************/

			/*********************** Sort Gaussian component by 'weight / sigma' Start ****************************/
			for (int kk = 0; kk < GMM_MAX_COMPONT; kk++)
			{
				for (int rr = kk; rr< GMM_MAX_COMPONT; rr++)
				{
					if (modelWData[rr] / modelSData[rr] > modelWData[kk] / modelSData[kk])
					{
						float temp_weight = modelWData[rr];
						modelWData[rr] = modelWData[kk];
						modelWData[kk] = temp_weight;

						unsigned char temp_mean = modelMData[rr];
						modelMData[rr] = modelMData[kk];
						modelMData[kk] = temp_mean;

						float temp_sigma = modelSData[rr];
						modelSData[rr] = modelSData[kk];
						modelSData[kk] = temp_sigma;
					}
				}
			}
			/*********************** Sort Gaussian model by 'weight / sigma' End ****************************/

			/*********************** Create new Gaussian component Start ****************************/
			if (num_fit == GMM_MAX_COMPONT && modelWData[GMM_MAX_COMPONT - 1] == 0)
			{
				//if there is no exit component fit,then start a new component
				for (int k = 0; k < GMM_MAX_COMPONT; k++)
				{
					if (0 == modelWData[k])
					{
						if (k == 0)
							modelWData[k] = 1;
						else
							modelWData[k] = GMM_LEARN_ALPHA;
						
            modelMData[k] = _imageData[j];
						modelSData[k] = 15.0;

						//normalization the weight,let they sum to 1
						for (int q = 0; q < GMM_MAX_COMPONT && q != k; q++)
						{
							/****update the other unfit's weight,u and sigma remain unchanged****/
							modelWData[q] *= (1 - GMM_LEARN_ALPHA);
						}
						break;
					}
				}
			}
			else if (num_fit == GMM_MAX_COMPONT && modelWData[GMM_MAX_COMPONT - 1] != 0)
			{
				modelMData[GMM_MAX_COMPONT - 1] = _imageData[j];
				modelSData[GMM_MAX_COMPONT - 1] = 15.0;
			}
			/*********************** Create new Gaussian component End ****************************/

			modelWData += GMM_MAX_COMPONT;
			modelSData += GMM_MAX_COMPONT;
			modelMData += GMM_MAX_COMPONT;
		}
	}
}

void testGMM(unsigned char* _image, unsigned char* mask, float* modelW, float* modelS, unsigned char* modelM, int height, int width)
{
	/*********************** Predict ****************************/
	for (int i = 0; i < height; i++)
	{
		float *modelWData = modelW + i * width * GMM_MAX_COMPONT;
		float *modelSData = modelS + i * width * GMM_MAX_COMPONT;
		unsigned char *modelMData = modelM + i * width * GMM_MAX_COMPONT;
		const unsigned char *_imageData = _image + i * width;
		unsigned char *maskData = mask + i * width;
		for (int j = 0; j < width; j++)
		{
			float sum_w = 0.0;
			for (unsigned char k = 0; k < GMM_MAX_COMPONT; k++)
			{
				if (abs(_imageData[j] - modelMData[k]) < (unsigned char)(2.5 * modelSData[k]))
				{
					maskData[j] = 0;
					break;
				}
				sum_w += modelWData[k];
				if (sum_w >= GMM_THRESHOD_SUMW)
				{
					maskData[j] = 255;
					break;
				}
			}
			modelWData += GMM_MAX_COMPONT;
			modelSData += GMM_MAX_COMPONT;
			modelMData += GMM_MAX_COMPONT;
		}
	}
}

int main()
{	
  float *modelW = new float[HEIGHT * GMM_MAX_COMPONT * WIDTH];
  float *modelS = new float[HEIGHT * GMM_MAX_COMPONT * WIDTH];
  unsigned char *modelM = new unsigned char[HEIGHT * GMM_MAX_COMPONT * WIDTH];;
  unsigned char *frame = new unsigned char[HEIGHT * WIDTH];
  unsigned char *mask = new unsigned char[HEIGHT * WIDTH];
  unsigned char *mask2 = new unsigned char[HEIGHT * WIDTH];
  int height = HEIGHT;
  int width = WIDTH;  

  memset(modelW, 0, sizeof(modelW));
  memset(modelS, 0, sizeof(modelM));
  memset(modelM, 0, sizeof(modelS));
  memset(mask, 0, sizeof(mask));

  // For GPU  
  float *dev_modelW, *dev_modelS;
  unsigned char *dev_frame, *dev_mask, *dev_modelM;

  hipMalloc((void**)&dev_modelW, (HEIGHT * GMM_MAX_COMPONT * WIDTH) * sizeof(float));
  hipMalloc((void**)&dev_modelS, (HEIGHT * GMM_MAX_COMPONT * WIDTH) * sizeof(float));
  hipMalloc((void**)&dev_modelM, (HEIGHT * GMM_MAX_COMPONT * WIDTH) * sizeof(unsigned char));
  hipMalloc((void**)&dev_frame, (HEIGHT * WIDTH) * sizeof(unsigned char));
  hipMalloc((void**)&dev_mask, (HEIGHT * WIDTH) * sizeof(unsigned char));

  hipMemcpy(dev_modelW,
             modelW,
             HEIGHT * GMM_MAX_COMPONT * WIDTH * sizeof(float),
             hipMemcpyHostToDevice);
  hipMemcpy(dev_modelS,
             modelS,
             HEIGHT * GMM_MAX_COMPONT * WIDTH * sizeof(float),
             hipMemcpyHostToDevice);
  hipMemcpy(dev_modelM,
             modelM,
             HEIGHT * GMM_MAX_COMPONT * WIDTH * sizeof(unsigned char),
             hipMemcpyHostToDevice);
  
  dim3 block(32,8);
  dim3 grid((HEIGHT + block.x - 1) / block.x, 
					  (WIDTH + block.y - 1) / block.y);

  clock_t start, end;
  clock_t start2, end2;
	double sum_t = 0;
	double sum_t2 = 0;
	 
  srand(unsigned(time(0)));  

  int frame_num = 100;
  for (int t = 0; t < frame_num; t++)
  {
    for (int i = 0; i < height; i++)
      for (int j = 0; j < width; j++)
        *(frame + i * width + j) = rand() % 255;
    
    start = clock();  
    trainGMM(frame, mask, modelW, modelS, modelM, height, width);
    testGMM(frame, mask, modelW, modelS, modelM, height, width);
    end = clock();
    sum_t += end - start;

    start2 = clock();
    hipMemcpy(dev_frame,
               frame,
               HEIGHT * WIDTH * sizeof(unsigned char),
               hipMemcpyHostToDevice);
    trainGMM_CUDA<<<grid, block>>>(dev_frame, dev_mask,  dev_modelW, dev_modelS, dev_modelM, height, width);    
    testGMM_CUDA<<<grid, block>>>(dev_frame, dev_mask,  dev_modelW, dev_modelS, dev_modelM, height, width);    
    hipMemcpy(mask2,
               dev_mask,
               HEIGHT * WIDTH * sizeof(unsigned char),
               hipMemcpyDeviceToHost);
    end2 = clock();
    sum_t2 += end2 - start2;
  
  // TEST
  /*
  int diff_count = 0;
  for (int i = 0; i < height * width; i++)
    if (mask[i] != mask2[i])
      diff_count++;
  
  cout <<"Diff: " << diff_count << endl;
  */
  }
	cout <<"CPU: " << (sum_t / frame_num) / CLOCKS_PER_SEC << endl;
	cout <<"GPU: " << (sum_t2 / frame_num) / CLOCKS_PER_SEC << endl;
}

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

                                        # End of file scope inline assembly
	.globl	_Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii # -- Begin function _Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii
	.type	_Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii,@function
_Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii: # @_Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.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	4(%rsp), %r8
	movl	%r9d, (%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	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%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	$_Z13trainGMM_CUDAPhS_PfS0_S_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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__trainGMM_CUDAPhS_PfS0_S_ii, .Lfunc_end0-_Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii # -- Begin function _Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii
	.type	_Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii,@function
_Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii: # @_Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.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	4(%rsp), %r8
	movl	%r9d, (%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	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%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	$_Z12testGMM_CUDAPhS_PfS0_S_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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_end1:
	.size	_Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii, .Lfunc_end1-_Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z8trainGMMPhS_PfS0_S_ii
.LCPI2_0:
	.quad	0x4008000000000000              # double 3
.LCPI2_1:
	.quad	0x3f747ae147ae147b              # double 0.0050000000000000001
.LCPI2_3:
	.long	0x3ba3d70a                      # float 0.00499999989
	.long	0x3f800000                      # float 1
.LCPI2_4:
	.quad	0x3fefd70a3d70a3d7              # double 0.99499999999999999
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI2_2:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z8trainGMMPhS_PfS0_S_ii
	.type	_Z8trainGMMPhS_PfS0_S_ii,@function
_Z8trainGMMPhS_PfS0_S_ii:               # @_Z8trainGMMPhS_PfS0_S_ii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r8, -16(%rsp)                  # 8-byte Spill
	movq	%rcx, -24(%rsp)                 # 8-byte Spill
	movq	%rdx, -32(%rsp)                 # 8-byte Spill
	movq	%rdi, -40(%rsp)                 # 8-byte Spill
	testl	%r9d, %r9d
	jle	.LBB2_8
# %bb.1:                                # %.lr.ph150
	movslq	56(%rsp), %rax
	movl	%r9d, %ecx
	movq	%rcx, -8(%rsp)                  # 8-byte Spill
	movq	%rax, -48(%rsp)                 # 8-byte Spill
	movl	%eax, %r10d
	xorl	%r11d, %r11d
	movsd	.LCPI2_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movss	.LCPI2_2(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movsd	.LCPI2_1(%rip), %xmm2           # xmm2 = mem[0],zero
	xorps	%xmm3, %xmm3
	movsd	.LCPI2_4(%rip), %xmm4           # xmm4 = mem[0],zero
.LBB2_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
                                        #       Child Loop BB2_5 Depth 3
                                        #       Child Loop BB2_12 Depth 3
                                        #         Child Loop BB2_13 Depth 4
                                        #       Child Loop BB2_20 Depth 3
                                        #       Child Loop BB2_23 Depth 3
	cmpl	$0, 56(%rsp)
	jle	.LBB2_7
# %bb.3:                                # %.preheader134.preheader
                                        #   in Loop: Header=BB2_2 Depth=1
	movq	%r11, %rax
	imulq	-48(%rsp), %rax                 # 8-byte Folded Reload
	movq	-40(%rsp), %rcx                 # 8-byte Reload
	leaq	(%rcx,%rax), %r14
	leaq	(%rax,%rax,2), %rax
	movq	-16(%rsp), %rcx                 # 8-byte Reload
	addq	%rax, %rcx
	movq	-24(%rsp), %rdx                 # 8-byte Reload
	leaq	(%rdx,%rax,4), %r8
	movq	-32(%rsp), %rdx                 # 8-byte Reload
	leaq	(%rdx,%rax,4), %r13
	xorl	%ebp, %ebp
.LBB2_4:                                # %.preheader134
                                        #   Parent Loop BB2_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_5 Depth 3
                                        #       Child Loop BB2_12 Depth 3
                                        #         Child Loop BB2_13 Depth 4
                                        #       Child Loop BB2_20 Depth 3
                                        #       Child Loop BB2_23 Depth 3
	xorl	%esi, %esi
	xorl	%eax, %eax
.LBB2_5:                                #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movzbl	(%r14,%rbp), %edi
	movzbl	(%rcx,%rsi), %edx
	subl	%edx, %edi
	movl	%edi, %edx
	imull	%edi, %edx
	xorps	%xmm5, %xmm5
	cvtsi2sd	%edx, %xmm5
	xorps	%xmm6, %xmm6
	cvtss2sd	(%r8,%rsi,4), %xmm6
	mulsd	%xmm0, %xmm6
	ucomisd	%xmm5, %xmm6
	jbe	.LBB2_9
# %bb.6:                                #   in Loop: Header=BB2_5 Depth=3
	movl	%edi, %r15d
	negl	%r15d
	cmovsl	%edi, %r15d
	movss	(%r13,%rsi,4), %xmm5            # xmm5 = mem[0],zero,zero,zero
	movaps	%xmm1, %xmm6
	subss	%xmm5, %xmm6
	cvtss2sd	%xmm6, %xmm6
	mulsd	%xmm2, %xmm6
	cvtss2sd	%xmm5, %xmm5
	addsd	%xmm6, %xmm5
	cvtsd2ss	%xmm5, %xmm5
	movss	%xmm5, (%r13,%rsi,4)
	cvtss2sd	%xmm5, %xmm5
	movapd	%xmm2, %xmm6
	divsd	%xmm5, %xmm6
	xorps	%xmm5, %xmm5
	cvtsi2sd	%r15d, %xmm5
	mulsd	%xmm6, %xmm5
	movzbl	(%rcx,%rsi), %edi
	xorps	%xmm6, %xmm6
	cvtsi2sd	%edi, %xmm6
	addsd	%xmm5, %xmm6
	cvttsd2si	%xmm6, %edi
	movb	%dil, (%rcx,%rsi)
	xorps	%xmm5, %xmm5
	cvtss2sd	(%r13,%rsi,4), %xmm5
	movapd	%xmm2, %xmm6
	divsd	%xmm5, %xmm6
	xorps	%xmm5, %xmm5
	cvtsi2ss	%edx, %xmm5
	movss	(%r8,%rsi,4), %xmm7             # xmm7 = mem[0],zero,zero,zero
	subss	%xmm7, %xmm5
	cvtss2sd	%xmm5, %xmm5
	mulsd	%xmm6, %xmm5
	xorps	%xmm6, %xmm6
	cvtss2sd	%xmm7, %xmm6
	addsd	%xmm5, %xmm6
	xorps	%xmm5, %xmm5
	cvtsd2ss	%xmm6, %xmm5
	movss	%xmm5, (%r8,%rsi,4)
	jmp	.LBB2_10
.LBB2_9:                                #   in Loop: Header=BB2_5 Depth=3
	movss	(%r13,%rsi,4), %xmm5            # xmm5 = mem[0],zero,zero,zero
	xorpd	%xmm6, %xmm6
	subss	%xmm5, %xmm6
	cvtss2sd	%xmm6, %xmm6
	mulsd	%xmm2, %xmm6
	cvtss2sd	%xmm5, %xmm5
	addsd	%xmm6, %xmm5
	cvtsd2ss	%xmm5, %xmm5
	movss	%xmm5, (%r13,%rsi,4)
	incl	%eax
.LBB2_10:                               #   in Loop: Header=BB2_5 Depth=3
	incq	%rsi
	cmpq	$3, %rsi
	jne	.LBB2_5
# %bb.11:                               # %.preheader.preheader
                                        #   in Loop: Header=BB2_4 Depth=2
	movq	%r13, %rsi
	movq	%r8, %r12
	movq	%rcx, %r15
	xorl	%edx, %edx
.LBB2_12:                               # %.preheader
                                        #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB2_13 Depth 4
	movss	(%r8,%rdx,4), %xmm5             # xmm5 = mem[0],zero,zero,zero
	movq	$-3, %rdi
.LBB2_13:                               #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        #       Parent Loop BB2_12 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movss	12(%rsi,%rdi,4), %xmm6          # xmm6 = mem[0],zero,zero,zero
	movaps	%xmm6, %xmm8
	divss	12(%r12,%rdi,4), %xmm8
	movss	(%r13,%rdx,4), %xmm7            # xmm7 = mem[0],zero,zero,zero
	movaps	%xmm7, %xmm9
	divss	%xmm5, %xmm9
	ucomiss	%xmm9, %xmm8
	jbe	.LBB2_15
# %bb.14:                               #   in Loop: Header=BB2_13 Depth=4
	movss	%xmm7, 12(%rsi,%rdi,4)
	movss	%xmm6, (%r13,%rdx,4)
	movb	3(%r15,%rdi), %r9b
	movb	(%rcx,%rdx), %bl
	movb	%bl, 3(%r15,%rdi)
	movb	%r9b, (%rcx,%rdx)
	movss	12(%r12,%rdi,4), %xmm5          # xmm5 = mem[0],zero,zero,zero
	movss	(%r8,%rdx,4), %xmm6             # xmm6 = mem[0],zero,zero,zero
	movss	%xmm6, 12(%r12,%rdi,4)
	movss	%xmm5, (%r8,%rdx,4)
.LBB2_15:                               #   in Loop: Header=BB2_13 Depth=4
	incq	%rdi
	movq	%rdx, %r9
	addq	%rdi, %r9
	jne	.LBB2_13
# %bb.16:                               #   in Loop: Header=BB2_12 Depth=3
	incq	%rdx
	incq	%r15
	addq	$4, %r12
	addq	$4, %rsi
	cmpq	$3, %rdx
	jne	.LBB2_12
# %bb.17:                               #   in Loop: Header=BB2_4 Depth=2
	cmpl	$3, %eax
	jne	.LBB2_26
# %bb.18:                               #   in Loop: Header=BB2_4 Depth=2
	movss	8(%r13), %xmm5                  # xmm5 = mem[0],zero,zero,zero
	ucomiss	%xmm3, %xmm5
	jne	.LBB2_25
	jp	.LBB2_25
# %bb.19:                               # %.preheader131.preheader
                                        #   in Loop: Header=BB2_4 Depth=2
	movl	$-1, %eax
	xorl	%edx, %edx
.LBB2_20:                               # %.preheader131
                                        #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r13,%rdx,4), %xmm5            # xmm5 = mem[0],zero,zero,zero
	ucomiss	%xmm3, %xmm5
	jne	.LBB2_24
	jnp	.LBB2_21
.LBB2_24:                               #   in Loop: Header=BB2_20 Depth=3
	incq	%rdx
	incl	%eax
	cmpq	$3, %rdx
	jne	.LBB2_20
	jmp	.LBB2_26
.LBB2_25:                               #   in Loop: Header=BB2_4 Depth=2
	movb	(%r14,%rbp), %al
	movb	%al, 2(%rcx)
	movl	$1097859072, 8(%r8)             # imm = 0x41700000
	jmp	.LBB2_26
.LBB2_21:                               #   in Loop: Header=BB2_4 Depth=2
	xorl	%esi, %esi
	testq	%rdx, %rdx
	sete	%sil
	movss	.LCPI2_3(,%rsi,4), %xmm5        # xmm5 = mem[0],zero,zero,zero
	movss	%xmm5, (%r13,%rdx,4)
	movb	(%r14,%rbp), %sil
	movb	%sil, (%rcx,%rdx)
	movl	$1097859072, (%r8,%rdx,4)       # imm = 0x41700000
	je	.LBB2_26
# %bb.22:                               # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_4 Depth=2
	movl	%eax, %eax
	cmpq	$2, %rax
	movl	$2, %edx
	cmovaeq	%rdx, %rax
	incq	%rax
	xorl	%edx, %edx
.LBB2_23:                               # %.lr.ph
                                        #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	xorps	%xmm5, %xmm5
	cvtss2sd	(%r13,%rdx,4), %xmm5
	mulsd	%xmm4, %xmm5
	cvtsd2ss	%xmm5, %xmm5
	movss	%xmm5, (%r13,%rdx,4)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB2_23
.LBB2_26:                               # %.critedge
                                        #   in Loop: Header=BB2_4 Depth=2
	addq	$12, %r13
	addq	$12, %r8
	addq	$3, %rcx
	incq	%rbp
	cmpq	%r10, %rbp
	jne	.LBB2_4
.LBB2_7:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r11
	cmpq	-8(%rsp), %r11                  # 8-byte Folded Reload
	jne	.LBB2_2
.LBB2_8:                                # %._crit_edge151
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z8trainGMMPhS_PfS0_S_ii, .Lfunc_end2-_Z8trainGMMPhS_PfS0_S_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7testGMMPhS_PfS0_S_ii
.LCPI3_0:
	.quad	0x4004000000000000              # double 2.5
.LCPI3_1:
	.quad	0x3fe6666666666666              # double 0.69999999999999996
	.text
	.globl	_Z7testGMMPhS_PfS0_S_ii
	.type	_Z7testGMMPhS_PfS0_S_ii,@function
_Z7testGMMPhS_PfS0_S_ii:                # @_Z7testGMMPhS_PfS0_S_ii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r8, -8(%rsp)                   # 8-byte Spill
	movq	%rcx, -16(%rsp)                 # 8-byte Spill
	movq	%rdx, -24(%rsp)                 # 8-byte Spill
	movq	%rsi, -32(%rsp)                 # 8-byte Spill
	testl	%r9d, %r9d
	jle	.LBB3_6
# %bb.1:                                # %.lr.ph
	movslq	56(%rsp), %rsi
	movl	%r9d, %r9d
	movl	%esi, %r11d
	xorl	%ebx, %ebx
	movsd	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movsd	.LCPI3_1(%rip), %xmm1           # xmm1 = mem[0],zero
.LBB3_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
                                        #       Child Loop BB3_8 Depth 3
	cmpl	$0, 56(%rsp)
	jle	.LBB3_5
# %bb.3:                                # %.preheader.preheader
                                        #   in Loop: Header=BB3_2 Depth=1
	movq	%rbx, %rax
	imulq	%rsi, %rax
	leaq	(%rdi,%rax), %r14
	movq	-32(%rsp), %rcx                 # 8-byte Reload
	leaq	(%rcx,%rax), %r15
	leaq	(%rax,%rax,2), %rax
	movq	-8(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax), %r12
	movq	-16(%rsp), %rcx                 # 8-byte Reload
	leaq	(%rcx,%rax,4), %r13
	movq	-24(%rsp), %rcx                 # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbp
	xorl	%eax, %eax
.LBB3_4:                                # %.preheader
                                        #   Parent Loop BB3_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_8 Depth 3
	movzbl	(%r14,%rax), %edx
	xorps	%xmm2, %xmm2
	xorl	%r8d, %r8d
.LBB3_8:                                #   Parent Loop BB3_2 Depth=1
                                        #     Parent Loop BB3_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movzbl	(%r12,%r8), %ecx
	movl	%edx, %r10d
	subl	%ecx, %r10d
	movl	%r10d, %ecx
	negl	%ecx
	cmovsl	%r10d, %ecx
	xorps	%xmm3, %xmm3
	cvtss2sd	(%r13,%r8,4), %xmm3
	mulsd	%xmm0, %xmm3
	cvttsd2si	%xmm3, %r10d
	movzbl	%r10b, %r10d
	cmpl	%r10d, %ecx
	jb	.LBB3_9
# %bb.10:                               #   in Loop: Header=BB3_8 Depth=3
	addss	(%rbp,%r8,4), %xmm2
	xorps	%xmm3, %xmm3
	cvtss2sd	%xmm2, %xmm3
	ucomisd	%xmm1, %xmm3
	jae	.LBB3_11
# %bb.7:                                #   in Loop: Header=BB3_8 Depth=3
	incq	%r8
	cmpq	$3, %r8
	jne	.LBB3_8
	jmp	.LBB3_13
.LBB3_9:                                #   in Loop: Header=BB3_4 Depth=2
	xorl	%r8d, %r8d
	jmp	.LBB3_12
.LBB3_11:                               #   in Loop: Header=BB3_4 Depth=2
	movb	$-1, %r8b
.LBB3_12:                               # %.loopexit.sink.split
                                        #   in Loop: Header=BB3_4 Depth=2
	movb	%r8b, (%r15,%rax)
.LBB3_13:                               # %.loopexit
                                        #   in Loop: Header=BB3_4 Depth=2
	addq	$12, %rbp
	addq	$12, %r13
	addq	$3, %r12
	incq	%rax
	cmpq	%r11, %rax
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	incq	%rbx
	cmpq	%r9, %rbx
	jne	.LBB3_2
.LBB3_6:                                # %._crit_edge54
	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_end3:
	.size	_Z7testGMMPhS_PfS0_S_ii, .Lfunc_end3-_Z7testGMMPhS_PfS0_S_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x4059000000000000              # double 100
.LCPI4_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	$136, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movabsq	$34359738400, %rbp              # imm = 0x800000020
	movl	$24883200, %edi                 # imm = 0x17BB000
	callq	_Znam
	movq	%rax, %r13
	movl	$24883200, %edi                 # imm = 0x17BB000
	callq	_Znam
	movq	%rax, %rbx
	movl	$6220800, %edi                  # imm = 0x5EEC00
	callq	_Znam
	movq	%rax, %r14
	movl	$2073600, %edi                  # imm = 0x1FA400
	callq	_Znam
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	movl	$2073600, %edi                  # imm = 0x1FA400
	callq	_Znam
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movl	$2073600, %edi                  # imm = 0x1FA400
	callq	_Znam
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	xorl	%r12d, %r12d
	movq	%r12, (%r13)
	movq	%r12, (%rbx)
	movq	%r12, (%r14)
	leaq	72(%rsp), %r15
	movl	$24883200, %esi                 # imm = 0x17BB000
	movq	%r15, %rdi
	callq	hipMalloc
	leaq	56(%rsp), %rdi
	movl	$24883200, %esi                 # imm = 0x17BB000
	callq	hipMalloc
	leaq	32(%rsp), %rdi
	movl	$6220800, %esi                  # imm = 0x5EEC00
	callq	hipMalloc
	leaq	48(%rsp), %rdi
	movl	$2073600, %esi                  # imm = 0x1FA400
	callq	hipMalloc
	leaq	40(%rsp), %rdi
	movl	$2073600, %esi                  # imm = 0x1FA400
	callq	hipMalloc
	movq	(%r15), %rdi
	movl	$24883200, %edx                 # imm = 0x17BB000
	movq	%r13, 112(%rsp)                 # 8-byte Spill
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	56(%rsp), %rax
	movq	(%rax), %rdi
	movl	$24883200, %edx                 # imm = 0x17BB000
	movq	%rbx, 104(%rsp)                 # 8-byte Spill
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	32(%rsp), %rax
	movq	(%rax), %rdi
	movl	$6220800, %edx                  # imm = 0x5EEC00
	movq	%r14, 96(%rsp)                  # 8-byte Spill
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	xorpd	%xmm0, %xmm0
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
.LBB4_1:                                # %.preheader75
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_2 Depth 2
                                        #       Child Loop BB4_3 Depth 3
	movq	64(%rsp), %rbx                  # 8-byte Reload
	xorl	%r14d, %r14d
.LBB4_2:                                # %.preheader
                                        #   Parent Loop BB4_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_3 Depth 3
	movq	$-1920, %r15                    # imm = 0xF880
.LBB4_3:                                #   Parent Loop BB4_1 Depth=1
                                        #     Parent Loop BB4_2 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	callq	rand
	cltq
	imulq	$-2139062143, %rax, %rcx        # imm = 0x80808081
	shrq	$32, %rcx
	addl	%eax, %ecx
	movl	%ecx, %edx
	shrl	$31, %edx
	shrl	$7, %ecx
	addl	%edx, %ecx
	addl	%eax, %ecx
	movb	%cl, 1920(%rbx,%r15)
	incq	%r15
	jne	.LBB4_3
# %bb.4:                                #   in Loop: Header=BB4_2 Depth=2
	incq	%r14
	addq	$1920, %rbx                     # imm = 0x780
	cmpq	$1080, %r14                     # imm = 0x438
	jne	.LBB4_2
# %bb.5:                                #   in Loop: Header=BB4_1 Depth=1
	movq	%r12, 128(%rsp)                 # 8-byte Spill
	callq	clock
	movq	%rax, 120(%rsp)                 # 8-byte Spill
	movl	$1920, %r12d                    # imm = 0x780
	movl	%r12d, (%rsp)
	movq	64(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	112(%rsp), %r14                 # 8-byte Reload
	movq	%r14, %rdx
	movq	104(%rsp), %r15                 # 8-byte Reload
	movq	%r15, %rcx
	movq	96(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %r8
	movl	$1080, %r9d                     # imm = 0x438
	callq	_Z8trainGMMPhS_PfS0_S_ii
	movl	%r12d, (%rsp)
	movq	%rbx, %rdi
	movq	88(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movq	%r15, %rcx
	movq	%r13, %r8
	movl	$1080, %r9d                     # imm = 0x438
	callq	_Z7testGMMPhS_PfS0_S_ii
	callq	clock
	movq	%rax, %r15
	callq	clock
	movq	%rax, %r14
	movq	48(%rsp), %rdi
	movl	$2073600, %edx                  # imm = 0x1FA400
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movabsq	$1030792151074, %r13            # imm = 0xF000000022
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_7
# %bb.6:                                #   in Loop: Header=BB4_1 Depth=1
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	72(%rsp), %rdx
	movq	56(%rsp), %rcx
	movq	32(%rsp), %r8
	movl	$1920, (%rsp)                   # imm = 0x780
	movl	$1080, %r9d                     # imm = 0x438
	callq	_Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii
.LBB4_7:                                #   in Loop: Header=BB4_1 Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movq	128(%rsp), %r12                 # 8-byte Reload
	jne	.LBB4_9
# %bb.8:                                #   in Loop: Header=BB4_1 Depth=1
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	72(%rsp), %rdx
	movq	56(%rsp), %rcx
	movq	32(%rsp), %r8
	movl	$1920, (%rsp)                   # imm = 0x780
	movl	$1080, %r9d                     # imm = 0x438
	callq	_Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii
.LBB4_9:                                #   in Loop: Header=BB4_1 Depth=1
	subq	120(%rsp), %r15                 # 8-byte Folded Reload
	cvtsi2sd	%r15, %xmm0
	movsd	16(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 16(%rsp)                 # 8-byte Spill
	movq	40(%rsp), %rsi
	movl	$2073600, %edx                  # imm = 0x1FA400
	movq	80(%rsp), %rdi                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	callq	clock
	subq	%r14, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	movsd	24(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 24(%rsp)                 # 8-byte Spill
	incl	%r12d
	cmpl	$100, %r12d
	jne	.LBB4_1
# %bb.10:
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$5, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	16(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	.LCPI4_0(%rip), %xmm0
	divsd	.LCPI4_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$5, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	.LCPI4_0(%rip), %xmm0
	divsd	.LCPI4_1(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	addq	$136, %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_end4:
	.size	main, .Lfunc_end4-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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13trainGMM_CUDAPhS_PfS0_S_ii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12testGMM_CUDAPhS_PfS0_S_ii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z13trainGMM_CUDAPhS_PfS0_S_ii,@object # @_Z13trainGMM_CUDAPhS_PfS0_S_ii
	.section	.rodata,"a",@progbits
	.globl	_Z13trainGMM_CUDAPhS_PfS0_S_ii
	.p2align	3, 0x0
_Z13trainGMM_CUDAPhS_PfS0_S_ii:
	.quad	_Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii
	.size	_Z13trainGMM_CUDAPhS_PfS0_S_ii, 8

	.type	_Z12testGMM_CUDAPhS_PfS0_S_ii,@object # @_Z12testGMM_CUDAPhS_PfS0_S_ii
	.globl	_Z12testGMM_CUDAPhS_PfS0_S_ii
	.p2align	3, 0x0
_Z12testGMM_CUDAPhS_PfS0_S_ii:
	.quad	_Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii
	.size	_Z12testGMM_CUDAPhS_PfS0_S_ii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CPU: "
	.size	.L.str, 6

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"GPU: "
	.size	.L.str.1, 6

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13trainGMM_CUDAPhS_PfS0_S_ii"
	.size	.L__unnamed_1, 31

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z12testGMM_CUDAPhS_PfS0_S_ii"
	.size	.L__unnamed_2, 30

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z28__device_stub__trainGMM_CUDAPhS_PfS0_S_ii
	.addrsig_sym _Z27__device_stub__testGMM_CUDAPhS_PfS0_S_ii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z13trainGMM_CUDAPhS_PfS0_S_ii
	.addrsig_sym _Z12testGMM_CUDAPhS_PfS0_S_ii
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13trainGMM_CUDAPhS_PfS0_S_ii ; -- Begin function _Z13trainGMM_CUDAPhS_PfS0_S_ii
	.globl	_Z13trainGMM_CUDAPhS_PfS0_S_ii
	.p2align	8
	.type	_Z13trainGMM_CUDAPhS_PfS0_S_ii,@function
_Z13trainGMM_CUDAPhS_PfS0_S_ii:         ; @_Z13trainGMM_CUDAPhS_PfS0_S_ii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x3c
	s_load_b64 s[2:3], s[0:1], 0x28
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v4, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s5, s4, 16
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[2:3], null, s14, s4, v[1:2]
	v_mad_u64_u32 v[0:1], null, s15, s5, v[4:5]
	v_cmp_gt_i32_e32 vcc_lo, s2, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_gt_i32_e64 s2, s3, v0
	s_and_b32 s2, vcc_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s4, s2
	s_cbranch_execz .LBB0_25
; %bb.1:
	v_mul_lo_u32 v3, v2, s3
	s_clause 0x2
	s_load_b64 s[4:5], s[0:1], 0x0
	s_load_b64 s[6:7], s[0:1], 0x20
	s_load_b128 s[0:3], s[0:1], 0x10
	v_ashrrev_i32_e32 v7, 31, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_mov_b32 v22, 0 :: v_dual_add_nc_u32 v1, v3, v0
	v_ashrrev_i32_e32 v4, 31, v3
	v_lshl_add_u32 v1, v1, 1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v2, 31, v1
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v3, vcc_lo, s4, v3
	v_add_co_ci_u32_e32 v10, vcc_lo, s5, v4, vcc_lo
	v_lshlrev_b64 v[8:9], 2, v[1:2]
	v_add_co_u32 v4, vcc_lo, s6, v1
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v2, vcc_lo
	v_add_co_u32 v6, vcc_lo, v3, v0
	v_add_co_ci_u32_e32 v7, vcc_lo, v10, v7, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v8
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v9, vcc_lo
	v_add_co_u32 v2, vcc_lo, s2, v8
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v9, vcc_lo
	v_dual_mov_b32 v9, v5 :: v_dual_mov_b32 v8, v4
	s_mov_b32 s0, 0x47ae147b
	s_mov_b32 s1, 0x3f747ae1
	s_mov_b64 s[2:3], 0
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add_co_u32 v10, vcc_lo, v2, s2
	v_add_co_ci_u32_e32 v11, vcc_lo, s3, v3, vcc_lo
	s_mov_b32 s4, exec_lo
	global_load_b32 v12, v[10:11], off
	global_load_u8 v13, v[6:7], off
	global_load_u8 v16, v[8:9], off
	s_waitcnt vmcnt(2)
	v_cvt_f64_f32_e32 v[14:15], v12
	s_waitcnt vmcnt(0)
	v_sub_nc_u32_e32 v13, v13, v16
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_i32_i24_e32 v12, v13, v13
	v_cvt_f64_u32_e32 v[16:17], v12
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[14:15], 0x40080000, v[14:15]
	v_cmpx_ngt_f64_e32 v[14:15], v[16:17]
	s_xor_b32 s4, exec_lo, s4
	s_cbranch_execz .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_co_u32 v10, vcc_lo, v0, s2
	v_add_co_ci_u32_e32 v11, vcc_lo, s3, v1, vcc_lo
	v_add_nc_u32_e32 v22, 1, v22
	global_load_b32 v14, v[10:11], off
	s_waitcnt vmcnt(0)
	v_cvt_f64_f32_e64 v[12:13], -v14
	v_cvt_f64_f32_e32 v[14:15], v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[12:13], s[0:1], v[14:15]
	v_cvt_f32_f64_e32 v12, v[12:13]
                                        ; implicit-def: $vgpr13
	global_store_b32 v[10:11], v12, off
                                        ; implicit-def: $vgpr12
                                        ; implicit-def: $vgpr10_vgpr11
.LBB0_4:                                ; %Flow257
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_and_not1_saveexec_b32 s4, s4
	s_cbranch_execz .LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_co_u32 v14, vcc_lo, v0, s2
	v_add_co_ci_u32_e32 v15, vcc_lo, s3, v1, vcc_lo
	v_cvt_f32_u32_e32 v12, v12
	global_load_b32 v16, v[14:15], off
	s_waitcnt vmcnt(0)
	v_sub_f32_e32 v18, 1.0, v16
	v_cvt_f64_f32_e32 v[16:17], v16
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_f32_e32 v[18:19], v18
	v_fma_f64 v[16:17], v[18:19], s[0:1], v[16:17]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f32_f64_e32 v20, v[16:17]
	v_cvt_f64_f32_e32 v[16:17], v20
	global_store_b32 v[14:15], v20, off
	global_load_u8 v27, v[8:9], off
	v_div_scale_f64 v[18:19], null, v[16:17], v[16:17], s[0:1]
	v_div_scale_f64 v[25:26], vcc_lo, s[0:1], v[16:17], s[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[20:21], v[18:19]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[23:24], -v[18:19], v[20:21], 1.0
	v_fma_f64 v[20:21], v[20:21], v[23:24], v[20:21]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[23:24], -v[18:19], v[20:21], 1.0
	v_fma_f64 v[20:21], v[20:21], v[23:24], v[20:21]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[23:24], v[25:26], v[20:21]
	v_fma_f64 v[18:19], -v[18:19], v[23:24], v[25:26]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_div_fmas_f64 v[18:19], v[18:19], v[20:21], v[23:24]
	v_sub_nc_u32_e32 v20, 0, v13
	s_waitcnt vmcnt(0)
	v_cvt_f64_u32_e32 v[23:24], v27
	v_max_i32_e32 v13, v13, v20
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f64_i32_e32 v[20:21], v13
	v_div_fixup_f64 v[16:17], v[18:19], v[16:17], s[0:1]
	v_fma_f64 v[16:17], v[16:17], v[20:21], v[23:24]
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_i32_f64_e32 v13, v[16:17]
	global_store_b8 v[8:9], v13, off
	global_load_b32 v13, v[14:15], off
	global_load_b32 v21, v[10:11], off
	s_waitcnt vmcnt(1)
	v_cvt_f64_f32_e32 v[13:14], v13
	s_waitcnt vmcnt(0)
	v_sub_f32_e32 v12, v12, v21
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f64 v[15:16], null, v[13:14], v[13:14], s[0:1]
	v_div_scale_f64 v[23:24], vcc_lo, s[0:1], v[13:14], s[0:1]
	v_rcp_f64_e32 v[17:18], v[15:16]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[19:20], -v[15:16], v[17:18], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[17:18], v[17:18], v[19:20], v[17:18]
	v_fma_f64 v[19:20], -v[15:16], v[17:18], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[17:18], v[17:18], v[19:20], v[17:18]
	v_mul_f64 v[19:20], v[23:24], v[17:18]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[15:16], -v[15:16], v[19:20], v[23:24]
	v_div_fmas_f64 v[15:16], v[15:16], v[17:18], v[19:20]
	v_cvt_f64_f32_e32 v[17:18], v12
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_div_fixup_f64 v[12:13], v[15:16], v[13:14], s[0:1]
	v_cvt_f64_f32_e32 v[14:15], v21
	v_fma_f64 v[12:13], v[12:13], v[17:18], v[14:15]
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_f64_e32 v12, v[12:13]
	global_store_b32 v[10:11], v12, off
.LBB0_6:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s4
	v_add_co_u32 v8, vcc_lo, v8, 1
	v_add_co_ci_u32_e32 v9, vcc_lo, 0, v9, vcc_lo
	s_add_u32 s2, s2, 4
	s_addc_u32 s3, s3, 0
	s_cmp_lg_u32 s2, 12
	s_cbranch_scc1 .LBB0_2
; %bb.7:                                ; %.preheader133.preheader
	v_dual_mov_b32 v9, v3 :: v_dual_mov_b32 v8, v2
	v_dual_mov_b32 v11, v1 :: v_dual_mov_b32 v10, v0
	s_mov_b64 s[2:3], 0
	s_mov_b32 s1, 0
.LBB0_8:                                ; %.preheader133
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_9 Depth 2
	s_mov_b32 s0, s2
	v_dual_mov_b32 v19, v9 :: v_dual_mov_b32 v18, v8
	s_lshl_b64 s[4:5], s[0:1], 2
	v_dual_mov_b32 v21, v11 :: v_dual_mov_b32 v20, v10
	v_add_co_u32 v12, vcc_lo, v2, s4
	v_add_co_ci_u32_e32 v13, vcc_lo, s5, v3, vcc_lo
	v_add_co_u32 v14, vcc_lo, v0, s4
	v_add_co_ci_u32_e32 v15, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v23, v[12:13], off
	v_add_co_u32 v16, vcc_lo, v4, s0
	v_add_co_ci_u32_e32 v17, vcc_lo, 0, v5, vcc_lo
	s_mov_b64 s[4:5], s[2:3]
.LBB0_9:                                ;   Parent Loop BB0_8 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b32 v24, v[20:21], off
	global_load_b32 v26, v[18:19], off
	global_load_b32 v25, v[14:15], off
	s_waitcnt vmcnt(1)
	v_div_scale_f32 v27, null, v26, v26, v24
	s_waitcnt vmcnt(0)
	v_div_scale_f32 v28, null, v23, v23, v25
	v_div_scale_f32 v33, vcc_lo, v24, v26, v24
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_rcp_f32_e32 v29, v27
	v_rcp_f32_e32 v30, v28
	s_waitcnt_depctr 0xfff
	v_fma_f32 v31, -v27, v29, 1.0
	v_fma_f32 v32, -v28, v30, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_fmac_f32 v29, v31, v29 :: v_dual_fmac_f32 v30, v32, v30
	v_div_scale_f32 v31, s0, v25, v23, v25
	v_mul_f32_e32 v32, v33, v29
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_f32_e32 v34, v31, v30
	v_fma_f32 v35, -v27, v32, v33
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v36, -v28, v34, v31
	v_fmac_f32_e32 v32, v35, v29
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fmac_f32_e32 v34, v36, v30
	v_fma_f32 v27, -v27, v32, v33
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v28, -v28, v34, v31
	v_div_fmas_f32 v27, v27, v29, v32
	s_mov_b32 vcc_lo, s0
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fmas_f32 v28, v28, v30, v34
	v_div_fixup_f32 v26, v27, v26, v24
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f32 v27, v28, v23, v25
	v_cmpx_gt_f32_e32 v26, v27
	s_cbranch_execz .LBB0_11
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=2
	v_add_co_u32 v26, vcc_lo, v4, s4
	v_add_co_ci_u32_e32 v27, vcc_lo, s5, v5, vcc_lo
	global_store_b32 v[20:21], v25, off
	global_store_b32 v[14:15], v24, off
	s_clause 0x1
	global_load_u8 v23, v[16:17], off
	global_load_u8 v24, v[26:27], off
	s_waitcnt vmcnt(1)
	global_store_b8 v[26:27], v23, off
	s_waitcnt vmcnt(0)
	global_store_b8 v[16:17], v24, off
	global_load_b32 v24, v[12:13], off
	global_load_b32 v23, v[18:19], off
	s_waitcnt vmcnt(1)
	global_store_b32 v[18:19], v24, off
	s_waitcnt vmcnt(0)
	global_store_b32 v[12:13], v23, off
.LBB0_11:                               ;   in Loop: Header=BB0_9 Depth=2
	s_or_b32 exec_lo, exec_lo, s0
	v_add_co_u32 v20, vcc_lo, v20, 4
	v_add_co_ci_u32_e32 v21, vcc_lo, 0, v21, vcc_lo
	v_add_co_u32 v18, vcc_lo, v18, 4
	s_add_u32 s4, s4, 1
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v19, vcc_lo
	s_addc_u32 s5, s5, 0
	s_add_i32 s0, s4, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_gt_u32 s0, 1
	s_cbranch_scc0 .LBB0_9
; %bb.12:                               ;   in Loop: Header=BB0_8 Depth=1
	v_add_co_u32 v10, vcc_lo, v10, 4
	v_add_co_ci_u32_e32 v11, vcc_lo, 0, v11, vcc_lo
	v_add_co_u32 v8, vcc_lo, v8, 4
	v_add_co_ci_u32_e32 v9, vcc_lo, 0, v9, vcc_lo
	s_add_u32 s2, s2, 1
	s_addc_u32 s3, s3, 0
	s_cmp_eq_u32 s2, 3
	s_cbranch_scc0 .LBB0_8
; %bb.13:
	v_cmp_eq_u32_e32 vcc_lo, 3, v22
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_25
; %bb.14:
	global_load_b32 v8, v[0:1], off offset:8
	s_mov_b32 s0, exec_lo
	s_waitcnt vmcnt(0)
	v_cmpx_neq_f32_e32 0, v8
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_16
; %bb.15:
	global_load_u8 v0, v[6:7], off
	v_mov_b32_e32 v1, 0x41700000
                                        ; implicit-def: $vgpr6_vgpr7
	s_waitcnt vmcnt(0)
	global_store_b8 v[4:5], v0, off offset:2
	global_store_b32 v[2:3], v1, off offset:8
                                        ; implicit-def: $vgpr4
                                        ; implicit-def: $vgpr2
                                        ; implicit-def: $vgpr0_vgpr1
.LBB0_16:                               ; %Flow252
	s_and_not1_saveexec_b32 s0, s0
	s_cbranch_execz .LBB0_25
; %bb.17:                               ; %.preheader.preheader
	v_dual_mov_b32 v13, v1 :: v_dual_mov_b32 v12, v0
	s_mov_b64 s[0:1], 0
	s_mov_b32 s4, 0
                                        ; implicit-def: $sgpr5
                                        ; implicit-def: $sgpr7
                                        ; implicit-def: $sgpr6
.LBB0_18:                               ; %.preheader
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v8, v[12:13], off
	v_dual_mov_b32 v10, v12 :: v_dual_mov_b32 v11, v13
	s_or_b32 s6, s6, exec_lo
	s_or_b32 s7, s7, exec_lo
	s_mov_b32 s8, exec_lo
                                        ; implicit-def: $sgpr2_sgpr3
                                        ; implicit-def: $vgpr12_vgpr13
	s_waitcnt vmcnt(0)
	v_cmpx_neq_f32_e32 0, v8
; %bb.19:                               ;   in Loop: Header=BB0_18 Depth=1
	s_add_u32 s2, s0, 1
	s_addc_u32 s3, s1, 0
	s_cmp_eq_u32 s2, 3
	v_add_co_u32 v12, vcc_lo, v10, 4
	s_cselect_b32 s9, -1, 0
	v_add_co_ci_u32_e32 v13, vcc_lo, 0, v11, vcc_lo
	s_and_not1_b32 s7, s7, exec_lo
	s_and_b32 s9, s9, exec_lo
	s_and_not1_b32 s6, s6, exec_lo
	s_or_b32 s7, s7, s9
; %bb.20:                               ; %Flow250
                                        ;   in Loop: Header=BB0_18 Depth=1
	s_or_b32 exec_lo, exec_lo, s8
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	s_and_b32 s8, exec_lo, s7
	v_dual_mov_b32 v9, s1 :: v_dual_mov_b32 v8, s0
	s_or_b32 s4, s8, s4
	s_and_not1_b32 s0, s5, exec_lo
	s_and_b32 s1, s6, exec_lo
	s_or_b32 s5, s0, s1
	s_mov_b64 s[0:1], s[2:3]
	s_and_not1_b32 exec_lo, exec_lo, s4
	s_cbranch_execnz .LBB0_18
; %bb.21:                               ; %loop.exit.guard
	s_or_b32 exec_lo, exec_lo, s4
	s_and_saveexec_b32 s0, s5
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_25
; %bb.22:
	v_cmp_eq_u32_e32 vcc_lo, 0, v8
	s_mov_b32 s1, 0
	s_mov_b32 s0, exec_lo
	v_cndmask_b32_e64 v12, 0x3ba3d70a, 1.0, vcc_lo
	v_add_co_u32 v4, vcc_lo, v4, v8
	v_add_co_ci_u32_e32 v5, vcc_lo, v5, v9, vcc_lo
	global_store_b32 v[10:11], v12, off
	global_load_u8 v10, v[6:7], off
	v_lshlrev_b64 v[6:7], 2, v[8:9]
	v_mov_b32_e32 v9, 0x41700000
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v2, vcc_lo, v2, v6
	v_add_co_ci_u32_e32 v3, vcc_lo, v3, v7, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b8 v[4:5], v10, off
	global_store_b32 v[2:3], v9, off
	v_cmpx_ne_u32_e32 0, v8
	s_cbranch_execz .LBB0_25
; %bb.23:                               ; %.lr.ph.preheader
	s_mov_b32 s2, 0x3d70a3d7
	s_mov_b32 s3, 0x3fefd70a
.LBB0_24:                               ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v2, v[0:1], off
	v_add_nc_u32_e32 v8, -1, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_cmp_eq_u32_e32 vcc_lo, 0, v8
	s_or_b32 s1, vcc_lo, s1
	s_waitcnt vmcnt(0)
	v_cvt_f64_f32_e32 v[2:3], v2
	v_mul_f64 v[2:3], v[2:3], s[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_cvt_f32_f64_e32 v2, v[2:3]
	global_store_b32 v[0:1], v2, off
	v_add_co_u32 v0, s0, v0, 4
	v_add_co_ci_u32_e64 v1, s0, 0, v1, s0
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_24
.LBB0_25:                               ; %.critedge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13trainGMM_CUDAPhS_PfS0_S_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.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 37
		.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	_Z13trainGMM_CUDAPhS_PfS0_S_ii, .Lfunc_end0-_Z13trainGMM_CUDAPhS_PfS0_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1880
; NumSgprs: 18
; NumVgprs: 37
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 4
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 37
; 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
	.protected	_Z12testGMM_CUDAPhS_PfS0_S_ii ; -- Begin function _Z12testGMM_CUDAPhS_PfS0_S_ii
	.globl	_Z12testGMM_CUDAPhS_PfS0_S_ii
	.p2align	8
	.type	_Z12testGMM_CUDAPhS_PfS0_S_ii,@function
_Z12testGMM_CUDAPhS_PfS0_S_ii:          ; @_Z12testGMM_CUDAPhS_PfS0_S_ii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x3c
	s_load_b64 s[2:3], s[0:1], 0x28
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v4, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s5, s4, 16
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[2:3], null, s14, s4, v[1:2]
	v_mad_u64_u32 v[0:1], null, s15, s5, v[4:5]
	v_cmp_gt_i32_e32 vcc_lo, s2, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_gt_i32_e64 s2, s3, v0
	s_and_b32 s2, vcc_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s4, s2
	s_cbranch_execz .LBB1_9
; %bb.1:
	s_load_b256 s[4:11], s[0:1], 0x0
	v_mul_lo_u32 v1, v2, s3
	v_ashrrev_i32_e32 v3, 31, v0
	s_load_b64 s[0:1], s[0:1], 0x20
	v_mov_b32_e32 v11, 0
	s_mov_b32 s2, 0
                                        ; implicit-def: $sgpr3
	v_mov_b32_e32 v12, 0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v2, 31, v1
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v4, vcc_lo, s4, v1
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v2, vcc_lo
                                        ; implicit-def: $sgpr4
                                        ; implicit-def: $sgpr5
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, v4, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, v5, v3, vcc_lo
	global_load_u8 v4, v[4:5], off
	v_add_nc_u32_e32 v5, v1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshl_add_u32 v9, v5, 1, v5
	v_ashrrev_i32_e32 v10, 31, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[7:8], 2, v[9:10]
	v_add_co_u32 v5, vcc_lo, s8, v7
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v6, vcc_lo, s9, v8, vcc_lo
	v_add_co_u32 v7, vcc_lo, s10, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s11, v8, vcc_lo
	v_add_co_u32 v9, vcc_lo, s0, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, s1, v10, vcc_lo
	s_mov_b32 s0, 0x66666666
	s_mov_b32 s1, 0x3fe66666
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	v_and_b32_e32 v13, 0xff, v12
	s_or_b32 s5, s5, exec_lo
	s_or_b32 s4, s4, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v15, 2, v13
	v_add_co_u32 v16, vcc_lo, v7, v15
	v_add_co_ci_u32_e32 v17, vcc_lo, 0, v8, vcc_lo
	global_load_b32 v12, v[16:17], off
	v_add_co_u32 v16, vcc_lo, v9, v13
	v_add_co_ci_u32_e32 v17, vcc_lo, 0, v10, vcc_lo
	global_load_u8 v14, v[16:17], off
	s_waitcnt vmcnt(1)
	v_cvt_f64_f32_e32 v[16:17], v12
	s_waitcnt vmcnt(0)
	v_sub_nc_u32_e32 v14, v4, v14
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[16:17], 0x40040000, v[16:17]
	v_cvt_i32_f64_e32 v12, v[16:17]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v16, 0, v14
	v_max_i32_e32 v14, v14, v16
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_cmp_ge_u32_e32 vcc_lo, v14, v12
	v_mov_b32_e32 v14, 0
                                        ; implicit-def: $vgpr12
	s_and_saveexec_b32 s8, vcc_lo
	s_xor_b32 s8, exec_lo, s8
	s_cbranch_execz .LBB1_6
; %bb.3:                                ;   in Loop: Header=BB1_2 Depth=1
	v_add_co_u32 v14, vcc_lo, v5, v15
	v_add_co_ci_u32_e32 v15, vcc_lo, 0, v6, vcc_lo
	s_mov_b32 s9, -1
	s_mov_b32 s10, -1
	s_mov_b32 s11, exec_lo
	global_load_b32 v12, v[14:15], off
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v11, v11, v12
                                        ; implicit-def: $vgpr12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_f32_e32 v[14:15], v11
	v_cmpx_nle_f64_e32 s[0:1], v[14:15]
; %bb.4:                                ;   in Loop: Header=BB1_2 Depth=1
	v_cmp_lt_u16_e32 vcc_lo, 1, v13
	v_add_nc_u16 v12, v13, 1
	s_xor_b32 s10, exec_lo, -1
	s_or_not1_b32 s9, vcc_lo, exec_lo
; %bb.5:                                ; %Flow89
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s11
	v_mov_b32_e32 v14, 0xff
	s_and_not1_b32 s5, s5, exec_lo
	s_and_b32 s10, s10, exec_lo
	s_and_not1_b32 s4, s4, exec_lo
	s_and_b32 s9, s9, exec_lo
	s_or_b32 s5, s5, s10
	s_or_b32 s4, s4, s9
.LBB1_6:                                ; %Flow88
                                        ;   in Loop: Header=BB1_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s8
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s8, exec_lo, s4
	s_or_b32 s2, s8, s2
	s_and_not1_b32 s3, s3, exec_lo
	s_and_b32 s8, s5, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s3, s3, s8
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB1_2
; %bb.7:                                ; %loop.exit.guard
	s_or_b32 exec_lo, exec_lo, s2
	s_and_saveexec_b32 s0, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB1_9
; %bb.8:                                ; %.loopexit.sink.split
	v_add_co_u32 v1, vcc_lo, s6, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s7, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, v1, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, v2, v3, vcc_lo
	global_store_b8 v[0:1], v14, off
.LBB1_9:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12testGMM_CUDAPhS_PfS0_S_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.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 18
		.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_end1:
	.size	_Z12testGMM_CUDAPhS_PfS0_S_ii, .Lfunc_end1-_Z12testGMM_CUDAPhS_PfS0_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 632
; NumSgprs: 18
; NumVgprs: 18
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 18
; 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
      - .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
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         44
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13trainGMM_CUDAPhS_PfS0_S_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13trainGMM_CUDAPhS_PfS0_S_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     37
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .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
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         44
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12testGMM_CUDAPhS_PfS0_S_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12testGMM_CUDAPhS_PfS0_S_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     18
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
