#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#define m(data,y,x,dim)		data[y*dim+x]
#define MAX_THREADS		1024

struct cuComplex {
	float r;
	float i;
	__device__ cuComplex() : r(0), i(0) {}
	__device__ cuComplex( float a) : r(a), i(0) {}
	__device__ cuComplex( float a, float b ) : r(a), i(b) {}
	float real(void){return r;}
	float imag(void){return i;}
	__device__ float magnitude2( void ) {
	return r * r + i * i;
	}
	__device__ cuComplex operator*(const cuComplex& a) {
	return cuComplex(r*a.r - i*a.i, i*a.r + r*a.i);
	}
	__device__ cuComplex operator+(const cuComplex& a) {
	return cuComplex(r+a.r, i+a.i);
	}
	__device__ cuComplex operator-(const cuComplex& a) {
	return cuComplex(r-a.r, i-a.i);
	}
};
struct myComplex {
	float r;
	float i;
	myComplex() : r(0), i(0) {}
	myComplex( float a) : r(a), i(0) {}
	myComplex( float a, float b ) : r(a), i(b) {}
	float real(void){return r;}
	float imag(void){return i;}
	float magnitude2( void ) {
	return r * r + i * i;
	}
	myComplex operator*(const myComplex& a) {
	return myComplex(r*a.r - i*a.i, i*a.r + r*a.i);
	}
	myComplex operator+(const myComplex& a) {
	return myComplex(r+a.r, i+a.i);
	}
	myComplex operator-(const myComplex& a) {
	return myComplex(r-a.r, i-a.i);
	}
	myComplex operator/(const cuComplex& a) {
	return myComplex(r-a.r, i-a.i);
	}
};

// ===========================> Functions Prototype <===============================
void fill(float* data, int size);
float maxi(float in1, float in2);
void estimX(myComplex v, myComplex wvar, myComplex* umean, myComplex* uvar);
double calc_mse(float* data1, float* data2, int size);
double calc_mse(myComplex* data1, cuComplex* data2, int size);
void cpuMul_yx(float* a, float* b, myComplex* c, int di2, int di3, int y, int x);
void cpuMul(float* a, float* b, myComplex* c, int di1, int di2, int di3);
void cpuKernel(float* a1, float* b1, myComplex* c1, float* a2, float* b2, myComplex* c2, int di1, int di2, int di3);
__device__ float cuMulReal(float* a, float* b, int row, int column, int di2, int di3);
__device__ void cuEstimX(cuComplex* out1, float* out2, float s1, float s2);
__global__ void kernelFunc(float* a1d, float* b1d, cuComplex* c1d, float* a2d, float* b2d, cuComplex* c2d, int di1, int di2, int di3);
void gpuKernel(float* a1, float* b1, cuComplex* c1, float* a2, float* b2, cuComplex* c2, int di1, int di2, int di3);
// =================================================================================

int main(int argc, char** argv) {

    struct cudaDeviceProp p;
    cudaGetDeviceProperties(&p, 0);
    printf("Device Name: %s\n", p.name);
	printf("shared mem size: %d\n", p.regsPerBlock);
	
	// get parameter from command line to build Matrix dimension
	const int di1 = 200;
	const int di2 = 64;
	const int di3 = 450;
	
	// allocate memory in CPU for calculation
	float* a1;
	float* b1;
	myComplex* c1_serial;
	cuComplex* c1;
	float* a2;
	float* b2;
	myComplex* c2_serial;
	cuComplex* c2;
	a1        = (float*)malloc(di1*di2 * sizeof(float));
	b1        = (float*)malloc(di2*di3 * sizeof(float));
	c1_serial = (myComplex*)malloc(di1*di3 * sizeof(myComplex));
	c1        = (cuComplex*)malloc(di1*di3 * sizeof(cuComplex));
	a2        = (float*)malloc(di1*di2 * sizeof(float));
	b2        = (float*)malloc(di2*di3 * sizeof(float));
	c2_serial = (myComplex*)malloc(di1*di3 * sizeof(myComplex));
	c2        = (cuComplex*)malloc(di1*di3 * sizeof(cuComplex));
		
	// fill a, b matrices with random values between -16.0f and 16.0f
	srand(0);
	fill(a1, di1*di2);
	fill(b1, di2*di3);
	fill(a2, di1*di2);
	fill(b2, di2*di3);
	
	// time measurement for CPU calculation
	clock_t t0 = clock();
	cpuKernel (a1, b1, c1_serial, a2, b2, c2_serial, di1, di2, di3);
	clock_t t1 = clock();
		
	// time measurement for GPU calculation
	clock_t t2 = clock();
	gpuKernel (a1, b1, c1, a2, b2, c2, di1, di2, di3);
	clock_t t3 = clock();

	// check correctness of calculation
	float mse;
	mse = calc_mse( c1_serial, c1, di1*di3 ) + calc_mse( c2_serial, c2, di1*di3 );

	printf("dim1=%d dim2=%d dim3=%d\t CPU=%06ld ms GPU=%06ld ms mse=%f\n",di1, di2, di3, (t1-t0)/1000, (t3-t2)/1000, mse);
		
	// free allocated memory for later use
	free(a1);
	free(b1);
	free(c1_serial);
	free(c1);
	free(a2);
	free(b2);
	free(c2_serial);
	free(c2);
   
	return 0;
}

//-----------------------------------------------------------------------------
void fill(float* data, int size) {
    for (int i=0; i<size; ++i)
        data[i] = (float) (rand() % 33 - 16);
}

double calc_mse (myComplex* data1, cuComplex* data2, int size) {

	double mse = 0.0;
	int i; for (i=0; i<size; i++) {
		myComplex diff = (data1[i]/data2[i]);
		float e = diff.magnitude2();
		// printf("1r=%.4f, 1i=%.2f, 2r=%.4f, 2i=%.2f",data1[i].real(), data1[i].imag(), data2[i].real(), data2[i].imag());
		// printf("  diffR=%.2f, diffI=%.2f, e=%f\r\n",diff.real(), diff.imag(),e);
		mse += e;
		// printf("i=%d, mse=%f ",i,mse);
	}
	// i=1839;
	// printf("1r=%.4f, 1i=%.2f, 2r=%.4f, 2i=%.2f\r\n",data1[i].real(), data1[i].imag(), data2[i].real(), data2[i].imag());
	mse = mse / size;
	return mse;
}

double calc_mse (float* data1, float* data2, int size) {

	double mse = 0.0;
	int i; for (i=0; i<size; i++) {
		double e = data1[i]-data2[i];
		e = e * e;
		mse += e;
	}
	mse = mse / size;
	return mse;
}

//-----------------------------------------------------------------------------
void cpuMul_yx(float* a, float* b, myComplex* c, int di2, int di3, int y, int x) { // one element
	m(c,y,x,di3)=0;
    for(int k=0; k<di2; k++) {
		m(c,y,x,di3) = m(c,y,x,di3) + myComplex(m(a,y,k,di2) * m(b,k,x,di3));
	}
}
void cpuMul(float* a, float* b, myComplex* c, int di1, int di2, int di3) { // entire matrix
    for(int y=0; y<di1; y++)
    for(int x=0; x<di3; x++)
	{
		cpuMul_yx(a,b,c,di2,di3,y,x);
	}
}
void cpuKernel(float* a1, float* b1, myComplex* c1, float* a2, float* b2, myComplex* c2, int di1, int di2, int di3) { // entire matrix
	int i=0;
	// myComplex umean;
	// float uvar;
	
	cpuMul(a1,b1,c1,di1,di2,di3);
	cpuMul(a2,b2,c2,di1,di2,di3);
	for(i=0; i<di1*di3; i++)
		estimX(c1[i], c2[i], c1+i, c2+i);
	// printf("umean=%f, uvar=%f", creal(umean), creal(uvar));
}

float maxi(float in1, float in2) {
	if (in1 > in2)
		return in1;
	else
		return in2;
}

void estimX(myComplex v, myComplex wvar, myComplex* umean, myComplex* uvar) {

	float wvar_inv;
	float logpxr1, logpxr2, logpxr3, logpxr4, max_log;
	float pxr1, pxr2, pxr3, pxr4, sum_pxr;
	float uvar1, uvar2, uvar3, uvar4;
	
	myComplex x0_1(-0.7071, 0.7071);
	myComplex x0_2(-0.7071, -0.7071);
	myComplex x0_3(0.7071, 0.7071);
	myComplex x0_4(0.7071, -0.7071);
	
	wvar_inv = 1;///(wvar.r);//imag=0 ast
	logpxr1 = wvar_inv*((v - x0_1).magnitude2());
	logpxr2 = wvar_inv*((v - x0_2).magnitude2());
	logpxr3 = wvar_inv*((v - x0_3).magnitude2());
	logpxr4 = wvar_inv*((v - x0_4).magnitude2());
	
	max_log = maxi(maxi(logpxr1,logpxr2),maxi(logpxr3,logpxr4));
	
	logpxr1 = logpxr1 - max_log;
	logpxr2 = logpxr2 - max_log;
	logpxr3 = logpxr3 - max_log;
	logpxr4 = logpxr4 - max_log;
	
	pxr1 = exp(logpxr1);
	pxr2 = exp(logpxr2);
	pxr3 = exp(logpxr3);
	pxr4 = exp(logpxr4);
	
	sum_pxr = pxr1 + pxr2 + pxr3 + pxr4;
	
	pxr1 = pxr1;///sum_pxr;
	pxr2 = pxr2;///sum_pxr;
	pxr3 = pxr3;///sum_pxr;
	pxr4 = pxr4;///sum_pxr;
	
	*umean = myComplex(pxr1,0)*x0_1 + myComplex(pxr2,0)*x0_2 + myComplex(pxr3,0)*x0_3 + myComplex(pxr4,0)*x0_4;
	// printf("umeanR=%.3f, I=%.3f\r\n", (*umean-x0_1).r, (*umean-x0_1).i);
	uvar1 = pxr1*((*umean-x0_1).magnitude2());
	uvar2 = pxr2*((*umean-x0_2).magnitude2());
	uvar3 = pxr3*((*umean-x0_3).magnitude2());
	uvar4 = pxr4*((*umean-x0_4).magnitude2());
	
	*uvar = myComplex(uvar1 + uvar2 + uvar3 + uvar4);
	
}

