/*
The code generates a 3D image of a stack of images.

For each image (matrix) calculate the variance at all points, and then create a topography matrix (relief matrix) with
the position (number in the stack) of the image that had the largest variance in a pixel. The same with the color of the
image (RGB matrices).
*/

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

//************Global variables***************

struct point
{
	int x;
	int y;
};
#define IJ_TO_ID(i,j) (((i)*dimy)+(j))

//************** Kernel CUDA *********************
__global__  void EDF(int *R_d, int *G_d, int *B_d, int *Rf_d, int *Gf_d, int *Bf_d, int *topof_d, long double *max_d, int d) {

	int idx = threadIdx.x + blockIdx.x*blockDim.x;
	int idy = threadIdx.y + blockIdx.y*blockDim.y;
	int id = idx + idy*blockDim.x*gridDim.x;

	//int id = idy + idx*blockDim.y*gridDim.y;

	int dimx = 1040, dimy = 1388, tam_imag = 1040*1388, msk = 3, M_d[9], k;
	long double X = 0.f, Xprom = 0.f, Y = 0.f, var = 0.f;
	//Rf_d[id] = id;
	//int img_x = (id) % dimx;
	//int img_y = (id) / dimx;

	int img_x = id / dimy;
	int img_y = id % dimy;

	//int i = 0;
	//unsigned long long int id2;

	M_d[0] = ((img_x < 1 || img_y < 1) ? 0 : G_d[IJ_TO_ID(img_x - 1, img_y - 1)]);
	M_d[1] = ((img_x < 1) ? 0 : G_d[IJ_TO_ID(img_x - 1, img_y)]);
	M_d[2] = ((img_x<1 || img_y>dimy - 2) ? 0 : G_d[IJ_TO_ID(img_x - 1, img_y + 1)]);
	M_d[3] = ((img_y < 1) ? 0 : G_d[IJ_TO_ID(img_x, img_y - 1)]);  //img_x
	M_d[4] = G_d[IJ_TO_ID(img_x, img_y)];
	M_d[5] = ((img_y > dimy - 2) ? 0 : G_d[IJ_TO_ID(img_x, img_y + 1)]);
	M_d[6] = ((img_x > dimx - 2 || img_y < 1) ? 0 : G_d[IJ_TO_ID(img_x + 1, img_y - 1)]);
	M_d[7] = ((img_x > dimx - 2) ? 0 : G_d[IJ_TO_ID(img_x + 1, img_y)]);
	M_d[8] = ((img_x > dimx - 2 || img_y > dimy - 2) ? 0 : G_d[IJ_TO_ID(img_x + 1, img_y + 1)]);


	for (k = 0;k < msk*msk;k++)
		X += M_d[k];

	Xprom = ((long double)X) / (msk*msk);

	for (k = 0;k < msk*msk;k++)
		Y += (Xprom - M_d[k])*(Xprom - M_d[k]);
	
	var = ((long double)Y) / (msk*msk);
	
	//syncthreads();
	__syncthreads();

	if (var > max_d[id]) {
		topof_d[id] = d;
		Rf_d[id] = R_d[id];
		Gf_d[id] = G_d[id];
		Bf_d[id] = B_d[id];
		max_d[id] = var;
	}
}


long msk = 3, dimx = 1040, dimy = 1388, tam_imag = 1040*1388;
//*****************Main function**********************
int main(int argc, char* argv[]) {

	//***************Variables**************
	int i, j, m, cont, tam_B, init, fin;
	cudaError_t cudaStatus;
	FILE *matrizR, *matrizG, *matrizB;
	int d;
	float t;
	clock_t tinicio, t_GPU;
	tinicio = clock();

	int *topof_h, *R_h, *G_h, *B_h, *Rf_h, *Gf_h, *Bf_h;
	long double *max_h;

	int *topof_d, *R_d, *G_d, *B_d, *Rf_d, *Gf_d, *Bf_d;
	long double *max_d;

	//************ Malloc in host and device *************** 
	R_h = (int *)malloc(sizeof(int)*tam_imag);
	cudaStatus = cudaMalloc((void**)&R_d, tam_imag * sizeof(int));
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMalloc failed for R_d!\n");
		exit(0);
	}
	G_h = (int *)malloc(sizeof(int)*tam_imag);
	cudaStatus = cudaMalloc((void**)&G_d, tam_imag * sizeof(int));
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMalloc failed for G_d Line=%d!\n", __LINE__);
		exit(0);
	}
	B_h = (int *)malloc(sizeof(int)*tam_imag);
	cudaStatus = cudaMalloc((void**)&B_d, tam_imag * sizeof(int));
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMalloc failed for R_d!\n");
		exit(0);
	}

	Rf_h = (int *)malloc(sizeof(int)*tam_imag);
	memset((void*)Rf_h, 0, sizeof(int)*tam_imag);
	cudaStatus = cudaMalloc((void**)&Rf_d, tam_imag * sizeof(int));
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMalloc failed for Rf_d!\n");
		exit(0);
	}
	Gf_h = (int *)malloc(sizeof(int)*tam_imag);
	memset((void*)Gf_h, 0, sizeof(int)*tam_imag);
	cudaStatus = cudaMalloc((void**)&Gf_d, tam_imag * sizeof(int));
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMemcpy failed for Gf_d line %d!\n", __LINE__);
		fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
		exit(0);
	}
	Bf_h = (int *)malloc(sizeof(int)*tam_imag);
	memset((void*)Bf_h, 0, sizeof(int)*tam_imag);
	cudaStatus = cudaMalloc((void**)&Bf_d, tam_imag * sizeof(int));
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMalloc failed for Bf_d!\n");
		fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
		exit(0);
	}
	topof_h = (int *)malloc(sizeof(int)*tam_imag);
	memset((void *)topof_h, 0, sizeof(int)*tam_imag);
	cudaStatus = cudaMalloc((void**)&topof_d, tam_imag * sizeof(int));
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMemcpy failed for topof_d line %d!\n", __LINE__);
		fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
		exit(0);
	}

	//cudaMemset((void *)topof_d, 0, tam_imag * sizeof(int)); //hosam

	max_h = (long double *)malloc(sizeof(long double)*tam_imag);
	memset((void*)max_h, 0, sizeof(long double)*tam_imag);
	cudaStatus = cudaMalloc((void**)&max_d, tam_imag * sizeof(long double));
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaMemcpy failed for max_d line %d!\n", __LINE__);
		fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
		exit(0);
	}
	//cudaMemset(max_d, 0, sizeof(float)*tam_imag);

	//cudaMemset((void *)max_h, 0, sizeof(float)*tam_imag);

	//init=atoi(argv[1]);
	//fin=atoi(argv[2]);
	init = 1;
	fin = 20;

	//*************** Principal FOR ****************
	for (d = init;d <= fin;d++)
	{

		printf("d=%d \n", d);
		//*****************Read RGB files****************
		char rutaR[1024];
		sprintf(rutaR, "%s%d%s", "RGB/", d, "/R");
		matrizR = fopen(rutaR, "r+");
		if (!matrizR)
		{
			printf("Error open file R\n");
			exit(0);
		}

		char rutaG[1024];
		sprintf(rutaG, "%s%d%s", "RGB/", d, "/G");
		matrizG = fopen(rutaG, "r+");
		if (!matrizG)
		{
			printf("Error open file G\n");
			exit(0);
		}

		char rutaB[1024];
		sprintf(rutaB, "%s%d%s", "RGB/", d, "/B");
		matrizB = fopen(rutaB, "r+");
		if (!matrizB)
		{
			printf("Error open file B\n");
			exit(0);
		}

		memset((void*)R_h, 0, sizeof(int)*tam_imag);
		memset((void*)G_h, 0, sizeof(int)*tam_imag);
		memset((void*)B_h, 0, sizeof(int)*tam_imag);

		for(i=0;i<dimx;i++){
			for(j=0;j<dimy;j++){
				fscanf(matrizR, "%d", &R_h[i*dimy + j]);
				fscanf(matrizG, "%d", &G_h[i*dimy + j]);
				fscanf(matrizB, "%d", &B_h[i*dimy + j]);
			}
		}
		fclose(matrizR);
		fclose(matrizG);
		fclose(matrizB);

		//***************** Kernel EDF *******************

		cudaStatus = cudaMemcpy(R_d, R_h, sizeof(int)*tam_imag, cudaMemcpyHostToDevice);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for R_d line %d!\n", __LINE__);
			exit(0);
		}

		cudaStatus = cudaMemcpy(G_d, G_h, sizeof(int)*tam_imag, cudaMemcpyHostToDevice);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for G_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = cudaMemcpy(B_d, B_h, sizeof(int)*tam_imag, cudaMemcpyHostToDevice);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for B_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}

		cudaStatus = cudaMemcpy(Rf_d, Rf_h, sizeof(int)*tam_imag, cudaMemcpyHostToDevice);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for Rf_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = cudaMemcpy(Gf_d, Gf_h, sizeof(int)*tam_imag, cudaMemcpyHostToDevice);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for Gf_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = cudaMemcpy(Bf_d, Bf_h, sizeof(int)*tam_imag, cudaMemcpyHostToDevice);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for Bf_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}

		cudaStatus = cudaMemcpy(topof_d, topof_h, sizeof(int)*tam_imag, cudaMemcpyHostToDevice);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for topof_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = cudaMemcpy(max_d, max_h, sizeof(long double)*tam_imag, cudaMemcpyHostToDevice);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for max_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}

		dim3 Grid(347, 20);
		dim3 Block(13, 16);

		EDF <<<Grid, Block >>> (R_d, G_d, B_d, Rf_d, Gf_d, Bf_d, topof_d, max_d, d);

		//printf("\n\n FINISH \n\n");
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The code stops here
		cudaStatus = cudaMemcpy(Rf_h, Rf_d, sizeof(int)*tam_imag, cudaMemcpyDeviceToHost);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for Rf_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = cudaMemcpy(Gf_h, Gf_d, sizeof(int)*tam_imag, cudaMemcpyDeviceToHost);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for Gf_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = cudaMemcpy(Bf_h, Bf_d, sizeof(int)*tam_imag, cudaMemcpyDeviceToHost);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for Bf_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}

		cudaStatus = cudaMemcpy(topof_h, topof_d, sizeof(int)*tam_imag, cudaMemcpyDeviceToHost);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for topof_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = cudaMemcpy(max_h, max_d, sizeof(long double)*tam_imag, cudaMemcpyDeviceToHost);
		if (cudaStatus != cudaSuccess) {
			fprintf(stderr, "cudaMemcpy failed for max_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", cudaGetErrorString(cudaStatus));
			exit(0);
		}

	} //End for

	  //****************Save results**************
	FILE *archTopo, *archR, *archG, *archB;
	archTopo = fopen("Resultados/topo-f3.txt", "w+");
	archR = fopen("Resultados/R-f3.txt", "w+");
	archG = fopen("Resultados/G-f3.txt", "w+");
	archB = fopen("Resultados/B-f3.txt", "w+");
	for(i=0;i<dimx;i++) {
		for(j=0;j<dimy;j++) {
			fprintf(archTopo, "%d ", topof_h[i*dimy + j]);
			fprintf(archR, "%d ", Rf_h[i*dimy + j]);
			fprintf(archG, "%d ", Gf_h[i*dimy + j]);
			fprintf(archB, "%d ", Bf_h[i*dimy + j]);
		}
		fprintf(archTopo, "\n");
		fprintf(archR, "\n");
		fprintf(archG, "\n");
		fprintf(archB, "\n");
	}
	/*for(i=0;i<tam_imag;i++) {

			fprintf(archTopo, "%d ", topof_h[i]);
			fprintf(archR, "%d ", Rf_h[i]);
			fprintf(archG, "%d ", Gf_h[i]);
			fprintf(archB, "%d ", Bf_h[i]);

	}*/

	fclose(archTopo);
	fclose(archR);
	fclose(archG);
	fclose(archB);

	free(max_h);
	free(topof_h);
	free(R_h);
	free(G_h);
	free(B_h);
	free(Rf_h);
	free(Gf_h);
	free(Bf_h);

	cudaFree(max_d);
	cudaFree(topof_d);
	cudaFree(R_d);
	cudaFree(G_d);
	cudaFree(B_d);
	cudaFree(Rf_d);
	cudaFree(Gf_d);
	cudaFree(Bf_d);


	t_GPU = clock();
	t = ((float)t_GPU - (float)tinicio) / CLOCKS_PER_SEC;
	printf("\ntiempo de procesamiento de varianzas: %6.3fs\n", t);

	//getchar ();
	cudaStatus = cudaDeviceReset();
	if (cudaStatus != cudaSuccess) {
		fprintf(stderr, "cudaDeviceReset failed!");
		return 1;
	}

	return 0;

}//END Main function

	.file	"tmpxft_002fae52_00000000-6_f3_kernel-M.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z37__device_stub__Z3EDFPiS_S_S_S_S_S_PeiPiS_S_S_S_S_S_Pei
	.type	_Z37__device_stub__Z3EDFPiS_S_S_S_S_S_PeiPiS_S_S_S_S_S_Pei, @function
