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

__global__ void matrixMultGPU(int *a_ll,int *a_lr,int *a_ul, int *a_ur,int *b_ll,int *b_lr,int *b_ul, int *b_ur, int *c_ll,int *c_lr,int *c_ul, int *c_ur, int *t_ll,int *t_lr,int *t_ul, int *t_ur,int N){

	int k, sum_cur = 0,sum_cul = 0,sum_cll = 0,sum_clr = 0,sum_tur = 0,sum_tul = 0,sum_tll = 0,sum_tlr = 0;
	int col = threadIdx.x + blockDim.x * blockIdx.x;
	int fil = threadIdx.y + blockDim.y * blockIdx.y;
	if (col < N && fil < N) 
	{
		for (k = 0; k < N; k++) 
		{
			sum_cul += a_ul[fil * N + k] * b_ul[k * N + col];
			sum_cur += a_ul[fil * N + k] * b_ur[k * N + col];
			sum_cll += a_ll[fil * N + k] * b_ul[k * N + col];
			sum_clr += a_ll[fil * N + k] * b_ur[k * N + col];
			
			sum_tul += a_ur[fil * N + k] * b_ll[k * N + col];
			sum_tur += a_ur[fil * N + k] * b_lr[k * N + col];
			sum_tll += a_lr[fil * N + k] * b_ll[k * N + col];
			sum_tlr += a_lr[fil * N + k] * b_lr[k * N + col];
		}
		c_ul[fil * N + col] = sum_cul;
		c_ur[fil * N + col] = sum_cur;
		c_ll[fil * N + col] = sum_cll;
		c_lr[fil * N + col] = sum_clr;
		
		t_ul[fil * N + col] = sum_tul;
		t_ll[fil * N + col] = sum_tll;
		t_lr[fil * N + col] = sum_tlr;
		t_ur[fil * N + col] = sum_tur;
		__syncthreads();
		
		c_ul[fil * N + col]+=t_ul[fil * N + col];
		c_ll[fil * N + col]+=t_ll[fil * N + col];
		c_lr[fil * N + col]+=t_lr[fil * N + col];
		c_ur[fil * N + col]+=t_ur[fil * N + col];
	}
}