__device__ void cuEstimX(cuComplex* out1, float* out2, float s1, float s2){
	float s2_inv;
	cuComplex s1_cpx;
	
	float logpxr1, logpxr2, logpxr3, logpxr4, max_log;
	float pxr1, pxr2, pxr3, pxr4, sum_pxr;
	float uvar1, uvar2, uvar3, uvar4;
	
	cuComplex x0_1(-0.7071, 0.7071);
	cuComplex x0_2(-0.7071, -0.7071);
	cuComplex x0_3(0.7071 , 0.7071);
	cuComplex x0_4(0.7071 , -0.7071);
	
	s2_inv = 1;///s2;
	s1_cpx.r = s1;
	logpxr1 = s2_inv*((s1_cpx - x0_1).magnitude2());
	logpxr2 = s2_inv*((s1_cpx - x0_2).magnitude2());
	logpxr3 = s2_inv*((s1_cpx - x0_3).magnitude2());
	logpxr4 = s2_inv*((s1_cpx - x0_4).magnitude2());
	
	max_log = logpxr1;
	if(logpxr2>max_log)
		max_log=logpxr2;
	if(logpxr3>max_log)
		max_log=logpxr3;
	if(logpxr4>max_log)
		max_log=logpxr4;
	
	logpxr1 = logpxr1 - max_log;
	logpxr2 = logpxr2 - max_log;
	logpxr3 = logpxr3 - max_log;
	logpxr4 = logpxr4 - max_log;
	
	pxr1 = exp(logpxr1);
	pxr2 = exp(logpxr2);
	pxr3 = exp(logpxr3);
	pxr4 = exp(logpxr4);
	
	sum_pxr = pxr1 + pxr2 + pxr3 + pxr4;
	
	pxr1 = pxr1;//sum_pxr;
	pxr2 = pxr2;//sum_pxr;
	pxr3 = pxr3;//sum_pxr;
	pxr4 = pxr4;//sum_pxr;
	
	*out1 = (cuComplex(pxr1,0)*x0_1 + cuComplex(pxr2,0)*x0_2 + cuComplex(pxr3,0)*x0_3 + cuComplex(pxr4,0)*x0_4);
	uvar1 = pxr1*((*out1-x0_1).magnitude2());
	uvar2 = pxr2*((*out1-x0_2).magnitude2());
	uvar3 = pxr3*((*out1-x0_3).magnitude2());
	uvar4 = pxr4*((*out1-x0_4).magnitude2());
	
	*out2 = (uvar1 + uvar2 + uvar3 + uvar4);
}

__device__ float cuMulReal(float* a, float* b, int row, int column, int di2, int di3){
	int k;
	float s = 0.0f;
	
	for (k=0; k<di2; k++){
		s += m(a,row,k,di2) * m(b,k,column,di3);
	}
	return s;
}
__device__ cuComplex cuMulCpx(cuComplex* a, cuComplex* b, int row, int column, int di2, int di3){
	int k;
	cuComplex s(0.0f, 0.0f);
	
	for (k=0; k<di2; k++){
		s = s + (m(a,row,k,di2) * m(b,k,column,di3));
	}
	return s;
}
__global__ void kernelFunc(float* a1d, float* b1d, cuComplex* c1d, float* a2d, float* b2d, cuComplex* c2d, int di1, int di2, int di3) {

	int tx = threadIdx.x;
	int by = blockIdx.y;
	int bx = blockIdx.x;
	int row, column;
	float s1 = 0.0f;
	float s2 = 0.0f;
	cuComplex tmp(0);
	cuComplex* out1=&tmp;
	float tmp2=0.0f;
	float* out2=&tmp2;
	
	row = bx;
	column = (by)*(blockDim.x)+tx;
	
	s1 = cuMulReal(a1d, b1d, row, column, di2, di3);
	
	s2 = cuMulReal(a2d, b2d, row, column, di2, di3);
	
	cuEstimX(out1, out2, s1, s2);
	
	m(c1d,row,column,di3) = cuComplex(*out1);
	m(c2d,row,column,di3) = cuComplex(*out2);
}
//-----------------------------------------------------------------------------
void gpuKernel(float* a1, float* b1, cuComplex* c1, float* a2, float* b2, cuComplex* c2, int di1, int di2, int di3) {
	// allocate memory on GPU
	// copy data to GPU
	// call kernelFunc
	// copy the results back to CPU
	// free GPU memory
	float *a1d, *b1d;
	float *a2d, *b2d;
	cuComplex *c1d, *c2d;
	
	cudaMalloc((void**)&a1d, di1*di2*sizeof(float));
	cudaMalloc((void**)&b1d, di2*di3*sizeof(float));
	cudaMalloc((void**)&c1d, di1*di3*sizeof(cuComplex));
	cudaMalloc((void**)&a2d, di1*di2*sizeof(float));
	cudaMalloc((void**)&b2d, di2*di3*sizeof(float));
	cudaMalloc((void**)&c2d, di1*di3*sizeof(cuComplex));
	
	cudaMemcpy(a1d, a1, di1*di2*sizeof(float), cudaMemcpyHostToDevice);
	cudaMemcpy(b1d, b1, di2*di3*sizeof(float), cudaMemcpyHostToDevice);
	cudaMemcpy(a2d, a2, di1*di2*sizeof(float), cudaMemcpyHostToDevice);
	cudaMemcpy(b2d, b2, di2*di3*sizeof(float), cudaMemcpyHostToDevice);
	
	//kernelFunc <<<dim3(n/MAX_THREADS,n/MAX_THREADS,MAX_THREADS),MAX_THREADS>>> (ad,bd,cd,n);
	kernelFunc<<< dim3(di1,1,1), di3 >>>(a1d, b1d, c1d, a2d, b2d, c2d, di1, di2, di3);
	
	cudaMemcpy(c1, c1d, di1*di3*sizeof(cuComplex), cudaMemcpyDeviceToHost);
	cudaMemcpy(c2, c2d, di1*di3*sizeof(cuComplex), cudaMemcpyDeviceToHost);
	
	cudaFree(a1d);
	cudaFree(b1d);
	cudaFree(c1d);
	cudaFree(a2d);
	cudaFree(b2d);
	cudaFree(c2d);
}
	.file	"tmpxft_0023995a_00000000-6_GAMP_v3.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2073:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2073:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZN9myComplex10magnitude2Ev.isra.0, @function
_ZN9myComplex10magnitude2Ev.isra.0:
.LFB2214:
	.cfi_startproc
	mulss	%xmm1, %xmm1
	mulss	%xmm0, %xmm0
	addss	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2214:
	.size	_ZN9myComplex10magnitude2Ev.isra.0, .-_ZN9myComplex10magnitude2Ev.isra.0
	.globl	_Z4fillPfi
	.type	_Z4fillPfi, @function
_Z4fillPfi:
.LFB2059:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$33, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 48
.L4:
	cmpl	%ebx, %ebp
	jle	.L8
	call	rand@PLT
	cltd
	idivl	%r13d
	subl	$16, %edx
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L4
.L8:
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z4fillPfi, .-_Z4fillPfi
	.globl	_Z8calc_mseP9myComplexP9cuComplexi
	.type	_Z8calc_mseP9myComplexP9cuComplexi, @function
_Z8calc_mseP9myComplexP9cuComplexi:
.LFB2060:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	xorps	%xmm2, %xmm2
.L10:
	cmpl	%eax, %edx
	jle	.L12
	movss	4(%rdi,%rax,8), %xmm1
	movss	(%rdi,%rax,8), %xmm0
	subss	4(%rsi,%rax,8), %xmm1
	subss	(%rsi,%rax,8), %xmm0
	incq	%rax
	call	_ZN9myComplex10magnitude2Ev.isra.0
	cvtss2sd	%xmm0, %xmm0
	addsd	%xmm0, %xmm2
	jmp	.L10
.L12:
	cvtsi2sdl	%edx, %xmm0
	divsd	%xmm0, %xmm2
	movaps	%xmm2, %xmm0
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z8calc_mseP9myComplexP9cuComplexi, .-_Z8calc_mseP9myComplexP9cuComplexi
	.globl	_Z8calc_msePfS_i
	.type	_Z8calc_msePfS_i, @function
_Z8calc_msePfS_i:
.LFB2061:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
.L14:
	cmpl	%eax, %edx
	jle	.L16
	movss	(%rdi,%rax,4), %xmm1
	subss	(%rsi,%rax,4), %xmm1
	incq	%rax
	cvtss2sd	%xmm1, %xmm1
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	jmp	.L14
.L16:
	cvtsi2sdl	%edx, %xmm1
	divsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z8calc_msePfS_i, .-_Z8calc_msePfS_i
	.globl	_Z9cpuMul_yxPfS_P9myComplexiiii
	.type	_Z9cpuMul_yxPfS_P9myComplexiiii, @function
_Z9cpuMul_yxPfS_P9myComplexiiii:
.LFB2062:
	.cfi_startproc
	endbr64
	movl	%r9d, %eax
	movq	%rdx, %r10
	xorps	%xmm1, %xmm1
	movl	%ecx, %edx
	imull	%r8d, %eax
	movslq	8(%rsp), %rcx
	movslq	%r8d, %r8
	imull	%edx, %r9d
	salq	$2, %r8
	leaq	(%rsi,%rcx,4), %rsi
	addl	%ecx, %eax
	xorl	%ecx, %ecx
	cltq
	movslq	%r9d, %r9
	leaq	(%r10,%rax,8), %rax
	xorl	%r10d, %r10d
	leaq	(%rdi,%r9,4), %rdi
	movq	%r10, (%rax)
.L18:
	cmpl	%ecx, %edx
	jle	.L20
	movss	4(%rax), %xmm2
	movss	(%rdi,%rcx,4), %xmm0
	incq	%rcx
	mulss	(%rsi), %xmm0
	addq	%r8, %rsi
	addss	%xmm1, %xmm2
	addss	(%rax), %xmm0
	movss	%xmm2, 4(%rax)
	movss	%xmm0, (%rax)
	jmp	.L18
.L20:
	ret
	.cfi_endproc
.LFE2062:
	.size	_Z9cpuMul_yxPfS_P9myComplexiiii, .-_Z9cpuMul_yxPfS_P9myComplexiiii
	.globl	_Z6cpuMulPfS_P9myComplexiii
	.type	_Z6cpuMulPfS_P9myComplexiii, @function
_Z6cpuMulPfS_P9myComplexiii:
.LFB2063:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r11d, %r11d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%r8d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r9d, %ebx
	pushq	%r10
	.cfi_def_cfa_offset 64
	movq	%rdi, (%rsp)
.L22:
	cmpl	%ebp, %r11d
	jge	.L27
	xorl	%r15d, %r15d
.L24:
	cmpl	%ebx, %r15d
	jge	.L28
	pushq	%r15
	.cfi_def_cfa_offset 72
	movq	8(%rsp), %rdi
	movq	%r13, %rdx
	movl	%r11d, %r9d
	movl	%ebx, %r8d
	movl	%r14d, %ecx
	movq	%r12, %rsi
	incl	%r15d
	call	_Z9cpuMul_yxPfS_P9myComplexiiii
	popq	%rdx
	.cfi_def_cfa_offset 64
	jmp	.L24
.L28:
	incl	%r11d
	jmp	.L22
.L27:
	popq	%rax
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2063:
	.size	_Z6cpuMulPfS_P9myComplexiii, .-_Z6cpuMulPfS_P9myComplexiii
	.globl	_Z4maxiff
	.type	_Z4maxiff, @function