_Z37__device_stub__Z3EDFPiS_S_S_S_S_S_PeiPiS_S_S_S_S_S_Pei:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	224(%rsp), %rax
	movq	%rdi, 56(%rsp)
	leaq	80(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	92(%rsp), %rsi
	movq	%rax, 8(%rsp)
	movq	232(%rsp), %rax
	movq	%rdx, 40(%rsp)
	leaq	64(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	72(%rsp), %rcx
	movq	%r8, 24(%rsp)
	movq	%r9, 16(%rsp)
	movq	%rax, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 88(%rsp)
	movq	%rax, 128(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 176(%rsp)
	movq	%rsp, %rax
	movq	%rax, 184(%rsp)
	leaq	240(%rsp), %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 80(%rsp)
	movq	%rax, 92(%rsp)
	movl	$1, 100(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	72(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z3EDFPiS_S_S_S_S_S_Pei(%rip), %rdi
	pushq	72(%rsp)
	.cfi_def_cfa_offset 240
	movq	108(%rsp), %rcx
	movl	116(%rsp), %r8d
	movq	96(%rsp), %rsi
	movl	104(%rsp), %edx
	leaq	144(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L2:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z37__device_stub__Z3EDFPiS_S_S_S_S_S_PeiPiS_S_S_S_S_S_Pei, .-_Z37__device_stub__Z3EDFPiS_S_S_S_S_S_PeiPiS_S_S_S_S_S_Pei
	.globl	_Z3EDFPiS_S_S_S_S_S_Pei
	.type	_Z3EDFPiS_S_S_S_S_S_Pei, @function
_Z3EDFPiS_S_S_S_S_S_Pei:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z3EDFPiS_S_S_S_S_S_PeiPiS_S_S_S_S_S_Pei
	.cfi_endproc
.LFE2053:
	.size	_Z3EDFPiS_S_S_S_S_S_Pei, .-_Z3EDFPiS_S_S_S_S_S_Pei
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"cudaMalloc failed for R_d!\n"
.LC1:
	.string	"cudaMalloc failed for G_d Line=%d!\n"
.LC2:
	.string	"cudaMalloc failed for Rf_d!\n"
.LC3:
	.string	"cudaMemcpy failed for Gf_d line %d!\n"
.LC4:
	.string	"ERROR: %s\n"
.LC5:
	.string	"cudaMalloc failed for Bf_d!\n"
.LC6:
	.string	"cudaMemcpy failed for topof_d line %d!\n"
.LC7:
	.string	"cudaMemcpy failed for max_d line %d!\n"
.LC8:
	.string	"d=%d \n"
.LC9:
	.string	"RGB/"
.LC10:
	.string	"%s%d%s"
.LC11:
	.string	"/R"
.LC12:
	.string	"r+"
.LC13:
	.string	"Error open file R\n"
.LC14:
	.string	"/G"
.LC15:
	.string	"Error open file G\n"
.LC16:
	.string	"/B"
.LC17:
	.string	"Error open file B\n"
.LC18:
	.string	"%d"
.LC19:
	.string	"cudaMemcpy failed for R_d line %d!\n"
.LC20:
	.string	"cudaMemcpy failed for G_d line %d!\n"
.LC21:
	.string	"cudaMemcpy failed for B_d line %d!\n"
.LC22:
	.string	"cudaMemcpy failed for Rf_d line %d!\n"
.LC23:
	.string	"cudaMemcpy failed for Bf_d line %d!\n"
.LC24:
	.string	"cudaMemcpy failed for Rf_h line %d!\n"
.LC25:
	.string	"cudaMemcpy failed for Gf_h line %d!\n"
.LC26:
	.string	"cudaMemcpy failed for Bf_h line %d!\n"
.LC27:
	.string	"cudaMemcpy failed for topof_h line %d!\n"
.LC28:
	.string	"cudaMemcpy failed for max_h line %d!\n"
.LC29:
	.string	"w+"
.LC30:
	.string	"Resultados/topo-f3.txt"
.LC31:
	.string	"Resultados/R-f3.txt"
.LC32:
	.string	"Resultados/G-f3.txt"
.LC33:
	.string	"Resultados/B-f3.txt"
.LC34:
	.string	"%d "
.LC35:
	.string	"\n"
.LC37:
	.string	"\ntiempo de procesamiento de varianzas: %6.3fs\n"
.LC38:
	.string	"cudaDeviceReset failed!"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$3272, %rsp
	.cfi_def_cfa_offset 3328
	movq	%fs:40, %rax
	movq	%rax, 3256(%rsp)
	xorl	%eax, %eax
	call	clock@PLT
	movq	%rax, 88(%rsp)
	movq	tam_imag(%rip), %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 64(%rsp)
	call	malloc@PLT
	movq	64(%rsp), %rsi
	leaq	104(%rsp), %rdi
	movq	%rax, 32(%rsp)
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L52
	movq	tam_imag(%rip), %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 72(%rsp)
	call	malloc@PLT
	movq	72(%rsp), %rsi
	leaq	112(%rsp), %rdi
	movq	%rax, 40(%rsp)
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L10
	movl	$109, %ecx
	leaq	.LC1(%rip), %rdx
.L51:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L50:
	xorl	%edi, %edi
	call	exit@PLT
.L10:
	movq	tam_imag(%rip), %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 80(%rsp)
	call	malloc@PLT
	movq	80(%rsp), %rsi
	leaq	120(%rsp), %rdi
	movq	%rax, 48(%rsp)
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L11
.L52:
	leaq	.LC0(%rip), %rdx
	jmp	.L53
.L11:
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	xorl	%esi, %esi
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	__memset_chk@PLT
	leaq	128(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L12
	leaq	.LC2(%rip), %rdx
.L53:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L50
.L12:
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	xorl	%esi, %esi
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	__memset_chk@PLT
	movq	%rbx, %rsi
	leaq	136(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$130, %ecx
	leaq	.LC3(%rip), %rdx
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	.L59
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	xorl	%esi, %esi
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
	call	__memset_chk@PLT
	movq	%rbx, %rsi
	leaq	144(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L14
	movq	stderr(%rip), %rdi
	leaq	.LC5(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L58:
	movl	%ebx, %edi
	jmp	.L54
.L14:
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	xorl	%esi, %esi
	movq	%rax, %rdi
	movq	%rax, 24(%rsp)
	call	__memset_chk@PLT
	movq	%rbx, %rsi
	leaq	96(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L15
	movl	$146, %ecx
	leaq	.LC6(%rip), %rdx
.L59:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L58
.L15:
	movq	tam_imag(%rip), %rbx
	salq	$4, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rcx
	movq	%rbx, %rdx
	xorl	%esi, %esi
	movq	%rax, %rdi
	movq	%rax, 56(%rsp)
	call	__memset_chk@PLT
	movq	%rbx, %rsi
	leaq	152(%rsp), %rdi
	movl	$1, %ebx
	call	cudaMalloc@PLT
	movl	$157, %ecx
	movl	%eax, %ebp
	testl	%eax, %eax
	jne	.L57
.L16:
	movl	%ebx, %edx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebx, %r9d
	movl	$1024, %edx
	leaq	.LC11(%rip), %rax
	leaq	184(%rsp), %r13
	pushq	%r10
	.cfi_def_cfa_offset 3336
	movl	$2, %esi
	leaq	.LC10(%rip), %r12
	pushq	%rax
	.cfi_def_cfa_offset 3344
	leaq	.LC9(%rip), %r8
	movq	%r12, %rcx
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	popq	%r11
	.cfi_def_cfa_offset 3336
	popq	%rbp
	.cfi_def_cfa_offset 3328
	leaq	.LC12(%rip), %rbp
	movq	%rbp, %rsi
	movq	%r13, %rdi
	call	fopen@PLT
	movq	%rax, %r14
	testq	%rax, %rax
	jne	.L17
	leaq	.LC13(%rip), %rsi
	jmp	.L56
.L17:
	movl	%ebx, %r9d
	movq	%r12, %rcx
	movl	$1024, %edx
	movl	$2, %esi
	leaq	.LC14(%rip), %rax
	leaq	1208(%rsp), %r13
	pushq	%rdi
	.cfi_def_cfa_offset 3336
	pushq	%rax
	.cfi_def_cfa_offset 3344
	movq	%r13, %rdi
	leaq	.LC9(%rip), %r8
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	popq	%r8
	.cfi_def_cfa_offset 3336
	movq	%r13, %rdi
	popq	%r9
	.cfi_def_cfa_offset 3328
	movq	%rbp, %rsi
	call	fopen@PLT
	movq	%rax, %r13
	testq	%rax, %rax
	jne	.L18
	leaq	.LC15(%rip), %rsi
	jmp	.L56
.L18:
	leaq	.LC16(%rip), %rax
	movq	%r12, %rcx
	movl	%ebx, %r9d
	movl	$2, %esi
	leaq	2232(%rsp), %r15
	pushq	%rdx
	.cfi_def_cfa_offset 3336
	leaq	.LC9(%rip), %r8
	movl	$1024, %edx
	pushq	%rax
	.cfi_def_cfa_offset 3344
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	popq	%rcx
	.cfi_def_cfa_offset 3336
	movq	%r15, %rdi
	popq	%rsi
	.cfi_def_cfa_offset 3328
	movq	%rbp, %rsi
	call	fopen@PLT
	movq	%rax, %r12
	testq	%rax, %rax
	jne	.L19
	leaq	.LC17(%rip), %rsi
.L56:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L50
.L19:
	movq	64(%rsp), %rcx
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	xorl	%r15d, %r15d
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rbp
	movq	%rbp, %rdx
	call	__memset_chk@PLT
	movq	72(%rsp), %rcx
	movq	%rbp, %rdx
	xorl	%esi, %esi
	movq	40(%rsp), %rdi
	call	__memset_chk@PLT
	movq	80(%rsp), %rcx
	movq	%rbp, %rdx
	xorl	%esi, %esi
	movq	48(%rsp), %rdi
	call	__memset_chk@PLT
.L20:
	cmpq	dimx(%rip), %r15
	jge	.L60
	xorl	%ebp, %ebp
.L22:
	movq	dimy(%rip), %rax
	cmpq	%rax, %rbp
	jge	.L61
	imulq	%r15, %rax
	movq	32(%rsp), %rcx
	leaq	.LC18(%rip), %rsi
	movq	%r14, %rdi
	addq	%rbp, %rax
	leaq	(%rcx,%rax,4), %rdx
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	dimy(%rip), %rax
	movq	40(%rsp), %rsi
	movq	%r13, %rdi
	imulq	%r15, %rax
	addq	%rbp, %rax
	leaq	(%rsi,%rax,4), %rdx
	leaq	.LC18(%rip), %rsi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	dimy(%rip), %rax
	movq	48(%rsp), %rcx
	movq	%r12, %rdi
	leaq	.LC18(%rip), %rsi
	imulq	%r15, %rax
	addq	%rbp, %rax
	incq	%rbp
	leaq	(%rcx,%rax,4), %rdx
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	jmp	.L22
.L61:
	incq	%r15
	jmp	.L20
.L60:
	movq	%r14, %rdi
	call	fclose@PLT
	movq	%r13, %rdi
	call	fclose@PLT
	movq	%r12, %rdi
	call	fclose@PLT
	movq	32(%rsp), %rsi
	movq	104(%rsp), %rdi
	movl	$1, %ecx
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L23
	movl	$222, %ecx
	leaq	.LC19(%rip), %rdx
	jmp	.L51
.L23:
	movq	40(%rsp), %rsi
	movq	112(%rsp), %rdi
	movl	$1, %ecx
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L24
	movl	$228, %ecx
	leaq	.LC20(%rip), %rdx
	jmp	.L55
.L24:
	movq	48(%rsp), %rsi
	movq	120(%rsp), %rdi
	movl	$1, %ecx
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L25
	movl	$234, %ecx
	leaq	.LC21(%rip), %rdx
	jmp	.L55
.L25:
	movq	tam_imag(%rip), %rax
	movq	(%rsp), %rsi
	movl	$1, %ecx
	movq	128(%rsp), %rdi
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L26
	movl	$241, %ecx
	leaq	.LC22(%rip), %rdx
	jmp	.L55
.L26:
	movq	tam_imag(%rip), %rax
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movq	136(%rsp), %rdi
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L27
	movl	$247, %ecx
	leaq	.LC3(%rip), %rdx
	jmp	.L55
.L27:
	movq	tam_imag(%rip), %rax
	movq	16(%rsp), %rsi
	movl	$1, %ecx
	movq	144(%rsp), %rdi
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L28
	movl	$253, %ecx
	leaq	.LC23(%rip), %rdx
	jmp	.L55
.L28:
	movq	24(%rsp), %rsi
	movq	96(%rsp), %rdi
	movl	$1, %ecx
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L29
	movl	$260, %ecx
	leaq	.LC6(%rip), %rdx
	jmp	.L55
.L29:
	movq	tam_imag(%rip), %rdx
	movq	56(%rsp), %rsi
	movl	$1, %ecx
	movq	152(%rsp), %rdi
	salq	$4, %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L30
	movl	$266, %ecx
.L57:
	leaq	.LC7(%rip), %rdx
	jmp	.L55
.L30:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$68719476749, %rdx
	movabsq	$85899346267, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	pushq	%rax
	.cfi_def_cfa_offset 3336
	pushq	%rbx
	.cfi_def_cfa_offset 3344
	pushq	168(%rsp)
	.cfi_def_cfa_offset 3352
	pushq	120(%rsp)
	.cfi_def_cfa_offset 3360
	movq	176(%rsp), %r9
	movq	168(%rsp), %r8
	movq	160(%rsp), %rcx
	movq	152(%rsp), %rdx
	movq	144(%rsp), %rsi
	movq	136(%rsp), %rdi
	call	_Z37__device_stub__Z3EDFPiS_S_S_S_S_S_PeiPiS_S_S_S_S_S_Pei
	addq	$32, %rsp
	.cfi_def_cfa_offset 3328
.L31:
	movq	tam_imag(%rip), %rax
	movq	(%rsp), %rdi
	movl	$2, %ecx
	movq	128(%rsp), %rsi
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L32
	movl	$280, %ecx
	leaq	.LC24(%rip), %rdx
	jmp	.L55
.L32:
	movq	tam_imag(%rip), %rax
	movq	8(%rsp), %rdi
	movl	$2, %ecx
	movq	136(%rsp), %rsi
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L33
	movl	$286, %ecx
	leaq	.LC25(%rip), %rdx
	jmp	.L55
.L33:
	movq	tam_imag(%rip), %rax
	movq	16(%rsp), %rdi
	movl	$2, %ecx
	movq	144(%rsp), %rsi
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L34
	movl	$292, %ecx
	leaq	.LC26(%rip), %rdx
	jmp	.L55
.L34:
	movq	96(%rsp), %rsi
	movq	24(%rsp), %rdi
	movl	$2, %ecx
	movq	tam_imag(%rip), %rax
	leaq	0(,%rax,4), %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L35
	movl	$299, %ecx
	leaq	.LC27(%rip), %rdx
	jmp	.L55
.L35:
	movq	tam_imag(%rip), %rdx
	movq	56(%rsp), %rdi
	movl	$2, %ecx
	movq	152(%rsp), %rsi
	salq	$4, %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.L36
	movl	$305, %ecx
	leaq	.LC28(%rip), %rdx
.L55:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	%ebp, %edi
.L54:
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	leaq	.LC4(%rip), %rdx
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L50
.L36:
	incl	%ebx
	cmpl	$21, %ebx
	jne	.L16
	leaq	.LC29(%rip), %rbx
	leaq	.LC30(%rip), %rdi
	movq	%rbx, %rsi
	leaq	.LC34(%rip), %r15
	call	fopen@PLT
	movq	%rbx, %rsi
	leaq	.LC31(%rip), %rdi
	movq	%rax, %r14
	call	fopen@PLT
	movq	%rbx, %rsi
	leaq	.LC32(%rip), %rdi
	movq	%rax, %r13
	call	fopen@PLT
	movq	%rbx, %rsi
	leaq	.LC33(%rip), %rdi
	xorl	%ebx, %ebx
	movq	%rax, %r12
	call	fopen@PLT
	movq	%rax, 64(%rsp)
.L37:
	cmpq	dimx(%rip), %rbx
	jge	.L62
	xorl	%ebp, %ebp
.L39:
	movq	dimy(%rip), %rax
	cmpq	%rax, %rbp
	jge	.L63
	imulq	%rbx, %rax
	movq	24(%rsp), %rsi
	movq	%r15, %rdx
	movq	%r14, %rdi
	addq	%rbp, %rax
	movl	(%rsi,%rax,4), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	(%rsp), %rcx
	movq	%r15, %rdx
	movq	%r13, %rdi
	movq	dimy(%rip), %rax
	movl	$2, %esi
	imulq	%rbx, %rax
	addq	%rbp, %rax
	movl	(%rcx,%rax,4), %ecx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	movq	%r12, %rdi
	movq	dimy(%rip), %rax
	imulq	%rbx, %rax
	addq	%rbp, %rax
	movl	(%rsi,%rax,4), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	dimy(%rip), %rax
	movq	16(%rsp), %rcx
	movq	%r15, %rdx
	movq	64(%rsp), %rdi
	movl	$2, %esi
	imulq	%rbx, %rax
	addq	%rbp, %rax
	incq	%rbp
	movl	(%rcx,%rax,4), %ecx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L39
.L63:
	leaq	.LC35(%rip), %rbp
	movq	%r14, %rdi
	xorl	%eax, %eax
	incq	%rbx
	movq	%rbp, %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	%rbp, %rdx
	movl	$2, %esi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	%rbp, %rdx
	movl	$2, %esi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	64(%rsp), %rdi
	movq	%rbp, %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	jmp	.L37
.L62:
	movq	%r14, %rdi
	call	fclose@PLT
	movq	%r13, %rdi
	call	fclose@PLT
	movq	%r12, %rdi
	call	fclose@PLT
	movq	64(%rsp), %rdi
	call	fclose@PLT
	movq	56(%rsp), %rdi
	call	free@PLT
	movq	24(%rsp), %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	(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movq	152(%rsp), %rdi
	call	cudaFree@PLT
	movq	96(%rsp), %rdi
	call	cudaFree@PLT
	movq	104(%rsp), %rdi
	call	cudaFree@PLT
	movq	112(%rsp), %rdi
	call	cudaFree@PLT
	movq	120(%rsp), %rdi
	call	cudaFree@PLT
	movq	128(%rsp), %rdi
	call	cudaFree@PLT
	movq	136(%rsp), %rdi
	call	cudaFree@PLT
	movq	144(%rsp), %rdi
	call	cudaFree@PLT
	call	clock@PLT
	cvtsi2ssq	88(%rsp), %xmm1
	movl	$2, %edi
	leaq	.LC37(%rip), %rsi
	cvtsi2ssq	%rax, %xmm0
	movb	$1, %al
	subss	%xmm1, %xmm0
	divss	.LC36(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	call	cudaDeviceReset@PLT
	movl	%eax, %edx
	xorl	%eax, %eax
	testl	%edx, %edx
	je	.L8
	movq	stderr(%rip), %rdi
	leaq	.LC38(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	$1, %eax
.L8:
	movq	3256(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	addq	$3272, %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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC39:
	.string	"_Z3EDFPiS_S_S_S_S_S_Pei"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC39(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z3EDFPiS_S_S_S_S_S_Pei(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2055:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	tam_imag
	.data
	.align 8
	.type	tam_imag, @object
	.size	tam_imag, 8
tam_imag:
	.quad	1443520
	.globl	dimy
	.align 8
	.type	dimy, @object
	.size	dimy, 8
dimy:
	.quad	1388
	.globl	dimx
	.align 8
	.type	dimx, @object
	.size	dimx, 8
dimx:
	.quad	1040
	.globl	msk
	.align 8
	.type	msk, @object
	.size	msk, 8
msk:
	.quad	3
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC36:
	.long	1232348160
	.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:

/*
The code generates a 3D image of a stack of images.

For each image (matrix) calculate the variance at all points, and then create a topography matrix (relief matrix) with
the position (number in the stack) of the image that had the largest variance in a pixel. The same with the color of the
image (RGB matrices).
*/

#include "hip/hip_runtime.h"

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

#include <time.h>

//************Global variables***************

struct point
{
	int x;
	int y;
};
#define IJ_TO_ID(i,j) (((i)*dimy)+(j))

//************** Kernel CUDA *********************
__global__  void EDF(int *R_d, int *G_d, int *B_d, int *Rf_d, int *Gf_d, int *Bf_d, int *topof_d, long double *max_d, int d) {

	int idx = threadIdx.x + blockIdx.x*blockDim.x;
	int idy = threadIdx.y + blockIdx.y*blockDim.y;
	int id = idx + idy*blockDim.x*gridDim.x;

	//int id = idy + idx*blockDim.y*gridDim.y;

	int dimx = 1040, dimy = 1388, tam_imag = 1040*1388, msk = 3, M_d[9], k;
	long double X = 0.f, Xprom = 0.f, Y = 0.f, var = 0.f;
	//Rf_d[id] = id;
	//int img_x = (id) % dimx;
	//int img_y = (id) / dimx;

	int img_x = id / dimy;
	int img_y = id % dimy;

	//int i = 0;
	//unsigned long long int id2;

	M_d[0] = ((img_x < 1 || img_y < 1) ? 0 : G_d[IJ_TO_ID(img_x - 1, img_y - 1)]);
	M_d[1] = ((img_x < 1) ? 0 : G_d[IJ_TO_ID(img_x - 1, img_y)]);
	M_d[2] = ((img_x<1 || img_y>dimy - 2) ? 0 : G_d[IJ_TO_ID(img_x - 1, img_y + 1)]);
	M_d[3] = ((img_y < 1) ? 0 : G_d[IJ_TO_ID(img_x, img_y - 1)]);  //img_x
	M_d[4] = G_d[IJ_TO_ID(img_x, img_y)];
	M_d[5] = ((img_y > dimy - 2) ? 0 : G_d[IJ_TO_ID(img_x, img_y + 1)]);
	M_d[6] = ((img_x > dimx - 2 || img_y < 1) ? 0 : G_d[IJ_TO_ID(img_x + 1, img_y - 1)]);
	M_d[7] = ((img_x > dimx - 2) ? 0 : G_d[IJ_TO_ID(img_x + 1, img_y)]);
	M_d[8] = ((img_x > dimx - 2 || img_y > dimy - 2) ? 0 : G_d[IJ_TO_ID(img_x + 1, img_y + 1)]);


	for (k = 0;k < msk*msk;k++)
		X += M_d[k];

	Xprom = ((long double)X) / (msk*msk);

	for (k = 0;k < msk*msk;k++)
		Y += (Xprom - M_d[k])*(Xprom - M_d[k]);
	
	var = ((long double)Y) / (msk*msk);
	
	//syncthreads();
	__syncthreads();

	if (var > max_d[id]) {
		topof_d[id] = d;
		Rf_d[id] = R_d[id];
		Gf_d[id] = G_d[id];
		Bf_d[id] = B_d[id];
		max_d[id] = var;
	}
}


long msk = 3, dimx = 1040, dimy = 1388, tam_imag = 1040*1388;
//*****************Main function**********************
int main(int argc, char* argv[]) {

	//***************Variables**************
	int i, j, m, cont, tam_B, init, fin;
	hipError_t cudaStatus;
	FILE *matrizR, *matrizG, *matrizB;
	int d;
	float t;
	clock_t tinicio, t_GPU;
	tinicio = clock();

	int *topof_h, *R_h, *G_h, *B_h, *Rf_h, *Gf_h, *Bf_h;
	long double *max_h;

	int *topof_d, *R_d, *G_d, *B_d, *Rf_d, *Gf_d, *Bf_d;
	long double *max_d;

	//************ Malloc in host and device *************** 
	R_h = (int *)malloc(sizeof(int)*tam_imag);
	cudaStatus = hipMalloc((void**)&R_d, tam_imag * sizeof(int));
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMalloc failed for R_d!\n");
		exit(0);
	}
	G_h = (int *)malloc(sizeof(int)*tam_imag);
	cudaStatus = hipMalloc((void**)&G_d, tam_imag * sizeof(int));
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMalloc failed for G_d Line=%d!\n", __LINE__);
		exit(0);
	}
	B_h = (int *)malloc(sizeof(int)*tam_imag);
	cudaStatus = hipMalloc((void**)&B_d, tam_imag * sizeof(int));
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMalloc failed for R_d!\n");
		exit(0);
	}

	Rf_h = (int *)malloc(sizeof(int)*tam_imag);
	memset((void*)Rf_h, 0, sizeof(int)*tam_imag);
	cudaStatus = hipMalloc((void**)&Rf_d, tam_imag * sizeof(int));
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMalloc failed for Rf_d!\n");
		exit(0);
	}
	Gf_h = (int *)malloc(sizeof(int)*tam_imag);
	memset((void*)Gf_h, 0, sizeof(int)*tam_imag);
	cudaStatus = hipMalloc((void**)&Gf_d, tam_imag * sizeof(int));
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMemcpy failed for Gf_d line %d!\n", __LINE__);
		fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
		exit(0);
	}
	Bf_h = (int *)malloc(sizeof(int)*tam_imag);
	memset((void*)Bf_h, 0, sizeof(int)*tam_imag);
	cudaStatus = hipMalloc((void**)&Bf_d, tam_imag * sizeof(int));
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMalloc failed for Bf_d!\n");
		fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
		exit(0);
	}
	topof_h = (int *)malloc(sizeof(int)*tam_imag);
	memset((void *)topof_h, 0, sizeof(int)*tam_imag);
	cudaStatus = hipMalloc((void**)&topof_d, tam_imag * sizeof(int));
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMemcpy failed for topof_d line %d!\n", __LINE__);
		fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
		exit(0);
	}

	//cudaMemset((void *)topof_d, 0, tam_imag * sizeof(int)); //hosam

	max_h = (long double *)malloc(sizeof(long double)*tam_imag);
	memset((void*)max_h, 0, sizeof(long double)*tam_imag);
	cudaStatus = hipMalloc((void**)&max_d, tam_imag * sizeof(long double));
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipMemcpy failed for max_d line %d!\n", __LINE__);
		fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
		exit(0);
	}
	//cudaMemset(max_d, 0, sizeof(float)*tam_imag);

	//cudaMemset((void *)max_h, 0, sizeof(float)*tam_imag);

	//init=atoi(argv[1]);
	//fin=atoi(argv[2]);
	init = 1;
	fin = 20;

	//*************** Principal FOR ****************
	for (d = init;d <= fin;d++)
	{

		printf("d=%d \n", d);
		//*****************Read RGB files****************
		char rutaR[1024];
		sprintf(rutaR, "%s%d%s", "RGB/", d, "/R");
		matrizR = fopen(rutaR, "r+");
		if (!matrizR)
		{
			printf("Error open file R\n");
			exit(0);
		}

		char rutaG[1024];
		sprintf(rutaG, "%s%d%s", "RGB/", d, "/G");
		matrizG = fopen(rutaG, "r+");
		if (!matrizG)
		{
			printf("Error open file G\n");
			exit(0);
		}

		char rutaB[1024];
		sprintf(rutaB, "%s%d%s", "RGB/", d, "/B");
		matrizB = fopen(rutaB, "r+");
		if (!matrizB)
		{
			printf("Error open file B\n");
			exit(0);
		}

		memset((void*)R_h, 0, sizeof(int)*tam_imag);
		memset((void*)G_h, 0, sizeof(int)*tam_imag);
		memset((void*)B_h, 0, sizeof(int)*tam_imag);

		for(i=0;i<dimx;i++){
			for(j=0;j<dimy;j++){
				fscanf(matrizR, "%d", &R_h[i*dimy + j]);
				fscanf(matrizG, "%d", &G_h[i*dimy + j]);
				fscanf(matrizB, "%d", &B_h[i*dimy + j]);
			}
		}
		fclose(matrizR);
		fclose(matrizG);
		fclose(matrizB);

		//***************** Kernel EDF *******************

		cudaStatus = hipMemcpy(R_d, R_h, sizeof(int)*tam_imag, hipMemcpyHostToDevice);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for R_d line %d!\n", __LINE__);
			exit(0);
		}

		cudaStatus = hipMemcpy(G_d, G_h, sizeof(int)*tam_imag, hipMemcpyHostToDevice);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for G_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = hipMemcpy(B_d, B_h, sizeof(int)*tam_imag, hipMemcpyHostToDevice);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for B_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}

		cudaStatus = hipMemcpy(Rf_d, Rf_h, sizeof(int)*tam_imag, hipMemcpyHostToDevice);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for Rf_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = hipMemcpy(Gf_d, Gf_h, sizeof(int)*tam_imag, hipMemcpyHostToDevice);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for Gf_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = hipMemcpy(Bf_d, Bf_h, sizeof(int)*tam_imag, hipMemcpyHostToDevice);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for Bf_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}

		cudaStatus = hipMemcpy(topof_d, topof_h, sizeof(int)*tam_imag, hipMemcpyHostToDevice);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for topof_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = hipMemcpy(max_d, max_h, sizeof(long double)*tam_imag, hipMemcpyHostToDevice);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for max_d line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}

		dim3 Grid(347, 20);
		dim3 Block(13, 16);

		EDF <<<Grid, Block >>> (R_d, G_d, B_d, Rf_d, Gf_d, Bf_d, topof_d, max_d, d);

		//printf("\n\n FINISH \n\n");
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The code stops here
		cudaStatus = hipMemcpy(Rf_h, Rf_d, sizeof(int)*tam_imag, hipMemcpyDeviceToHost);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for Rf_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = hipMemcpy(Gf_h, Gf_d, sizeof(int)*tam_imag, hipMemcpyDeviceToHost);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for Gf_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = hipMemcpy(Bf_h, Bf_d, sizeof(int)*tam_imag, hipMemcpyDeviceToHost);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for Bf_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}

		cudaStatus = hipMemcpy(topof_h, topof_d, sizeof(int)*tam_imag, hipMemcpyDeviceToHost);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for topof_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}
		cudaStatus = hipMemcpy(max_h, max_d, sizeof(long double)*tam_imag, hipMemcpyDeviceToHost);
		if (cudaStatus != hipSuccess) {
			fprintf(stderr, "hipMemcpy failed for max_h line %d!\n", __LINE__);
			fprintf(stderr, "ERROR: %s\n", hipGetErrorString(cudaStatus));
			exit(0);
		}

	} //End for

	  //****************Save results**************
	FILE *archTopo, *archR, *archG, *archB;
	archTopo = fopen("Resultados/topo-f3.txt", "w+");
	archR = fopen("Resultados/R-f3.txt", "w+");
	archG = fopen("Resultados/G-f3.txt", "w+");
	archB = fopen("Resultados/B-f3.txt", "w+");
	for(i=0;i<dimx;i++) {
		for(j=0;j<dimy;j++) {
			fprintf(archTopo, "%d ", topof_h[i*dimy + j]);
			fprintf(archR, "%d ", Rf_h[i*dimy + j]);
			fprintf(archG, "%d ", Gf_h[i*dimy + j]);
			fprintf(archB, "%d ", Bf_h[i*dimy + j]);
		}
		fprintf(archTopo, "\n");
		fprintf(archR, "\n");
		fprintf(archG, "\n");
		fprintf(archB, "\n");
	}
	/*for(i=0;i<tam_imag;i++) {

			fprintf(archTopo, "%d ", topof_h[i]);
			fprintf(archR, "%d ", Rf_h[i]);
			fprintf(archG, "%d ", Gf_h[i]);
			fprintf(archB, "%d ", Bf_h[i]);

	}*/

	fclose(archTopo);
	fclose(archR);
	fclose(archG);
	fclose(archB);

	free(max_h);
	free(topof_h);
	free(R_h);
	free(G_h);
	free(B_h);
	free(Rf_h);
	free(Gf_h);
	free(Bf_h);

	hipFree(max_d);
	hipFree(topof_d);
	hipFree(R_d);
	hipFree(G_d);
	hipFree(B_d);
	hipFree(Rf_d);
	hipFree(Gf_d);
	hipFree(Bf_d);


	t_GPU = clock();
	t = ((float)t_GPU - (float)tinicio) / CLOCKS_PER_SEC;
	printf("\ntiempo de procesamiento de varianzas: %6.3fs\n", t);

	//getchar ();
	cudaStatus = hipDeviceReset();
	if (cudaStatus != hipSuccess) {
		fprintf(stderr, "hipDeviceReset failed!");
		return 1;
	}

	return 0;

}//END Main function

	.text
	.file	"f3_kernel-M.hip"
	.globl	_Z18__device_stub__EDFPiS_S_S_S_S_S_Pei # -- Begin function _Z18__device_stub__EDFPiS_S_S_S_S_S_Pei
	.type	_Z18__device_stub__EDFPiS_S_S_S_S_S_Pei,@function
_Z18__device_stub__EDFPiS_S_S_S_S_S_Pei: # @_Z18__device_stub__EDFPiS_S_S_S_S_S_Pei
	.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	$_Z3EDFPiS_S_S_S_S_S_Pei, %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_end0:
	.size	_Z18__device_stub__EDFPiS_S_S_S_S_S_Pei, .Lfunc_end0-_Z18__device_stub__EDFPiS_S_S_S_S_S_Pei
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI1_0:
	.long	0x49742400                      # float 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$3256, %rsp                     # imm = 0xCB8
	.cfi_def_cfa_offset 3312
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	callq	clock
	movq	%rax, %r14
	movq	tam_imag(%rip), %rbx
	shlq	$2, %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	leaq	152(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_66
# %bb.1:
	movq	tam_imag(%rip), %rbx
	shlq	$2, %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	leaq	144(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_67
# %bb.2:
	movq	tam_imag(%rip), %rbx
	shlq	$2, %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	leaq	136(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_66
# %bb.3:
	movq	tam_imag(%rip), %rbx
	shlq	$2, %rbx
	movl	$1, %edi
	movq	%rbx, %rsi
	callq	calloc@PLT
	movq	%rax, 128(%rsp)                 # 8-byte Spill
	leaq	104(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_68
# %bb.4:
	movq	tam_imag(%rip), %rbx
	shlq	$2, %rbx
	movl	$1, %edi
	movq	%rbx, %rsi
	callq	calloc@PLT
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	leaq	96(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_70
# %bb.5:
	movq	%r14, 168(%rsp)                 # 8-byte Spill
	movq	tam_imag(%rip), %r14
	shlq	$2, %r14
	movl	$1, %edi
	movq	%r14, %rsi
	callq	calloc@PLT
	movq	%rax, %rbx
	leaq	88(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_71
# %bb.6:
	movq	tam_imag(%rip), %r15
	shlq	$2, %r15
	movl	$1, %edi
	movq	%r15, %rsi
	callq	calloc@PLT
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	leaq	112(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_72
# %bb.7:
	movq	%rbx, 24(%rsp)                  # 8-byte Spill
	movq	tam_imag(%rip), %r15
	shlq	$4, %r15
	movl	$1, %edi
	movq	%r15, %rsi
	callq	calloc@PLT
	movq	%rax, 120(%rsp)                 # 8-byte Spill
	leaq	80(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_73
# %bb.8:                                # %.preheader197.preheader
	movl	$1, %ebx
.LBB1_9:                                # %.preheader197
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_14 Depth 2
                                        #       Child Loop BB1_16 Depth 3
	movl	$.L.str.8, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.9, %esi
	movl	$.L.str.10, %edx
	movl	$.L.str.11, %r8d
	leaq	2224(%rsp), %r14
	movq	%r14, %rdi
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	sprintf
	movl	$.L.str.12, %esi
	movq	%r14, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_44
# %bb.10:                               #   in Loop: Header=BB1_9 Depth=1
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	$.L.str.9, %esi
	movl	$.L.str.10, %edx
	movl	$.L.str.14, %r8d
	leaq	1200(%rsp), %r14
	movq	%r14, %rdi
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	sprintf
	movl	$.L.str.12, %esi
	movq	%r14, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_45
# %bb.11:                               #   in Loop: Header=BB1_9 Depth=1
	movq	%rax, %r15
	movl	$.L.str.9, %esi
	movl	$.L.str.10, %edx
	movl	$.L.str.16, %r8d
	leaq	176(%rsp), %r14
	movq	%r14, %rdi
	movq	%rbx, 160(%rsp)                 # 8-byte Spill
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	sprintf
	movl	$.L.str.12, %esi
	movq	%r14, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_46
# %bb.12:                               #   in Loop: Header=BB1_9 Depth=1
	movq	%rax, %r14
	movq	tam_imag(%rip), %rbx
	shlq	$2, %rbx
	movq	64(%rsp), %rdi                  # 8-byte Reload
	xorl	%esi, %esi
	movq	%rbx, %rdx
	callq	memset@PLT
	movq	56(%rsp), %rdi                  # 8-byte Reload
	xorl	%esi, %esi
	movq	%rbx, %rdx
	callq	memset@PLT
	movq	48(%rsp), %rdi                  # 8-byte Reload
	xorl	%esi, %esi
	movq	%rbx, %rdx
	callq	memset@PLT
	movq	dimx(%rip), %rax
	testq	%rax, %rax
	jle	.LBB1_19
# %bb.13:                               # %.preheader196.preheader
                                        #   in Loop: Header=BB1_9 Depth=1
	movq	dimy(%rip), %rdx
	xorl	%ebx, %ebx
	xorl	%ecx, %ecx
	movq	%r15, 8(%rsp)                   # 8-byte Spill
	movq	%r14, (%rsp)                    # 8-byte Spill
.LBB1_14:                               # %.preheader196
                                        #   Parent Loop BB1_9 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_16 Depth 3
	testq	%rdx, %rdx
	jle	.LBB1_18
# %bb.15:                               # %.lr.ph.preheader
                                        #   in Loop: Header=BB1_14 Depth=2
	movq	%rcx, 72(%rsp)                  # 8-byte Spill
	movq	64(%rsp), %r15                  # 8-byte Reload
	movq	56(%rsp), %r14                  # 8-byte Reload
	movq	48(%rsp), %r12                  # 8-byte Reload
	xorl	%r13d, %r13d
	movq	40(%rsp), %rbp                  # 8-byte Reload
.LBB1_16:                               # %.lr.ph
                                        #   Parent Loop BB1_9 Depth=1
                                        #     Parent Loop BB1_14 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	imulq	%rbx, %rdx
	addq	%r15, %rdx
	movl	$.L.str.18, %esi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movq	dimy(%rip), %rdx
	imulq	%rbx, %rdx
	addq	%r14, %rdx
	movl	$.L.str.18, %esi
	movq	8(%rsp), %rdi                   # 8-byte Reload
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movq	dimy(%rip), %rdx
	imulq	%rbx, %rdx
	addq	%r12, %rdx
	movl	$.L.str.18, %esi
	movq	(%rsp), %rdi                    # 8-byte Reload
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	incq	%r13
	movq	dimy(%rip), %rdx
	addq	$4, %r12
	addq	$4, %r14
	addq	$4, %r15
	cmpq	%r13, %rdx
	jg	.LBB1_16
# %bb.17:                               # %._crit_edge.loopexit
                                        #   in Loop: Header=BB1_14 Depth=2
	movq	dimx(%rip), %rax
	movq	8(%rsp), %r15                   # 8-byte Reload
	movq	(%rsp), %r14                    # 8-byte Reload
	movq	72(%rsp), %rcx                  # 8-byte Reload
.LBB1_18:                               # %._crit_edge
                                        #   in Loop: Header=BB1_14 Depth=2
	incq	%rcx
	addq	$4, %rbx
	cmpq	%rcx, %rax
	jg	.LBB1_14
.LBB1_19:                               # %._crit_edge277
                                        #   in Loop: Header=BB1_9 Depth=1
	movq	40(%rsp), %rdi                  # 8-byte Reload
	callq	fclose
	movq	%r15, %rdi
	callq	fclose
	movq	%r14, %rdi
	callq	fclose
	movq	152(%rsp), %rdi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	64(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_64
# %bb.20:                               #   in Loop: Header=BB1_9 Depth=1
	movq	144(%rsp), %rdi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	56(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	movq	128(%rsp), %rbx                 # 8-byte Reload
	jne	.LBB1_60
# %bb.21:                               #   in Loop: Header=BB1_9 Depth=1
	movq	136(%rsp), %rdi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_59
# %bb.22:                               #   in Loop: Header=BB1_9 Depth=1
	movq	104(%rsp), %rdi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_58
# %bb.23:                               #   in Loop: Header=BB1_9 Depth=1
	movq	96(%rsp), %rdi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	32(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_57
# %bb.24:                               #   in Loop: Header=BB1_9 Depth=1
	movq	88(%rsp), %rdi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_56
# %bb.25:                               #   in Loop: Header=BB1_9 Depth=1
	movq	112(%rsp), %rdi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_54
# %bb.26:                               #   in Loop: Header=BB1_9 Depth=1
	movq	80(%rsp), %rdi
	movq	tam_imag(%rip), %rdx
	shlq	$4, %rdx
	movq	120(%rsp), %rsi                 # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_55
# %bb.27:                               #   in Loop: Header=BB1_9 Depth=1
	movabsq	$85899346267, %rdi              # imm = 0x140000015B
	movl	$1, %esi
	movabsq	$68719476749, %rdx              # imm = 0x100000000D
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_29
# %bb.28:                               #   in Loop: Header=BB1_9 Depth=1
	movq	152(%rsp), %rdi
	movq	144(%rsp), %rsi
	movq	136(%rsp), %rdx
	movq	104(%rsp), %rcx
	movq	96(%rsp), %r8
	movq	88(%rsp), %r9
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	pushq	168(%rsp)                       # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	96(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	136(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z18__device_stub__EDFPiS_S_S_S_S_S_Pei
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
.LBB1_29:                               #   in Loop: Header=BB1_9 Depth=1
	movq	104(%rsp), %rsi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_53
# %bb.30:                               #   in Loop: Header=BB1_9 Depth=1
	movq	96(%rsp), %rsi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	32(%rsp), %rdi                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	movq	24(%rsp), %rdi                  # 8-byte Reload
	movq	16(%rsp), %rbx                  # 8-byte Reload
	jne	.LBB1_50
# %bb.31:                               #   in Loop: Header=BB1_9 Depth=1
	movq	88(%rsp), %rsi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_51
# %bb.32:                               #   in Loop: Header=BB1_9 Depth=1
	movq	112(%rsp), %rsi
	movq	tam_imag(%rip), %rdx
	shlq	$2, %rdx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_52
# %bb.33:                               #   in Loop: Header=BB1_9 Depth=1
	movq	80(%rsp), %rsi
	movq	tam_imag(%rip), %rdx
	shlq	$4, %rdx
	movq	120(%rsp), %rdi                 # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_49
# %bb.34:                               #   in Loop: Header=BB1_9 Depth=1
	movq	160(%rsp), %rbx                 # 8-byte Reload
	incl	%ebx
	cmpl	$21, %ebx
	jne	.LBB1_9
# %bb.35:
	movl	$.L.str.29, %edi
	movl	$.L.str.30, %esi
	callq	fopen
	movq	%rax, %r14
	movl	$.L.str.31, %edi
	movl	$.L.str.30, %esi
	callq	fopen
	movq	%rax, %r15
	movl	$.L.str.32, %edi
	movl	$.L.str.30, %esi
	callq	fopen
	movq	%rax, %r12
	movl	$.L.str.33, %edi
	movl	$.L.str.30, %esi
	callq	fopen
	movq	%rax, %r13
	cmpq	$0, dimx(%rip)
	jle	.LBB1_41
# %bb.36:                               # %.preheader.preheader
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	movq	%r15, 8(%rsp)                   # 8-byte Spill
	movq	%r12, (%rsp)                    # 8-byte Spill
	movq	%r13, 72(%rsp)                  # 8-byte Spill
	movq	16(%rsp), %rbp                  # 8-byte Reload
.LBB1_37:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_39 Depth 2
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movq	dimy(%rip), %rax
	testq	%rax, %rax
	movq	32(%rsp), %r12                  # 8-byte Reload
	movq	24(%rsp), %r13                  # 8-byte Reload
	movq	%r14, %r15
	jle	.LBB1_40
# %bb.38:                               # %.lr.ph280.preheader
                                        #   in Loop: Header=BB1_37 Depth=1
	xorl	%r14d, %r14d
.LBB1_39:                               # %.lr.ph280
                                        #   Parent Loop BB1_37 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	imulq	%rbx, %rax
	addq	%rbp, %rax
	movl	(%rax,%r14,4), %edx
	movl	$.L.str.34, %esi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	fprintf
	movq	dimy(%rip), %rax
	imulq	%rbx, %rax
	addq	128(%rsp), %rax                 # 8-byte Folded Reload
	movl	(%rax,%r14,4), %edx
	movl	$.L.str.34, %esi
	movq	8(%rsp), %rdi                   # 8-byte Reload
	xorl	%eax, %eax
	callq	fprintf
	movq	dimy(%rip), %rax
	imulq	%rbx, %rax
	addq	%r12, %rax
	movl	(%rax,%r14,4), %edx
	movl	$.L.str.34, %esi
	movq	(%rsp), %rdi                    # 8-byte Reload
	xorl	%eax, %eax
	callq	fprintf
	movq	dimy(%rip), %rax
	imulq	%rbx, %rax
	addq	%r13, %rax
	movl	(%rax,%r14,4), %edx
	movl	$.L.str.34, %esi
	movq	72(%rsp), %rdi                  # 8-byte Reload
	xorl	%eax, %eax
	callq	fprintf
	incq	%r14
	movq	dimy(%rip), %rax
	cmpq	%r14, %rax
	jg	.LBB1_39
.LBB1_40:                               # %._crit_edge281
                                        #   in Loop: Header=BB1_37 Depth=1
	movl	$10, %edi
	movq	%r15, %rsi
	movq	%r15, %r14
	callq	fputc@PLT
	movl	$10, %edi
	movq	8(%rsp), %r15                   # 8-byte Reload
	movq	%r15, %rsi
	callq	fputc@PLT
	movl	$10, %edi
	movq	(%rsp), %r12                    # 8-byte Reload
	movq	%r12, %rsi
	callq	fputc@PLT
	movl	$10, %edi
	movq	72(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rsi
	callq	fputc@PLT
	movq	40(%rsp), %rax                  # 8-byte Reload
	incq	%rax
	addq	$4, %rbx
	cmpq	%rax, dimx(%rip)
	jg	.LBB1_37
.LBB1_41:                               # %._crit_edge283
	movq	%r14, %rdi
	callq	fclose
	movq	%r15, %rdi
	callq	fclose
	movq	%r12, %rdi
	callq	fclose
	movq	%r13, %rdi
	callq	fclose
	movq	120(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	64(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	56(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	48(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	128(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	24(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	80(%rsp), %rdi
	callq	hipFree
	movq	112(%rsp), %rdi
	callq	hipFree
	movq	152(%rsp), %rdi
	callq	hipFree
	movq	144(%rsp), %rdi
	callq	hipFree
	movq	136(%rsp), %rdi
	callq	hipFree
	movq	104(%rsp), %rdi
	callq	hipFree
	movq	96(%rsp), %rdi
	callq	hipFree
	movq	88(%rsp), %rdi
	callq	hipFree
	callq	clock
	cvtsi2ss	%rax, %xmm0
	cvtsi2ssq	168(%rsp), %xmm1        # 8-byte Folded Reload
	subss	%xmm1, %xmm0
	divss	.LCPI1_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.36, %edi
	movb	$1, %al
	callq	printf
	callq	hipDeviceReset
	movl	%eax, %ecx
	xorl	%eax, %eax
	testl	%ecx, %ecx
	jne	.LBB1_43
.LBB1_42:
	addq	$3256, %rsp                     # imm = 0xCB8
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB1_43:
	.cfi_def_cfa_offset 3312
	movq	stderr(%rip), %rcx
	movl	$.L.str.37, %edi
	movl	$22, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movl	$1, %eax
	jmp	.LBB1_42
.LBB1_44:
	movl	$.Lstr, %edi
	jmp	.LBB1_47
.LBB1_45:
	movl	$.Lstr.1, %edi
	jmp	.LBB1_47
.LBB1_46:
	movl	$.Lstr.2, %edi
.LBB1_47:
	callq	puts@PLT
	jmp	.LBB1_48
.LBB1_49:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.28, %esi
	movl	$305, %edx                      # imm = 0x131
	jmp	.LBB1_61
.LBB1_50:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.25, %esi
	movl	$286, %edx                      # imm = 0x11E
	jmp	.LBB1_61
.LBB1_51:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.26, %esi
	movl	$292, %edx                      # imm = 0x124
	jmp	.LBB1_61
.LBB1_52:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.27, %esi
	movl	$299, %edx                      # imm = 0x12B
	jmp	.LBB1_61
.LBB1_53:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.24, %esi
	movl	$280, %edx                      # imm = 0x118
	jmp	.LBB1_61
.LBB1_54:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.6, %esi
	movl	$260, %edx                      # imm = 0x104
	jmp	.LBB1_61
.LBB1_55:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.7, %esi
	movl	$266, %edx                      # imm = 0x10A
	jmp	.LBB1_61
.LBB1_56:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.23, %esi
	movl	$253, %edx
	jmp	.LBB1_61
.LBB1_57:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$247, %edx
	jmp	.LBB1_61
.LBB1_58:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.22, %esi
	movl	$241, %edx
	jmp	.LBB1_61
.LBB1_59:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.21, %esi
	movl	$234, %edx
	jmp	.LBB1_61
.LBB1_60:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.20, %esi
	movl	$228, %edx
.LBB1_61:
	xorl	%eax, %eax
	callq	fprintf
.LBB1_62:
	movq	stderr(%rip), %rbx
	movl	%ebp, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movq	%rbx, %rdi
.LBB1_63:
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
.LBB1_48:
	xorl	%edi, %edi
	callq	exit
.LBB1_64:
	movq	stderr(%rip), %rdi
	movl	$.L.str.19, %esi
	movl	$222, %edx
.LBB1_65:
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB1_48
.LBB1_66:
	movq	stderr(%rip), %rcx
	movl	$.L.str, %edi
	movl	$26, %esi
	jmp	.LBB1_69
.LBB1_67:
	movq	stderr(%rip), %rdi
	movl	$.L.str.1, %esi
	movl	$109, %edx
	jmp	.LBB1_65
.LBB1_68:
	movq	stderr(%rip), %rcx
	movl	$.L.str.2, %edi
	movl	$27, %esi
.LBB1_69:
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB1_48
.LBB1_70:
	movl	%eax, %ebx
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movl	$130, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %esi
	movq	%r14, %rdi
	jmp	.LBB1_63
.LBB1_71:
	movl	%eax, %ebp
	movq	stderr(%rip), %rcx
	movl	$.L.str.5, %edi
	movl	$27, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB1_62
.LBB1_72:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.6, %esi
	movl	$146, %edx
	jmp	.LBB1_61
.LBB1_73:
	movl	%eax, %ebp
	movq	stderr(%rip), %rdi
	movl	$.L.str.7, %esi
	movl	$157, %edx
	jmp	.LBB1_61
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z3EDFPiS_S_S_S_S_S_Pei, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB3_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z3EDFPiS_S_S_S_S_S_Pei,@object # @_Z3EDFPiS_S_S_S_S_S_Pei
	.section	.rodata,"a",@progbits
	.globl	_Z3EDFPiS_S_S_S_S_S_Pei
	.p2align	3, 0x0
_Z3EDFPiS_S_S_S_S_S_Pei:
	.quad	_Z18__device_stub__EDFPiS_S_S_S_S_S_Pei
	.size	_Z3EDFPiS_S_S_S_S_S_Pei, 8

	.type	msk,@object                     # @msk
	.data
	.globl	msk
	.p2align	3, 0x0
msk:
	.quad	3                               # 0x3
	.size	msk, 8

	.type	dimx,@object                    # @dimx
	.globl	dimx
	.p2align	3, 0x0
dimx:
	.quad	1040                            # 0x410
	.size	dimx, 8

	.type	dimy,@object                    # @dimy
	.globl	dimy
	.p2align	3, 0x0
dimy:
	.quad	1388                            # 0x56c
	.size	dimy, 8

	.type	tam_imag,@object                # @tam_imag
	.globl	tam_imag
	.p2align	3, 0x0
tam_imag:
	.quad	1443520                         # 0x1606c0
	.size	tam_imag, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"hipMalloc failed for R_d!\n"
	.size	.L.str, 27

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"hipMalloc failed for G_d Line=%d!\n"
	.size	.L.str.1, 35

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"hipMalloc failed for Rf_d!\n"
	.size	.L.str.2, 28

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"hipMemcpy failed for Gf_d line %d!\n"
	.size	.L.str.3, 36

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"ERROR: %s\n"
	.size	.L.str.4, 11

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"hipMalloc failed for Bf_d!\n"
	.size	.L.str.5, 28

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"hipMemcpy failed for topof_d line %d!\n"
	.size	.L.str.6, 39

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"hipMemcpy failed for max_d line %d!\n"
	.size	.L.str.7, 37

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"d=%d \n"
	.size	.L.str.8, 7

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"%s%d%s"
	.size	.L.str.9, 7

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"RGB/"
	.size	.L.str.10, 5

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"/R"
	.size	.L.str.11, 3

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"r+"
	.size	.L.str.12, 3

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"/G"
	.size	.L.str.14, 3

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"/B"
	.size	.L.str.16, 3

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"%d"
	.size	.L.str.18, 3

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"hipMemcpy failed for R_d line %d!\n"
	.size	.L.str.19, 35

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"hipMemcpy failed for G_d line %d!\n"
	.size	.L.str.20, 35

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"hipMemcpy failed for B_d line %d!\n"
	.size	.L.str.21, 35

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"hipMemcpy failed for Rf_d line %d!\n"
	.size	.L.str.22, 36

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"hipMemcpy failed for Bf_d line %d!\n"
	.size	.L.str.23, 36

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"hipMemcpy failed for Rf_h line %d!\n"
	.size	.L.str.24, 36

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"hipMemcpy failed for Gf_h line %d!\n"
	.size	.L.str.25, 36

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"hipMemcpy failed for Bf_h line %d!\n"
	.size	.L.str.26, 36

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"hipMemcpy failed for topof_h line %d!\n"
	.size	.L.str.27, 39

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"hipMemcpy failed for max_h line %d!\n"
	.size	.L.str.28, 37

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"Resultados/topo-f3.txt"
	.size	.L.str.29, 23

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"w+"
	.size	.L.str.30, 3

	.type	.L.str.31,@object               # @.str.31
.L.str.31:
	.asciz	"Resultados/R-f3.txt"
	.size	.L.str.31, 20

	.type	.L.str.32,@object               # @.str.32
.L.str.32:
	.asciz	"Resultados/G-f3.txt"
	.size	.L.str.32, 20

	.type	.L.str.33,@object               # @.str.33
.L.str.33:
	.asciz	"Resultados/B-f3.txt"
	.size	.L.str.33, 20

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

	.type	.L.str.36,@object               # @.str.36
.L.str.36:
	.asciz	"\ntiempo de procesamiento de varianzas: %6.3fs\n"
	.size	.L.str.36, 47

	.type	.L.str.37,@object               # @.str.37
.L.str.37:
	.asciz	"hipDeviceReset failed!"
	.size	.L.str.37, 23

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z3EDFPiS_S_S_S_S_S_Pei"
	.size	.L__unnamed_1, 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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Error open file R"
	.size	.Lstr, 18

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Error open file G"
	.size	.Lstr.1, 18

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Error open file B"
	.size	.Lstr.2, 18

	.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 _Z18__device_stub__EDFPiS_S_S_S_S_S_Pei
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z3EDFPiS_S_S_S_S_S_Pei
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z3EDFPiS_S_S_S_S_S_Pei ; -- Begin function _Z3EDFPiS_S_S_S_S_S_Pei
	.globl	_Z3EDFPiS_S_S_S_S_S_Pei
	.p2align	8
	.type	_Z3EDFPiS_S_S_S_S_S_Pei,@function
_Z3EDFPiS_S_S_S_S_S_Pei:                ; @_Z3EDFPiS_S_S_S_S_S_Pei
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x54
	s_load_b32 s3, s[0:1], 0x48
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s4, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s4, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[3:4], null, v2, s3, s[14:15]
	s_load_b512 s[8:23], s[0:1], 0x0
	v_mad_u64_u32 v[9:10], null, v3, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_hi_i32 v0, 0x5e6ea9af, v9
	v_cmp_lt_i32_e64 s3, 0x56b, v9
	v_lshrrev_b32_e32 v1, 31, v0
	v_ashrrev_i32_e32 v0, 9, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, v0, v1
	v_mul_i32_i24_e32 v8, 0x56c, v0
	v_mov_b32_e32 v0, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v13, v9, v8
	v_cmp_lt_i32_e64 s2, 0, v13
	v_cmp_gt_i32_e32 vcc_lo, 1, v13
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s4, s3, s2
	s_and_saveexec_b32 s5, s4
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_add3_u32 v0, v13, v8, 0xfffffa93
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v0, s4, s10, v0
	v_add_co_ci_u32_e64 v1, s4, s11, v1, s4
	global_load_b32 v0, v[0:1], off
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s5
	s_and_saveexec_b32 s4, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s4, exec_lo, s4
	s_cbranch_execz .LBB0_6
; %bb.3:
	v_add3_u32 v1, v13, v8, 0xfffffa94
	s_mov_b32 s5, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	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_1)
	v_add_co_u32 v1, s3, s10, v1
	v_add_co_ci_u32_e64 v2, s3, s11, v2, s3
	global_load_b32 v1, v[1:2], off
	v_mov_b32_e32 v2, 0
	v_cmpx_gt_i32_e32 0x56b, v13
	s_cbranch_execz .LBB0_5
; %bb.4:
	v_add3_u32 v2, v13, v8, 0xfffffa95
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v2, s3, s10, v2
	v_add_co_ci_u32_e64 v3, s3, s11, v3, s3
	global_load_b32 v2, v[2:3], off
.LBB0_5:                                ; %Flow182
	s_or_b32 exec_lo, exec_lo, s5
.LBB0_6:                                ; %Flow184
	s_and_not1_saveexec_b32 s3, s4
	s_cbranch_execz .LBB0_8
; %bb.7:                                ; %.critedge
	s_mov_b32 s4, 0
	s_waitcnt vmcnt(0)
	v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v1, s4
.LBB0_8:
	s_or_b32 exec_lo, exec_lo, s3
	v_mov_b32_e32 v5, 0
	v_mov_b32_e32 v3, 0
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_10
; %bb.9:
	v_ashrrev_i32_e32 v4, 31, v8
	v_ashrrev_i32_e32 v6, 31, v13
	v_add_co_u32 v3, s2, v13, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v4, s2, v6, v4, s2
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v3, s2, s10, v3
	v_add_co_ci_u32_e64 v4, s2, s11, v4, s2
	global_load_b32 v3, v[3:4], off offset:-4
.LBB0_10:                               ; %._crit_edge
	s_or_b32 exec_lo, exec_lo, s3
	v_ashrrev_i32_e32 v10, 31, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[11:12], 2, v[9:10]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v11, s2, s10, v11
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v12, s2, s11, v12, s2
	v_cmp_gt_i32_e64 s2, 0x56b, v13
	global_load_b32 v4, v[11:12], off
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_12
; %bb.11:
	global_load_b32 v5, v[11:12], off offset:4
.LBB0_12:
	s_or_b32 exec_lo, exec_lo, s3
	v_cmp_gt_i32_e64 s3, 0x160154, v9
	v_mov_b32_e32 v6, 0
	s_xor_b32 s4, vcc_lo, -1
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	s_and_b32 s5, s3, s4
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s4, s5
	s_cbranch_execz .LBB0_14
; %bb.13:
	v_add_nc_u32_e32 v11, 0x56b, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v12, 31, v11
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v11, vcc_lo, s10, v11
	v_add_co_ci_u32_e32 v12, vcc_lo, s11, v12, vcc_lo
	global_load_b32 v6, v[11:12], off
.LBB0_14:
	s_or_b32 exec_lo, exec_lo, s4
	s_and_saveexec_b32 s4, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s3, exec_lo, s4
	s_cbranch_execz .LBB0_18
; %bb.15:
	v_add3_u32 v7, v13, v8, 0x56c
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v8, 31, v7
	v_lshlrev_b64 v[7:8], 2, v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v7, vcc_lo, s10, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s11, v8, vcc_lo
	global_load_b32 v7, v[7:8], off
	v_mov_b32_e32 v8, 0
	s_and_saveexec_b32 s4, s2
	s_cbranch_execz .LBB0_17
; %bb.16:
	v_add_nc_u32_e32 v11, 0x56d, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v12, 31, v11
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v11, vcc_lo, s10, v11
	v_add_co_ci_u32_e32 v12, vcc_lo, s11, v12, vcc_lo
	global_load_b32 v8, v[11:12], off
.LBB0_17:                               ; %Flow
	s_or_b32 exec_lo, exec_lo, s4
.LBB0_18:                               ; %Flow180
	s_and_not1_saveexec_b32 s2, s3
	s_cbranch_execz .LBB0_20
; %bb.19:                               ; %.critedge125
	s_mov_b32 s3, 0
	s_waitcnt vmcnt(0)
	v_dual_mov_b32 v8, 0 :: v_dual_mov_b32 v7, s3
.LBB0_20:
	s_or_b32 exec_lo, exec_lo, s2
	v_mov_b32_e32 v11, 0
	v_mov_b32_e32 v12, 0
	s_mov_b64 s[2:3], 0
.LBB0_21:                               ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 m0, s2
	s_add_u32 s2, s2, 1
	s_waitcnt vmcnt(0)
	v_movrels_b32_e32 v13, v0
	s_addc_u32 s3, s3, 0
	s_cmp_lg_u32 s2, 9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_i32_e32 v[13:14], v13
	v_add_f64 v[11:12], v[11:12], v[13:14]
	s_cbranch_scc1 .LBB0_21
; %bb.22:
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_div_scale_f64 v[13:14], null, 0x40220000, 0x40220000, v[11:12]
	s_mov_b64 s[2:3], 0
	v_rcp_f64_e32 v[15:16], v[13:14]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[17:18], -v[13:14], v[15:16], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[15:16], v[15:16], v[17:18], v[15:16]
	v_fma_f64 v[17:18], -v[13:14], v[15:16], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fma_f64 v[15:16], v[15:16], v[17:18], v[15:16]
	v_div_scale_f64 v[17:18], vcc_lo, v[11:12], 0x40220000, v[11:12]
	v_mul_f64 v[19:20], v[17:18], v[15:16]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[13:14], -v[13:14], v[19:20], v[17:18]
	v_div_fmas_f64 v[13:14], v[13:14], v[15:16], v[19:20]
	s_delay_alu instid0(VALU_DEP_1)
	v_div_fixup_f64 v[13:14], v[13:14], 0x40220000, v[11:12]
	v_mov_b32_e32 v11, 0
	v_mov_b32_e32 v12, 0
.LBB0_23:                               ; =>This Inner Loop Header: Depth=1
	s_mov_b32 m0, s2
	s_add_u32 s2, s2, 1
	v_movrels_b32_e32 v15, v0
	s_addc_u32 s3, s3, 0
	s_cmp_lg_u32 s2, 9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_i32_e32 v[15:16], v15
	v_add_f64 v[15:16], v[13:14], -v[15:16]
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f64 v[11:12], v[15:16], v[15:16], v[11:12]
	s_cbranch_scc1 .LBB0_23
; %bb.24:
	s_delay_alu instid0(VALU_DEP_1)
	v_div_scale_f64 v[2:3], null, 0x40220000, 0x40220000, v[11:12]
	v_lshlrev_b64 v[0:1], 3, v[9:10]
	s_barrier
	buffer_gl0_inv
	s_mov_b32 s2, exec_lo
	v_add_co_u32 v0, vcc_lo, s22, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s23, v1, vcc_lo
	global_load_b64 v[6:7], v[0:1], off
	v_rcp_f64_e32 v[4:5], v[2:3]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[13:14], -v[2:3], v[4:5], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[4:5], v[4:5], v[13:14], v[4:5]
	v_fma_f64 v[13:14], -v[2:3], v[4:5], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fma_f64 v[4:5], v[4:5], v[13:14], v[4:5]
	v_div_scale_f64 v[13:14], vcc_lo, v[11:12], 0x40220000, v[11:12]
	v_mul_f64 v[15:16], v[13:14], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[2:3], -v[2:3], v[15:16], v[13:14]
	v_div_fmas_f64 v[2:3], v[2:3], v[4:5], v[15:16]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_div_fixup_f64 v[2:3], v[2:3], 0x40220000, v[11:12]
	s_waitcnt vmcnt(0)
	v_cmpx_gt_f64_e32 v[2:3], v[6:7]
	s_cbranch_execz .LBB0_26
; %bb.25:
	s_load_b32 s0, s[0:1], 0x40
	v_lshlrev_b64 v[4:5], 2, v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, s20, v4
	v_add_co_ci_u32_e32 v7, vcc_lo, s21, v5, vcc_lo
	v_add_co_u32 v8, vcc_lo, s8, v4
	v_add_co_ci_u32_e32 v9, vcc_lo, s9, v5, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v10, s0
	global_store_b32 v[6:7], v10, off
	global_load_b32 v10, v[8:9], off
	v_add_co_u32 v6, vcc_lo, s14, v4
	v_add_co_ci_u32_e32 v7, vcc_lo, s15, v5, vcc_lo
	v_add_co_u32 v8, vcc_lo, s10, v4
	v_add_co_ci_u32_e32 v9, vcc_lo, s11, v5, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b32 v[6:7], v10, off
	global_load_b32 v10, v[8:9], off
	v_add_co_u32 v6, vcc_lo, s16, v4
	v_add_co_ci_u32_e32 v7, vcc_lo, s17, v5, vcc_lo
	v_add_co_u32 v8, vcc_lo, s12, v4
	v_add_co_ci_u32_e32 v9, vcc_lo, s13, v5, vcc_lo
	v_add_co_u32 v4, vcc_lo, s18, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s19, v5, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b32 v[6:7], v10, off
	global_load_b32 v6, v[8:9], off
	s_waitcnt vmcnt(0)
	global_store_b32 v[4:5], v6, off
	global_store_b64 v[0:1], v[2:3], off
.LBB0_26:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z3EDFPiS_S_S_S_S_S_Pei
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 328
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 21
		.amdhsa_next_free_sgpr 24
		.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	_Z3EDFPiS_S_S_S_S_S_Pei, .Lfunc_end0-_Z3EDFPiS_S_S_S_S_S_Pei
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1468
; NumSgprs: 26
; NumVgprs: 21
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 26
; NumVGPRsForWavesPerEU: 21
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