int main (void){
	//Creación de variables del sistema
	int *a, *b, *c, N,NN;
	int *a_ul,*a_ur,*a_ll,*a_lr,*b_ul,*b_ur,*b_ll,*b_lr,*c_ul,*c_ur,*c_ll,*c_lr;
	int *da_ul,*da_ur,*da_ll,*da_lr,*db_ul,*db_ur,*db_ll,*db_lr,*dc_ul,*dc_ur,*dc_ll,*dc_lr,*dt_ul,*dt_ur,*dt_ll,*dt_lr;
	int i,j;
	int T,div=1, iteraciones=10,ind=0;
	float elapsedTime;
	printf("Ingrese el tamano deseado para las matrices:\n");
	scanf("%d",&NN);
	if(NN%2!=0 || NN<2)
	{
		printf("El tamaño debe ser mayor a dos y par\n");
		exit(1);
	}
	N=(int)NN/2;
	//Creación de variables de tiempo
	cudaEvent_t start,stop;
	cudaEventCreate(&start);
	cudaEventCreate(&stop);
	
	printf("Creando espacio e inicializando matrices...\n");
	
	//Asignación e inicialización de memoria
	a=(int*)malloc(NN*NN*sizeof(int));
	b=(int*)malloc(NN*NN*sizeof(int));
	c=(int*)malloc(NN*NN*sizeof(int));
	
	a_ll=(int*)malloc(N*N*sizeof(int));
	a_lr=(int*)malloc(N*N*sizeof(int));
	a_ul=(int*)malloc(N*N*sizeof(int));
	a_ur=(int*)malloc(N*N*sizeof(int));
	
	b_ll=(int*)malloc(N*N*sizeof(int));
	b_lr=(int*)malloc(N*N*sizeof(int));
	b_ul=(int*)malloc(N*N*sizeof(int));
	b_ur=(int*)malloc(N*N*sizeof(int));
	
	c_ll=(int*)malloc(N*N*sizeof(int));
	c_lr=(int*)malloc(N*N*sizeof(int));
	c_ul=(int*)malloc(N*N*sizeof(int));
	c_ur=(int*)malloc(N*N*sizeof(int));
	
	//Inicialización de Matrices
	for(i=0;i<NN;i++)
	{
		for(j=0;j<NN;j++)
		{
			a[i*NN+j]=i*j;
			b[i*NN+j]=i*j;
		}
	}
	
	//Creación de submatrices
	for(i=0;i<N;i++)
	{
		for(j=0;j<N;j++)
		{
			a_ul[i*N+j]=a[i*NN+j];
			a_ur[i*N+j]=a[i*NN+j+N];
			a_ll[i*N+j]=a[(i+N)*NN+j];
			a_lr[i*N+j]=a[(i+N)*NN+j+N];
			
			b_ul[i*N+j]=b[i*NN+j];
			b_ur[i*N+j]=b[i*NN+j+N];
			b_ll[i*N+j]=b[(i+N)*NN+j];
			b_lr[i*N+j]=b[(i+N)*NN+j+N];
		}
	}
	
	{
	if(cudaMalloc(&da_ll,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&da_ul,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&da_ur,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&da_lr,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&db_ll,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&db_lr,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&db_ul,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&db_ur,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&dc_ur,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&dc_ul,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&dc_ll,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&dc_lr,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&dt_ur,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&dt_ul,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&dt_ll,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(cudaMalloc(&dt_lr,N*N*sizeof(int))!=cudaSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	}
	printf("Asignacion de memoria correcta\n");
	//Cálculo de bloques e hilos
	while((float)N/(float)div>32)
	{
		div++;
	}
	float f_N=(float)N,f_div=(float)div;
	T=(int)ceil(f_N/f_div);
	dim3 ThreadsBloque(T,T);
	dim3 Bloques(div, div);
	printf("Se va a realizar la suma con %d bloques y %d hilos\n",div,T);
	printf("Se va a realizar %d iteraciones de matrices %dx%d\n",iteraciones,NN,NN);
	
	//Ejecución de kernel
	cudaEventRecord(start,0);
	{
	//Copia de memoria a GPU
	if(cudaMemcpy(da_ll,a_ll,N*N*sizeof(int),cudaMemcpyHostToDevice)!=cudaSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(cudaMemcpy(da_lr,a_lr,N*N*sizeof(int),cudaMemcpyHostToDevice)!=cudaSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(cudaMemcpy(da_ul,a_ul,N*N*sizeof(int),cudaMemcpyHostToDevice)!=cudaSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(cudaMemcpy(da_ur,a_ur,N*N*sizeof(int),cudaMemcpyHostToDevice)!=cudaSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(cudaMemcpy(db_ll,b_ll,N*N*sizeof(int),cudaMemcpyHostToDevice)!=cudaSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(cudaMemcpy(db_lr,b_lr,N*N*sizeof(int),cudaMemcpyHostToDevice)!=cudaSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(cudaMemcpy(db_ul,b_ul,N*N*sizeof(int),cudaMemcpyHostToDevice)!=cudaSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(cudaMemcpy(db_ur,b_ur,N*N*sizeof(int),cudaMemcpyHostToDevice)!=cudaSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	}
	
	
	while(ind<iteraciones)
	{	
		matrixMultGPU<<<Bloques, ThreadsBloque>>>(da_ll,da_lr,da_ul,da_ur,db_ll,db_lr,db_ul,db_ur,dc_ll,dc_lr,dc_ul,dc_ur,dt_ll,dt_lr,dt_ul,dt_ur,N);
		ind++;
	}
	
	
	
	cudaMemcpy(c_ll,dc_ll,N*N*sizeof(int),cudaMemcpyDeviceToHost);
	cudaMemcpy(c_lr,dc_lr,N*N*sizeof(int),cudaMemcpyDeviceToHost);
	cudaMemcpy(c_ur,dc_ur,N*N*sizeof(int),cudaMemcpyDeviceToHost);
	cudaMemcpy(c_ul,dc_ul,N*N*sizeof(int),cudaMemcpyDeviceToHost);
	cudaEventRecord(stop,0);
	cudaEventSynchronize(stop);
	cudaEventElapsedTime(&elapsedTime,start,stop);
	printf("El tiempo tomado para %d iteraciones fue de %3.5f ms\n",iteraciones,elapsedTime);
	for(i=0;i<N;i++)
	{
		for(j=0;j<N;j++)
		{
			c[i*NN+j]=c_ul[i*N+j];
			c[i*NN+j+N]=c_ur[i*N+j];
			c[(i+N)*NN+j]=c_ll[i*N+j];
			c[(i+N)*NN+j+N]=c_lr[i*N+j];
		}
	}
	
	printf("Por ejemplo %d deberia ser 0\n",c[3*NN]);
	printf("Por ejemplo %d deberia ser 0\n",c[(int)NN/2]);
	printf("Por ejemplo %d deberia ser %d\n",c[NN+1],(int)((2*pow(NN-1,3)+3*pow(NN-1,2)+NN-1)/6));
	/*
	for(i=0;i<NN;i++)
	{	
		printf("\n");
		for(j=0;j<NN;j++)
		{
			printf("\t%d",a[i*NN+j]);
		}
		//printf("\t");
		for(j=0;j<NN;j++)
		{
			printf("\t%d",b[i*NN+j]);
		}
		//printf("\t");
		for(j=0;j<NN;j++)
		{
			printf("\t%d",c[i*NN+j]);
		}
	}
	*/
	
	free(a);
	free(a_ll);
	free(a_lr);
	free(a_ul);
	free(a_ur);
	free(b_ur);
	free(b_ll);
	free(b_lr);
	free(b_ul);
	free(c_ll);
	free(c_lr);
	free(c_ul);
	free(c_ur);
	free(b);
	free(c);
	cudaFree(da_ll);
	cudaFree(da_lr);
	cudaFree(da_ul);
	cudaFree(da_ur);
	cudaFree(db_ll);
	cudaFree(db_lr);
	cudaFree(db_ul);
	cudaFree(db_ur);
	cudaFree(dc_ll);
	cudaFree(dc_lr);
	cudaFree(dc_ul);
	cudaFree(dc_ur);
	cudaFree(dt_ll);
	cudaFree(dt_lr);
	cudaFree(dt_ul);
	cudaFree(dt_ur);
		
	return 0;
}
	.file	"tmpxft_0023e125_00000000-6_Mat_3t.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	_Z64__device_stub__Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_iPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.type	_Z64__device_stub__Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_iPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, @function
_Z64__device_stub__Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_iPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i:
.LFB2052:
	.cfi_startproc
	endbr64
	subq	$344, %rsp
	.cfi_def_cfa_offset 352
	movq	352(%rsp), %rax
	movq	%rdi, 120(%rsp)
	leaq	144(%rsp), %rdi
	movq	%rsi, 112(%rsp)
	leaq	156(%rsp), %rsi
	movq	%rax, 72(%rsp)
	movq	360(%rsp), %rax
	movq	%rdx, 104(%rsp)
	leaq	128(%rsp), %rdx
	movq	%rax, 64(%rsp)
	movq	368(%rsp), %rax
	movq	%rcx, 96(%rsp)
	leaq	136(%rsp), %rcx
	movq	%rax, 56(%rsp)
	movq	376(%rsp), %rax
	movq	%r8, 88(%rsp)
	movq	%rax, 48(%rsp)
	movq	384(%rsp), %rax
	movq	%r9, 80(%rsp)
	movq	%rax, 40(%rsp)
	movq	392(%rsp), %rax
	movq	%rax, 32(%rsp)
	movq	400(%rsp), %rax
	movq	%rax, 24(%rsp)
	movq	408(%rsp), %rax
	movq	%rax, 16(%rsp)
	movq	416(%rsp), %rax
	movq	%rax, 8(%rsp)
	movq	424(%rsp), %rax
	movq	%rax, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 328(%rsp)
	xorl	%eax, %eax
	leaq	120(%rsp), %rax
	movq	%rax, 192(%rsp)
	leaq	112(%rsp), %rax
	movq	%rax, 200(%rsp)
	leaq	104(%rsp), %rax
	movq	%rax, 208(%rsp)
	leaq	96(%rsp), %rax
	movq	%rax, 216(%rsp)
	leaq	88(%rsp), %rax
	movq	%rax, 224(%rsp)
	leaq	80(%rsp), %rax
	movq	%rax, 232(%rsp)
	leaq	72(%rsp), %rax
	movq	%rax, 240(%rsp)
	leaq	64(%rsp), %rax
	movq	%rax, 248(%rsp)
	leaq	56(%rsp), %rax
	movq	%rax, 256(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 264(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 272(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 280(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 288(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 296(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 304(%rsp)
	movq	%rsp, %rax
	movq	%rax, 312(%rsp)
	leaq	432(%rsp), %rax
	movq	%rax, 320(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 144(%rsp)
	movl	$1, 152(%rsp)
	movq	%rax, 156(%rsp)
	movl	$1, 164(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	136(%rsp)
	.cfi_def_cfa_offset 360
	leaq	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i(%rip), %rdi
	pushq	136(%rsp)
	.cfi_def_cfa_offset 368
	movq	172(%rsp), %rcx
	movl	180(%rsp), %r8d
	movq	160(%rsp), %rsi
	movl	168(%rsp), %edx
	leaq	208(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 360
	popq	%rdx
	.cfi_def_cfa_offset 352
.L2:
	movq	328(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$344, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2052:
	.size	_Z64__device_stub__Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_iPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, .-_Z64__device_stub__Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_iPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.globl	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.type	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, @function
_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z64__device_stub__Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_iPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.cfi_endproc
.LFE2053:
	.size	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, .-_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Ingrese el tamano deseado para las matrices:\n"
.LC1:
	.string	"%d"
.LC2:
	.string	"El tama\303\261o debe ser mayor a dos y par\n"
.LC3:
	.string	"Creando espacio e inicializando matrices...\n"
.LC4:
	.string	"########\nHubo un problema en la asignacion de memoria en la GPU\n########\n"
.LC5:
	.string	"Asignacion de memoria correcta\n"
.LC7:
	.string	"Se va a realizar la suma con %d bloques y %d hilos\n"
.LC8:
	.string	"Se va a realizar %d iteraciones de matrices %dx%d\n"
.LC9:
	.string	"#########\nHubo un problema en la copia de memoria a la GPU\n#########\n"
.LC10:
	.string	"El tiempo tomado para %d iteraciones fue de %3.5f ms\n"
.LC11:
	.string	"Por ejemplo %d deberia ser 0\n"
.LC15:
	.string	"Por ejemplo %d deberia ser %d\n"
	.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
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	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	$360, %rsp
	.cfi_def_cfa_offset 416
	movq	%fs:40, %rax
	movq	%rax, 344(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	168(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc23_scanf@PLT
	movl	168(%rsp), %eax
	cmpl	$1, %eax
	jle	.L31
	testb	$1, %al
	je	.L9
.L31:
	leaq	.LC2(%rip), %rsi
	jmp	.L40
.L9:
	sarl	%eax
	leaq	304(%rsp), %rdi
	movl	%eax, %r13d
	call	cudaEventCreate@PLT
	leaq	312(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	168(%rsp), %ebx
	movl	%ebx, %ebp
	imull	%ebx, %ebp
	movslq	%ebp, %rbp
	salq	$2, %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, 32(%rsp)
	call	malloc@PLT
	movq	%rax, %r15
	movl	%r13d, %eax
	imull	%r13d, %eax
	cltq
	leaq	0(,%rax,4), %r14
	movq	%r14, %rdi
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 80(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 88(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 96(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 104(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 112(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 120(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 128(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 136(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 40(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 48(%rsp)
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, 56(%rsp)
	call	malloc@PLT
	movslq	%ebx, %r9
	xorl	%esi, %esi
	movq	%rax, 64(%rsp)
	salq	$2, %r9
	xorl	%eax, %eax
.L11:
	cmpl	%eax, %ebx
	jle	.L41
	movq	%rsi, %rdx
	xorl	%ecx, %ecx
	xorl	%edi, %edi
.L12:
	movq	24(%rsp), %r10
	incl	%edi
	movl	%ecx, (%r10,%rdx)
	movq	32(%rsp), %r10
	movl	%ecx, (%r10,%rdx)
	addl	%eax, %ecx
	addq	$4, %rdx
	cmpl	%edi, %ebx
	jne	.L12
	incl	%eax
	addq	%r9, %rsi
	jmp	.L11
.L41:
	imull	%r13d, %ebx
	movslq	%r13d, %rax
	movl	%r13d, %edx
	xorl	%r8d, %r8d
	movq	%rax, 144(%rsp)
	salq	$2, %rax
	leal	-1(%r13), %r12d
	xorl	%r10d, %r10d
	movq	%rax, 16(%rsp)
	movslq	%ebx, %rax
	leaq	0(,%rdx,4), %rbx
	movq	24(%rsp), %rdx
	movq	%rbx, 8(%rsp)
	movq	16(%rsp), %rbx
	salq	$2, %rax
	leaq	(%rbx,%rdx), %rbp
	movq	32(%rsp), %rdx
	addq	%rdx, %rbx
	xorl	%edx, %edx
.L14:
	movq	96(%rsp), %rcx
	incl	%r10d
	leaq	(%rcx,%rdx), %r11
	movq	24(%rsp), %rcx
	movq	%r11, %rdi
	leaq	(%rcx,%r8), %rsi
	movq	8(%rsp), %rcx
	rep movsb
	movq	104(%rsp), %rcx
	leaq	(%r8,%rbp), %rsi
	leaq	(%rcx,%rdx), %r11
	movq	8(%rsp), %rcx
	movq	%r11, %rdi
	rep movsb
	movq	80(%rsp), %rcx
	leaq	(%rcx,%rdx), %r11
	movq	24(%rsp), %rcx
	movq	%r11, %rdi
	leaq	(%rcx,%rax), %rsi
	movq	8(%rsp), %rcx
	rep movsb
	movq	88(%rsp), %rcx
	leaq	(%rax,%rbp), %rsi
	leaq	(%rcx,%rdx), %r11
	movq	8(%rsp), %rcx
	movq	%r11, %rdi
	rep movsb
	movq	128(%rsp), %rcx
	leaq	(%rcx,%rdx), %r11
	movq	32(%rsp), %rcx
	movq	%r11, %rdi
	leaq	(%rcx,%r8), %rsi
	movq	8(%rsp), %rcx
	rep movsb
	movq	136(%rsp), %rcx
	leaq	(%r8,%rbx), %rsi
	addq	%r9, %r8
	leaq	(%rcx,%rdx), %r11
	movq	8(%rsp), %rcx
	movq	%r11, %rdi
	rep movsb
	movq	112(%rsp), %rcx
	leaq	(%rcx,%rdx), %r11
	movq	32(%rsp), %rcx
	movq	%r11, %rdi
	leaq	(%rcx,%rax), %rsi
	movq	8(%rsp), %rcx
	rep movsb
	movq	120(%rsp), %rcx
	leaq	(%rax,%rbx), %rsi
	addq	%r9, %rax
	leaq	(%rcx,%rdx), %r11
	movq	8(%rsp), %rcx
	movq	%r11, %rdi
	rep movsb
	movq	16(%rsp), %rcx
	addq	%rcx, %rdx
	cmpl	%r10d, %r13d
	jne	.L14
	leaq	192(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L15
.L16:
	leaq	.LC4(%rip), %rsi
.L40:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L15:
	leaq	176(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	184(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	200(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	224(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	232(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	208(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	216(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	248(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	240(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	256(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	264(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	280(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	272(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	288(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	296(%rsp), %rdi
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movl	$1, %ebx
	call	__printf_chk@PLT
	cvtsi2ssl	%r13d, %xmm2
.L17:
	cvtsi2ssl	%ebx, %xmm1
	movaps	%xmm2, %xmm0
	divss	%xmm1, %xmm0
	comiss	.LC6(%rip), %xmm0
	jbe	.L42
	incl	%ebx
	jmp	.L17
.L42:
	call	ceilf@PLT
	movl	%ebx, %edx
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	cvttss2sil	%xmm0, %ecx
	movl	$2, %edi
	movl	$1, 328(%rsp)
	movl	%ebx, 332(%rsp)
	movl	%ebx, 336(%rsp)
	movl	$1, 340(%rsp)
	movl	%ecx, 320(%rsp)
	movl	%ecx, 324(%rsp)
	call	__printf_chk@PLT
	movl	168(%rsp), %ecx
	movl	$10, %edx
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	movl	%ecx, %r8d
	call	__printf_chk@PLT
	movq	304(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rsi
	movl	$1, %ecx
	movq	%r14, %rdx
	movq	192(%rsp), %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L19
.L20:
	leaq	.LC9(%rip), %rsi
	jmp	.L40
.L19:
	movq	88(%rsp), %rsi
	movq	200(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	jne	.L20
	movq	96(%rsp), %rsi
	movq	176(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	jne	.L20
	movq	104(%rsp), %rsi
	movq	184(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	jne	.L20
	movq	112(%rsp), %rsi
	movq	224(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	jne	.L20
	movq	120(%rsp), %rsi
	movq	232(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	jne	.L20
	movq	128(%rsp), %rsi
	movq	208(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	jne	.L20
	movq	136(%rsp), %rsi
	movq	216(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	jne	.L20
	movl	$10, %ebx
.L22:
	movl	328(%rsp), %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	320(%rsp), %rdx
	movq	332(%rsp), %rdi
	movl	340(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	pushq	%rax
	.cfi_def_cfa_offset 424
	pushq	%r13
	.cfi_def_cfa_offset 432
	pushq	296(%rsp)
	.cfi_def_cfa_offset 440
	pushq	296(%rsp)
	.cfi_def_cfa_offset 448
	pushq	328(%rsp)
	.cfi_def_cfa_offset 456
	pushq	328(%rsp)
	.cfi_def_cfa_offset 464
	pushq	296(%rsp)
	.cfi_def_cfa_offset 472
	pushq	296(%rsp)
	.cfi_def_cfa_offset 480
	pushq	328(%rsp)
	.cfi_def_cfa_offset 488
	pushq	328(%rsp)
	.cfi_def_cfa_offset 496
	pushq	296(%rsp)
	.cfi_def_cfa_offset 504
	pushq	296(%rsp)
	.cfi_def_cfa_offset 512
	movq	328(%rsp), %r9
	movq	320(%rsp), %r8
	movq	280(%rsp), %rcx
	movq	272(%rsp), %rdx
	movq	296(%rsp), %rsi
	movq	288(%rsp), %rdi
	call	_Z64__device_stub__Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_iPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	addq	$96, %rsp
	.cfi_def_cfa_offset 416
.L21:
	decl	%ebx
	jne	.L22
	movq	256(%rsp), %rsi
	movq	40(%rsp), %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	264(%rsp), %rsi
	movq	48(%rsp), %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	248(%rsp), %rsi
	movq	64(%rsp), %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	240(%rsp), %rsi
	movq	56(%rsp), %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	xorl	%r14d, %r14d
	call	cudaMemcpy@PLT
	movq	312(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	312(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	312(%rsp), %rdx
	movq	304(%rsp), %rsi
	leaq	172(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movl	$10, %edx
	leaq	.LC10(%rip), %rsi
	movb	$1, %al
	cvtss2sd	172(%rsp), %xmm0
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	16(%rsp), %rbp
	xorl	%r11d, %r11d
	xorl	%r10d, %r10d
	movslq	168(%rsp), %rdx
	movl	%r14d, 156(%rsp)
	movq	%rdx, %rax
	movl	%edx, 76(%rsp)
	salq	$2, %rdx
	movl	%eax, %ecx
	movq	144(%rsp), %rax
	imull	%r13d, %ecx
	movslq	%ecx, %rcx
	leaq	1(%rcx,%r12), %r8
	addq	%rcx, %rax
	movq	8(%rsp), %r12
	leaq	0(,%rcx,4), %rbx
	salq	$2, %rax
	salq	$2, %r8
.L23:
	movq	16(%rsp), %rcx
	leaq	(%r12,%rcx), %r14
	leaq	(%r8,%rcx), %rdi
	cmpq	%r10, %r14
	setle	%cl
	cmpq	%r12, %rbp
	setge	%sil
	orl	%esi, %ecx
	cmpq	%rdi, %rbp
	setge	%sil
	cmpq	%r14, %rax
	setge	%r9b
	orl	%r9d, %esi
	andl	%ecx, %esi
	cmpq	%r8, %r10
	setge	%cl
	cmpq	%rbx, %r12
	setle	%r9b
	orl	%r9d, %ecx
	andl	%ecx, %esi
	cmpq	%r8, %rbp
	setge	%cl
	cmpq	%rbx, %r14
	movl	%ecx, %r9d
	setle	%cl
	orl	%r9d, %ecx
	andl	%esi, %ecx
	cmpq	%r10, %rdi
	setle	%sil
	cmpq	%r12, %rax
	setge	%r14b
	orl	%r14d, %esi
	testb	%sil, %cl
	jne	.L43
.L29:
	xorl	%r9d, %r9d
	leaq	(%r10,%r15), %rdi
	leaq	(%rbx,%r15), %rsi
	movq	%r11, %rcx
	movl	%r9d, 152(%rsp)
.L24:
	movq	56(%rsp), %r9
	incl	152(%rsp)
	movl	(%r9,%rcx), %r9d
	movl	%r9d, (%rdi)
	movq	64(%rsp), %r9
	movl	(%r9,%rcx), %r14d
	movq	144(%rsp), %r9
	movl	%r14d, (%rdi,%r9,4)
	movq	40(%rsp), %r9
	addq	$4, %rdi
	movl	(%r9,%rcx), %r9d
	movl	%r9d, (%rsi)
	movq	48(%rsp), %r9
	movl	(%r9,%rcx), %r14d
	movq	144(%rsp), %r9
	addq	$4, %rcx
	movl	%r14d, (%rsi,%r9,4)
	movl	152(%rsp), %r9d
	addq	$4, %rsi
	cmpl	%r9d, %r13d
	jne	.L24
	jmp	.L25
.L43:
	cmpq	%rbx, %rdi
	setle	%cl
	cmpq	%r8, %rax
	setge	%sil
	orb	%sil, %cl
	je	.L29
	movq	56(%rsp), %rcx
	leaq	(%r10,%r15), %r14
	movq	%r14, %rdi
	leaq	0(%rbp,%r15), %r14
	leaq	(%rcx,%r11), %rsi
	movq	8(%rsp), %rcx
	rep movsb
	movq	64(%rsp), %rcx
	movq	%r14, %rdi
	leaq	(%rbx,%r15), %r14
	leaq	(%rcx,%r11), %rsi
	movq	8(%rsp), %rcx
	rep movsb
	movq	40(%rsp), %rcx
	movq	%r14, %rdi
	leaq	(%rax,%r15), %r14
	leaq	(%rcx,%r11), %rsi
	movq	8(%rsp), %rcx
	rep movsb
	movq	48(%rsp), %rcx
	movq	%r14, %rdi
	leaq	(%rcx,%r11), %rsi
	movq	8(%rsp), %rcx
	rep movsb
.L25:
	incl	156(%rsp)
	addq	%rdx, %rax
	addq	%rdx, %rbp
	addq	%rdx, %r12
	movq	16(%rsp), %rcx
	addq	%rdx, %r10
	addq	%rdx, %rbx
	addq	%rdx, %r8
	movl	156(%rsp), %esi
	addq	%rcx, %r11
	cmpl	%esi, %r13d
	jne	.L23
	imull	$3, 76(%rsp), %r9d
	leaq	.LC11(%rip), %rbx
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movslq	%r9d, %r9
	movl	(%r15,%r9,4), %edx
	call	__printf_chk@PLT
	movl	168(%rsp), %eax
	movl	$2, %ecx
	movq	%rbx, %rsi
	movl	$2, %edi
	cltd
	idivl	%ecx
	cltq
	movl	(%r15,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	168(%rsp), %rbx
	movsd	.LC12(%rip), %xmm1
	leal	-1(%rbx), %eax
	cvtsi2sdl	%eax, %xmm2
	movaps	%xmm2, %xmm0
	movsd	%xmm2, 8(%rsp)
	call	pow@PLT
	movsd	8(%rsp), %xmm2
	movl	4(%r15,%rbx,4), %edx
	xorl	%eax, %eax
	addsd	%xmm0, %xmm0
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	mulsd	%xmm2, %xmm2
	mulsd	.LC12(%rip), %xmm2
	addsd	%xmm0, %xmm2
	cvtsi2sdl	%ebx, %xmm0
	addsd	%xmm0, %xmm2
	subsd	.LC13(%rip), %xmm2
	divsd	.LC14(%rip), %xmm2
	cvttsd2sil	%xmm2, %ecx
	call	__printf_chk@PLT
	movq	24(%rsp), %rdi
	call	free@PLT
	movq	80(%rsp), %rdi
	call	free@PLT
	movq	88(%rsp), %rdi
	call	free@PLT
	movq	96(%rsp), %rdi
	call	free@PLT
	movq	104(%rsp), %rdi
	call	free@PLT
	movq	136(%rsp), %rdi
	call	free@PLT
	movq	112(%rsp), %rdi
	call	free@PLT
	movq	120(%rsp), %rdi
	call	free@PLT
	movq	128(%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
	movq	64(%rsp), %rdi
	call	free@PLT
	movq	32(%rsp), %rdi
	call	free@PLT
	movq	%r15, %rdi
	call	free@PLT
	movq	192(%rsp), %rdi
	call	cudaFree@PLT
	movq	200(%rsp), %rdi
	call	cudaFree@PLT
	movq	176(%rsp), %rdi
	call	cudaFree@PLT
	movq	184(%rsp), %rdi
	call	cudaFree@PLT
	movq	224(%rsp), %rdi
	call	cudaFree@PLT
	movq	232(%rsp), %rdi
	call	cudaFree@PLT
	movq	208(%rsp), %rdi
	call	cudaFree@PLT
	movq	216(%rsp), %rdi
	call	cudaFree@PLT
	movq	256(%rsp), %rdi
	call	cudaFree@PLT
	movq	264(%rsp), %rdi
	call	cudaFree@PLT
	movq	240(%rsp), %rdi
	call	cudaFree@PLT
	movq	248(%rsp), %rdi
	call	cudaFree@PLT
	movq	288(%rsp), %rdi
	call	cudaFree@PLT
	movq	296(%rsp), %rdi
	call	cudaFree@PLT
	movq	272(%rsp), %rdi
	call	cudaFree@PLT
	movq	280(%rsp), %rdi
	call	cudaFree@PLT
	movq	344(%rsp), %rax
	subq	%fs:40, %rax
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	addq	$360, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC16:
	.string	"_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i"
	.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	.LC16(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2055:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC6:
	.long	1107296256
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC12:
	.long	0
	.long	1074266112
	.align 8
.LC13:
	.long	0
	.long	1072693248
	.align 8
.LC14:
	.long	0
	.long	1075314688
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


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

__global__ void matrixMultGPU(int *a_ll,int *a_lr,int *a_ul, int *a_ur,int *b_ll,int *b_lr,int *b_ul, int *b_ur, int *c_ll,int *c_lr,int *c_ul, int *c_ur, int *t_ll,int *t_lr,int *t_ul, int *t_ur,int N){

	int k, sum_cur = 0,sum_cul = 0,sum_cll = 0,sum_clr = 0,sum_tur = 0,sum_tul = 0,sum_tll = 0,sum_tlr = 0;
	int col = threadIdx.x + blockDim.x * blockIdx.x;
	int fil = threadIdx.y + blockDim.y * blockIdx.y;
	if (col < N && fil < N) 
	{
		for (k = 0; k < N; k++) 
		{
			sum_cul += a_ul[fil * N + k] * b_ul[k * N + col];
			sum_cur += a_ul[fil * N + k] * b_ur[k * N + col];
			sum_cll += a_ll[fil * N + k] * b_ul[k * N + col];
			sum_clr += a_ll[fil * N + k] * b_ur[k * N + col];
			
			sum_tul += a_ur[fil * N + k] * b_ll[k * N + col];
			sum_tur += a_ur[fil * N + k] * b_lr[k * N + col];
			sum_tll += a_lr[fil * N + k] * b_ll[k * N + col];
			sum_tlr += a_lr[fil * N + k] * b_lr[k * N + col];
		}
		c_ul[fil * N + col] = sum_cul;
		c_ur[fil * N + col] = sum_cur;
		c_ll[fil * N + col] = sum_cll;
		c_lr[fil * N + col] = sum_clr;
		
		t_ul[fil * N + col] = sum_tul;
		t_ll[fil * N + col] = sum_tll;
		t_lr[fil * N + col] = sum_tlr;
		t_ur[fil * N + col] = sum_tur;
		__syncthreads();
		
		c_ul[fil * N + col]+=t_ul[fil * N + col];
		c_ll[fil * N + col]+=t_ll[fil * N + col];
		c_lr[fil * N + col]+=t_lr[fil * N + col];
		c_ur[fil * N + col]+=t_ur[fil * N + col];
	}
}

int main (void){
	//Creación de variables del sistema
	int *a, *b, *c, N,NN;
	int *a_ul,*a_ur,*a_ll,*a_lr,*b_ul,*b_ur,*b_ll,*b_lr,*c_ul,*c_ur,*c_ll,*c_lr;
	int *da_ul,*da_ur,*da_ll,*da_lr,*db_ul,*db_ur,*db_ll,*db_lr,*dc_ul,*dc_ur,*dc_ll,*dc_lr,*dt_ul,*dt_ur,*dt_ll,*dt_lr;
	int i,j;
	int T,div=1, iteraciones=10,ind=0;
	float elapsedTime;
	printf("Ingrese el tamano deseado para las matrices:\n");
	scanf("%d",&NN);
	if(NN%2!=0 || NN<2)
	{
		printf("El tamaño debe ser mayor a dos y par\n");
		exit(1);
	}
	N=(int)NN/2;
	//Creación de variables de tiempo
	hipEvent_t start,stop;
	hipEventCreate(&start);
	hipEventCreate(&stop);
	
	printf("Creando espacio e inicializando matrices...\n");
	
	//Asignación e inicialización de memoria
	a=(int*)malloc(NN*NN*sizeof(int));
	b=(int*)malloc(NN*NN*sizeof(int));
	c=(int*)malloc(NN*NN*sizeof(int));
	
	a_ll=(int*)malloc(N*N*sizeof(int));
	a_lr=(int*)malloc(N*N*sizeof(int));
	a_ul=(int*)malloc(N*N*sizeof(int));
	a_ur=(int*)malloc(N*N*sizeof(int));
	
	b_ll=(int*)malloc(N*N*sizeof(int));
	b_lr=(int*)malloc(N*N*sizeof(int));
	b_ul=(int*)malloc(N*N*sizeof(int));
	b_ur=(int*)malloc(N*N*sizeof(int));
	
	c_ll=(int*)malloc(N*N*sizeof(int));
	c_lr=(int*)malloc(N*N*sizeof(int));
	c_ul=(int*)malloc(N*N*sizeof(int));
	c_ur=(int*)malloc(N*N*sizeof(int));
	
	//Inicialización de Matrices
	for(i=0;i<NN;i++)
	{
		for(j=0;j<NN;j++)
		{
			a[i*NN+j]=i*j;
			b[i*NN+j]=i*j;
		}
	}
	
	//Creación de submatrices
	for(i=0;i<N;i++)
	{
		for(j=0;j<N;j++)
		{
			a_ul[i*N+j]=a[i*NN+j];
			a_ur[i*N+j]=a[i*NN+j+N];
			a_ll[i*N+j]=a[(i+N)*NN+j];
			a_lr[i*N+j]=a[(i+N)*NN+j+N];
			
			b_ul[i*N+j]=b[i*NN+j];
			b_ur[i*N+j]=b[i*NN+j+N];
			b_ll[i*N+j]=b[(i+N)*NN+j];
			b_lr[i*N+j]=b[(i+N)*NN+j+N];
		}
	}
	
	{
	if(hipMalloc(&da_ll,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&da_ul,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&da_ur,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&da_lr,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&db_ll,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&db_lr,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&db_ul,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&db_ur,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&dc_ur,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&dc_ul,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&dc_ll,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&dc_lr,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&dt_ur,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&dt_ul,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&dt_ll,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	if(hipMalloc(&dt_lr,N*N*sizeof(int))!=hipSuccess)
	{
		printf("########\nHubo un problema en la asignacion de memoria en la GPU\n########\n");
		exit(1);
	}
	}
	printf("Asignacion de memoria correcta\n");
	//Cálculo de bloques e hilos
	while((float)N/(float)div>32)
	{
		div++;
	}
	float f_N=(float)N,f_div=(float)div;
	T=(int)ceil(f_N/f_div);
	dim3 ThreadsBloque(T,T);
	dim3 Bloques(div, div);
	printf("Se va a realizar la suma con %d bloques y %d hilos\n",div,T);
	printf("Se va a realizar %d iteraciones de matrices %dx%d\n",iteraciones,NN,NN);
	
	//Ejecución de kernel
	hipEventRecord(start,0);
	{
	//Copia de memoria a GPU
	if(hipMemcpy(da_ll,a_ll,N*N*sizeof(int),hipMemcpyHostToDevice)!=hipSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(hipMemcpy(da_lr,a_lr,N*N*sizeof(int),hipMemcpyHostToDevice)!=hipSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(hipMemcpy(da_ul,a_ul,N*N*sizeof(int),hipMemcpyHostToDevice)!=hipSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(hipMemcpy(da_ur,a_ur,N*N*sizeof(int),hipMemcpyHostToDevice)!=hipSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(hipMemcpy(db_ll,b_ll,N*N*sizeof(int),hipMemcpyHostToDevice)!=hipSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(hipMemcpy(db_lr,b_lr,N*N*sizeof(int),hipMemcpyHostToDevice)!=hipSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(hipMemcpy(db_ul,b_ul,N*N*sizeof(int),hipMemcpyHostToDevice)!=hipSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	if(hipMemcpy(db_ur,b_ur,N*N*sizeof(int),hipMemcpyHostToDevice)!=hipSuccess)
	{
		printf("#########\nHubo un problema en la copia de memoria a la GPU\n#########\n");
		exit(1);
	}
	}
	
	
	while(ind<iteraciones)
	{	
		matrixMultGPU<<<Bloques, ThreadsBloque>>>(da_ll,da_lr,da_ul,da_ur,db_ll,db_lr,db_ul,db_ur,dc_ll,dc_lr,dc_ul,dc_ur,dt_ll,dt_lr,dt_ul,dt_ur,N);
		ind++;
	}
	
	
	
	hipMemcpy(c_ll,dc_ll,N*N*sizeof(int),hipMemcpyDeviceToHost);
	hipMemcpy(c_lr,dc_lr,N*N*sizeof(int),hipMemcpyDeviceToHost);
	hipMemcpy(c_ur,dc_ur,N*N*sizeof(int),hipMemcpyDeviceToHost);
	hipMemcpy(c_ul,dc_ul,N*N*sizeof(int),hipMemcpyDeviceToHost);
	hipEventRecord(stop,0);
	hipEventSynchronize(stop);
	hipEventElapsedTime(&elapsedTime,start,stop);
	printf("El tiempo tomado para %d iteraciones fue de %3.5f ms\n",iteraciones,elapsedTime);
	for(i=0;i<N;i++)
	{
		for(j=0;j<N;j++)
		{
			c[i*NN+j]=c_ul[i*N+j];
			c[i*NN+j+N]=c_ur[i*N+j];
			c[(i+N)*NN+j]=c_ll[i*N+j];
			c[(i+N)*NN+j+N]=c_lr[i*N+j];
		}
	}
	
	printf("Por ejemplo %d deberia ser 0\n",c[3*NN]);
	printf("Por ejemplo %d deberia ser 0\n",c[(int)NN/2]);
	printf("Por ejemplo %d deberia ser %d\n",c[NN+1],(int)((2*pow(NN-1,3)+3*pow(NN-1,2)+NN-1)/6));
	/*
	for(i=0;i<NN;i++)
	{	
		printf("\n");
		for(j=0;j<NN;j++)
		{
			printf("\t%d",a[i*NN+j]);
		}
		//printf("\t");
		for(j=0;j<NN;j++)
		{
			printf("\t%d",b[i*NN+j]);
		}
		//printf("\t");
		for(j=0;j<NN;j++)
		{
			printf("\t%d",c[i*NN+j]);
		}
	}
	*/
	
	free(a);
	free(a_ll);
	free(a_lr);
	free(a_ul);
	free(a_ur);
	free(b_ur);
	free(b_ll);
	free(b_lr);
	free(b_ul);
	free(c_ll);
	free(c_lr);
	free(c_ul);
	free(c_ur);
	free(b);
	free(c);
	hipFree(da_ll);
	hipFree(da_lr);
	hipFree(da_ul);
	hipFree(da_ur);
	hipFree(db_ll);
	hipFree(db_lr);
	hipFree(db_ul);
	hipFree(db_ur);
	hipFree(dc_ll);
	hipFree(dc_lr);
	hipFree(dc_ul);
	hipFree(dc_ur);
	hipFree(dt_ll);
	hipFree(dt_lr);
	hipFree(dt_ul);
	hipFree(dt_ur);
		
	return 0;
}
	.text
	.file	"Mat_3t.hip"
	.globl	_Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i # -- Begin function _Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.type	_Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i,@function
_Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i: # @_Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.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	$240, %rsp
	.cfi_def_cfa_offset 288
	.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	288(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	296(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	304(%rsp), %rax
	movq	%rax, 64(%rbx)
	leaq	312(%rsp), %rax
	movq	%rax, 72(%rbx)
	leaq	320(%rsp), %rax
	movq	%rax, 80(%rbx)
	leaq	328(%rsp), %rax
	movq	%rax, 88(%rbx)
	leaq	336(%rsp), %rax
	movq	%rax, 96(%rbx)
	leaq	344(%rsp), %rax
	movq	%rax, 104(%rbx)
	leaq	352(%rsp), %rax
	movq	%rax, 112(%rbx)
	leaq	360(%rsp), %rax
	movq	%rax, 120(%rbx)
	leaq	368(%rsp), %rax
	movq	%rax, 128(%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	$_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$256, %rsp                      # imm = 0x100
	.cfi_adjust_cfa_offset -256
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, .Lfunc_end0-_Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI1_0:
	.long	0x42000000                      # float 32
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI1_1:
	.quad	0x4008000000000000              # double 3
.LCPI1_2:
	.quad	0xbff0000000000000              # double -1
.LCPI1_3:
	.quad	0x4018000000000000              # double 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	$440, %rsp                      # imm = 0x1B8
	.cfi_def_cfa_offset 496
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	12(%rsp), %rbx
	movl	$.L.str.1, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movl	(%rbx), %ecx
	cmpl	$2, %ecx
	jl	.LBB1_2
# %bb.1:
	movl	%ecx, %eax
	andl	$1, %eax
	jne	.LBB1_2
# %bb.4:
	movl	%ecx, %r12d
	shrl	%r12d
	leaq	272(%rsp), %rdi
	movq	%rcx, 64(%rsp)                  # 8-byte Spill
	callq	hipEventCreate
	leaq	144(%rsp), %rdi
	callq	hipEventCreate
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movslq	12(%rsp), %r13
	movl	%r13d, %ebx
	imull	%ebx, %ebx
	shlq	$2, %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, 248(%rsp)                 # 8-byte Spill
	movq	%r12, 48(%rsp)                  # 8-byte Spill
                                        # kill: def $r12d killed $r12d killed $r12 def $r12
	imull	%r12d, %r12d
	shlq	$2, %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 128(%rsp)                 # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %rbp
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 120(%rsp)                 # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	%r12, 56(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	malloc
	movq	%r13, %r11
	movq	%rbx, %r13
	movq	%rbp, %rbx
	movq	64(%rsp), %r10                  # 8-byte Reload
	movq	%r14, %r9
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%r11d, %r12d
	testq	%r11, %r11
	movq	%r14, 256(%rsp)                 # 8-byte Spill
	movq	%r15, 264(%rsp)                 # 8-byte Spill
	movq	%rbp, 112(%rsp)                 # 8-byte Spill
	movq	%r13, 104(%rsp)                 # 8-byte Spill
	jle	.LBB1_10
# %bb.5:                                # %.preheader323.lr.ph
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB1_6:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_7 Depth 2
	movl	%eax, %esi
	leaq	(%r15,%rsi,4), %rdx
	leaq	(%r9,%rsi,4), %rsi
	xorl	%edi, %edi
	xorl	%r8d, %r8d
.LBB1_7:                                #   Parent Loop BB1_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%edi, (%rsi,%r8,4)
	movl	%edi, (%rdx,%r8,4)
	incq	%r8
	addl	%ecx, %edi
	cmpq	%r8, %r12
	jne	.LBB1_7
# %bb.8:                                # %._crit_edge
                                        #   in Loop: Header=BB1_6 Depth=1
	incq	%rcx
	addl	%r12d, %eax
	cmpq	%r12, %rcx
	jne	.LBB1_6
# %bb.9:                                # %.preheader322
	movb	$1, %bpl
	cmpl	$2, %r10d
	jb	.LBB1_13
.LBB1_10:                               # %.preheader321.preheader
	addq	%r10, %r10
	andq	$-4, %r10
	movq	%r11, %rax
	shlq	$2, %rax
	movq	%rax, 312(%rsp)                 # 8-byte Spill
	movq	48(%rsp), %rcx                  # 8-byte Reload
	leal	-1(%rcx), %eax
	leaq	4(,%rax,4), %r14
	movl	%r11d, %ebx
	imull	%ecx, %ebx
	incl	%r12d
	imull	%ecx, %r12d
	xorl	%ebp, %ebp
	movq	%r15, %r13
	movq	%r9, %r15
	movq	%r10, 64(%rsp)                  # 8-byte Spill
	movq	%r11, 320(%rsp)                 # 8-byte Spill
.LBB1_11:                               # %.preheader321
                                        # =>This Inner Loop Header: Depth=1
	movq	%rcx, 136(%rsp)                 # 8-byte Spill
	movq	88(%rsp), %rax                  # 8-byte Reload
	addq	%rbp, %rax
	movq	%rax, 424(%rsp)                 # 8-byte Spill
	movslq	%r12d, %r12
	movq	264(%rsp), %rax                 # 8-byte Reload
	leaq	(%rax,%r12,4), %rcx
	movq	%rcx, 416(%rsp)                 # 8-byte Spill
	movq	120(%rsp), %rcx                 # 8-byte Reload
	leaq	(%rcx,%rbp), %rcx
	movq	%rcx, 408(%rsp)                 # 8-byte Spill
	movslq	%ebx, %rbx
	leaq	(%rax,%rbx,4), %rax
	movq	%rax, 400(%rsp)                 # 8-byte Spill
	movq	72(%rsp), %rax                  # 8-byte Reload
	leaq	(%rax,%rbp), %rax
	movq	%rax, 392(%rsp)                 # 8-byte Spill
	leaq	(%r13,%r10), %rax
	movq	%rax, 384(%rsp)                 # 8-byte Spill
	movq	80(%rsp), %rax                  # 8-byte Reload
	leaq	(%rax,%rbp), %rax
	movq	%rax, 376(%rsp)                 # 8-byte Spill
	movq	112(%rsp), %rax                 # 8-byte Reload
	leaq	(%rax,%rbp), %rax
	movq	%rax, 368(%rsp)                 # 8-byte Spill
	leaq	(%r9,%r12,4), %rax
	movq	%rax, 360(%rsp)                 # 8-byte Spill
	movq	128(%rsp), %rax                 # 8-byte Reload
	leaq	(%rax,%rbp), %rax
	movq	%rax, 352(%rsp)                 # 8-byte Spill
	leaq	(%r9,%rbx,4), %rax
	movq	%rax, 344(%rsp)                 # 8-byte Spill
	movq	96(%rsp), %rax                  # 8-byte Reload
	addq	%rbp, %rax
	movq	%rax, 336(%rsp)                 # 8-byte Spill
	leaq	(%r15,%r10), %rax
	movq	%rax, 328(%rsp)                 # 8-byte Spill
	movq	104(%rsp), %rax                 # 8-byte Reload
	leaq	(%rax,%rbp), %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
	movq	336(%rsp), %rdi                 # 8-byte Reload
	movq	328(%rsp), %rsi                 # 8-byte Reload
	movq	%r14, %rdx
	callq	memcpy@PLT
	movq	352(%rsp), %rdi                 # 8-byte Reload
	movq	344(%rsp), %rsi                 # 8-byte Reload
	movq	%r14, %rdx
	callq	memcpy@PLT
	movq	368(%rsp), %rdi                 # 8-byte Reload
	movq	360(%rsp), %rsi                 # 8-byte Reload
	movq	%r14, %rdx
	callq	memcpy@PLT
	movq	376(%rsp), %rdi                 # 8-byte Reload
	movq	%r13, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
	movq	392(%rsp), %rdi                 # 8-byte Reload
	movq	384(%rsp), %rsi                 # 8-byte Reload
	movq	%r14, %rdx
	callq	memcpy@PLT
	movq	408(%rsp), %rdi                 # 8-byte Reload
	movq	400(%rsp), %rsi                 # 8-byte Reload
	movq	%r14, %rdx
	callq	memcpy@PLT
	movq	424(%rsp), %rdi                 # 8-byte Reload
	movq	416(%rsp), %rsi                 # 8-byte Reload
	movq	%r14, %rdx
	callq	memcpy@PLT
	movq	320(%rsp), %r11                 # 8-byte Reload
	movq	64(%rsp), %r10                  # 8-byte Reload
	movq	256(%rsp), %r9                  # 8-byte Reload
	addl	%r11d, %ebx
	addl	%r11d, %r12d
	addq	%r10, %rbp
	movq	312(%rsp), %rax                 # 8-byte Reload
	addq	%rax, %r15
	addq	%rax, %r13
	movq	136(%rsp), %rcx                 # 8-byte Reload
	decq	%rcx
	jne	.LBB1_11
# %bb.12:
	xorl	%ebp, %ebp
.LBB1_13:                               # %._crit_edge328
	leaq	224(%rsp), %rdi
	movq	56(%rsp), %r14                  # 8-byte Reload
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.15:
	leaq	240(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	movq	128(%rsp), %r12                 # 8-byte Reload
	jne	.LBB1_14
# %bb.16:
	leaq	232(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.17:
	leaq	216(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.18:
	leaq	192(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.19:
	leaq	184(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.20:
	leaq	208(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.21:
	leaq	200(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.22:
	leaq	168(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.23:
	leaq	176(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.24:
	leaq	160(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.25:
	leaq	152(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.26:
	leaq	296(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.27:
	leaq	304(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.28:
	leaq	288(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.29:
	leaq	280(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.30:
	movl	%ebp, 136(%rsp)                 # 4-byte Spill
	movabsq	$4294967297, %rbx               # imm = 0x100000001
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	cvtsi2ssl	48(%rsp), %xmm1         # 4-byte Folded Reload
	xorl	%r13d, %r13d
	movss	.LCPI1_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
.LBB1_31:                               # =>This Inner Loop Header: Depth=1
	leal	1(%r13), %eax
	xorps	%xmm3, %xmm3
	cvtsi2ss	%eax, %xmm3
	movaps	%xmm1, %xmm0
	divss	%xmm3, %xmm0
	addq	%rbx, %r13
	ucomiss	%xmm2, %xmm0
	ja	.LBB1_31
# %bb.32:
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r14d
	movl	$.L.str.6, %edi
	movl	%r13d, %esi
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	printf
	movl	12(%rsp), %ecx
	movl	$.L.str.7, %edi
	movl	$10, %esi
	movl	%ecx, %edx
	xorl	%eax, %eax
	callq	printf
	movq	272(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	224(%rsp), %rdi
	movq	%r12, %rsi
	movq	56(%rsp), %rbp                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_33
# %bb.34:
	movq	216(%rsp), %rdi
	movq	112(%rsp), %rsi                 # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	movq	120(%rsp), %r12                 # 8-byte Reload
	jne	.LBB1_33
# %bb.35:
	movq	240(%rsp), %rdi
	movq	104(%rsp), %rsi                 # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_33
# %bb.36:
	movq	232(%rsp), %rdi
	movq	96(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_33
# %bb.37:
	movq	192(%rsp), %rdi
	movq	%r12, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_33
# %bb.38:
	movq	184(%rsp), %rdi
	movq	88(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	movq	80(%rsp), %rsi                  # 8-byte Reload
	jne	.LBB1_33
# %bb.39:
	movq	208(%rsp), %rdi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_33
# %bb.40:
	movq	200(%rsp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_33
# %bb.41:                               # %.preheader320.preheader
	imulq	%rbx, %r14
	movl	$10, %ebx
	movq	48(%rsp), %r15                  # 8-byte Reload
	movl	136(%rsp), %ebp                 # 4-byte Reload
.LBB1_42:                               # %.preheader320
                                        # =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_44
# %bb.43:                               #   in Loop: Header=BB1_42 Depth=1
	movq	224(%rsp), %rdi
	movq	216(%rsp), %rsi
	movq	240(%rsp), %rdx
	movq	232(%rsp), %rcx
	movq	192(%rsp), %r8
	movq	184(%rsp), %r9
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	312(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	328(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	312(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	328(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	216(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	232(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	216(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	232(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	280(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	296(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
.LBB1_44:                               #   in Loop: Header=BB1_42 Depth=1
	decl	%ebx
	jne	.LBB1_42
# %bb.45:
	movq	160(%rsp), %rsi
	movq	40(%rsp), %rdi                  # 8-byte Reload
	movq	56(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	152(%rsp), %rsi
	movq	32(%rsp), %rdi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	168(%rsp), %rsi
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	176(%rsp), %rsi
	movq	24(%rsp), %rdi                  # 8-byte Reload
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	144(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	144(%rsp), %rdi
	callq	hipEventSynchronize
	movq	272(%rsp), %rsi
	movq	144(%rsp), %rdx
	leaq	436(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.9, %edi
	movl	$10, %esi
	movb	$1, %al
	callq	printf
	movslq	12(%rsp), %rax
	testb	%bpl, %bpl
	jne	.LBB1_50
# %bb.46:                               # %.preheader.lr.ph
	movl	%r15d, %ecx
	movq	248(%rsp), %r12                 # 8-byte Reload
	leaq	(%r12,%rcx,4), %rdx
	leaq	(,%rax,4), %rsi
	leaq	4(,%rax,4), %rdi
	imulq	%rcx, %rdi
	addq	%r12, %rdi
	movq	%rcx, %r8
	imulq	%rax, %r8
	leaq	(%r12,%r8,4), %r8
	leaq	(,%rcx,4), %r9
	xorl	%r10d, %r10d
	movq	24(%rsp), %r11                  # 8-byte Reload
	movq	16(%rsp), %rbx                  # 8-byte Reload
	movq	40(%rsp), %r14                  # 8-byte Reload
	movq	32(%rsp), %r15                  # 8-byte Reload
.LBB1_47:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_48 Depth 2
	xorl	%r13d, %r13d
.LBB1_48:                               #   Parent Loop BB1_47 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r11,%r13,4), %ebp
	movl	%ebp, (%r12,%r13,4)
	movl	(%rbx,%r13,4), %ebp
	movl	%ebp, (%rdx,%r13,4)
	movl	(%r14,%r13,4), %ebp
	movl	%ebp, (%r8,%r13,4)
	movl	(%r15,%r13,4), %ebp
	movl	%ebp, (%rdi,%r13,4)
	incq	%r13
	cmpq	%r13, %rcx
	jne	.LBB1_48
# %bb.49:                               #   in Loop: Header=BB1_47 Depth=1
	incq	%r10
	addq	%rsi, %rdi
	addq	%rsi, %r8
	addq	%rsi, %rdx
	addq	%rsi, %r12
	addq	%r9, %r15
	addq	%r9, %r14
	addq	%r9, %rbx
	addq	%r9, %r11
	cmpq	%rcx, %r10
	jne	.LBB1_47
.LBB1_50:                               # %._crit_edge332
	leal	(%rax,%rax,2), %eax
	cltq
	movq	248(%rsp), %r14                 # 8-byte Reload
	movl	(%r14,%rax,4), %esi
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movl	12(%rsp), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%eax, %ecx
	sarl	%ecx
	movslq	%ecx, %rax
	movl	(%r14,%rax,4), %esi
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movslq	12(%rsp), %rax
	movl	4(%r14,%rax,4), %ebx
	decl	%eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	.LCPI1_1(%rip), %xmm1           # xmm1 = mem[0],zero
	callq	pow
	addsd	%xmm0, %xmm0
	movl	12(%rsp), %eax
	leal	-1(%rax), %ecx
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ecx, %xmm1
	mulsd	%xmm1, %xmm1
	mulsd	.LCPI1_1(%rip), %xmm1
	cvtsi2sd	%eax, %xmm2
	addsd	%xmm0, %xmm1
	addsd	%xmm1, %xmm2
	addsd	.LCPI1_2(%rip), %xmm2
	divsd	.LCPI1_3(%rip), %xmm2
	cvttsd2si	%xmm2, %edx
	movl	$.L.str.11, %edi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movq	256(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	128(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	112(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	104(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	96(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	72(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	120(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	88(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	80(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	40(%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	16(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	264(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	224(%rsp), %rdi
	callq	hipFree
	movq	216(%rsp), %rdi
	callq	hipFree
	movq	240(%rsp), %rdi
	callq	hipFree
	movq	232(%rsp), %rdi
	callq	hipFree
	movq	192(%rsp), %rdi
	callq	hipFree
	movq	184(%rsp), %rdi
	callq	hipFree
	movq	208(%rsp), %rdi
	callq	hipFree
	movq	200(%rsp), %rdi
	callq	hipFree
	movq	160(%rsp), %rdi
	callq	hipFree
	movq	152(%rsp), %rdi
	callq	hipFree
	movq	176(%rsp), %rdi
	callq	hipFree
	movq	168(%rsp), %rdi
	callq	hipFree
	movq	288(%rsp), %rdi
	callq	hipFree
	movq	280(%rsp), %rdi
	callq	hipFree
	movq	304(%rsp), %rdi
	callq	hipFree
	movq	296(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$440, %rsp                      # imm = 0x1B8
	.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_14:
	.cfi_def_cfa_offset 496
	movl	$.Lstr.26, %edi
	jmp	.LBB1_3
.LBB1_33:
	movl	$.Lstr.10, %edi
.LBB1_3:
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.LBB1_2:
	movl	$.Lstr.27, %edi
	jmp	.LBB1_3
.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	$_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, %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	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i,@object # @_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.p2align	3, 0x0
_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i:
	.quad	_Z28__device_stub__matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.size	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, 8

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Se va a realizar la suma con %d bloques y %d hilos\n"
	.size	.L.str.6, 52

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Se va a realizar %d iteraciones de matrices %dx%d\n"
	.size	.L.str.7, 51

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"El tiempo tomado para %d iteraciones fue de %3.5f ms\n"
	.size	.L.str.9, 54

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Por ejemplo %d deberia ser 0\n"
	.size	.L.str.10, 30

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Por ejemplo %d deberia ser %d\n"
	.size	.L.str.11, 31

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i"
	.size	.L__unnamed_1, 51

	.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	"Ingrese el tamano deseado para las matrices:"
	.size	.Lstr, 45

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Creando espacio e inicializando matrices..."
	.size	.Lstr.1, 44

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Asignacion de memoria correcta"
	.size	.Lstr.2, 31

	.type	.Lstr.10,@object                # @str.10
.Lstr.10:
	.asciz	"#########\nHubo un problema en la copia de memoria a la GPU\n#########"
	.size	.Lstr.10, 69

	.type	.Lstr.26,@object                # @str.26
.Lstr.26:
	.asciz	"########\nHubo un problema en la asignacion de memoria en la GPU\n########"
	.size	.Lstr.26, 73

	.type	.Lstr.27,@object                # @str.27
.Lstr.27:
	.asciz	"El tama\303\261o debe ser mayor a dos y par"
	.size	.Lstr.27, 38

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i ; -- Begin function _Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.globl	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
	.p2align	8
	.type	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i,@function
_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i: ; @_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x94
	s_load_b32 s2, s[0:1], 0x80
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s4, s3, 16
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s3, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s4, v[3:4]
	s_mov_b32 s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_max_i32_e32 v2, v0, v1
	v_cmpx_gt_i32_e64 s2, v2
	s_cbranch_execz .LBB0_5
; %bb.1:                                ; %.preheader
	v_mul_lo_u32 v1, v1, s2
	v_dual_mov_b32 v6, 0 :: v_dual_mov_b32 v3, 0
	v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v5, 0
	v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v7, 0
	v_dual_mov_b32 v8, 0 :: v_dual_mov_b32 v9, 0
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph.preheader
	s_load_b512 s[4:19], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	v_mov_b32_e32 v6, 0
	v_dual_mov_b32 v10, v0 :: v_dual_mov_b32 v5, 0
	v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v9, 0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_4) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_mov_b32_e32 v8, 0
	s_mov_b32 s3, s2
	v_mov_b32_e32 v7, 0
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v12, vcc_lo, s8, v2
	v_add_co_ci_u32_e32 v13, vcc_lo, s9, v3, vcc_lo
	v_add_co_u32 v14, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v15, vcc_lo, s5, v3, vcc_lo
	v_add_co_u32 v16, vcc_lo, s10, v2
	v_add_co_ci_u32_e32 v17, vcc_lo, s11, v3, vcc_lo
	v_add_co_u32 v18, vcc_lo, s6, v2
	v_add_co_ci_u32_e32 v19, vcc_lo, s7, v3, vcc_lo
	v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v3, 0
.LBB0_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v11, 31, v10
	global_load_b32 v28, v[12:13], off
	global_load_b32 v29, v[14:15], off
	global_load_b32 v30, v[16:17], off
	global_load_b32 v31, v[18:19], off
	s_add_i32 s3, s3, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	s_cmp_lg_u32 s3, 0
	v_lshlrev_b64 v[20:21], 2, v[10:11]
	v_add_nc_u32_e32 v10, s2, v10
	v_add_co_u32 v22, vcc_lo, s16, v20
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v23, vcc_lo, s17, v21, vcc_lo
	v_add_co_u32 v24, vcc_lo, s18, v20
	v_add_co_ci_u32_e32 v25, vcc_lo, s19, v21, vcc_lo
	v_add_co_u32 v26, vcc_lo, s12, v20
	v_add_co_ci_u32_e32 v27, vcc_lo, s13, v21, vcc_lo
	v_add_co_u32 v20, vcc_lo, s14, v20
	v_add_co_ci_u32_e32 v21, vcc_lo, s15, v21, vcc_lo
	global_load_b32 v11, v[22:23], off
	global_load_b32 v25, v[24:25], off
	global_load_b32 v32, v[26:27], off
	global_load_b32 v33, v[20:21], off
	v_add_co_u32 v12, vcc_lo, v12, 4
	v_add_co_ci_u32_e32 v13, vcc_lo, 0, v13, vcc_lo
	v_add_co_u32 v14, vcc_lo, v14, 4
	v_add_co_ci_u32_e32 v15, vcc_lo, 0, v15, vcc_lo
	v_add_co_u32 v16, vcc_lo, v16, 4
	v_add_co_ci_u32_e32 v17, vcc_lo, 0, v17, vcc_lo
	v_add_co_u32 v18, vcc_lo, v18, 4
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v19, vcc_lo
	s_waitcnt vmcnt(3)
	v_mad_u64_u32 v[20:21], null, v11, v28, v[9:10]
	s_waitcnt vmcnt(2)
	v_mad_u64_u32 v[21:22], null, v25, v28, v[6:7]
	v_mad_u64_u32 v[22:23], null, v29, v11, v[8:9]
	v_mad_u64_u32 v[23:24], null, v29, v25, v[7:8]
	s_delay_alu instid0(VALU_DEP_4)
	v_mov_b32_e32 v9, v20
	s_waitcnt vmcnt(1)
	v_mad_u64_u32 v[24:25], null, v32, v30, v[5:6]
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[25:26], null, v33, v30, v[4:5]
	v_mad_u64_u32 v[26:27], null, v31, v32, v[3:4]
	v_mad_u64_u32 v[27:28], null, v31, v33, v[2:3]
	v_dual_mov_b32 v6, v21 :: v_dual_mov_b32 v7, v23
	v_dual_mov_b32 v8, v22 :: v_dual_mov_b32 v5, v24
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_dual_mov_b32 v4, v25 :: v_dual_mov_b32 v3, v26
	v_mov_b32_e32 v2, v27
	s_cbranch_scc1 .LBB0_3
.LBB0_4:                                ; %._crit_edge
	s_load_b512 s[0:15], s[0:1], 0x40
	v_add_nc_u32_e32 v0, v1, v0
	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_2)
	v_add_co_u32 v10, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v11, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v12, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v13, vcc_lo, s7, v1, vcc_lo
	v_add_co_u32 v14, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v15, vcc_lo, s1, v1, vcc_lo
	v_add_co_u32 v16, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v17, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[10:11], v9, off
	global_store_b32 v[12:13], v6, off
	global_store_b32 v[14:15], v8, off
	v_add_co_u32 v8, vcc_lo, s12, v0
	v_add_co_ci_u32_e32 v9, vcc_lo, s13, v1, vcc_lo
	v_add_co_u32 v18, vcc_lo, s8, v0
	v_add_co_ci_u32_e32 v19, vcc_lo, s9, v1, vcc_lo
	v_add_co_u32 v20, vcc_lo, s10, v0
	v_add_co_ci_u32_e32 v21, vcc_lo, s11, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s14, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s15, v1, vcc_lo
	global_store_b32 v[16:17], v7, off
	global_store_b32 v[8:9], v5, off
	global_store_b32 v[18:19], v3, off
	global_store_b32 v[20:21], v2, off
	global_store_b32 v[0:1], v4, off
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	global_load_b32 v2, v[8:9], off
	global_load_b32 v3, v[10:11], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v2, v3, v2
	global_store_b32 v[10:11], v2, off
	global_load_b32 v2, v[18:19], off
	global_load_b32 v3, v[14:15], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v2, v3, v2
	global_store_b32 v[14:15], v2, off
	global_load_b32 v2, v[20:21], off
	global_load_b32 v3, v[16:17], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v2, v3, v2
	global_store_b32 v[16:17], v2, off
	global_load_b32 v0, v[0:1], off
	global_load_b32 v1, v[12:13], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v0, v1, v0
	global_store_b32 v[12:13], v0, off
.LBB0_5:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 392
		.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 34
		.amdhsa_next_free_sgpr 20
		.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	_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i, .Lfunc_end0-_Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 928
; NumSgprs: 22
; NumVgprs: 34
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 4
; NumSGPRsForWavesPerEU: 22
; NumVGPRsForWavesPerEU: 34
; 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
      - .address_space:  global
        .offset:         64
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         72
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         80
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         88
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         96
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         104
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         112
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         120
        .size:           8
        .value_kind:     global_buffer
      - .offset:         128
        .size:           4
        .value_kind:     by_value
      - .offset:         136
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         140
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         144
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         148
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         150
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         152
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         154
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         156
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         158
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         176
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         184
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         192
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         200
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 392
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     22
    .sgpr_spill_count: 0
    .symbol:         _Z13matrixMultGPUPiS_S_S_S_S_S_S_S_S_S_S_S_S_S_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     34
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
