#include "cuda.h"

#include <cstdio>

static float *h_points;
static float *d_points;
static double *h_pointsd;
static double *d_pointsd;
static unsigned int *d_groups;
static unsigned int d_psize;
static float d_pmax;
static float d_pmin;
static double d_pmaxd;
static double d_pmind;

__global__ void groupKernel(float *points, unsigned int psize, float *codebook, unsigned int csize, unsigned int *groups) {
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	if (idx < psize) {
		float d = abs(points[idx] - codebook[0]);
		float min = d;
		unsigned int g = 0;
		for(int i = 1; i < csize; i++) {
			d = abs(points[idx] - codebook[i]);
			g += (d < min) * (i - g);
			min -= (d < min) * (min - d);
		}
		groups[idx] = g;
	}
}

__global__ void groupKernel(double *points, unsigned int psize, double *codebook, unsigned int csize, unsigned int *groups) {
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	if (idx < psize) {
		double d = abs(points[idx] - codebook[0]);
		double min = d;
		unsigned int g = 0;
		for(int i = 1; i < csize; i++) {
			d = abs(points[idx] - codebook[i]);
			g += (d < min) * (i - g);
			min -= (d < min) * (min - d);
		}
		groups[idx] = g;
	}
}

void setupLloyds(float *points, unsigned int psize, float pmax, float pmin) {
	d_psize = psize;
	d_pmax = pmax;
	d_pmin = pmin;

	h_points = points;
  cudaMalloc((void**)&d_points, sizeof(float)*psize);
  cudaMalloc((void**)&d_groups, sizeof(unsigned int)*psize);

	cudaMemcpy(d_points, points, sizeof(float) * psize, cudaMemcpyHostToDevice);
}

void setupLloyds(double *points, unsigned int psize, double pmax, double pmin) {
	d_psize = psize;
	d_pmaxd = pmax;
	d_pmind = pmin;

	h_pointsd = points;
  cudaMalloc((void**)&d_pointsd, sizeof(double)*psize);
  cudaMalloc((void**)&d_groups, sizeof(unsigned int)*psize);

	cudaMemcpy(d_pointsd, points, sizeof(double) * psize, cudaMemcpyHostToDevice);
}

void lloyd(float *codebook, unsigned int csize, float stop_criteria, float *table, float &dist, float &reldist, unsigned int *groups) {

	float *d_codebook;
	dist = 0;
	reldist = 0;

	// Calculate initial table
	//can be done in gpu if csize is big enough
	for(int i = 0; i < csize-1; i++) {
		table[i] = (codebook[i] + codebook[i+1]) / 2;
	}

  cudaMalloc((void**)&d_codebook, sizeof(float)*csize);
	cudaMemcpy(d_codebook, codebook, sizeof(float)*csize, cudaMemcpyHostToDevice);

	// Assign each point its codebook group
	unsigned int threads = 256;
	unsigned int blocks = (d_psize - 1) / threads + 1;
	groupKernel<<<blocks, threads>>>(d_points, d_psize, d_codebook, csize, d_groups);

	cudaMemcpy(groups, d_groups, sizeof(unsigned int) * d_psize, cudaMemcpyDeviceToHost);
	
	unsigned int *incode = (unsigned int*)calloc(csize, sizeof(unsigned int));
	float *meancode = (float*)calloc(csize, sizeof(float));

	// Calculate the mean of each codebook group and distortion
	for(int i = 0; i < d_psize; i++) {
		incode[groups[i]]++;
		meancode[groups[i]] += h_points[i];
		dist += codebook[groups[i]] - h_points[i];
	}
	dist /= d_psize;

	reldist = abs(dist);

	while(reldist > stop_criteria) {

		// Update codebook
		//can be done in gpu if csize is big enough
		for(int i = 0; i < csize; i++) {
			if(incode[i] != 0) {
				codebook[i] = meancode[i] / incode[i];
				incode[i] = 0;
			} else if (i == 0) {
				codebook[i] = (table[0] + d_pmin) / 2;
			} else if (i == csize-1) {
				codebook[i] = (table[i-1] + d_pmax) / 2;
			} else {
				codebook[i] = (table[i-1] + table[i]) / 2;
			}
			meancode[i] = 0;
		}

		cudaMemcpy(d_codebook, codebook, sizeof(float)*csize, cudaMemcpyHostToDevice);

		// How to do this in CUDA efficiently?
		for(int i = 0; i < d_psize; i++) {
			for(int j = 0; j < csize-1; j++) {
				if((h_points[i] >= codebook[j])
				&& (h_points[i] < codebook[j+1])) {
					incode[j]++;
					meancode[j] += h_points[i];
					break;
				}
			}
		}

		// Update table
		//can be done in gpu if csize is big enough
		for(int i = 0; i < csize-1; i++) {
			if(incode[i] != 0) {
				table[i] = meancode[i] / incode[i];
				incode[i] = 0;
			} else {
				table[i] = (codebook[i] + codebook[i+1]) / 2;
			}
			meancode[i] = 0;
		}

		// Assign each point its codebook group
		groupKernel<<<blocks, threads>>>(d_points, d_psize, d_codebook, csize, d_groups);

		cudaMemcpy(groups, d_groups, sizeof(unsigned int) * d_psize, cudaMemcpyDeviceToHost);

		reldist = dist;
		dist = 0;

		// Calculate the mean of each codebook group and distortion
		for(int i = 0; i < d_psize; i++) {
			incode[groups[i]]++;
			meancode[groups[i]] += h_points[i];
			dist += codebook[groups[i]] - h_points[i];
		}
		dist /= d_psize;

		reldist = abs(reldist - dist);
	}  // END WHILE

	cudaFree(d_codebook);
	free(incode);
	free(meancode);
}

void lloyd(double *codebook, unsigned int csize, double stop_criteria, double *table, double &dist, double &reldist, unsigned int *groups) {

	double *d_codebook;
	dist = 0;
	reldist = 0;

	// Calculate initial table
	//can be done in gpu if csize is big enough
	for(int i = 0; i < csize-1; i++) {
		table[i] = (codebook[i] + codebook[i+1]) / 2;
	}

  cudaMalloc((void**)&d_codebook, sizeof(double)*csize);
	cudaMemcpy(d_codebook, codebook, sizeof(double)*csize, cudaMemcpyHostToDevice);

	// Assign each point its codebook group
	unsigned int threads = 256;
	unsigned int blocks = (d_psize - 1) / threads + 1;
	groupKernel<<<blocks, threads>>>(d_pointsd, d_psize, d_codebook, csize, d_groups);

	cudaMemcpy(groups, d_groups, sizeof(unsigned int) * d_psize, cudaMemcpyDeviceToHost);
	
	unsigned int *incode = (unsigned int*)calloc(csize, sizeof(unsigned int));
	double *meancode = (double*)calloc(csize, sizeof(double));

	// Calculate the mean of each codebook group and distortion
	for(int i = 0; i < d_psize; i++) {
		incode[groups[i]]++;
		meancode[groups[i]] += h_pointsd[i];
		dist += codebook[groups[i]] - h_pointsd[i];
	}
	dist /= d_psize;

	reldist = abs(dist);

	while(reldist > stop_criteria) {

		// Update codebook
		//can be done in gpu if csize is big enough
		for(int i = 0; i < csize; i++) {
			if(incode[i] != 0) {
				codebook[i] = meancode[i] / incode[i];
				incode[i] = 0;
			} else if (i == 0) {
				codebook[i] = (table[0] + d_pmind) / 2;
			} else if (i == csize-1) {
				codebook[i] = (table[i-1] + d_pmaxd) / 2;
			} else {
				codebook[i] = (table[i-1] + table[i]) / 2;
			}
			meancode[i] = 0;
		}

		cudaMemcpy(d_codebook, codebook, sizeof(double)*csize, cudaMemcpyHostToDevice);

		// How to do this in CUDA efficiently?
		for(int i = 0; i < d_psize; i++) {
			for(int j = 0; j < csize-1; j++) {
				if((h_pointsd[i] >= codebook[j])
				&& (h_pointsd[i] < codebook[j+1])) {
					incode[j]++;
					meancode[j] += h_pointsd[i];
					break;
				}
			}
		}

		// Update table
		//can be done in gpu if csize is big enough
		for(int i = 0; i < csize-1; i++) {
			if(incode[i] != 0) {
				table[i] = meancode[i] / incode[i];
				incode[i] = 0;
			} else {
				table[i] = (codebook[i] + codebook[i+1]) / 2;
			}
			meancode[i] = 0;
		}

		// Assign each point its codebook group
		groupKernel<<<blocks, threads>>>(d_pointsd, d_psize, d_codebook, csize, d_groups);

		cudaMemcpy(groups, d_groups, sizeof(unsigned int) * d_psize, cudaMemcpyDeviceToHost);

		reldist = dist;
		dist = 0;

		// Calculate the mean of each codebook group and distortion
		for(int i = 0; i < d_psize; i++) {
			incode[groups[i]]++;
			meancode[groups[i]] += h_pointsd[i];
			dist += codebook[groups[i]] - h_pointsd[i];
		}
		dist /= d_psize;

		reldist = abs(reldist - dist);
	}  // END WHILE

	cudaFree(d_codebook);
	free(incode);
	free(meancode);
}


void finalize() {
	cudaFree(d_points);
	cudaFree(d_groups);
}

void finalized() {
	cudaFree(d_pointsd);
	cudaFree(d_groups);
}


	.file	"tmpxft_0039ce18_00000000-6_lloyd.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11setupLloydsPfjff
	.type	_Z11setupLloydsPfjff, @function
_Z11setupLloydsPfjff:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rax
	.cfi_def_cfa_offset 32
	movl	%esi, _ZL7d_psize(%rip)
	movl	%esi, %esi
	leaq	0(,%rsi,4), %rbx
	movq	%rdi, _ZL8h_points(%rip)
	leaq	_ZL8d_points(%rip), %rdi
	movq	%rbx, %rsi
	movss	%xmm0, _ZL6d_pmax(%rip)
	movss	%xmm1, _ZL6d_pmin(%rip)
	call	cudaMalloc@PLT
	movq	%rbx, %rsi
	leaq	_ZL8d_groups(%rip), %rdi
	call	cudaMalloc@PLT
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	movl	$1, %ecx
	movq	_ZL8d_points(%rip), %rdi
	popq	%r8
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	cudaMemcpy@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z11setupLloydsPfjff, .-_Z11setupLloydsPfjff
	.globl	_Z11setupLloydsPdjdd
	.type	_Z11setupLloydsPdjdd, @function