_Z4maxiff:
.LFB2065:
	.cfi_startproc
	endbr64
	maxss	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2065:
	.size	_Z4maxiff, .-_Z4maxiff
	.globl	_Z6estimX9myComplexS_PS_S0_
	.type	_Z6estimX9myComplexS_PS_S0_, @function
_Z6estimX9myComplexS_PS_S0_:
.LFB2066:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movaps	%xmm0, %xmm5
	movaps	%xmm0, %xmm4
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	shufps	$85, %xmm5, %xmm5
	movaps	%xmm5, %xmm2
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movss	.LC2(%rip), %xmm6
	subss	.LC2(%rip), %xmm5
	addss	%xmm0, %xmm6
	movaps	%xmm5, %xmm1
	movaps	%xmm6, %xmm0
	call	_ZN9myComplex10magnitude2Ev.isra.0
	addss	.LC2(%rip), %xmm2
	movaps	%xmm0, %xmm3
	movaps	%xmm6, %xmm0
	movaps	%xmm2, %xmm1
	call	_ZN9myComplex10magnitude2Ev.isra.0
	subss	.LC2(%rip), %xmm4
	movaps	%xmm5, %xmm1
	movss	%xmm0, 16(%rsp)
	movaps	%xmm4, %xmm0
	call	_ZN9myComplex10magnitude2Ev.isra.0
	movaps	%xmm2, %xmm1
	movd	%xmm0, %r14d
	movaps	%xmm4, %xmm0
	call	_ZN9myComplex10magnitude2Ev.isra.0
	movd	%r14d, %xmm7
	maxss	%xmm0, %xmm7
	movss	%xmm0, 28(%rsp)
	movaps	%xmm3, %xmm0
	maxss	16(%rsp), %xmm0
	maxss	%xmm7, %xmm0
	subss	%xmm0, %xmm3
	movss	%xmm0, 12(%rsp)
	movaps	%xmm3, %xmm0
	call	expf@PLT
	movss	%xmm0, 20(%rsp)
	movss	16(%rsp), %xmm0
	subss	12(%rsp), %xmm0
	call	expf@PLT
	movss	%xmm0, 16(%rsp)
	movd	%r14d, %xmm0
	subss	12(%rsp), %xmm0
	call	expf@PLT
	movss	28(%rsp), %xmm1
	subss	12(%rsp), %xmm1
	movss	%xmm0, 24(%rsp)
	movaps	%xmm1, %xmm0
	call	expf@PLT
	movss	.LC3(%rip), %xmm3
	movss	.LC2(%rip), %xmm6
	movss	.LC2(%rip), %xmm7
	mulss	24(%rsp), %xmm6
	movaps	%xmm0, %xmm1
	movaps	%xmm0, %xmm5
	mulss	20(%rsp), %xmm7
	xorps	%xmm0, %xmm0
	mulss	%xmm3, %xmm1
	mulss	16(%rsp), %xmm3
	movaps	%xmm6, %xmm2
	movaps	%xmm7, %xmm4
	addss	%xmm0, %xmm2
	addss	%xmm3, %xmm4
	addss	%xmm0, %xmm3
	addss	%xmm2, %xmm4
	movaps	%xmm1, %xmm2
	addss	%xmm0, %xmm2
	subss	%xmm1, %xmm0
	addss	%xmm2, %xmm4
	movaps	%xmm3, %xmm2
	subss	%xmm7, %xmm2
	movss	.LC2(%rip), %xmm7
	movss	%xmm4, 4(%rbp)
	addss	%xmm6, %xmm2
	movaps	%xmm4, %xmm6
	subss	.LC2(%rip), %xmm6
	addss	%xmm0, %xmm2
	movaps	%xmm6, %xmm1
	addss	%xmm2, %xmm7
	movss	%xmm2, 0(%rbp)
	movaps	%xmm7, %xmm0
	call	_ZN9myComplex10magnitude2Ev.isra.0
	addss	.LC2(%rip), %xmm4
	movss	20(%rsp), %xmm3
	mulss	%xmm0, %xmm3
	movaps	%xmm7, %xmm0
	movaps	%xmm4, %xmm1
	call	_ZN9myComplex10magnitude2Ev.isra.0
	subss	.LC2(%rip), %xmm2
	movss	16(%rsp), %xmm7
	movaps	%xmm6, %xmm1
	mulss	%xmm0, %xmm7
	movaps	%xmm2, %xmm0
	call	_ZN9myComplex10magnitude2Ev.isra.0
	movss	24(%rsp), %xmm6
	movaps	%xmm4, %xmm1
	mulss	%xmm0, %xmm6
	movaps	%xmm2, %xmm0
	call	_ZN9myComplex10magnitude2Ev.isra.0
	addss	%xmm7, %xmm3
	movl	$0x00000000, 4(%rbx)
	mulss	%xmm5, %xmm0
	addss	%xmm6, %xmm3
	addss	%xmm0, %xmm3
	movss	%xmm3, (%rbx)
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2066:
	.size	_Z6estimX9myComplexS_PS_S0_, .-_Z6estimX9myComplexS_PS_S0_
	.globl	_Z9cpuKernelPfS_P9myComplexS_S_S1_iii
	.type	_Z9cpuKernelPfS_P9myComplexS_S_S1_iii, @function
_Z9cpuKernelPfS_P9myComplexS_S_S1_iii:
.LFB2064:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%r8, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r9, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	64(%rsp), %r12d
	movq	%rdx, %rbx
	movl	56(%rsp), %r8d
	movl	48(%rsp), %ecx
	movl	%r12d, %r9d
	call	_Z6cpuMulPfS_P9myComplexiii
	movl	56(%rsp), %r8d
	movl	%r12d, %r9d
	movq	%r13, %rdi
	movl	48(%rsp), %ecx
	movq	%rbp, %rdx
	movq	%r14, %rsi
	xorl	%r13d, %r13d
	call	_Z6cpuMulPfS_P9myComplexiii
	imull	48(%rsp), %r12d
.L47:
	cmpl	%r13d, %r12d
	jle	.L50
	movq	0(%rbp), %xmm1
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	incl	%r13d
	movq	(%rbx), %xmm0
	addq	$8, %rbp
	addq	$8, %rbx
	call	_Z6estimX9myComplexS_PS_S0_
	jmp	.L47
.L50:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2064:
	.size	_Z9cpuKernelPfS_P9myComplexS_S_S1_iii, .-_Z9cpuKernelPfS_P9myComplexS_S_S1_iii
	.globl	_Z8cuEstimXP9cuComplexPfff
	.type	_Z8cuEstimXP9cuComplexPfff, @function
_Z8cuEstimXP9cuComplexPfff:
.LFB2067:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2067:
	.size	_Z8cuEstimXP9cuComplexPfff, .-_Z8cuEstimXP9cuComplexPfff
	.globl	_Z9cuMulRealPfS_iiii
	.type	_Z9cuMulRealPfS_iiii, @function
_Z9cuMulRealPfS_iiii:
.LFB2068:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2068:
	.size	_Z9cuMulRealPfS_iiii, .-_Z9cuMulRealPfS_iiii
	.globl	_Z8cuMulCpxP9cuComplexS0_iiii
	.type	_Z8cuMulCpxP9cuComplexS0_iiii, @function
_Z8cuMulCpxP9cuComplexS0_iiii:
.LFB2069:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2069:
	.size	_Z8cuMulCpxP9cuComplexS0_iiii, .-_Z8cuMulCpxP9cuComplexS0_iiii
	.globl	_Z53__device_stub__Z10kernelFuncPfS_P9cuComplexS_S_S1_iiiPfS_P9cuComplexS_S_S1_iii
	.type	_Z53__device_stub__Z10kernelFuncPfS_P9cuComplexS_S_S1_iiiPfS_P9cuComplexS_S_S1_iii, @function