_Z11setupLloydsPdjdd:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	leaq	0(,%rbx,8), %r12
	movl	%esi, _ZL7d_psize(%rip)
	movq	%rdi, _ZL9h_pointsd(%rip)
	movq	%r12, %rsi
	leaq	_ZL9d_pointsd(%rip), %rdi
	movsd	%xmm0, _ZL7d_pmaxd(%rip)
	movsd	%xmm1, _ZL7d_pmind(%rip)
	call	cudaMalloc@PLT
	leaq	0(,%rbx,4), %rsi
	leaq	_ZL8d_groups(%rip), %rdi
	call	cudaMalloc@PLT
	movq	_ZL9d_pointsd(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movl	$1, %ecx
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	cudaMemcpy@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z11setupLloydsPdjdd, .-_Z11setupLloydsPdjdd
	.globl	_Z8finalizev
	.type	_Z8finalizev, @function
_Z8finalizev:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	_ZL8d_points(%rip), %rdi
	call	cudaFree@PLT
	movq	_ZL8d_groups(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	cudaFree@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z8finalizev, .-_Z8finalizev
	.globl	_Z9finalizedv
	.type	_Z9finalizedv, @function
_Z9finalizedv:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	_ZL9d_pointsd(%rip), %rdi
	call	cudaFree@PLT
	movq	_ZL8d_groups(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	cudaFree@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z9finalizedv, .-_Z9finalizedv
	.globl	_Z37__device_stub__Z11groupKernelPfjS_jPjPfjS_jPj
	.type	_Z37__device_stub__Z11groupKernelPfjS_jPjPfjS_jPj, @function
_Z37__device_stub__Z11groupKernelPfjS_jPjPfjS_jPj:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 16(%rsp)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L10
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z11groupKernelPfjS_jPj(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L10:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z37__device_stub__Z11groupKernelPfjS_jPjPfjS_jPj, .-_Z37__device_stub__Z11groupKernelPfjS_jPjPfjS_jPj
	.globl	_Z11groupKernelPfjS_jPj
	.type	_Z11groupKernelPfjS_jPj, @function
_Z11groupKernelPfjS_jPj:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z11groupKernelPfjS_jPjPfjS_jPj
	.cfi_endproc
.LFE2058:
	.size	_Z11groupKernelPfjS_jPj, .-_Z11groupKernelPfjS_jPj
	.globl	_Z5lloydPfjfS_RfS0_Pj
	.type	_Z5lloydPfjfS_RfS0_Pj, @function
_Z5lloydPfjfS_RfS0_Pj:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r8, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rcx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	decl	%ebx
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movss	.LC1(%rip), %xmm1
	movl	%esi, (%rsp)
	movq	%r9, 8(%rsp)
	movss	%xmm0, 28(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	movl	$0x00000000, (%rcx)
	movl	%ebx, 4(%rsp)
	movl	$0x00000000, (%r8)
.L17:
	movl	4(%rsp), %ebx
	cmpl	%ebx, %eax
	jnb	.L56
	movss	(%r14,%rax,4), %xmm0
	addss	4(%r14,%rax,4), %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%r12,%rax,4)
	incq	%rax
	jmp	.L17
.L56:
	movl	(%rsp), %r15d
	leaq	40(%rsp), %rdi
	leaq	0(,%r15,4), %rax
	movq	%rax, %rsi
	movq	%rax, 16(%rsp)
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdx
	movq	40(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	_ZL7d_psize(%rip), %eax
	salq	$8, %rdx
	movl	$1, %ecx
	movl	$1, 68(%rsp)
	movq	%rdx, 60(%rsp)
	decl	%eax
	shrl	$8, %eax
	incl	%eax
	movl	%eax, 48(%rsp)
	movl	%eax, 24(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L19
	movq	_ZL8d_groups(%rip), %r8
	movl	(%rsp), %ecx
	movq	40(%rsp), %rdx
	movl	_ZL7d_psize(%rip), %esi
	movq	_ZL8d_points(%rip), %rdi
	call	_Z37__device_stub__Z11groupKernelPfjS_jPjPfjS_jPj
.L19:
	movl	_ZL7d_psize(%rip), %edx
	movq	8(%rsp), %rdi
	movl	$2, %ecx
	movq	_ZL8d_groups(%rip), %rsi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movq	%r15, %rdi
	movl	$4, %esi
	call	calloc@PLT
	movl	$4, %esi
	movq	%r15, %rdi
	movq	%rax, %rbx
	call	calloc@PLT
	movl	_ZL7d_psize(%rip), %ecx
	movq	_ZL8h_points(%rip), %rsi
	movq	%rax, %r15
	xorl	%eax, %eax
.L20:
	cmpl	%ecx, %eax
	movss	0(%rbp), %xmm0
	jnb	.L57
	movq	8(%rsp), %rdi
	movl	(%rdi,%rax,4), %edi
	leaq	0(,%rdi,4), %rdx
	incl	(%rbx,%rdx)
	addq	%r15, %rdx
	movss	(%rdx), %xmm1
	addss	(%rsi,%rax,4), %xmm1
	movss	%xmm1, (%rdx)
	movss	(%r14,%rdi,4), %xmm1
	subss	(%rsi,%rax,4), %xmm1
	incq	%rax
	addss	%xmm1, %xmm0
	movss	%xmm0, 0(%rbp)
	jmp	.L20
.L57:
	cvtsi2ssl	%ecx, %xmm1
	divss	%xmm1, %xmm0
	movss	%xmm0, 0(%rbp)
.L55:
	andps	.LC2(%rip), %xmm0
	comiss	28(%rsp), %xmm0
	movss	%xmm0, 0(%r13)
	jbe	.L58
	movss	_ZL6d_pmin(%rip), %xmm1
	xorl	%eax, %eax
.L29:
	movl	(%rbx,%rax,4), %edx
	testl	%edx, %edx
	je	.L23
	cvtsi2ssq	%rdx, %xmm2
	movss	(%r15,%rax,4), %xmm0
	xorl	%ecx, %ecx
	movl	%ecx, (%rbx,%rax,4)
	divss	%xmm2, %xmm0
	movss	%xmm0, (%r14,%rax,4)
	jmp	.L26
.L23:
	testq	%rax, %rax
	jne	.L27
	movss	(%r12), %xmm0
	addss	%xmm1, %xmm0
	mulss	.LC1(%rip), %xmm0
	movss	%xmm0, (%r14)
	jmp	.L26
.L27:
	movss	-4(%r12,%rax,4), %xmm0
	cmpl	%eax, 4(%rsp)
	jne	.L28
	addss	_ZL6d_pmax(%rip), %xmm0
	jmp	.L54
.L28:
	addss	(%r12,%rax,4), %xmm0
.L54:
	mulss	.LC1(%rip), %xmm0
	movss	%xmm0, (%r14,%rax,4)
.L26:
	movl	(%rsp), %ecx
	movl	$0x00000000, (%r15,%rax,4)
	incq	%rax
	cmpl	%ecx, %eax
	jb	.L29
	movq	16(%rsp), %rdx
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	_ZL7d_psize(%rip), %ecx
	movq	_ZL8h_points(%rip), %rsi
	xorl	%edx, %edx
.L30:
	xorl	%eax, %eax
	cmpl	%ecx, %edx
	jnb	.L59
.L36:
	movl	4(%rsp), %edi
	cmpl	%edi, %eax
	jnb	.L34
	movss	(%rsi,%rdx,4), %xmm0
	comiss	(%r14,%rax,4), %xmm0
	jb	.L31
	movss	4(%r14,%rax,4), %xmm1
	comiss	%xmm0, %xmm1
	jbe	.L31
	salq	$2, %rax
	incl	(%rbx,%rax)
	addq	%r15, %rax
	addss	(%rax), %xmm0
	movss	%xmm0, (%rax)
	jmp	.L34
.L31:
	incq	%rax
	jmp	.L36
.L34:
	incq	%rdx
	jmp	.L30
.L59:
	movss	.LC1(%rip), %xmm1
.L37:
	movl	4(%rsp), %esi
	cmpl	%esi, %eax
	jnb	.L60
	movl	(%rbx,%rax,4), %edx
	testl	%edx, %edx
	je	.L38
	cvtsi2ssq	%rdx, %xmm2
	movss	(%r15,%rax,4), %xmm0
	xorl	%edx, %edx
	movl	%edx, (%rbx,%rax,4)
	divss	%xmm2, %xmm0
	movss	%xmm0, (%r12,%rax,4)
	jmp	.L41
.L38:
	movss	(%r14,%rax,4), %xmm0
	addss	4(%r14,%rax,4), %xmm0
	mulss	%xmm1, %xmm0
	movss	%xmm0, (%r12,%rax,4)
.L41:
	movl	$0x00000000, (%r15,%rax,4)
	incq	%rax
	jmp	.L37
.L60:
	movl	24(%rsp), %eax
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$8, %rdx
	movl	$1, %ecx
	movl	$1, 68(%rsp)
	movl	%eax, 48(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	movq	%rdx, 60(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L43
	movq	_ZL8d_groups(%rip), %r8
	movl	(%rsp), %ecx
	movq	40(%rsp), %rdx
	movl	_ZL7d_psize(%rip), %esi
	movq	_ZL8d_points(%rip), %rdi
	call	_Z37__device_stub__Z11groupKernelPfjS_jPjPfjS_jPj
.L43:
	movl	_ZL7d_psize(%rip), %edx
	movq	8(%rsp), %rdi
	movl	$2, %ecx
	movq	_ZL8d_groups(%rip), %rsi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movss	0(%rbp), %xmm0
	movl	_ZL7d_psize(%rip), %ecx
	xorl	%eax, %eax
	movq	_ZL8h_points(%rip), %rsi
	movss	%xmm0, 0(%r13)
	movl	$0x00000000, 0(%rbp)
.L44:
	cmpl	%ecx, %eax
	movss	0(%rbp), %xmm1
	jnb	.L61
	movq	8(%rsp), %rdi
	movl	(%rdi,%rax,4), %edi
	leaq	0(,%rdi,4), %rdx
	incl	(%rbx,%rdx)
	addq	%r15, %rdx
	movss	(%rdx), %xmm0
	addss	(%rsi,%rax,4), %xmm0
	movss	%xmm0, (%rdx)
	movss	(%r14,%rdi,4), %xmm0
	subss	(%rsi,%rax,4), %xmm0
	incq	%rax
	addss	%xmm0, %xmm1
	movss	%xmm1, 0(%rbp)
	jmp	.L44
.L61:
	cvtsi2ssl	%ecx, %xmm0
	divss	%xmm0, %xmm1
	movss	%xmm1, 0(%rbp)
	movss	0(%r13), %xmm0
	subss	%xmm1, %xmm0
	jmp	.L55
.L58:
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L47
	call	__stack_chk_fail@PLT
.L47:
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	movq	%r15, %rdi
	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
	jmp	free@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z5lloydPfjfS_RfS0_Pj, .-_Z5lloydPfjfS_RfS0_Pj
	.globl	_Z37__device_stub__Z11groupKernelPdjS_jPjPdjS_jPj
	.type	_Z37__device_stub__Z11groupKernelPdjS_jPjPdjS_jPj, @function
_Z37__device_stub__Z11groupKernelPdjS_jPjPdjS_jPj:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 16(%rsp)
	leaq	40(%rsp), %rcx
	movq	%r8, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L62
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z11groupKernelPdjS_jPj(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L62:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L64
	call	__stack_chk_fail@PLT
.L64:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z37__device_stub__Z11groupKernelPdjS_jPjPdjS_jPj, .-_Z37__device_stub__Z11groupKernelPdjS_jPjPdjS_jPj
	.globl	_Z11groupKernelPdjS_jPj
	.type	_Z11groupKernelPdjS_jPj, @function
_Z11groupKernelPdjS_jPj:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z11groupKernelPdjS_jPjPdjS_jPj
	.cfi_endproc
.LFE2060:
	.size	_Z11groupKernelPdjS_jPj, .-_Z11groupKernelPdjS_jPj
	.globl	_Z5lloydPdjdS_RdS0_Pj
	.type	_Z5lloydPdjdS_RdS0_Pj, @function
_Z5lloydPdjdS_RdS0_Pj:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r8, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rcx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	decl	%ebx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movsd	.LC4(%rip), %xmm1
	movl	%esi, 12(%rsp)
	movq	%r9, 16(%rsp)
	movsd	%xmm0, 40(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	movq	$0x000000000, (%rcx)
	movl	%ebx, 32(%rsp)
	movq	$0x000000000, (%r8)
.L68:
	movl	32(%rsp), %ebx
	cmpl	%ebx, %eax
	jnb	.L107
	movsd	(%r14,%rax,8), %xmm0
	addsd	8(%r14,%rax,8), %xmm0
	mulsd	%xmm1, %xmm0
	movsd	%xmm0, (%r12,%rax,8)
	incq	%rax
	jmp	.L68
.L107:
	movl	12(%rsp), %r15d
	leaq	56(%rsp), %rdi
	leaq	0(,%r15,8), %rax
	movq	%rax, %rsi
	movq	%rax, 24(%rsp)
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdx
	movq	56(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	_ZL7d_psize(%rip), %eax
	salq	$8, %rdx
	movl	$1, %ecx
	movl	$1, 84(%rsp)
	movq	%rdx, 76(%rsp)
	decl	%eax
	shrl	$8, %eax
	incl	%eax
	movl	%eax, 64(%rsp)
	movl	%eax, 36(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L70
	movq	_ZL8d_groups(%rip), %r8
	movl	12(%rsp), %ecx
	movq	56(%rsp), %rdx
	movl	_ZL7d_psize(%rip), %esi
	movq	_ZL9d_pointsd(%rip), %rdi
	call	_Z37__device_stub__Z11groupKernelPdjS_jPjPdjS_jPj
.L70:
	movl	_ZL7d_psize(%rip), %edx
	movq	16(%rsp), %rdi
	movl	$2, %ecx
	movq	_ZL8d_groups(%rip), %rsi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movq	%r15, %rdi
	movl	$4, %esi
	call	calloc@PLT
	movl	$8, %esi
	movq	%r15, %rdi
	movq	%rax, %rbx
	call	calloc@PLT
	movl	_ZL7d_psize(%rip), %ecx
	movq	_ZL9h_pointsd(%rip), %rsi
	movq	%rax, %r15
	xorl	%eax, %eax
.L71:
	cmpl	%ecx, %eax
	movsd	0(%rbp), %xmm0
	jnb	.L108
	movq	16(%rsp), %rdi
	movl	(%rdi,%rax,4), %edx
	leaq	(%r15,%rdx,8), %rdi
	incl	(%rbx,%rdx,4)
	movsd	(%rdi), %xmm1
	addsd	(%rsi,%rax,8), %xmm1
	movsd	%xmm1, (%rdi)
	movsd	(%r14,%rdx,8), %xmm1
	subsd	(%rsi,%rax,8), %xmm1
	incq	%rax
	addsd	%xmm1, %xmm0
	movsd	%xmm0, 0(%rbp)
	jmp	.L71
.L108:
	cvtsi2sdl	%ecx, %xmm1
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 0(%rbp)
.L106:
	andps	.LC5(%rip), %xmm0
	comisd	40(%rsp), %xmm0
	movsd	%xmm0, 0(%r13)
	jbe	.L109
	movsd	_ZL7d_pmind(%rip), %xmm1
	xorl	%eax, %eax
.L80:
	movl	(%rbx,%rax,4), %edx
	testl	%edx, %edx
	je	.L74
	cvtsi2sdq	%rdx, %xmm2
	movsd	(%r15,%rax,8), %xmm0
	xorl	%ecx, %ecx
	movl	%ecx, (%rbx,%rax,4)
	divsd	%xmm2, %xmm0
	movsd	%xmm0, (%r14,%rax,8)
	jmp	.L77
.L74:
	testq	%rax, %rax
	jne	.L78
	movsd	(%r12), %xmm0
	addsd	%xmm1, %xmm0
	mulsd	.LC4(%rip), %xmm0
	movsd	%xmm0, (%r14)
	jmp	.L77
.L78:
	movsd	-8(%r12,%rax,8), %xmm0
	cmpl	%eax, 32(%rsp)
	jne	.L79
	addsd	_ZL7d_pmaxd(%rip), %xmm0
	jmp	.L105
.L79:
	addsd	(%r12,%rax,8), %xmm0
.L105:
	mulsd	.LC4(%rip), %xmm0
	movsd	%xmm0, (%r14,%rax,8)
.L77:
	movl	12(%rsp), %ecx
	movq	$0x000000000, (%r15,%rax,8)
	incq	%rax
	cmpl	%ecx, %eax
	jb	.L80
	movq	24(%rsp), %rdx
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	_ZL7d_psize(%rip), %ecx
	movq	_ZL9h_pointsd(%rip), %rsi
	xorl	%edx, %edx
.L81:
	xorl	%eax, %eax
	cmpl	%ecx, %edx
	jnb	.L110
.L87:
	movl	32(%rsp), %edi
	cmpl	%edi, %eax
	jnb	.L85
	movsd	(%rsi,%rdx,8), %xmm0
	comisd	(%r14,%rax,8), %xmm0
	jb	.L82
	movsd	8(%r14,%rax,8), %xmm1
	comisd	%xmm0, %xmm1
	jbe	.L82
	incl	(%rbx,%rax,4)
	leaq	(%r15,%rax,8), %rax
	addsd	(%rax), %xmm0
	movsd	%xmm0, (%rax)
	jmp	.L85
.L82:
	incq	%rax
	jmp	.L87
.L85:
	incq	%rdx
	jmp	.L81
.L110:
	movsd	.LC4(%rip), %xmm1
.L88:
	movl	32(%rsp), %esi
	cmpl	%esi, %eax
	jnb	.L111
	movl	(%rbx,%rax,4), %edx
	testl	%edx, %edx
	je	.L89
	cvtsi2sdq	%rdx, %xmm2
	movsd	(%r15,%rax,8), %xmm0
	xorl	%edx, %edx
	movl	%edx, (%rbx,%rax,4)
	divsd	%xmm2, %xmm0
	movsd	%xmm0, (%r12,%rax,8)
	jmp	.L92
.L89:
	movsd	(%r14,%rax,8), %xmm0
	addsd	8(%r14,%rax,8), %xmm0
	mulsd	%xmm1, %xmm0
	movsd	%xmm0, (%r12,%rax,8)
.L92:
	movq	$0x000000000, (%r15,%rax,8)
	incq	%rax
	jmp	.L88
.L111:
	movl	36(%rsp), %eax
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$8, %rdx
	movl	$1, %ecx
	movl	$1, 84(%rsp)
	movl	%eax, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	movq	%rdx, 76(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L94
	movq	_ZL8d_groups(%rip), %r8
	movl	12(%rsp), %ecx
	movq	56(%rsp), %rdx
	movl	_ZL7d_psize(%rip), %esi
	movq	_ZL9d_pointsd(%rip), %rdi
	call	_Z37__device_stub__Z11groupKernelPdjS_jPjPdjS_jPj
.L94:
	movl	_ZL7d_psize(%rip), %edx
	movq	16(%rsp), %rdi
	movl	$2, %ecx
	movq	_ZL8d_groups(%rip), %rsi
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movsd	0(%rbp), %xmm0
	movl	_ZL7d_psize(%rip), %ecx
	xorl	%eax, %eax
	movq	_ZL9h_pointsd(%rip), %rsi
	movsd	%xmm0, 0(%r13)
	movq	$0x000000000, 0(%rbp)
.L95:
	cmpl	%ecx, %eax
	movsd	0(%rbp), %xmm1
	jnb	.L112
	movq	16(%rsp), %rdi
	movl	(%rdi,%rax,4), %edx
	leaq	(%r15,%rdx,8), %rdi
	incl	(%rbx,%rdx,4)
	movsd	(%rdi), %xmm0
	addsd	(%rsi,%rax,8), %xmm0
	movsd	%xmm0, (%rdi)
	movsd	(%r14,%rdx,8), %xmm0
	subsd	(%rsi,%rax,8), %xmm0
	incq	%rax
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 0(%rbp)
	jmp	.L95
.L112:
	cvtsi2sdl	%ecx, %xmm0
	divsd	%xmm0, %xmm1
	movsd	%xmm1, 0(%rbp)
	movsd	0(%r13), %xmm0
	subsd	%xmm1, %xmm0
	jmp	.L106
.L109:
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L98
	call	__stack_chk_fail@PLT
.L98:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	movq	%r15, %rdi
	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
	jmp	free@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z5lloydPdjdS_RdS0_Pj, .-_Z5lloydPdjdS_RdS0_Pj
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC6:
	.string	"_Z11groupKernelPdjS_jPj"
.LC7:
	.string	"_Z11groupKernelPfjS_jPj"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2062:
	.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	.LC6(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z11groupKernelPdjS_jPj(%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	.LC7(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z11groupKernelPfjS_jPj(%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
.LFE2062:
	.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
	.local	_ZL7d_pmind
	.comm	_ZL7d_pmind,8,8
	.local	_ZL7d_pmaxd
	.comm	_ZL7d_pmaxd,8,8
	.local	_ZL6d_pmin
	.comm	_ZL6d_pmin,4,4
	.local	_ZL6d_pmax
	.comm	_ZL6d_pmax,4,4
	.local	_ZL7d_psize
	.comm	_ZL7d_psize,4,4
	.local	_ZL8d_groups
	.comm	_ZL8d_groups,8,8
	.local	_ZL9d_pointsd
	.comm	_ZL9d_pointsd,8,8
	.local	_ZL9h_pointsd
	.comm	_ZL9h_pointsd,8,8
	.local	_ZL8d_points
	.comm	_ZL8d_points,8,8
	.local	_ZL8h_points
	.comm	_ZL8h_points,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1056964608
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC4:
	.long	0
	.long	1071644672
	.section	.rodata.cst16
	.align 16
.LC5:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.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 <cstdio>

static float *h_points;
static float *d_points;
static double *h_pointsd;
static double *d_pointsd;
static unsigned int *d_groups;
static unsigned int d_psize;
static float d_pmax;
static float d_pmin;
static double d_pmaxd;
static double d_pmind;

__global__ void groupKernel(float *points, unsigned int psize, float *codebook, unsigned int csize, unsigned int *groups) {
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	if (idx < psize) {
		float d = abs(points[idx] - codebook[0]);
		float min = d;
		unsigned int g = 0;
		for(int i = 1; i < csize; i++) {
			d = abs(points[idx] - codebook[i]);
			g += (d < min) * (i - g);
			min -= (d < min) * (min - d);
		}
		groups[idx] = g;
	}
}

__global__ void groupKernel(double *points, unsigned int psize, double *codebook, unsigned int csize, unsigned int *groups) {
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	if (idx < psize) {
		double d = abs(points[idx] - codebook[0]);
		double min = d;
		unsigned int g = 0;
		for(int i = 1; i < csize; i++) {
			d = abs(points[idx] - codebook[i]);
			g += (d < min) * (i - g);
			min -= (d < min) * (min - d);
		}
		groups[idx] = g;
	}
}

void setupLloyds(float *points, unsigned int psize, float pmax, float pmin) {
	d_psize = psize;
	d_pmax = pmax;
	d_pmin = pmin;

	h_points = points;
  hipMalloc((void**)&d_points, sizeof(float)*psize);
  hipMalloc((void**)&d_groups, sizeof(unsigned int)*psize);

	hipMemcpy(d_points, points, sizeof(float) * psize, hipMemcpyHostToDevice);
}

void setupLloyds(double *points, unsigned int psize, double pmax, double pmin) {
	d_psize = psize;
	d_pmaxd = pmax;
	d_pmind = pmin;

	h_pointsd = points;
  hipMalloc((void**)&d_pointsd, sizeof(double)*psize);
  hipMalloc((void**)&d_groups, sizeof(unsigned int)*psize);

	hipMemcpy(d_pointsd, points, sizeof(double) * psize, hipMemcpyHostToDevice);
}

void lloyd(float *codebook, unsigned int csize, float stop_criteria, float *table, float &dist, float &reldist, unsigned int *groups) {

	float *d_codebook;
	dist = 0;
	reldist = 0;

	// Calculate initial table
	//can be done in gpu if csize is big enough
	for(int i = 0; i < csize-1; i++) {
		table[i] = (codebook[i] + codebook[i+1]) / 2;
	}

  hipMalloc((void**)&d_codebook, sizeof(float)*csize);
	hipMemcpy(d_codebook, codebook, sizeof(float)*csize, hipMemcpyHostToDevice);

	// Assign each point its codebook group
	unsigned int threads = 256;
	unsigned int blocks = (d_psize - 1) / threads + 1;
	groupKernel<<<blocks, threads>>>(d_points, d_psize, d_codebook, csize, d_groups);

	hipMemcpy(groups, d_groups, sizeof(unsigned int) * d_psize, hipMemcpyDeviceToHost);
	
	unsigned int *incode = (unsigned int*)calloc(csize, sizeof(unsigned int));
	float *meancode = (float*)calloc(csize, sizeof(float));

	// Calculate the mean of each codebook group and distortion
	for(int i = 0; i < d_psize; i++) {
		incode[groups[i]]++;
		meancode[groups[i]] += h_points[i];
		dist += codebook[groups[i]] - h_points[i];
	}
	dist /= d_psize;

	reldist = abs(dist);

	while(reldist > stop_criteria) {

		// Update codebook
		//can be done in gpu if csize is big enough
		for(int i = 0; i < csize; i++) {
			if(incode[i] != 0) {
				codebook[i] = meancode[i] / incode[i];
				incode[i] = 0;
			} else if (i == 0) {
				codebook[i] = (table[0] + d_pmin) / 2;
			} else if (i == csize-1) {
				codebook[i] = (table[i-1] + d_pmax) / 2;
			} else {
				codebook[i] = (table[i-1] + table[i]) / 2;
			}
			meancode[i] = 0;
		}

		hipMemcpy(d_codebook, codebook, sizeof(float)*csize, hipMemcpyHostToDevice);

		// How to do this in CUDA efficiently?
		for(int i = 0; i < d_psize; i++) {
			for(int j = 0; j < csize-1; j++) {
				if((h_points[i] >= codebook[j])
				&& (h_points[i] < codebook[j+1])) {
					incode[j]++;
					meancode[j] += h_points[i];
					break;
				}
			}
		}

		// Update table
		//can be done in gpu if csize is big enough
		for(int i = 0; i < csize-1; i++) {
			if(incode[i] != 0) {
				table[i] = meancode[i] / incode[i];
				incode[i] = 0;
			} else {
				table[i] = (codebook[i] + codebook[i+1]) / 2;
			}
			meancode[i] = 0;
		}

		// Assign each point its codebook group
		groupKernel<<<blocks, threads>>>(d_points, d_psize, d_codebook, csize, d_groups);

		hipMemcpy(groups, d_groups, sizeof(unsigned int) * d_psize, hipMemcpyDeviceToHost);

		reldist = dist;
		dist = 0;

		// Calculate the mean of each codebook group and distortion
		for(int i = 0; i < d_psize; i++) {
			incode[groups[i]]++;
			meancode[groups[i]] += h_points[i];
			dist += codebook[groups[i]] - h_points[i];
		}
		dist /= d_psize;

		reldist = abs(reldist - dist);
	}  // END WHILE

	hipFree(d_codebook);
	free(incode);
	free(meancode);
}

void lloyd(double *codebook, unsigned int csize, double stop_criteria, double *table, double &dist, double &reldist, unsigned int *groups) {

	double *d_codebook;
	dist = 0;
	reldist = 0;

	// Calculate initial table
	//can be done in gpu if csize is big enough
	for(int i = 0; i < csize-1; i++) {
		table[i] = (codebook[i] + codebook[i+1]) / 2;
	}

  hipMalloc((void**)&d_codebook, sizeof(double)*csize);
	hipMemcpy(d_codebook, codebook, sizeof(double)*csize, hipMemcpyHostToDevice);

	// Assign each point its codebook group
	unsigned int threads = 256;
	unsigned int blocks = (d_psize - 1) / threads + 1;
	groupKernel<<<blocks, threads>>>(d_pointsd, d_psize, d_codebook, csize, d_groups);

	hipMemcpy(groups, d_groups, sizeof(unsigned int) * d_psize, hipMemcpyDeviceToHost);
	
	unsigned int *incode = (unsigned int*)calloc(csize, sizeof(unsigned int));
	double *meancode = (double*)calloc(csize, sizeof(double));

	// Calculate the mean of each codebook group and distortion
	for(int i = 0; i < d_psize; i++) {
		incode[groups[i]]++;
		meancode[groups[i]] += h_pointsd[i];
		dist += codebook[groups[i]] - h_pointsd[i];
	}
	dist /= d_psize;

	reldist = abs(dist);

	while(reldist > stop_criteria) {

		// Update codebook
		//can be done in gpu if csize is big enough
		for(int i = 0; i < csize; i++) {
			if(incode[i] != 0) {
				codebook[i] = meancode[i] / incode[i];
				incode[i] = 0;
			} else if (i == 0) {
				codebook[i] = (table[0] + d_pmind) / 2;
			} else if (i == csize-1) {
				codebook[i] = (table[i-1] + d_pmaxd) / 2;
			} else {
				codebook[i] = (table[i-1] + table[i]) / 2;
			}
			meancode[i] = 0;
		}

		hipMemcpy(d_codebook, codebook, sizeof(double)*csize, hipMemcpyHostToDevice);

		// How to do this in CUDA efficiently?
		for(int i = 0; i < d_psize; i++) {
			for(int j = 0; j < csize-1; j++) {
				if((h_pointsd[i] >= codebook[j])
				&& (h_pointsd[i] < codebook[j+1])) {
					incode[j]++;
					meancode[j] += h_pointsd[i];
					break;
				}
			}
		}

		// Update table
		//can be done in gpu if csize is big enough
		for(int i = 0; i < csize-1; i++) {
			if(incode[i] != 0) {
				table[i] = meancode[i] / incode[i];
				incode[i] = 0;
			} else {
				table[i] = (codebook[i] + codebook[i+1]) / 2;
			}
			meancode[i] = 0;
		}

		// Assign each point its codebook group
		groupKernel<<<blocks, threads>>>(d_pointsd, d_psize, d_codebook, csize, d_groups);

		hipMemcpy(groups, d_groups, sizeof(unsigned int) * d_psize, hipMemcpyDeviceToHost);

		reldist = dist;
		dist = 0;

		// Calculate the mean of each codebook group and distortion
		for(int i = 0; i < d_psize; i++) {
			incode[groups[i]]++;
			meancode[groups[i]] += h_pointsd[i];
			dist += codebook[groups[i]] - h_pointsd[i];
		}
		dist /= d_psize;

		reldist = abs(reldist - dist);
	}  // END WHILE

	hipFree(d_codebook);
	free(incode);
	free(meancode);
}


void finalize() {
	hipFree(d_points);
	hipFree(d_groups);
}

void finalized() {
	hipFree(d_pointsd);
	hipFree(d_groups);
}


	.text
	.file	"lloyd.hip"
	.globl	_Z26__device_stub__groupKernelPfjS_jPj # -- Begin function _Z26__device_stub__groupKernelPfjS_jPj
	.type	_Z26__device_stub__groupKernelPfjS_jPj,@function
_Z26__device_stub__groupKernelPfjS_jPj: # @_Z26__device_stub__groupKernelPfjS_jPj
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	movq	%rsp, %rdx
	movl	%ecx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z11groupKernelPfjS_jPj, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z26__device_stub__groupKernelPfjS_jPj, .Lfunc_end0-_Z26__device_stub__groupKernelPfjS_jPj
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__groupKernelPdjS_jPj # -- Begin function _Z26__device_stub__groupKernelPdjS_jPj
	.type	_Z26__device_stub__groupKernelPdjS_jPj,@function
_Z26__device_stub__groupKernelPdjS_jPj: # @_Z26__device_stub__groupKernelPdjS_jPj
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$128, %rsp
	.cfi_def_cfa_offset 176
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	movq	%rsp, %rdx
	movl	%ecx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z11groupKernelPdjS_jPj, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$144, %rsp
	.cfi_adjust_cfa_offset -144
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z26__device_stub__groupKernelPdjS_jPj, .Lfunc_end1-_Z26__device_stub__groupKernelPdjS_jPj
	.cfi_endproc
                                        # -- End function
	.globl	_Z11setupLloydsPfjff            # -- Begin function _Z11setupLloydsPfjff
	.type	_Z11setupLloydsPfjff,@function
_Z11setupLloydsPfjff:                   # @_Z11setupLloydsPfjff
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %rbx
	movl	%esi, _ZL7d_psize(%rip)
	movss	%xmm0, _ZL6d_pmax(%rip)
	movss	%xmm1, _ZL6d_pmin(%rip)
	movq	%rdi, _ZL8h_points(%rip)
	movl	%esi, %r14d
	shlq	$2, %r14
	movl	$_ZL8d_points, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	$_ZL8d_groups, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	_ZL8d_points(%rip), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	hipMemcpy                       # TAILCALL
.Lfunc_end2:
	.size	_Z11setupLloydsPfjff, .Lfunc_end2-_Z11setupLloydsPfjff
	.cfi_endproc
                                        # -- End function
	.globl	_Z11setupLloydsPdjdd            # -- Begin function _Z11setupLloydsPdjdd
	.type	_Z11setupLloydsPdjdd,@function
_Z11setupLloydsPdjdd:                   # @_Z11setupLloydsPdjdd
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, _ZL7d_psize(%rip)
	movsd	%xmm0, _ZL7d_pmaxd(%rip)
	movsd	%xmm1, _ZL7d_pmind(%rip)
	movq	%rdi, _ZL9h_pointsd(%rip)
	movl	%esi, %r14d
	leaq	(,%r14,8), %r15
	movl	$_ZL9d_pointsd, %edi
	movq	%r15, %rsi
	callq	hipMalloc
	shlq	$2, %r14
	movl	$_ZL8d_groups, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	_ZL9d_pointsd(%rip), %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	hipMemcpy                       # TAILCALL
.Lfunc_end3:
	.size	_Z11setupLloydsPdjdd, .Lfunc_end3-_Z11setupLloydsPdjdd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z5lloydPfjfS_RfS0_Pj
.LCPI4_0:
	.long	0x3f000000                      # float 0.5
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI4_1:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.text
	.globl	_Z5lloydPfjfS_RfS0_Pj
	.type	_Z5lloydPfjfS_RfS0_Pj,@function
_Z5lloydPfjfS_RfS0_Pj:                  # @_Z5lloydPfjfS_RfS0_Pj
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.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	%r9, 16(%rsp)                   # 8-byte Spill
	movq	%rcx, %r15
	movq	%rdx, %r12
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movq	%rdi, %r13
	xorl	%eax, %eax
	movl	%eax, (%rcx)
	movq	%r8, 40(%rsp)                   # 8-byte Spill
	movl	%eax, (%r8)
	movl	%esi, 8(%rsp)                   # 4-byte Spill
	decl	%esi
	movl	%esi, 52(%rsp)                  # 4-byte Spill
	movl	%esi, %ebp
	je	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
	movss	.LCPI4_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r13,%rax,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	addss	4(%r13,%rax,4), %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%r12,%rax,4)
	leaq	1(%rax), %rcx
	movq	%rcx, %rax
	cmpq	%rcx, %rbp
	jne	.LBB4_2
.LBB4_3:                                # %._crit_edge
	movl	8(%rsp), %eax                   # 4-byte Reload
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	leaq	(,%rax,4), %rbx
	leaq	24(%rsp), %r14
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	(%r14), %rdi
	movq	%r13, %rsi
	movq	%rbx, 64(%rsp)                  # 8-byte Spill
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	_ZL7d_psize(%rip), %eax
	decl	%eax
	shrl	$8, %eax
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	leaq	(%rax,%rdx), %rdi
	addq	$-255, %rdi
	movq	%rdi, 56(%rsp)                  # 8-byte Spill
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_5
# %bb.4:
	movq	_ZL8d_points(%rip), %rdi
	movl	_ZL7d_psize(%rip), %esi
	movq	24(%rsp), %rdx
	movq	_ZL8d_groups(%rip), %r8
	movl	8(%rsp), %ecx                   # 4-byte Reload
	callq	_Z26__device_stub__groupKernelPfjS_jPj
.LBB4_5:
	movq	_ZL8d_groups(%rip), %rsi
	movl	_ZL7d_psize(%rip), %edx
	shlq	$2, %rdx
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$4, %esi
	movq	32(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	callq	calloc
	movq	%rax, %r14
	movl	$4, %esi
	movq	%rbx, %rdi
	callq	calloc
	movq	%rax, %rbx
	movl	_ZL7d_psize(%rip), %eax
	movss	(%r15), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	testq	%rax, %rax
	je	.LBB4_8
# %bb.6:                                # %.lr.ph176
	movq	_ZL8h_points(%rip), %rcx
	xorl	%edx, %edx
	movq	16(%rsp), %rdi                  # 8-byte Reload
.LBB4_7:                                # =>This Inner Loop Header: Depth=1
	movl	(%rdi,%rdx,4), %esi
	incl	(%r14,%rsi,4)
	movss	(%rcx,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movss	(%rbx,%rsi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	addss	%xmm1, %xmm2
	movss	%xmm2, (%rbx,%rsi,4)
	movss	(%r13,%rsi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	%xmm1, %xmm2
	addss	%xmm2, %xmm0
	movss	%xmm0, (%r15)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB4_7
.LBB4_8:                                # %._crit_edge177
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rax, %xmm1
	divss	%xmm1, %xmm0
	movss	%xmm0, (%r15)
	andps	.LCPI4_1(%rip), %xmm0
	movq	40(%rsp), %rax                  # 8-byte Reload
	movss	%xmm0, (%rax)
	ucomiss	12(%rsp), %xmm0                 # 4-byte Folded Reload
	jbe	.LBB4_40
# %bb.9:                                # %.preheader168.lr.ph
	leaq	(,%rbp,4), %rsi
	movss	.LCPI4_0(%rip), %xmm4           # xmm4 = mem[0],zero,zero,zero
	movq	%rsi, 32(%rsp)                  # 8-byte Spill
.LBB4_10:                               # %.preheader168
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_12 Depth 2
                                        #     Child Loop BB4_16 Depth 2
                                        #       Child Loop BB4_18 Depth 3
                                        #     Child Loop BB4_29 Depth 2
                                        #     Child Loop BB4_42 Depth 2
	cmpl	$0, 8(%rsp)                     # 4-byte Folded Reload
	movq	64(%rsp), %rdx                  # 8-byte Reload
	je	.LBB4_14
# %bb.11:                               # %.lr.ph180
                                        #   in Loop: Header=BB4_10 Depth=1
	movss	_ZL6d_pmax(%rip), %xmm0         # xmm0 = mem[0],zero,zero,zero
	movss	_ZL6d_pmin(%rip), %xmm1         # xmm1 = mem[0],zero,zero,zero
	xorl	%eax, %eax
.LBB4_12:                               #   Parent Loop BB4_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r14,%rax), %ecx
	testl	%ecx, %ecx
	je	.LBB4_21
# %bb.13:                               #   in Loop: Header=BB4_12 Depth=2
	movl	%ecx, %ecx
	xorps	%xmm2, %xmm2
	cvtsi2ss	%rcx, %xmm2
	movss	(%rbx,%rax), %xmm3              # xmm3 = mem[0],zero,zero,zero
	divss	%xmm2, %xmm3
	movss	%xmm3, (%r13,%rax)
	movl	$0, (%r14,%rax)
.LBB4_26:                               #   in Loop: Header=BB4_12 Depth=2
	movl	$0, (%rbx,%rax)
	addq	$4, %rax
	cmpq	%rax, %rdx
	jne	.LBB4_12
	jmp	.LBB4_14
.LBB4_21:                               #   in Loop: Header=BB4_12 Depth=2
	testq	%rax, %rax
	je	.LBB4_22
# %bb.23:                               #   in Loop: Header=BB4_12 Depth=2
	cmpq	%rax, %rsi
	jne	.LBB4_25
# %bb.24:                               #   in Loop: Header=BB4_12 Depth=2
	movss	-4(%r12,%rbp,4), %xmm2          # xmm2 = mem[0],zero,zero,zero
	addss	%xmm0, %xmm2
	mulss	%xmm4, %xmm2
	movss	%xmm2, (%r13,%rbp,4)
	jmp	.LBB4_26
.LBB4_22:                               #   in Loop: Header=BB4_12 Depth=2
	movss	(%r12), %xmm2                   # xmm2 = mem[0],zero,zero,zero
	addss	%xmm1, %xmm2
	mulss	%xmm4, %xmm2
	movss	%xmm2, (%r13)
	jmp	.LBB4_26
.LBB4_25:                               #   in Loop: Header=BB4_12 Depth=2
	movss	-4(%r12,%rax), %xmm2            # xmm2 = mem[0],zero,zero,zero
	addss	(%r12,%rax), %xmm2
	mulss	%xmm4, %xmm2
	movss	%xmm2, (%r13,%rax)
	jmp	.LBB4_26
.LBB4_14:                               # %._crit_edge181
                                        #   in Loop: Header=BB4_10 Depth=1
	movq	24(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	_ZL7d_psize(%rip), %eax
	testq	%rax, %rax
	movl	52(%rsp), %edi                  # 4-byte Reload
	je	.LBB4_27
# %bb.15:                               # %.preheader.lr.ph
                                        #   in Loop: Header=BB4_10 Depth=1
	movq	_ZL8h_points(%rip), %rcx
	xorl	%edx, %edx
.LBB4_16:                               # %.preheader
                                        #   Parent Loop BB4_10 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_18 Depth 3
	testl	%edi, %edi
	je	.LBB4_32
# %bb.17:                               # %.lr.ph183
                                        #   in Loop: Header=BB4_16 Depth=2
	movss	(%rcx,%rdx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	xorl	%esi, %esi
.LBB4_18:                               #   Parent Loop BB4_10 Depth=1
                                        #     Parent Loop BB4_16 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	ucomiss	(%r13,%rsi,4), %xmm0
	jb	.LBB4_31
# %bb.19:                               #   in Loop: Header=BB4_18 Depth=3
	movss	4(%r13,%rsi,4), %xmm1           # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	ja	.LBB4_20
.LBB4_31:                               #   in Loop: Header=BB4_18 Depth=3
	incq	%rsi
	cmpq	%rsi, %rbp
	jne	.LBB4_18
	jmp	.LBB4_32
.LBB4_20:                               #   in Loop: Header=BB4_16 Depth=2
	incl	(%r14,%rsi,4)
	addss	(%rbx,%rsi,4), %xmm0
	movss	%xmm0, (%rbx,%rsi,4)
.LBB4_32:                               # %.loopexit
                                        #   in Loop: Header=BB4_16 Depth=2
	incq	%rdx
	cmpq	%rax, %rdx
	jne	.LBB4_16
.LBB4_27:                               # %.preheader167
                                        #   in Loop: Header=BB4_10 Depth=1
	testl	%edi, %edi
	movss	.LCPI4_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	je	.LBB4_35
# %bb.28:                               # %.lr.ph187.preheader
                                        #   in Loop: Header=BB4_10 Depth=1
	xorl	%eax, %eax
.LBB4_29:                               # %.lr.ph187
                                        #   Parent Loop BB4_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r14,%rax,4), %ecx
	testl	%ecx, %ecx
	je	.LBB4_33
# %bb.30:                               #   in Loop: Header=BB4_29 Depth=2
	movl	%ecx, %ecx
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rcx, %xmm1
	movss	(%rbx,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	divss	%xmm1, %xmm0
	movl	$0, (%r14,%rax,4)
	jmp	.LBB4_34
.LBB4_33:                               #   in Loop: Header=BB4_29 Depth=2
	movss	(%r13,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	addss	4(%r13,%rax,4), %xmm0
	mulss	%xmm2, %xmm0
.LBB4_34:                               #   in Loop: Header=BB4_29 Depth=2
	movss	%xmm0, (%r12,%rax,4)
	movl	$0, (%rbx,%rax,4)
	incq	%rax
	cmpq	%rax, %rbp
	jne	.LBB4_29
.LBB4_35:                               # %._crit_edge188
                                        #   in Loop: Header=BB4_10 Depth=1
	movq	56(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_37
# %bb.36:                               #   in Loop: Header=BB4_10 Depth=1
	movq	_ZL8d_points(%rip), %rdi
	movl	_ZL7d_psize(%rip), %esi
	movq	24(%rsp), %rdx
	movq	_ZL8d_groups(%rip), %r8
	movl	8(%rsp), %ecx                   # 4-byte Reload
	callq	_Z26__device_stub__groupKernelPfjS_jPj
.LBB4_37:                               #   in Loop: Header=BB4_10 Depth=1
	movq	_ZL8d_groups(%rip), %rsi
	movl	_ZL7d_psize(%rip), %edx
	shlq	$2, %rdx
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movss	(%r15), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movq	40(%rsp), %rax                  # 8-byte Reload
	movss	%xmm0, (%rax)
	movl	$0, (%r15)
	movl	_ZL7d_psize(%rip), %eax
	xorps	%xmm0, %xmm0
	testq	%rax, %rax
	je	.LBB4_38
# %bb.41:                               # %.lr.ph192
                                        #   in Loop: Header=BB4_10 Depth=1
	movq	_ZL8h_points(%rip), %rcx
	xorl	%edx, %edx
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movss	.LCPI4_0(%rip), %xmm4           # xmm4 = mem[0],zero,zero,zero
.LBB4_42:                               #   Parent Loop BB4_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rdi,%rdx,4), %esi
	incl	(%r14,%rsi,4)
	movss	(%rcx,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movss	(%rbx,%rsi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	addss	%xmm1, %xmm2
	movss	%xmm2, (%rbx,%rsi,4)
	movss	(%r13,%rsi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	%xmm1, %xmm2
	addss	%xmm2, %xmm0
	movss	%xmm0, (%r15)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB4_42
	jmp	.LBB4_39
.LBB4_38:                               #   in Loop: Header=BB4_10 Depth=1
	movss	.LCPI4_0(%rip), %xmm4           # xmm4 = mem[0],zero,zero,zero
.LBB4_39:                               # %._crit_edge193
                                        #   in Loop: Header=BB4_10 Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rax, %xmm1
	divss	%xmm1, %xmm0
	movss	%xmm0, (%r15)
	movq	40(%rsp), %rax                  # 8-byte Reload
	movss	(%rax), %xmm1                   # xmm1 = mem[0],zero,zero,zero
	subss	%xmm0, %xmm1
	andps	.LCPI4_1(%rip), %xmm1
	movss	%xmm1, (%rax)
	ucomiss	12(%rsp), %xmm1                 # 4-byte Folded Reload
	movq	32(%rsp), %rsi                  # 8-byte Reload
	ja	.LBB4_10
.LBB4_40:                               # %._crit_edge195
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	%r14, %rdi
	callq	free
	movq	%rbx, %rdi
	callq	free
	addq	$72, %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	_Z5lloydPfjfS_RfS0_Pj, .Lfunc_end4-_Z5lloydPfjfS_RfS0_Pj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z5lloydPdjdS_RdS0_Pj
.LCPI5_0:
	.quad	0x3fe0000000000000              # double 0.5
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI5_1:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.text
	.globl	_Z5lloydPdjdS_RdS0_Pj
	.type	_Z5lloydPdjdS_RdS0_Pj,@function
_Z5lloydPdjdS_RdS0_Pj:                  # @_Z5lloydPdjdS_RdS0_Pj
	.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	$88, %rsp
	.cfi_def_cfa_offset 144
	.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	%r9, 16(%rsp)                   # 8-byte Spill
	movq	%rcx, %r15
	movq	%rdx, %r12
	movsd	%xmm0, 56(%rsp)                 # 8-byte Spill
	movq	%rdi, %r13
	xorl	%eax, %eax
	movq	%rax, (%rcx)
	movq	%r8, 40(%rsp)                   # 8-byte Spill
	movq	%rax, (%r8)
	movl	%esi, 12(%rsp)                  # 4-byte Spill
	decl	%esi
	movl	%esi, 52(%rsp)                  # 4-byte Spill
	movl	%esi, %ebx
	je	.LBB5_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
	movsd	.LCPI5_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r13,%rax,8), %xmm1            # xmm1 = mem[0],zero
	addsd	8(%r13,%rax,8), %xmm1
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, (%r12,%rax,8)
	leaq	1(%rax), %rcx
	movq	%rcx, %rax
	cmpq	%rcx, %rbx
	jne	.LBB5_2
.LBB5_3:                                # %._crit_edge
	movl	12(%rsp), %eax                  # 4-byte Reload
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	leaq	(,%rax,8), %rbp
	leaq	24(%rsp), %r14
	movq	%r14, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movq	(%r14), %rdi
	movq	%r13, %rsi
	movq	%rbp, 80(%rsp)                  # 8-byte Spill
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	_ZL7d_psize(%rip), %eax
	decl	%eax
	shrl	$8, %eax
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	leaq	(%rax,%rdx), %rdi
	addq	$-255, %rdi
	movq	%rdi, 72(%rsp)                  # 8-byte Spill
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_5
# %bb.4:
	movq	_ZL9d_pointsd(%rip), %rdi
	movl	_ZL7d_psize(%rip), %esi
	movq	24(%rsp), %rdx
	movq	_ZL8d_groups(%rip), %r8
	movl	12(%rsp), %ecx                  # 4-byte Reload
	callq	_Z26__device_stub__groupKernelPdjS_jPj
.LBB5_5:
	movq	_ZL8d_groups(%rip), %rsi
	movl	_ZL7d_psize(%rip), %edx
	shlq	$2, %rdx
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$4, %esi
	movq	32(%rsp), %rbp                  # 8-byte Reload
	movq	%rbp, %rdi
	callq	calloc
	movq	%rax, %r14
	movl	$8, %esi
	movq	%rbp, %rdi
	callq	calloc
	movq	%rax, %rbp
	movl	_ZL7d_psize(%rip), %eax
	movsd	(%r15), %xmm0                   # xmm0 = mem[0],zero
	testq	%rax, %rax
	je	.LBB5_8
# %bb.6:                                # %.lr.ph176
	movq	_ZL9h_pointsd(%rip), %rcx
	xorl	%edx, %edx
	movq	16(%rsp), %rdi                  # 8-byte Reload
.LBB5_7:                                # =>This Inner Loop Header: Depth=1
	movl	(%rdi,%rdx,4), %esi
	incl	(%r14,%rsi,4)
	movsd	(%rcx,%rdx,8), %xmm1            # xmm1 = mem[0],zero
	movsd	(%rbp,%rsi,8), %xmm2            # xmm2 = mem[0],zero
	addsd	%xmm1, %xmm2
	movsd	%xmm2, (%rbp,%rsi,8)
	movsd	(%r13,%rsi,8), %xmm2            # xmm2 = mem[0],zero
	subsd	%xmm1, %xmm2
	addsd	%xmm2, %xmm0
	movsd	%xmm0, (%r15)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB5_7
.LBB5_8:                                # %._crit_edge177
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	%xmm1, %xmm0
	movsd	%xmm0, (%r15)
	andpd	.LCPI5_1(%rip), %xmm0
	movq	40(%rsp), %rax                  # 8-byte Reload
	movlpd	%xmm0, (%rax)
	ucomisd	56(%rsp), %xmm0                 # 8-byte Folded Reload
	jbe	.LBB5_40
# %bb.9:                                # %.preheader168.lr.ph
	leaq	(,%rbx,4), %rsi
	shlq	$2, 32(%rsp)                    # 8-byte Folded Spill
	movsd	.LCPI5_0(%rip), %xmm4           # xmm4 = mem[0],zero
	movq	%rsi, 64(%rsp)                  # 8-byte Spill
.LBB5_10:                               # %.preheader168
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_12 Depth 2
                                        #     Child Loop BB5_16 Depth 2
                                        #       Child Loop BB5_18 Depth 3
                                        #     Child Loop BB5_29 Depth 2
                                        #     Child Loop BB5_42 Depth 2
	cmpl	$0, 12(%rsp)                    # 4-byte Folded Reload
	movq	32(%rsp), %rdx                  # 8-byte Reload
	je	.LBB5_14
# %bb.11:                               # %.lr.ph180
                                        #   in Loop: Header=BB5_10 Depth=1
	movsd	_ZL7d_pmaxd(%rip), %xmm0        # xmm0 = mem[0],zero
	movsd	_ZL7d_pmind(%rip), %xmm1        # xmm1 = mem[0],zero
	xorl	%eax, %eax
.LBB5_12:                               #   Parent Loop BB5_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r14,%rax), %ecx
	testl	%ecx, %ecx
	je	.LBB5_21
# %bb.13:                               #   in Loop: Header=BB5_12 Depth=2
	movl	%ecx, %ecx
	xorps	%xmm2, %xmm2
	cvtsi2sd	%rcx, %xmm2
	movsd	(%rbp,%rax,2), %xmm3            # xmm3 = mem[0],zero
	divsd	%xmm2, %xmm3
	movsd	%xmm3, (%r13,%rax,2)
	movl	$0, (%r14,%rax)
.LBB5_26:                               #   in Loop: Header=BB5_12 Depth=2
	movq	$0, (%rbp,%rax,2)
	addq	$4, %rax
	cmpq	%rax, %rdx
	jne	.LBB5_12
	jmp	.LBB5_14
.LBB5_21:                               #   in Loop: Header=BB5_12 Depth=2
	testq	%rax, %rax
	je	.LBB5_22
# %bb.23:                               #   in Loop: Header=BB5_12 Depth=2
	cmpq	%rax, %rsi
	jne	.LBB5_25
# %bb.24:                               #   in Loop: Header=BB5_12 Depth=2
	movsd	-8(%r12,%rbx,8), %xmm2          # xmm2 = mem[0],zero
	addsd	%xmm0, %xmm2
	mulsd	%xmm4, %xmm2
	movsd	%xmm2, (%r13,%rbx,8)
	jmp	.LBB5_26
.LBB5_22:                               #   in Loop: Header=BB5_12 Depth=2
	movsd	(%r12), %xmm2                   # xmm2 = mem[0],zero
	addsd	%xmm1, %xmm2
	mulsd	%xmm4, %xmm2
	movsd	%xmm2, (%r13)
	jmp	.LBB5_26
.LBB5_25:                               #   in Loop: Header=BB5_12 Depth=2
	movsd	-8(%r12,%rax,2), %xmm2          # xmm2 = mem[0],zero
	addsd	(%r12,%rax,2), %xmm2
	mulsd	%xmm4, %xmm2
	movsd	%xmm2, (%r13,%rax,2)
	jmp	.LBB5_26
.LBB5_14:                               # %._crit_edge181
                                        #   in Loop: Header=BB5_10 Depth=1
	movq	24(%rsp), %rdi
	movq	%r13, %rsi
	movq	80(%rsp), %rdx                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	movl	_ZL7d_psize(%rip), %eax
	testq	%rax, %rax
	movl	52(%rsp), %edi                  # 4-byte Reload
	je	.LBB5_27
# %bb.15:                               # %.preheader.lr.ph
                                        #   in Loop: Header=BB5_10 Depth=1
	movq	_ZL9h_pointsd(%rip), %rcx
	xorl	%edx, %edx
.LBB5_16:                               # %.preheader
                                        #   Parent Loop BB5_10 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB5_18 Depth 3
	testl	%edi, %edi
	je	.LBB5_32
# %bb.17:                               # %.lr.ph183
                                        #   in Loop: Header=BB5_16 Depth=2
	movsd	(%rcx,%rdx,8), %xmm0            # xmm0 = mem[0],zero
	xorl	%esi, %esi
.LBB5_18:                               #   Parent Loop BB5_10 Depth=1
                                        #     Parent Loop BB5_16 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	ucomisd	(%r13,%rsi,8), %xmm0
	jb	.LBB5_31
# %bb.19:                               #   in Loop: Header=BB5_18 Depth=3
	movsd	8(%r13,%rsi,8), %xmm1           # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	ja	.LBB5_20
.LBB5_31:                               #   in Loop: Header=BB5_18 Depth=3
	incq	%rsi
	cmpq	%rsi, %rbx
	jne	.LBB5_18
	jmp	.LBB5_32
.LBB5_20:                               #   in Loop: Header=BB5_16 Depth=2
	incl	(%r14,%rsi,4)
	addsd	(%rbp,%rsi,8), %xmm0
	movsd	%xmm0, (%rbp,%rsi,8)
.LBB5_32:                               # %.loopexit
                                        #   in Loop: Header=BB5_16 Depth=2
	incq	%rdx
	cmpq	%rax, %rdx
	jne	.LBB5_16
.LBB5_27:                               # %.preheader167
                                        #   in Loop: Header=BB5_10 Depth=1
	testl	%edi, %edi
	movsd	.LCPI5_0(%rip), %xmm2           # xmm2 = mem[0],zero
	je	.LBB5_35
# %bb.28:                               # %.lr.ph187.preheader
                                        #   in Loop: Header=BB5_10 Depth=1
	xorl	%eax, %eax
.LBB5_29:                               # %.lr.ph187
                                        #   Parent Loop BB5_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r14,%rax,4), %ecx
	testl	%ecx, %ecx
	je	.LBB5_33
# %bb.30:                               #   in Loop: Header=BB5_29 Depth=2
	movsd	(%rbp,%rax,8), %xmm0            # xmm0 = mem[0],zero
	movl	%ecx, %ecx
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rcx, %xmm1
	divsd	%xmm1, %xmm0
	movl	$0, (%r14,%rax,4)
	jmp	.LBB5_34
.LBB5_33:                               #   in Loop: Header=BB5_29 Depth=2
	movsd	(%r13,%rax,8), %xmm0            # xmm0 = mem[0],zero
	addsd	8(%r13,%rax,8), %xmm0
	mulsd	%xmm2, %xmm0
.LBB5_34:                               #   in Loop: Header=BB5_29 Depth=2
	movsd	%xmm0, (%r12,%rax,8)
	movq	$0, (%rbp,%rax,8)
	incq	%rax
	cmpq	%rax, %rbx
	jne	.LBB5_29
.LBB5_35:                               # %._crit_edge188
                                        #   in Loop: Header=BB5_10 Depth=1
	movq	72(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movabsq	$4294967552, %rdx               # imm = 0x100000100
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_37
# %bb.36:                               #   in Loop: Header=BB5_10 Depth=1
	movq	_ZL9d_pointsd(%rip), %rdi
	movl	_ZL7d_psize(%rip), %esi
	movq	24(%rsp), %rdx
	movq	_ZL8d_groups(%rip), %r8
	movl	12(%rsp), %ecx                  # 4-byte Reload
	callq	_Z26__device_stub__groupKernelPdjS_jPj
.LBB5_37:                               #   in Loop: Header=BB5_10 Depth=1
	movq	_ZL8d_groups(%rip), %rsi
	movl	_ZL7d_psize(%rip), %edx
	shlq	$2, %rdx
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movsd	(%r15), %xmm0                   # xmm0 = mem[0],zero
	movq	40(%rsp), %rax                  # 8-byte Reload
	movsd	%xmm0, (%rax)
	movq	$0, (%r15)
	movl	_ZL7d_psize(%rip), %eax
	xorpd	%xmm0, %xmm0
	testq	%rax, %rax
	je	.LBB5_38
# %bb.41:                               # %.lr.ph192
                                        #   in Loop: Header=BB5_10 Depth=1
	movq	_ZL9h_pointsd(%rip), %rcx
	xorl	%edx, %edx
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movsd	.LCPI5_0(%rip), %xmm4           # xmm4 = mem[0],zero
.LBB5_42:                               #   Parent Loop BB5_10 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rdi,%rdx,4), %esi
	incl	(%r14,%rsi,4)
	movsd	(%rcx,%rdx,8), %xmm1            # xmm1 = mem[0],zero
	movsd	(%rbp,%rsi,8), %xmm2            # xmm2 = mem[0],zero
	addsd	%xmm1, %xmm2
	movsd	%xmm2, (%rbp,%rsi,8)
	movsd	(%r13,%rsi,8), %xmm2            # xmm2 = mem[0],zero
	subsd	%xmm1, %xmm2
	addsd	%xmm2, %xmm0
	movsd	%xmm0, (%r15)
	incq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB5_42
	jmp	.LBB5_39
.LBB5_38:                               #   in Loop: Header=BB5_10 Depth=1
	movsd	.LCPI5_0(%rip), %xmm4           # xmm4 = mem[0],zero
.LBB5_39:                               # %._crit_edge193
                                        #   in Loop: Header=BB5_10 Depth=1
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	%xmm1, %xmm0
	movsd	%xmm0, (%r15)
	movq	40(%rsp), %rax                  # 8-byte Reload
	movsd	(%rax), %xmm1                   # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	andpd	.LCPI5_1(%rip), %xmm1
	movlpd	%xmm1, (%rax)
	ucomisd	56(%rsp), %xmm1                 # 8-byte Folded Reload
	movq	64(%rsp), %rsi                  # 8-byte Reload
	ja	.LBB5_10
.LBB5_40:                               # %._crit_edge195
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	%r14, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z5lloydPdjdS_RdS0_Pj, .Lfunc_end5-_Z5lloydPdjdS_RdS0_Pj
	.cfi_endproc
                                        # -- End function
	.globl	_Z8finalizev                    # -- Begin function _Z8finalizev
	.type	_Z8finalizev,@function
_Z8finalizev:                           # @_Z8finalizev
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	_ZL8d_points(%rip), %rdi
	callq	hipFree
	movq	_ZL8d_groups(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	hipFree                         # TAILCALL
.Lfunc_end6:
	.size	_Z8finalizev, .Lfunc_end6-_Z8finalizev
	.cfi_endproc
                                        # -- End function
	.globl	_Z9finalizedv                   # -- Begin function _Z9finalizedv
	.type	_Z9finalizedv,@function
_Z9finalizedv:                          # @_Z9finalizedv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	_ZL9d_pointsd(%rip), %rdi
	callq	hipFree
	movq	_ZL8d_groups(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	hipFree                         # TAILCALL
.Lfunc_end7:
	.size	_Z9finalizedv, .Lfunc_end7-_Z9finalizedv
	.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	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11groupKernelPfjS_jPj, %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	$_Z11groupKernelPdjS_jPj, %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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z11groupKernelPfjS_jPj,@object # @_Z11groupKernelPfjS_jPj
	.section	.rodata,"a",@progbits
	.globl	_Z11groupKernelPfjS_jPj
	.p2align	3, 0x0
_Z11groupKernelPfjS_jPj:
	.quad	_Z26__device_stub__groupKernelPfjS_jPj
	.size	_Z11groupKernelPfjS_jPj, 8

	.type	_Z11groupKernelPdjS_jPj,@object # @_Z11groupKernelPdjS_jPj
	.globl	_Z11groupKernelPdjS_jPj
	.p2align	3, 0x0
_Z11groupKernelPdjS_jPj:
	.quad	_Z26__device_stub__groupKernelPdjS_jPj
	.size	_Z11groupKernelPdjS_jPj, 8

	.type	_ZL7d_psize,@object             # @_ZL7d_psize
	.local	_ZL7d_psize
	.comm	_ZL7d_psize,4,4
	.type	_ZL6d_pmax,@object              # @_ZL6d_pmax
	.local	_ZL6d_pmax
	.comm	_ZL6d_pmax,4,4
	.type	_ZL6d_pmin,@object              # @_ZL6d_pmin
	.local	_ZL6d_pmin
	.comm	_ZL6d_pmin,4,4
	.type	_ZL8h_points,@object            # @_ZL8h_points
	.local	_ZL8h_points
	.comm	_ZL8h_points,8,8
	.type	_ZL8d_points,@object            # @_ZL8d_points
	.local	_ZL8d_points
	.comm	_ZL8d_points,8,8
	.type	_ZL8d_groups,@object            # @_ZL8d_groups
	.local	_ZL8d_groups
	.comm	_ZL8d_groups,8,8
	.type	_ZL7d_pmaxd,@object             # @_ZL7d_pmaxd
	.local	_ZL7d_pmaxd
	.comm	_ZL7d_pmaxd,8,8
	.type	_ZL7d_pmind,@object             # @_ZL7d_pmind
	.local	_ZL7d_pmind
	.comm	_ZL7d_pmind,8,8
	.type	_ZL9h_pointsd,@object           # @_ZL9h_pointsd
	.local	_ZL9h_pointsd
	.comm	_ZL9h_pointsd,8,8
	.type	_ZL9d_pointsd,@object           # @_ZL9d_pointsd
	.local	_ZL9d_pointsd
	.comm	_ZL9d_pointsd,8,8
	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z11groupKernelPfjS_jPj"
	.size	.L__unnamed_1, 24

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z11groupKernelPdjS_jPj"
	.size	.L__unnamed_2, 24

	.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 _Z26__device_stub__groupKernelPfjS_jPj
	.addrsig_sym _Z26__device_stub__groupKernelPdjS_jPj
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11groupKernelPfjS_jPj
	.addrsig_sym _Z11groupKernelPdjS_jPj
	.addrsig_sym _ZL8d_points
	.addrsig_sym _ZL8d_groups
	.addrsig_sym _ZL9d_pointsd
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11groupKernelPfjS_jPj ; -- Begin function _Z11groupKernelPfjS_jPj
	.globl	_Z11groupKernelPfjS_jPj
	.p2align	8
	.type	_Z11groupKernelPfjS_jPj,@function
_Z11groupKernelPfjS_jPj:                ; @_Z11groupKernelPfjS_jPj
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_u32_e64 s3, v1
	s_cbranch_execz .LBB0_5
; %bb.1:
	s_load_b32 s4, s[0:1], 0x18
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_u32 s4, 2
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph.preheader
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x0
	s_load_b64 s[6:7], s[0:1], 0x10
	s_mov_b32 s5, 1
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo
	s_load_b32 s2, s[6:7], 0x0
	global_load_b32 v3, v[2:3], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_subrev_f32_e32 v2, s2, v3
	s_add_u32 s2, s6, 4
	s_addc_u32 s3, s7, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_and_b32_e32 v4, 0x7fffffff, v2
	v_mov_b32_e32 v2, 0
.LBB0_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s6, s[2:3], 0x0
	s_waitcnt lgkmcnt(0)
	v_subrev_f32_e32 v5, s6, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cmp_lt_f32_e64 s6, |v5|, v4
	v_sub_f32_e64 v5, v4, |v5|
	v_cndmask_b32_e64 v6, 0, 1.0, s6
	v_cndmask_b32_e64 v2, v2, s5, s6
	s_add_i32 s5, s5, 1
	s_add_u32 s2, s2, 4
	s_addc_u32 s3, s3, 0
	v_fma_f32 v4, -v5, v6, v4
	s_cmp_eq_u32 s4, s5
	s_cbranch_scc0 .LBB0_3
.LBB0_4:                                ; %Flow44
	s_load_b64 s[0:1], s[0:1], 0x20
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB0_5:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11groupKernelPfjS_jPj
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 7
		.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	_Z11groupKernelPfjS_jPj, .Lfunc_end0-_Z11groupKernelPfjS_jPj
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 312
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z11groupKernelPdjS_jPj ; -- Begin function _Z11groupKernelPdjS_jPj
	.globl	_Z11groupKernelPdjS_jPj
	.p2align	8
	.type	_Z11groupKernelPdjS_jPj,@function
_Z11groupKernelPdjS_jPj:                ; @_Z11groupKernelPdjS_jPj
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_u32_e64 s3, v1
	s_cbranch_execz .LBB1_5
; %bb.1:
	s_load_b32 s4, s[0:1], 0x18
	v_ashrrev_i32_e32 v2, 31, v1
	v_mov_b32_e32 v0, 0
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_u32 s4, 2
	s_cbranch_scc1 .LBB1_4
; %bb.2:                                ; %.lr.ph.preheader
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x0
	s_load_b64 s[6:7], s[0:1], 0x10
	v_lshlrev_b64 v[3:4], 3, v[1:2]
	v_mov_b32_e32 v0, 0
	s_mov_b32 s5, 1
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s2, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo
	s_load_b64 s[2:3], s[6:7], 0x0
	global_load_b64 v[3:4], v[3:4], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_f64 v[5:6], v[3:4], -s[2:3]
	v_mov_b32_e32 v7, 0
	s_add_u32 s2, s6, 8
	s_addc_u32 s3, s7, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_and_b32_e32 v6, 0x7fffffff, v6
.LBB1_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b64 s[6:7], s[2:3], 0x0
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[8:9], v[3:4], -s[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cmp_lt_f64_e64 s6, |v[8:9]|, v[5:6]
	v_add_f64 v[9:10], v[5:6], -|v[8:9]|
	v_cndmask_b32_e64 v8, 0, 0x3ff00000, s6
	v_cndmask_b32_e64 v0, v0, s5, s6
	s_add_i32 s5, s5, 1
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
	s_delay_alu instid0(VALU_DEP_3)
	v_fma_f64 v[5:6], -v[9:10], v[7:8], v[5:6]
	s_cmp_eq_u32 s4, s5
	s_cbranch_scc0 .LBB1_3
.LBB1_4:                                ; %Flow44
	s_load_b64 s[0:1], s[0:1], 0x20
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, s0, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	global_store_b32 v[1:2], v0, off
.LBB1_5:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11groupKernelPdjS_jPj
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 11
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z11groupKernelPdjS_jPj, .Lfunc_end1-_Z11groupKernelPdjS_jPj
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 344
; NumSgprs: 18
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 11
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