_Z53__device_stub__Z10kernelFuncPfS_P9cuComplexS_S_S1_iiiPfS_P9cuComplexS_S_S1_iii:
.LFB2095:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	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)
	movq	%r9, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%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)
	movq	%rsp, %rax
	movq	%rax, 152(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	216(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	224(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L57
	pushq	56(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z10kernelFuncPfS_P9cuComplexS_S_S1_iii(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 224
	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 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L57:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L59
	call	__stack_chk_fail@PLT
.L59:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2095:
	.size	_Z53__device_stub__Z10kernelFuncPfS_P9cuComplexS_S_S1_iiiPfS_P9cuComplexS_S_S1_iii, .-_Z53__device_stub__Z10kernelFuncPfS_P9cuComplexS_S_S1_iiiPfS_P9cuComplexS_S_S1_iii
	.globl	_Z10kernelFuncPfS_P9cuComplexS_S_S1_iii
	.type	_Z10kernelFuncPfS_P9cuComplexS_S_S1_iii, @function
_Z10kernelFuncPfS_P9cuComplexS_S_S1_iii:
.LFB2096:
	.cfi_startproc
	endbr64
	jmp	_Z53__device_stub__Z10kernelFuncPfS_P9cuComplexS_S_S1_iiiPfS_P9cuComplexS_S_S1_iii
	.cfi_endproc
.LFE2096:
	.size	_Z10kernelFuncPfS_P9cuComplexS_S_S1_iii, .-_Z10kernelFuncPfS_P9cuComplexS_S_S1_iii
	.globl	_Z9gpuKernelPfS_P9cuComplexS_S_S1_iii
	.type	_Z9gpuKernelPfS_P9cuComplexS_S_S1_iii, @function
_Z9gpuKernelPfS_P9cuComplexS_S_S1_iii:
.LFB2070:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rcx, %r13
	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	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%r8, 32(%rsp)
	movl	192(%rsp), %ebx
	leaq	48(%rsp), %rdi
	movq	%r9, 40(%rsp)
	movl	200(%rsp), %r12d
	movq	%rdx, 24(%rsp)
	movl	208(%rsp), %ebp
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	movl	%ebx, %eax
	imull	%r12d, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, (%rsp)
	call	cudaMalloc@PLT
	movl	%r12d, %eax
	leaq	56(%rsp), %rdi
	imull	%ebp, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movl	%ebx, %eax
	leaq	80(%rsp), %rdi
	imull	%ebp, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rsi
	movq	%rax, 16(%rsp)
	call	cudaMalloc@PLT
	movq	(%rsp), %rsi
	leaq	64(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rsi
	leaq	72(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rsi
	leaq	88(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	(%rsp), %rdx
	movq	48(%rsp), %rdi
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	56(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	(%rsp), %rdx
	movq	64(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	32(%rsp), %rsi
	movl	$1, %ecx
	movq	72(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	%ebp, 108(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	%ebx, 96(%rsp)
	movq	%rax, 112(%rsp)
	movl	116(%rsp), %ecx
	movq	%rax, 100(%rsp)
	movq	108(%rsp), %rdx
	movq	96(%rsp), %rdi
	movl	104(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L63
	pushq	%rax
	.cfi_def_cfa_offset 200
	pushq	%rbp
	.cfi_def_cfa_offset 208
	pushq	%r12
	.cfi_def_cfa_offset 216
	pushq	%rbx
	.cfi_def_cfa_offset 224
	movq	120(%rsp), %r9
	movq	104(%rsp), %r8
	movq	96(%rsp), %rcx
	movq	112(%rsp), %rdx
	movq	88(%rsp), %rsi
	movq	80(%rsp), %rdi
	call	_Z53__device_stub__Z10kernelFuncPfS_P9cuComplexS_S_S1_iiiPfS_P9cuComplexS_S_S1_iii
	addq	$32, %rsp
	.cfi_def_cfa_offset 192
.L63:
	movq	16(%rsp), %rdx
	movq	80(%rsp), %rsi
	movl	$2, %ecx
	movq	24(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdx
	movq	88(%rsp), %rsi
	movl	$2, %ecx
	movq	40(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L64
	call	__stack_chk_fail@PLT
.L64:
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2070:
	.size	_Z9gpuKernelPfS_P9cuComplexS_S_S1_iii, .-_Z9gpuKernelPfS_P9cuComplexS_S_S1_iii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC4:
	.string	"Device Name: %s\n"
.LC5:
	.string	"shared mem size: %d\n"
.LC6:
	.string	"dim1=%d dim2=%d dim3=%d\t CPU=%06ld ms GPU=%06ld ms mse=%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2058:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%esi, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1096, %rsp
	.cfi_def_cfa_offset 1152
	movq	%fs:40, %rax
	movq	%rax, 1080(%rsp)
	xorl	%eax, %eax
	leaq	48(%rsp), %rbx
	movq	%rbx, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movl	352(%rsp), %edx
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$51200, %edi
	call	malloc@PLT
	movl	$115200, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$720000, %edi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movl	$720000, %edi
	movq	%rax, %r15
	call	malloc@PLT
	movl	$51200, %edi
	movq	%rax, %r14
	call	malloc@PLT
	movl	$115200, %edi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	movl	$720000, %edi
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	movl	$720000, %edi
	movq	%rax, 32(%rsp)
	call	malloc@PLT
	xorl	%edi, %edi
	movq	%rax, 40(%rsp)
	call	srand@PLT
	movl	$12800, %esi
	movq	%r13, %rdi
	call	_Z4fillPfi
	movq	8(%rsp), %rdi
	movl	$28800, %esi
	call	_Z4fillPfi
	movq	16(%rsp), %rdi
	movl	$12800, %esi
	call	_Z4fillPfi
	movq	24(%rsp), %rdi
	movl	$28800, %esi
	call	_Z4fillPfi
	call	clock@PLT
	movq	%r15, %rdx
	movq	%r13, %rdi
	movq	%rax, %r12
	pushq	%rax
	.cfi_def_cfa_offset 1160
	pushq	$450
	.cfi_def_cfa_offset 1168
	pushq	$64
	.cfi_def_cfa_offset 1176
	pushq	$200
	.cfi_def_cfa_offset 1184
	movq	64(%rsp), %r9
	movq	56(%rsp), %r8
	movq	48(%rsp), %rcx
	movq	40(%rsp), %rsi
	call	_Z9cpuKernelPfS_P9myComplexS_S_S1_iii
	addq	$32, %rsp
	.cfi_def_cfa_offset 1152
	call	clock@PLT
	movq	%rax, %rbx
	call	clock@PLT
	movq	%r13, %rdi
	pushq	%rdx
	.cfi_def_cfa_offset 1160
	movq	%r14, %rdx
	movq	%rax, %rbp
	pushq	$450
	.cfi_def_cfa_offset 1168
	pushq	$64
	.cfi_def_cfa_offset 1176
	pushq	$200
	.cfi_def_cfa_offset 1184
	movq	72(%rsp), %r9
	movq	56(%rsp), %r8
	movq	48(%rsp), %rcx
	movq	40(%rsp), %rsi
	call	_Z9gpuKernelPfS_P9cuComplexS_S_S1_iii
	addq	$32, %rsp
	.cfi_def_cfa_offset 1152
	call	clock@PLT
	movl	$90000, %edx
	movq	%r14, %rsi
	movq	%r15, %rdi
	movq	%rax, %rcx
	movl	$450, %r8d
	call	_Z8calc_mseP9myComplexP9cuComplexi
	movq	32(%rsp), %rdi
	movq	40(%rsp), %rsi
	movaps	%xmm0, %xmm3
	call	_Z8calc_mseP9myComplexP9cuComplexi
	movq	%rbx, %rax
	movl	$1000, %esi
	pushq	%rdi
	.cfi_def_cfa_offset 1160
	subq	%r12, %rax
	addsd	%xmm3, %xmm0
	movl	$2, %edi
	cqto
	idivq	%rsi
	cvtsd2ss	%xmm0, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movq	%rax, %r9
	movq	%rcx, %rax
	movl	$64, %ecx
	subq	%rbp, %rax
	cqto
	idivq	%rsi
	movl	$200, %edx
	leaq	.LC6(%rip), %rsi
	pushq	%rax
	.cfi_def_cfa_offset 1168
	movb	$1, %al
	call	__printf_chk@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	24(%rsp), %rdi
	call	free@PLT
	movq	%r15, %rdi
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	32(%rsp), %rdi
	call	free@PLT
	movq	40(%rsp), %rdi
	call	free@PLT
	movq	48(%rsp), %rdi
	call	free@PLT
	movq	56(%rsp), %rdi
	call	free@PLT
	popq	%r8
	.cfi_def_cfa_offset 1160
	popq	%r9
	.cfi_def_cfa_offset 1152
	movq	1080(%rsp), %rax
	subq	%fs:40, %rax
	je	.L67
	call	__stack_chk_fail@PLT
.L67:
	addq	$1096, %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
.LFE2058:
	.size	main, .-main
	.section	.rodata.str1.1
.LC7:
	.string	"_Z10kernelFuncPfS_P9cuComplexS_S_S1_iii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2098:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z10kernelFuncPfS_P9cuComplexS_S_S1_iii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2098:
	.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
.LC2:
	.long	1060439169
	.align 4
.LC3:
	.long	-1087044479
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include "hip/hip_runtime.h"


#define m(data,y,x,dim)		data[y*dim+x]
#define MAX_THREADS		1024

struct hipComplex {
	float r;
	float i;
	__device__ hipComplex() : r(0), i(0) {}
	__device__ hipComplex( float a) : r(a), i(0) {}
	__device__ hipComplex( float a, float b ) : r(a), i(b) {}
	float real(void){return r;}
	float imag(void){return i;}
	__device__ float magnitude2( void ) {
	return r * r + i * i;
	}
	__device__ hipComplex operator*(const hipComplex& a) {
	return hipComplex(r*a.r - i*a.i, i*a.r + r*a.i);
	}
	__device__ hipComplex operator+(const hipComplex& a) {
	return hipComplex(r+a.r, i+a.i);
	}
	__device__ hipComplex operator-(const hipComplex& a) {
	return hipComplex(r-a.r, i-a.i);
	}
};
struct myComplex {
	float r;
	float i;
	myComplex() : r(0), i(0) {}
	myComplex( float a) : r(a), i(0) {}
	myComplex( float a, float b ) : r(a), i(b) {}
	float real(void){return r;}
	float imag(void){return i;}
	float magnitude2( void ) {
	return r * r + i * i;
	}
	myComplex operator*(const myComplex& a) {
	return myComplex(r*a.r - i*a.i, i*a.r + r*a.i);
	}
	myComplex operator+(const myComplex& a) {
	return myComplex(r+a.r, i+a.i);
	}
	myComplex operator-(const myComplex& a) {
	return myComplex(r-a.r, i-a.i);
	}
	myComplex operator/(const hipComplex& a) {
	return myComplex(r-a.r, i-a.i);
	}
};

// ===========================> Functions Prototype <===============================
void fill(float* data, int size);
float maxi(float in1, float in2);
void estimX(myComplex v, myComplex wvar, myComplex* umean, myComplex* uvar);
double calc_mse(float* data1, float* data2, int size);
double calc_mse(myComplex* data1, hipComplex* data2, int size);
void cpuMul_yx(float* a, float* b, myComplex* c, int di2, int di3, int y, int x);
void cpuMul(float* a, float* b, myComplex* c, int di1, int di2, int di3);
void cpuKernel(float* a1, float* b1, myComplex* c1, float* a2, float* b2, myComplex* c2, int di1, int di2, int di3);
__device__ float cuMulReal(float* a, float* b, int row, int column, int di2, int di3);
__device__ void cuEstimX(hipComplex* out1, float* out2, float s1, float s2);
__global__ void kernelFunc(float* a1d, float* b1d, hipComplex* c1d, float* a2d, float* b2d, hipComplex* c2d, int di1, int di2, int di3);
void gpuKernel(float* a1, float* b1, hipComplex* c1, float* a2, float* b2, hipComplex* c2, int di1, int di2, int di3);
// =================================================================================

int main(int argc, char** argv) {

    struct hipDeviceProp_t p;
    hipGetDeviceProperties(&p, 0);
    printf("Device Name: %s\n", p.name);
	printf("shared mem size: %d\n", p.regsPerBlock);
	
	// get parameter from command line to build Matrix dimension
	const int di1 = 200;
	const int di2 = 64;
	const int di3 = 450;
	
	// allocate memory in CPU for calculation
	float* a1;
	float* b1;
	myComplex* c1_serial;
	hipComplex* c1;
	float* a2;
	float* b2;
	myComplex* c2_serial;
	hipComplex* c2;
	a1        = (float*)malloc(di1*di2 * sizeof(float));
	b1        = (float*)malloc(di2*di3 * sizeof(float));
	c1_serial = (myComplex*)malloc(di1*di3 * sizeof(myComplex));
	c1        = (hipComplex*)malloc(di1*di3 * sizeof(hipComplex));
	a2        = (float*)malloc(di1*di2 * sizeof(float));
	b2        = (float*)malloc(di2*di3 * sizeof(float));
	c2_serial = (myComplex*)malloc(di1*di3 * sizeof(myComplex));
	c2        = (hipComplex*)malloc(di1*di3 * sizeof(hipComplex));
		
	// fill a, b matrices with random values between -16.0f and 16.0f
	srand(0);
	fill(a1, di1*di2);
	fill(b1, di2*di3);
	fill(a2, di1*di2);
	fill(b2, di2*di3);
	
	// time measurement for CPU calculation
	clock_t t0 = clock();
	cpuKernel (a1, b1, c1_serial, a2, b2, c2_serial, di1, di2, di3);
	clock_t t1 = clock();
		
	// time measurement for GPU calculation
	clock_t t2 = clock();
	gpuKernel (a1, b1, c1, a2, b2, c2, di1, di2, di3);
	clock_t t3 = clock();

	// check correctness of calculation
	float mse;
	mse = calc_mse( c1_serial, c1, di1*di3 ) + calc_mse( c2_serial, c2, di1*di3 );

	printf("dim1=%d dim2=%d dim3=%d\t CPU=%06ld ms GPU=%06ld ms mse=%f\n",di1, di2, di3, (t1-t0)/1000, (t3-t2)/1000, mse);
		
	// free allocated memory for later use
	free(a1);
	free(b1);
	free(c1_serial);
	free(c1);
	free(a2);
	free(b2);
	free(c2_serial);
	free(c2);
   
	return 0;
}

//-----------------------------------------------------------------------------
void fill(float* data, int size) {
    for (int i=0; i<size; ++i)
        data[i] = (float) (rand() % 33 - 16);
}

double calc_mse (myComplex* data1, hipComplex* data2, int size) {

	double mse = 0.0;
	int i; for (i=0; i<size; i++) {
		myComplex diff = (data1[i]/data2[i]);
		float e = diff.magnitude2();
		// printf("1r=%.4f, 1i=%.2f, 2r=%.4f, 2i=%.2f",data1[i].real(), data1[i].imag(), data2[i].real(), data2[i].imag());
		// printf("  diffR=%.2f, diffI=%.2f, e=%f\r\n",diff.real(), diff.imag(),e);
		mse += e;
		// printf("i=%d, mse=%f ",i,mse);
	}
	// i=1839;
	// printf("1r=%.4f, 1i=%.2f, 2r=%.4f, 2i=%.2f\r\n",data1[i].real(), data1[i].imag(), data2[i].real(), data2[i].imag());
	mse = mse / size;
	return mse;
}

double calc_mse (float* data1, float* data2, int size) {

	double mse = 0.0;
	int i; for (i=0; i<size; i++) {
		double e = data1[i]-data2[i];
		e = e * e;
		mse += e;
	}
	mse = mse / size;
	return mse;
}

//-----------------------------------------------------------------------------
void cpuMul_yx(float* a, float* b, myComplex* c, int di2, int di3, int y, int x) { // one element
	m(c,y,x,di3)=0;
    for(int k=0; k<di2; k++) {
		m(c,y,x,di3) = m(c,y,x,di3) + myComplex(m(a,y,k,di2) * m(b,k,x,di3));
	}
}
void cpuMul(float* a, float* b, myComplex* c, int di1, int di2, int di3) { // entire matrix
    for(int y=0; y<di1; y++)
    for(int x=0; x<di3; x++)
	{
		cpuMul_yx(a,b,c,di2,di3,y,x);
	}
}
void cpuKernel(float* a1, float* b1, myComplex* c1, float* a2, float* b2, myComplex* c2, int di1, int di2, int di3) { // entire matrix
	int i=0;
	// myComplex umean;
	// float uvar;
	
	cpuMul(a1,b1,c1,di1,di2,di3);
	cpuMul(a2,b2,c2,di1,di2,di3);
	for(i=0; i<di1*di3; i++)
		estimX(c1[i], c2[i], c1+i, c2+i);
	// printf("umean=%f, uvar=%f", creal(umean), creal(uvar));
}

float maxi(float in1, float in2) {
	if (in1 > in2)
		return in1;
	else
		return in2;
}

void estimX(myComplex v, myComplex wvar, myComplex* umean, myComplex* uvar) {

	float wvar_inv;
	float logpxr1, logpxr2, logpxr3, logpxr4, max_log;
	float pxr1, pxr2, pxr3, pxr4, sum_pxr;
	float uvar1, uvar2, uvar3, uvar4;
	
	myComplex x0_1(-0.7071, 0.7071);
	myComplex x0_2(-0.7071, -0.7071);
	myComplex x0_3(0.7071, 0.7071);
	myComplex x0_4(0.7071, -0.7071);
	
	wvar_inv = 1;///(wvar.r);//imag=0 ast
	logpxr1 = wvar_inv*((v - x0_1).magnitude2());
	logpxr2 = wvar_inv*((v - x0_2).magnitude2());
	logpxr3 = wvar_inv*((v - x0_3).magnitude2());
	logpxr4 = wvar_inv*((v - x0_4).magnitude2());
	
	max_log = maxi(maxi(logpxr1,logpxr2),maxi(logpxr3,logpxr4));
	
	logpxr1 = logpxr1 - max_log;
	logpxr2 = logpxr2 - max_log;
	logpxr3 = logpxr3 - max_log;
	logpxr4 = logpxr4 - max_log;
	
	pxr1 = exp(logpxr1);
	pxr2 = exp(logpxr2);
	pxr3 = exp(logpxr3);
	pxr4 = exp(logpxr4);
	
	sum_pxr = pxr1 + pxr2 + pxr3 + pxr4;
	
	pxr1 = pxr1;///sum_pxr;
	pxr2 = pxr2;///sum_pxr;
	pxr3 = pxr3;///sum_pxr;
	pxr4 = pxr4;///sum_pxr;
	
	*umean = myComplex(pxr1,0)*x0_1 + myComplex(pxr2,0)*x0_2 + myComplex(pxr3,0)*x0_3 + myComplex(pxr4,0)*x0_4;
	// printf("umeanR=%.3f, I=%.3f\r\n", (*umean-x0_1).r, (*umean-x0_1).i);
	uvar1 = pxr1*((*umean-x0_1).magnitude2());
	uvar2 = pxr2*((*umean-x0_2).magnitude2());
	uvar3 = pxr3*((*umean-x0_3).magnitude2());
	uvar4 = pxr4*((*umean-x0_4).magnitude2());
	
	*uvar = myComplex(uvar1 + uvar2 + uvar3 + uvar4);
	
}

__device__ void cuEstimX(hipComplex* out1, float* out2, float s1, float s2){
	float s2_inv;
	hipComplex s1_cpx;
	
	float logpxr1, logpxr2, logpxr3, logpxr4, max_log;
	float pxr1, pxr2, pxr3, pxr4, sum_pxr;
	float uvar1, uvar2, uvar3, uvar4;
	
	hipComplex x0_1(-0.7071, 0.7071);
	hipComplex x0_2(-0.7071, -0.7071);
	hipComplex x0_3(0.7071 , 0.7071);
	hipComplex x0_4(0.7071 , -0.7071);
	
	s2_inv = 1;///s2;
	s1_cpx.r = s1;
	logpxr1 = s2_inv*((s1_cpx - x0_1).magnitude2());
	logpxr2 = s2_inv*((s1_cpx - x0_2).magnitude2());
	logpxr3 = s2_inv*((s1_cpx - x0_3).magnitude2());
	logpxr4 = s2_inv*((s1_cpx - x0_4).magnitude2());
	
	max_log = logpxr1;
	if(logpxr2>max_log)
		max_log=logpxr2;
	if(logpxr3>max_log)
		max_log=logpxr3;
	if(logpxr4>max_log)
		max_log=logpxr4;
	
	logpxr1 = logpxr1 - max_log;
	logpxr2 = logpxr2 - max_log;
	logpxr3 = logpxr3 - max_log;
	logpxr4 = logpxr4 - max_log;
	
	pxr1 = exp(logpxr1);
	pxr2 = exp(logpxr2);
	pxr3 = exp(logpxr3);
	pxr4 = exp(logpxr4);
	
	sum_pxr = pxr1 + pxr2 + pxr3 + pxr4;
	
	pxr1 = pxr1;//sum_pxr;
	pxr2 = pxr2;//sum_pxr;
	pxr3 = pxr3;//sum_pxr;
	pxr4 = pxr4;//sum_pxr;
	
	*out1 = (hipComplex(pxr1,0)*x0_1 + hipComplex(pxr2,0)*x0_2 + hipComplex(pxr3,0)*x0_3 + hipComplex(pxr4,0)*x0_4);
	uvar1 = pxr1*((*out1-x0_1).magnitude2());
	uvar2 = pxr2*((*out1-x0_2).magnitude2());
	uvar3 = pxr3*((*out1-x0_3).magnitude2());
	uvar4 = pxr4*((*out1-x0_4).magnitude2());
	
	*out2 = (uvar1 + uvar2 + uvar3 + uvar4);
}

__device__ float cuMulReal(float* a, float* b, int row, int column, int di2, int di3){
	int k;
	float s = 0.0f;
	
	for (k=0; k<di2; k++){
		s += m(a,row,k,di2) * m(b,k,column,di3);
	}
	return s;
}
__device__ hipComplex cuMulCpx(hipComplex* a, hipComplex* b, int row, int column, int di2, int di3){
	int k;
	hipComplex s(0.0f, 0.0f);
	
	for (k=0; k<di2; k++){
		s = s + (m(a,row,k,di2) * m(b,k,column,di3));
	}
	return s;
}
__global__ void kernelFunc(float* a1d, float* b1d, hipComplex* c1d, float* a2d, float* b2d, hipComplex* c2d, int di1, int di2, int di3) {

	int tx = threadIdx.x;
	int by = blockIdx.y;
	int bx = blockIdx.x;
	int row, column;
	float s1 = 0.0f;
	float s2 = 0.0f;
	hipComplex tmp(0);
	hipComplex* out1=&tmp;
	float tmp2=0.0f;
	float* out2=&tmp2;
	
	row = bx;
	column = (by)*(blockDim.x)+tx;
	
	s1 = cuMulReal(a1d, b1d, row, column, di2, di3);
	
	s2 = cuMulReal(a2d, b2d, row, column, di2, di3);
	
	cuEstimX(out1, out2, s1, s2);
	
	m(c1d,row,column,di3) = hipComplex(*out1);
	m(c2d,row,column,di3) = hipComplex(*out2);
}
//-----------------------------------------------------------------------------
void gpuKernel(float* a1, float* b1, hipComplex* c1, float* a2, float* b2, hipComplex* c2, int di1, int di2, int di3) {
	// allocate memory on GPU
	// copy data to GPU
	// call kernelFunc
	// copy the results back to CPU
	// free GPU memory
	float *a1d, *b1d;
	float *a2d, *b2d;
	hipComplex *c1d, *c2d;
	
	hipMalloc((void**)&a1d, di1*di2*sizeof(float));
	hipMalloc((void**)&b1d, di2*di3*sizeof(float));
	hipMalloc((void**)&c1d, di1*di3*sizeof(hipComplex));
	hipMalloc((void**)&a2d, di1*di2*sizeof(float));
	hipMalloc((void**)&b2d, di2*di3*sizeof(float));
	hipMalloc((void**)&c2d, di1*di3*sizeof(hipComplex));
	
	hipMemcpy(a1d, a1, di1*di2*sizeof(float), hipMemcpyHostToDevice);
	hipMemcpy(b1d, b1, di2*di3*sizeof(float), hipMemcpyHostToDevice);
	hipMemcpy(a2d, a2, di1*di2*sizeof(float), hipMemcpyHostToDevice);
	hipMemcpy(b2d, b2, di2*di3*sizeof(float), hipMemcpyHostToDevice);
	
	//kernelFunc <<<dim3(n/MAX_THREADS,n/MAX_THREADS,MAX_THREADS),MAX_THREADS>>> (ad,bd,cd,n);
	kernelFunc<<< dim3(di1,1,1), di3 >>>(a1d, b1d, c1d, a2d, b2d, c2d, di1, di2, di3);
	
	hipMemcpy(c1, c1d, di1*di3*sizeof(hipComplex), hipMemcpyDeviceToHost);
	hipMemcpy(c2, c2d, di1*di3*sizeof(hipComplex), hipMemcpyDeviceToHost);
	
	hipFree(a1d);
	hipFree(b1d);
	hipFree(c1d);
	hipFree(a2d);
	hipFree(b2d);
	hipFree(c2d);
}
	.text
	.file	"GAMP_v3.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x40f5f90000000000              # double 9.0E+4
	.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	$1528, %rsp                     # imm = 0x5F8
	.cfi_def_cfa_offset 1584
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	56(%rsp), %rbx
	xorl	%r13d, %r13d
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	movl	$.L.str, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	304(%rbx), %esi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$51200, %edi                    # imm = 0xC800
	callq	malloc
	movq	%rax, %rbp
	movl	$115200, %edi                   # imm = 0x1C200
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	$720000, %edi                   # imm = 0xAFC80
	callq	malloc
	movq	%rax, %r15
	movl	$720000, %edi                   # imm = 0xAFC80
	callq	malloc
	movq	%rax, %r12
	movl	$51200, %edi                    # imm = 0xC800
	callq	malloc
	movq	%rax, (%rsp)                    # 8-byte Spill
	movl	$115200, %edi                   # imm = 0x1C200
	callq	malloc
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movl	$720000, %edi                   # imm = 0xAFC80
	callq	malloc
	movq	%rax, %rbx
	movl	$720000, %edi                   # imm = 0xAFC80
	callq	malloc
	movq	%rax, %r14
	xorl	%edi, %edi
	callq	srand
.LBB0_1:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1041204193, %rax, %rcx         # imm = 0x3E0F83E1
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$35, %rcx
	addl	%edx, %ecx
	movl	%ecx, %edx
	shll	$5, %edx
	addl	%ecx, %edx
	negl	%edx
	addl	%edx, %eax
	addl	$-16, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%rbp,%r13,4)
	incq	%r13
	cmpq	$12800, %r13                    # imm = 0x3200
	jne	.LBB0_1
# %bb.2:                                # %.lr.ph.i32.preheader
	movq	%rbp, 24(%rsp)                  # 8-byte Spill
	xorl	%r13d, %r13d
	movq	16(%rsp), %rbp                  # 8-byte Reload
.LBB0_3:                                # %.lr.ph.i32
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1041204193, %rax, %rcx         # imm = 0x3E0F83E1
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$35, %rcx
	addl	%edx, %ecx
	movl	%ecx, %edx
	shll	$5, %edx
	addl	%ecx, %edx
	negl	%edx
	addl	%edx, %eax
	addl	$-16, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%rbp,%r13,4)
	incq	%r13
	cmpq	$28800, %r13                    # imm = 0x7080
	jne	.LBB0_3
# %bb.4:                                # %.lr.ph.i37.preheader
	xorl	%r13d, %r13d
	movq	(%rsp), %rbp                    # 8-byte Reload
.LBB0_5:                                # %.lr.ph.i37
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1041204193, %rax, %rcx         # imm = 0x3E0F83E1
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$35, %rcx
	addl	%edx, %ecx
	movl	%ecx, %edx
	shll	$5, %edx
	addl	%ecx, %edx
	negl	%edx
	addl	%edx, %eax
	addl	$-16, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%rbp,%r13,4)
	incq	%r13
	cmpq	$12800, %r13                    # imm = 0x3200
	jne	.LBB0_5
# %bb.6:                                # %.lr.ph.i42.preheader
	xorl	%r13d, %r13d
	movq	8(%rsp), %rbp                   # 8-byte Reload
.LBB0_7:                                # %.lr.ph.i42
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1041204193, %rax, %rcx         # imm = 0x3E0F83E1
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$35, %rcx
	addl	%edx, %ecx
	movl	%ecx, %edx
	shll	$5, %edx
	addl	%ecx, %edx
	negl	%edx
	addl	%edx, %eax
	addl	$-16, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%rbp,%r13,4)
	incq	%r13
	cmpq	$28800, %r13                    # imm = 0x7080
	jne	.LBB0_7
# %bb.8:                                # %_Z4fillPfi.exit46
	callq	clock
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movl	$450, %r11d                     # imm = 0x1C2
	movl	$64, %r10d
	movl	$200, %eax
	movq	32(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rdi
	movq	%rbp, %r8
	movq	24(%rsp), %rbp                  # 8-byte Reload
	movq	%rbp, %rsi
	movq	%r15, %rdx
	movq	8(%rsp), %rcx                   # 8-byte Reload
	movq	%rbx, %r9
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	callq	_Z9cpuKernelPfS_P9myComplexS_S_S1_iii
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	callq	clock
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	callq	clock
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	%r13, %rdi
	movq	%rbp, %rsi
	movq	%r12, %rdx
	movq	8(%rsp), %rcx                   # 8-byte Reload
	movq	16(%rsp), %r8                   # 8-byte Reload
	movq	%r14, %r9
	movl	$450, %eax                      # imm = 0x1C2
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	movl	$64, %eax
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	movl	$200, %eax
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	callq	_Z9gpuKernelPfS_P10hipComplexS_S_S1_iii
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	xorl	%r13d, %r13d
	callq	clock
	xorpd	%xmm3, %xmm3
	movq	%rax, %rcx
.LBB0_9:                                # %.lr.ph.i47
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r15,%r13,8), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	4(%r15,%r13,8), %xmm1           # xmm1 = mem[0],zero,zero,zero
	subss	(%r12,%r13,8), %xmm0
	subss	4(%r12,%r13,8), %xmm1
	mulss	%xmm0, %xmm0
	mulss	%xmm1, %xmm1
	addss	%xmm0, %xmm1
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	addsd	%xmm0, %xmm3
	incq	%r13
	cmpq	$90000, %r13                    # imm = 0x15F90
	jne	.LBB0_9
# %bb.10:                               # %.lr.ph.i51.preheader
	xorps	%xmm0, %xmm0
	xorl	%eax, %eax
.LBB0_11:                               # %.lr.ph.i51
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rbx,%rax,8), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movss	4(%rbx,%rax,8), %xmm2           # xmm2 = mem[0],zero,zero,zero
	subss	(%r14,%rax,8), %xmm1
	subss	4(%r14,%rax,8), %xmm2
	mulss	%xmm1, %xmm1
	mulss	%xmm2, %xmm2
	addss	%xmm1, %xmm2
	xorps	%xmm1, %xmm1
	cvtss2sd	%xmm2, %xmm1
	addsd	%xmm1, %xmm0
	incq	%rax
	cmpq	$90000, %rax                    # imm = 0x15F90
	jne	.LBB0_11
# %bb.12:                               # %_Z8calc_mseP9myComplexP10hipComplexi.exit56
	movsd	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm3
	divsd	%xmm1, %xmm0
	addsd	%xmm3, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movq	32(%rsp), %rax                  # 8-byte Reload
	subq	48(%rsp), %rax                  # 8-byte Folded Reload
	movabsq	$2361183241434822607, %rsi      # imm = 0x20C49BA5E353F7CF
	imulq	%rsi
	movq	%rdx, %r8
	shrq	$63, %r8
	sarq	$7, %rdx
	addq	%rdx, %r8
	subq	40(%rsp), %rcx                  # 8-byte Folded Reload
	movq	%rcx, %rax
	imulq	%rsi
	movq	%rdx, %r9
	shrq	$63, %r9
	sarq	$7, %rdx
	addq	%rdx, %r9
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.2, %edi
	movl	$200, %esi
	movl	$64, %edx
	movl	$450, %ecx                      # imm = 0x1C2
	movb	$1, %al
	callq	printf
	movq	24(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%rbp, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	(%rsp), %rdi                    # 8-byte Reload
	callq	free
	movq	8(%rsp), %rdi                   # 8-byte Reload
	callq	free
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$1528, %rsp                     # imm = 0x5F8
	.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_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z4fillPfi                      # -- Begin function _Z4fillPfi
	.type	_Z4fillPfi,@function
_Z4fillPfi:                             # @_Z4fillPfi
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB1_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1041204193, %rax, %rcx         # imm = 0x3E0F83E1
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$35, %rcx
	addl	%edx, %ecx
	movl	%ecx, %edx
	shll	$5, %edx
	addl	%ecx, %edx
	negl	%edx
	addl	%edx, %eax
	addl	$-16, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB1_4:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z4fillPfi, .Lfunc_end1-_Z4fillPfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z9cpuKernelPfS_P9myComplexS_S_S1_iii # -- Begin function _Z9cpuKernelPfS_P9myComplexS_S_S1_iii
	.type	_Z9cpuKernelPfS_P9myComplexS_S_S1_iii,@function
_Z9cpuKernelPfS_P9myComplexS_S_S1_iii:  # @_Z9cpuKernelPfS_P9myComplexS_S_S1_iii
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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, %rbx
	movq	%r8, %r15
	movq	%rcx, %r12
	movq	%rdx, %r14
	movl	64(%rsp), %r13d
	movl	72(%rsp), %r8d
	movl	80(%rsp), %ebp
	movl	%r13d, %ecx
	movl	%ebp, %r9d
	callq	_Z6cpuMulPfS_P9myComplexiii
	movq	%r12, %rdi
	movq	%r15, %rsi
	movq	%rbx, %rdx
	movl	%r13d, %ecx
	movl	72(%rsp), %r8d
	movl	%ebp, %r9d
	callq	_Z6cpuMulPfS_P9myComplexiii
	imull	%r13d, %ebp
	testl	%ebp, %ebp
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r15d
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r14), %xmm0                   # xmm0 = mem[0],zero
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_Z6estimX9myComplexS_PS_S0_
	addq	$8, %rbx
	addq	$8, %r14
	decq	%r15
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	addq	$8, %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_end2:
	.size	_Z9cpuKernelPfS_P9myComplexS_S_S1_iii, .Lfunc_end2-_Z9cpuKernelPfS_P9myComplexS_S_S1_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z9gpuKernelPfS_P10hipComplexS_S_S1_iii # -- Begin function _Z9gpuKernelPfS_P10hipComplexS_S_S1_iii
	.type	_Z9gpuKernelPfS_P10hipComplexS_S_S1_iii,@function
_Z9gpuKernelPfS_P10hipComplexS_S_S1_iii: # @_Z9gpuKernelPfS_P10hipComplexS_S_S1_iii
	.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, 80(%rsp)                   # 8-byte Spill
	movq	%r8, 64(%rsp)                   # 8-byte Spill
	movq	%rcx, 56(%rsp)                  # 8-byte Spill
	movq	%rdx, 72(%rsp)                  # 8-byte Spill
	movq	%rsi, 48(%rsp)                  # 8-byte Spill
	movq	%rdi, %r12
	movl	160(%rsp), %r15d
	movl	144(%rsp), %ecx
	movl	152(%rsp), %r14d
	movl	%r14d, %eax
	imull	%ecx, %eax
	movq	%rcx, %r13
	movslq	%eax, %rbx
	shlq	$2, %rbx
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movl	%r15d, %eax
	imull	%r14d, %eax
	movslq	%eax, %r14
	shlq	$2, %r14
	leaq	16(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	%r15d, %eax
	imull	%r13d, %eax
	movslq	%eax, %r15
	shlq	$3, %r15
	leaq	8(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	40(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	leaq	32(%rsp), %r13
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	%rsp, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	24(%rsp), %rax
	movq	(%rax), %rdi
	movq	%r12, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rdi
	movq	56(%rsp), %rsi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	144(%rsp), %ebx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r13), %rdi
	movq	64(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	160(%rsp), %r14d
	movl	$1, %ecx
	callq	hipMemcpy
	movq	%rbx, %rdi
	btsq	$32, %rdi
	movq	%r14, %rdx
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_2
# %bb.1:
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rcx
	movq	32(%rsp), %r8
	movq	(%rsp), %r9
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	movl	168(%rsp), %eax
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	callq	_Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
.LBB3_2:
	movq	8(%rsp), %rsi
	movq	72(%rsp), %rdi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rsi
	movq	80(%rsp), %rdi                  # 8-byte Reload
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	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_end3:
	.size	_Z9gpuKernelPfS_P10hipComplexS_S_S1_iii, .Lfunc_end3-_Z9gpuKernelPfS_P10hipComplexS_S_S1_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8calc_mseP9myComplexP10hipComplexi # -- Begin function _Z8calc_mseP9myComplexP10hipComplexi
	.type	_Z8calc_mseP9myComplexP10hipComplexi,@function
_Z8calc_mseP9myComplexP10hipComplexi:   # @_Z8calc_mseP9myComplexP10hipComplexi
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB4_1
# %bb.2:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorpd	%xmm0, %xmm0
	xorl	%ecx, %ecx
.LBB4_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rcx,8), %xmm1            # xmm1 = mem[0],zero,zero,zero
	movss	4(%rdi,%rcx,8), %xmm2           # xmm2 = mem[0],zero,zero,zero
	subss	(%rsi,%rcx,8), %xmm1
	subss	4(%rsi,%rcx,8), %xmm2
	mulss	%xmm1, %xmm1
	mulss	%xmm2, %xmm2
	addss	%xmm1, %xmm2
	xorps	%xmm1, %xmm1
	cvtss2sd	%xmm2, %xmm1
	addsd	%xmm1, %xmm0
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB4_3
	jmp	.LBB4_4
.LBB4_1:
	xorpd	%xmm0, %xmm0
.LBB4_4:                                # %._crit_edge
	xorps	%xmm1, %xmm1
	cvtsi2sd	%edx, %xmm1
	divsd	%xmm1, %xmm0
	retq
.Lfunc_end4:
	.size	_Z8calc_mseP9myComplexP10hipComplexi, .Lfunc_end4-_Z8calc_mseP9myComplexP10hipComplexi
	.cfi_endproc
                                        # -- End function
	.globl	_Z8calc_msePfS_i                # -- Begin function _Z8calc_msePfS_i
	.type	_Z8calc_msePfS_i,@function
_Z8calc_msePfS_i:                       # @_Z8calc_msePfS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB5_1
# %bb.2:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorpd	%xmm0, %xmm0
	xorl	%ecx, %ecx
.LBB5_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%rcx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	subss	(%rsi,%rcx,4), %xmm1
	cvtss2sd	%xmm1, %xmm1
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB5_3
	jmp	.LBB5_4
.LBB5_1:
	xorpd	%xmm0, %xmm0
.LBB5_4:                                # %._crit_edge
	xorps	%xmm1, %xmm1
	cvtsi2sd	%edx, %xmm1
	divsd	%xmm1, %xmm0
	retq
.Lfunc_end5:
	.size	_Z8calc_msePfS_i, .Lfunc_end5-_Z8calc_msePfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z9cpuMul_yxPfS_P9myComplexiiii # -- Begin function _Z9cpuMul_yxPfS_P9myComplexiiii
	.type	_Z9cpuMul_yxPfS_P9myComplexiiii,@function
_Z9cpuMul_yxPfS_P9myComplexiiii:        # @_Z9cpuMul_yxPfS_P9myComplexiiii
	.cfi_startproc
# %bb.0:
	movl	8(%rsp), %r10d
	movl	%r9d, %eax
	imull	%r8d, %eax
	addl	%r10d, %eax
	cltq
	movq	$0, (%rdx,%rax,8)
	testl	%ecx, %ecx
	jle	.LBB6_3
# %bb.1:                                # %.lr.ph
	imull	%ecx, %r9d
	movslq	%r9d, %r9
	movslq	%r8d, %r8
	movslq	%r10d, %r10
	movl	%ecx, %ecx
	leaq	(%rdi,%r9,4), %rdi
	leaq	(%rsi,%r10,4), %rsi
	shlq	$2, %r8
	xorps	%xmm0, %xmm0
	xorl	%r9d, %r9d
.LBB6_2:                                # =>This Inner Loop Header: Depth=1
	movss	(%rdi,%r9,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	mulss	(%rsi), %xmm1
	addss	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	movss	%xmm0, %xmm1                    # xmm1 = xmm0[0],xmm1[1,2,3]
	movlps	%xmm1, (%rdx,%rax,8)
	incq	%r9
	addq	%r8, %rsi
	cmpq	%r9, %rcx
	jne	.LBB6_2
.LBB6_3:                                # %._crit_edge
	retq
.Lfunc_end6:
	.size	_Z9cpuMul_yxPfS_P9myComplexiiii, .Lfunc_end6-_Z9cpuMul_yxPfS_P9myComplexiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z6cpuMulPfS_P9myComplexiii     # -- Begin function _Z6cpuMulPfS_P9myComplexiii
	.type	_Z6cpuMulPfS_P9myComplexiii,@function
_Z6cpuMulPfS_P9myComplexiii:            # @_Z6cpuMulPfS_P9myComplexiii
	.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	%rdx, -8(%rsp)                  # 8-byte Spill
	testl	%ecx, %ecx
	jle	.LBB7_9
# %bb.1:                                # %.preheader.lr.ph
	movslq	%r9d, %rax
	movl	%r8d, %r10d
	movslq	%r8d, %r11
	movl	%ecx, %edx
	movl	%eax, %ebx
	shlq	$2, %rax
	shlq	$2, %r11
	xorl	%r14d, %r14d
.LBB7_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_4 Depth 2
                                        #       Child Loop BB7_6 Depth 3
	testl	%r9d, %r9d
	jle	.LBB7_8
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB7_2 Depth=1
	movl	%r14d, %ecx
	imull	%r9d, %ecx
	movq	-8(%rsp), %r15                  # 8-byte Reload
	leaq	(%r15,%rcx,8), %r15
	movq	%rsi, %r12
	xorl	%r13d, %r13d
.LBB7_4:                                #   Parent Loop BB7_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB7_6 Depth 3
	movq	$0, (%r15,%r13,8)
	testl	%r8d, %r8d
	jle	.LBB7_7
# %bb.5:                                # %.lr.ph.i
                                        #   in Loop: Header=BB7_4 Depth=2
	xorps	%xmm0, %xmm0
	movq	%r12, %rbp
	xorl	%ecx, %ecx
.LBB7_6:                                #   Parent Loop BB7_2 Depth=1
                                        #     Parent Loop BB7_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rdi,%rcx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%rbp), %xmm1
	addss	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	movss	%xmm0, %xmm1                    # xmm1 = xmm0[0],xmm1[1,2,3]
	movlps	%xmm1, (%r15,%r13,8)
	incq	%rcx
	addq	%rax, %rbp
	cmpq	%rcx, %r10
	jne	.LBB7_6
.LBB7_7:                                # %_Z9cpuMul_yxPfS_P9myComplexiiii.exit
                                        #   in Loop: Header=BB7_4 Depth=2
	incq	%r13
	addq	$4, %r12
	cmpq	%rbx, %r13
	jne	.LBB7_4
.LBB7_8:                                # %._crit_edge
                                        #   in Loop: Header=BB7_2 Depth=1
	incq	%r14
	addq	%r11, %rdi
	cmpq	%rdx, %r14
	jne	.LBB7_2
.LBB7_9:                                # %._crit_edge16
	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_end7:
	.size	_Z6cpuMulPfS_P9myComplexiii, .Lfunc_end7-_Z6cpuMulPfS_P9myComplexiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z6estimX9myComplexS_PS_S0_
.LCPI8_0:
	.long	0x3f350481                      # float 0.707099974
.LCPI8_1:
	.long	0xbf350481                      # float -0.707099974
	.text
	.globl	_Z6estimX9myComplexS_PS_S0_
	.type	_Z6estimX9myComplexS_PS_S0_,@function
_Z6estimX9myComplexS_PS_S0_:            # @_Z6estimX9myComplexS_PS_S0_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$72, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movaps	%xmm0, %xmm4
	movss	.LCPI8_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movaps	%xmm4, %xmm5
	addss	%xmm0, %xmm5
	movaps	%xmm0, %xmm3
	movaps	%xmm4, %xmm1
	shufps	$85, %xmm4, %xmm1               # xmm1 = xmm1[1,1],xmm4[1,1]
	movss	.LCPI8_1(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movaps	%xmm1, %xmm6
	addss	%xmm0, %xmm6
	movaps	%xmm0, %xmm2
	mulss	%xmm5, %xmm5
	mulss	%xmm6, %xmm6
	movaps	%xmm5, %xmm0
	addss	%xmm6, %xmm0
	addss	%xmm3, %xmm1
	mulss	%xmm1, %xmm1
	addss	%xmm1, %xmm5
	addss	%xmm2, %xmm4
	mulss	%xmm4, %xmm4
	addss	%xmm4, %xmm6
	addss	%xmm1, %xmm4
	movaps	%xmm0, %xmm1
	maxss	%xmm5, %xmm1
	movaps	%xmm6, %xmm2
	maxss	%xmm4, %xmm2
	maxss	%xmm2, %xmm1
	subss	%xmm1, %xmm0
	subss	%xmm1, %xmm5
	movaps	%xmm5, 16(%rsp)                 # 16-byte Spill
	subss	%xmm1, %xmm6
	movaps	%xmm6, 32(%rsp)                 # 16-byte Spill
	subss	%xmm1, %xmm4
	movaps	%xmm4, 48(%rsp)                 # 16-byte Spill
	callq	expf
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	movaps	16(%rsp), %xmm0                 # 16-byte Reload
	callq	expf
	movss	%xmm0, 16(%rsp)                 # 4-byte Spill
	movaps	32(%rsp), %xmm0                 # 16-byte Reload
	callq	expf
	movss	%xmm0, 32(%rsp)                 # 4-byte Spill
	movaps	48(%rsp), %xmm0                 # 16-byte Reload
	callq	expf
	movss	12(%rsp), %xmm11                # 4-byte Reload
                                        # xmm11 = mem[0],zero,zero,zero
	movaps	%xmm11, %xmm2
	movss	.LCPI8_0(%rip), %xmm6           # xmm6 = mem[0],zero,zero,zero
	mulss	%xmm6, %xmm2
	movss	16(%rsp), %xmm10                # 4-byte Reload
                                        # xmm10 = mem[0],zero,zero,zero
	movaps	%xmm10, %xmm3
	movss	.LCPI8_1(%rip), %xmm8           # xmm8 = mem[0],zero,zero,zero
	mulss	%xmm8, %xmm3
	xorps	%xmm1, %xmm1
	movaps	%xmm3, %xmm4
	addss	%xmm1, %xmm4
	subss	%xmm2, %xmm4
	addss	%xmm2, %xmm3
	movss	32(%rsp), %xmm9                 # 4-byte Reload
                                        # xmm9 = mem[0],zero,zero,zero
	movaps	%xmm9, %xmm5
	movaps	%xmm6, %xmm2
	mulss	%xmm6, %xmm5
	movaps	%xmm5, %xmm6
	addss	%xmm1, %xmm6
	addss	%xmm3, %xmm6
	addss	%xmm4, %xmm5
	movaps	%xmm0, %xmm3
	mulss	%xmm2, %xmm3
	movaps	%xmm2, %xmm7
	movaps	%xmm3, %xmm2
	addss	%xmm1, %xmm2
	subss	%xmm3, %xmm1
	addss	%xmm5, %xmm2
	addss	%xmm6, %xmm1
	movaps	%xmm2, %xmm3
	unpcklps	%xmm1, %xmm3                    # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
	movlps	%xmm3, (%r14)
	movaps	%xmm2, %xmm4
	addss	%xmm7, %xmm4
	movaps	%xmm1, %xmm3
	addss	%xmm8, %xmm3
	mulss	%xmm4, %xmm4
	mulss	%xmm3, %xmm3
	movaps	%xmm4, %xmm5
	addss	%xmm3, %xmm5
	mulss	%xmm11, %xmm5
	addss	%xmm7, %xmm1
	mulss	%xmm1, %xmm1
	addss	%xmm1, %xmm4
	mulss	%xmm10, %xmm4
	addss	%xmm5, %xmm4
	addss	%xmm8, %xmm2
	mulss	%xmm2, %xmm2
	addss	%xmm2, %xmm3
	mulss	%xmm9, %xmm3
	addss	%xmm4, %xmm3
	addss	%xmm1, %xmm2
	mulss	%xmm0, %xmm2
	addss	%xmm3, %xmm2
	movss	%xmm2, (%rbx)
	movl	$0, 4(%rbx)
	addq	$72, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z6estimX9myComplexS_PS_S0_, .Lfunc_end8-_Z6estimX9myComplexS_PS_S0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z4maxiff                       # -- Begin function _Z4maxiff
	.type	_Z4maxiff,@function
_Z4maxiff:                              # @_Z4maxiff
	.cfi_startproc
# %bb.0:
	maxss	%xmm1, %xmm0
	retq
.Lfunc_end9:
	.size	_Z4maxiff, .Lfunc_end9-_Z4maxiff
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii # -- Begin function _Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii
	.type	_Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii,@function
_Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii: # @_Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii
	.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	$176, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	224(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	232(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	240(%rsp), %rax
	movq	%rax, 64(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$192, %rsp
	.cfi_adjust_cfa_offset -192
	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_end10:
	.size	_Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii, .Lfunc_end10-_Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__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	.LBB12_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
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Device Name: %s\n"
	.size	.L.str, 17

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"shared mem size: %d\n"
	.size	.L.str.1, 21

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"dim1=%d dim2=%d dim3=%d\t CPU=%06ld ms GPU=%06ld ms mse=%f\n"
	.size	.L.str.2, 59

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

	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii"
	.size	.L__unnamed_1, 42

	.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 _Z25__device_stub__kernelFuncPfS_P10hipComplexS_S_S1_iii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z10kernelFuncPfS_P10hipComplexS_S_S1_iii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii ; -- Begin function _Z10kernelFuncPfS_P10hipComplexS_S_S1_iii
	.globl	_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii
	.p2align	8
	.type	_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii,@function
_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii: ; @_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii
; %bb.0:
	s_clause 0x3
	s_load_b32 s10, s[0:1], 0x4c
	s_load_b64 s[8:9], s[0:1], 0x34
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[2:3], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s10, s10, 0xffff
	s_cmp_lt_i32 s8, 1
	v_mad_u64_u32 v[1:2], null, s15, s10, v[0:1]
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph.i
	s_mul_i32 s10, s14, s8
	v_mov_b32_e32 v0, 0
	s_ashr_i32 s11, s10, 31
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_mov_b32_e32 v2, v1
	s_lshl_b64 s[10:11], s[10:11], 2
	s_add_u32 s4, s4, s10
	s_addc_u32 s5, s5, s11
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	s_load_b32 s10, s[4:5], 0x0
	s_add_i32 s8, s8, -1
	s_add_u32 s4, s4, 4
	s_addc_u32 s5, s5, 0
	v_lshlrev_b64 v[3:4], 2, v[2:3]
	v_add_nc_u32_e32 v2, s9, v2
	s_cmp_lg_u32 s8, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s6, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s7, v4, vcc_lo
	global_load_b32 v3, v[3:4], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_fmac_f32_e32 v0, s10, v3
	s_cbranch_scc1 .LBB0_2
	s_branch .LBB0_4
.LBB0_3:
	v_mov_b32_e32 v0, 0
.LBB0_4:                                ; %_Z9cuMulRealPfS_iiii.exit39
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_add_f32_e32 v2, 0x3f350481, v0
	v_add_f32_e32 v0, 0xbf350481, v0
	s_load_b64 s[0:1], s[0:1], 0x28
	v_fmaak_f32 v2, v2, v2, 0x3efffebd
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmaak_f32 v0, v0, v0, 0x3efffebd
	v_cmp_gt_f32_e32 vcc_lo, v0, v2
	v_cndmask_b32_e32 v3, v2, v0, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v2, v2, v3
	v_mul_f32_e32 v4, 0x3fb8aa3b, v2
	v_sub_f32_e32 v0, v0, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_rndne_f32_e32 v5, v4
	v_mul_f32_e32 v6, 0x3fb8aa3b, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f32 v7, 0x3fb8aa3b, v0, -v6
	v_rndne_f32_e32 v8, v6
	v_fmac_f32_e32 v7, 0x32a5705f, v0
	v_fma_f32 v3, 0x3fb8aa3b, v2, -v4
	v_sub_f32_e32 v4, v4, v5
	v_cvt_i32_f32_e32 v5, v5
	v_cmp_ngt_f32_e32 vcc_lo, 0xc2ce8ed0, v2
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v3, 0x32a5705f, v2
	v_dual_add_f32 v3, v4, v3 :: v_dual_sub_f32 v4, v6, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_exp_f32_e32 v3, v3
	s_waitcnt_depctr 0xfff
	v_ldexp_f32 v3, v3, v5
	v_cvt_i32_f32_e32 v5, v8
	v_cndmask_b32_e32 v3, 0, v3, vcc_lo
	v_cmp_nlt_f32_e32 vcc_lo, 0x42b17218, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v6, 0x7f800000, v3, vcc_lo
	v_cmp_ngt_f32_e32 vcc_lo, 0xc2ce8ed0, v0
	v_fma_f32 v3, 0xbf350481, v6, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_fmac_f32 v3, 0xbf350481, v6 :: v_dual_add_f32 v4, v4, v7
	v_exp_f32_e32 v4, v4
	s_waitcnt_depctr 0xfff
	v_ldexp_f32 v4, v4, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_cndmask_b32_e32 v2, 0, v4, vcc_lo
	v_cmp_nlt_f32_e32 vcc_lo, 0x42b17218, v0
	v_mul_f32_e32 v0, 0xbf350481, v6
	v_cndmask_b32_e32 v8, 0x7f800000, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fmac_f32_e32 v0, 0x3f350481, v6
	v_fma_f32 v2, 0x3f350481, v8, 0
	v_fmac_f32_e32 v3, 0x3f350481, v8
	v_fma_f32 v4, 0xbf350481, v8, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v0, v0, v2
	v_dual_add_f32 v2, v2, v3 :: v_dual_add_f32 v3, v4, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_4)
	v_add_f32_e32 v0, 0x3f350481, v2
	v_mad_u64_u32 v[4:5], null, s14, s9, v[1:2]
	v_add_f32_e32 v1, 0xbf350481, v2
	v_add_f32_e32 v9, 0x3f350481, v3
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_dual_add_f32 v7, 0xbf350481, v3 :: v_dual_mul_f32 v0, v0, v0
	v_mul_f32_e32 v11, v1, v1
	v_ashrrev_i32_e32 v5, 31, v4
	v_mov_b32_e32 v1, 0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_4) | instid1(VALU_DEP_4)
	v_fma_f32 v10, v7, v7, v0
	v_fmac_f32_e32 v0, v9, v9
	v_fma_f32 v7, v7, v7, v11
	v_fmac_f32_e32 v11, v9, v9
	v_lshlrev_b64 v[4:5], 3, v[4:5]
	v_mul_f32_e32 v0, v6, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fmac_f32_e32 v0, v6, v10
	v_add_co_u32 v6, vcc_lo, s2, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_fmac_f32_e32 v0, v8, v7
	v_add_co_ci_u32_e32 v7, vcc_lo, s3, v5, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_fmac_f32_e32 v0, v8, v11
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	global_store_b64 v[6:7], v[2:3], off
	global_store_b64 v[4:5], v[0:1], off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10kernelFuncPfS_P10hipComplexS_S_S1_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.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 0
		.amdhsa_next_free_vgpr 12
		.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	_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii, .Lfunc_end0-_Z10kernelFuncPfS_P10hipComplexS_S_S1_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 724
; NumSgprs: 18
; NumVgprs: 12
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 12
; 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: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .offset:         48
        .size:           4
        .value_kind:     by_value
      - .offset:         52
        .size:           4
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10kernelFuncPfS_P10hipComplexS_S_S1_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10kernelFuncPfS_P10hipComplexS_S_S1_iii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     12
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
