#include<stdio.h>
#include <stdlib.h>
#include<malloc.h>
#include <time.h>
#include<cuda.h>

typedef char* string;

__global__
void multGPU(float* A, int rowsA, int colsA, float* B, int rowsB, int colsB, float* C){
  int row = blockIdx.y * blockDim.y + threadIdx.y;
  int col = blockIdx.x * blockDim.x + threadIdx.x;
  if((col < colsB)&&(row < rowsA)) {
    for(int M = 0; M < rowsB; M++) {
        C[row * colsB + col]+= A[row * colsA + M] * B[M * colsB + col];
    }
  }
}

__host__
void multCPU(float* A, int rowsA, int colsA, float* B, int rowsB, int colsB, float* C){
  int i, j;
  for(i = 0; i < rowsA; i++){
    for(j = 0; j< colsB; j++){
      for(int M = 0; M < rowsB; M++){
        C[i * colsB + j] += A[i * colsA + M] * B[ M * colsB + j];
      }
    }
  }
}

__host__
bool compare(float *A, float *B, int rows, int cols){
  int i, j;
	for(i = 0; i < rows; i++) {
		for(j = 0; j < cols; j++) {
			if (A[ i * cols + j] != B[i * cols + j]) return false;
		}
	}
	return true;
}

__host__
void load(float *M, FILE *stream, int rows, int cols) {
  int i, j;
  for(i = 0; i < rows; i++) {
    for(j = 0; j < cols; j++) {
      fscanf(stream, "%f,", &M[i * cols + j]);
    }
  }
  fclose(stream);
}

__host__
void save(float *M, int rows, int cols, string file_name) {
  FILE *stream;
  int i, j;
  stream = fopen(file_name, "w");
  fprintf(stream, "%d\n", rows);
  fprintf(stream, "%d\n", cols);
  for(i = 0; i < rows; i++) {
    for(j = 0; j < cols; j++) {
      if (j + 1 == cols) fprintf(stream, "%.2f", M[i * cols + j]);
      else fprintf(stream, "%.2f,", M[i * cols + j]);
    }
    fprintf(stream, "%s\n","");
  }
  fclose(stream);
}

__host__
void print(float* M, int rows, int cols){
  printf("---------------print matrix--------------\n");
  for(int i = 0; i < rows; i++) {
    for(int j = 0; j < cols; j++) {
      printf("%f ", M[i * cols + j]);
    }
    printf("\n");
  }
}


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

	if (argc != 3) {
    printf("Must be called with the names of the files\n");
    return 1;
  }

  //-------------------------------CPU--------------------------------------

	time_t time_start, time_end;
	float *A, *B, *C;
	int rowsA, colsA, rowsB, colsB;
  double timeCPU, timeGPU;

  FILE *arc1, *arc2;
  arc1 = fopen(argv[1], "r");
  arc2 = fopen(argv[2], "r");

  fscanf(arc1, "%d", &rowsA);
  fscanf(arc1, "%d", &colsA);
  fscanf(arc2, "%d", &rowsB);
  fscanf(arc2, "%d", &colsB);

  //RESERVA MEMORIA EN CPU

  A = (float*)malloc(rowsA * colsA * sizeof(float));
  B = (float*)malloc(rowsB * colsB * sizeof(float));
	C = (float*)malloc(rowsA * colsB * sizeof(float));

	load(A, arc1, rowsA, colsA);
   // printf("rowsA: %d\n", rowsA);
  // printf("colsA: %d\n", colsA);
  // print(A, rowsA, colsA);

  load(B, arc2, rowsB, colsB);
  // printf("rowsA: %d\n", rowsB);
  // printf("colsA: %d\n", colsB);
  // print(B, rowsB, colsB);

	if (colsA != rowsB) return 1; // tiene que ser iguales filas M2 y col M1

	time_start = clock();
	multCPU(A, rowsA, colsA, B, rowsB, colsB, C);
	time_end = clock();

  // print(C, rowsA, colsB);

  timeCPU = difftime(time_end, time_start);
  printf ("Elasped time in CPU: %.2lf seconds.\n", timeCPU);

  // save(C, rowsA, colsB, "CPU.out");

	//-------------------------------GPU--------------------------------------
  cudaError_t error = cudaSuccess;
  float *d_A, *d_B, *d_C, *h_C;
	h_C = (float*)malloc(rowsA * colsB * sizeof(float));

	error = cudaMalloc((void**)&d_A, rowsA * colsA * sizeof(float));
  if (error != cudaSuccess) {
      printf("Error al asignar memoria a d_A");
      return 1;
  }

  error = cudaMalloc((void**)&d_B, rowsB * colsB * sizeof(float));
  if (error != cudaSuccess) {
      printf("Error al asignar memoria a d_B");
      return 1;
  }

  error = cudaMalloc((void**)&d_C, rowsA * colsB * sizeof(float));
  if (error != cudaSuccess) {
      printf("Error al asignar memoria a d_C");
      return 1;
  }

	cudaMemcpy(d_A, A, rowsA * colsA * sizeof(float), cudaMemcpyHostToDevice);
	cudaMemcpy(d_B, B, rowsB * colsB * sizeof(float), cudaMemcpyHostToDevice);

  int blockSize = 32;
	dim3 dimblock(blockSize, blockSize, 1);
  dim3 dimGrid(ceil((colsB) / float(blockSize)), ceil((rowsA) / float(blockSize)), 1);

  time_start = clock();
	multGPU<<<dimGrid,dimblock>>>(d_A, rowsA, colsA, d_B, rowsB, colsB, d_C);
	cudaDeviceSynchronize();
  time_end = clock();

  timeGPU = difftime(time_end, time_start);
  printf ("Tiempo trasncurrido en GPU: %.2lf seconds.\n", timeGPU);

	cudaMemcpy(h_C, d_C, rowsA * colsB * sizeof(float), cudaMemcpyDeviceToHost);

	// print(h_C, rowsA, colsB);

	if (!compare(h_C, C, rowsA, colsB)) {
    printf("Error al multiplicar\n");
  } else {
    printf("tiempo acelerado: %lf\n", timeCPU / timeGPU);
    // save(h_C, rowsA, colsB, "GPU.out");
  }

	free(A); free(B); free(C); free(h_C);
	cudaFree(d_A); cudaFree(d_B); cudaFree(d_C);
	return 0;
}

	.file	"tmpxft_002f26f2_00000000-6_multimatriz.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z7multCPUPfiiS_iiS_
	.type	_Z7multCPUPfiiS_iiS_, @function
_Z7multCPUPfiiS_iiS_:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%r9d, %r11
	xorl	%r10d, %r10d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	salq	$2, %r11
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	movq	%rcx, -8(%rsp)
	xorl	%ecx, %ecx
.L3:
	cmpl	%ebp, %r10d
	jge	.L2
	movslq	%ecx, %rax
	movq	-8(%rsp), %rsi
	leaq	(%rdi,%rax,4), %r15
	xorl	%eax, %eax
.L8:
	cmpl	%r9d, %eax
	jge	.L5
	movq	56(%rsp), %r14
	leal	(%rax,%rbx), %edx
	movq	%rsi, %r13
	movslq	%edx, %rdx
	leaq	(%r14,%rdx,4), %r14
	xorl	%edx, %edx
.L6:
	cmpl	%edx, %r8d
	jle	.L11
	movss	(%r15,%rdx,4), %xmm0
	mulss	0(%r13), %xmm0
	incq	%rdx
	addq	%r11, %r13
	addss	(%r14), %xmm0
	movss	%xmm0, (%r14)
	jmp	.L6
.L11:
	incl	%eax
	addq	$4, %rsi
	jmp	.L8
.L5:
	incl	%r10d
	addl	%r9d, %ebx
	addl	%r12d, %ecx
	jmp	.L3
.L2:
	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	_Z7multCPUPfiiS_iiS_, .-_Z7multCPUPfiiS_iiS_
	.globl	_Z7comparePfS_ii
	.type	_Z7comparePfS_ii, @function
_Z7comparePfS_ii:
.LFB2028:
	.cfi_startproc
	endbr64
	movq	%rdi, %r10
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
.L13:
	cmpl	%edx, %r9d
	jge	.L19
	movslq	%r8d, %rax
	xorl	%edi, %edi
	salq	$2, %rax
.L17:
	cmpl	%ecx, %edi
	jge	.L21
	movss	(%r10,%rax), %xmm0
	addq	$4, %rax
	ucomiss	-4(%rsi,%rax), %xmm0
	jp	.L18
	jne	.L18
	incl	%edi
	jmp	.L17
.L21:
	incl	%r9d
	addl	%ecx, %r8d
	jmp	.L13
.L18:
	xorl	%eax, %eax
	ret
.L19:
	movb	$1, %al
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z7comparePfS_ii, .-_Z7comparePfS_ii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%f,"
	.text
	.globl	_Z4loadPfP8_IO_FILEii
	.type	_Z4loadPfP8_IO_FILEii, @function
_Z4loadPfP8_IO_FILEii:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edx, %r9d
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	movq	%rsi, %rdi
	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
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
.L23:
	cmpl	%r9d, %r15d
	jge	.L25
	movslq	%ebx, %rax
	xorl	%r12d, %r12d
	leaq	(%r14,%rax,4), %r13
.L26:
	cmpl	%ebp, %r12d
	jge	.L28
	movq	%r13, %rdx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	movq	%rdi, (%rsp)
	movl	%r9d, 12(%rsp)
	incl	%r12d
	addq	$4, %r13
	call	__isoc23_fscanf@PLT
	movl	12(%rsp), %r9d
	movq	(%rsp), %rdi
	jmp	.L26
.L28:
	incl	%r15d
	addl	%ebp, %ebx
	jmp	.L23
.L25:
	addq	$24, %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
	jmp	fclose@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z4loadPfP8_IO_FILEii, .-_Z4loadPfP8_IO_FILEii
	.section	.rodata.str1.1
.LC1:
	.string	"w"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%.2f"
.LC4:
	.string	"%.2f,"
.LC5:
	.string	""
.LC6:
	.string	"%s\n"
	.text
	.globl	_Z4savePfiiPc
	.type	_Z4savePfiiPc, @function
_Z4savePfiiPc:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%esi, %r12d
	leaq	.LC1(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%rdi, 8(%rsp)
	movq	%rcx, %rdi
	call	fopen@PLT
	movl	%r12d, %ecx
	movq	%rbp, %rdx
	movl	$2, %esi
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	(%rsp), %rdi
	movl	%ebx, %ecx
	movq	%rbp, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L30:
	cmpl	%r12d, %r15d
	jge	.L34
	movq	8(%rsp), %rcx
	movslq	%r14d, %rax
	xorl	%ebp, %ebp
	leaq	(%rcx,%rax,4), %r13
.L35:
	cmpl	%ebx, %ebp
	jge	.L38
	incl	%ebp
	leaq	.LC3(%rip), %rdx
	cvtss2sd	0(%r13), %xmm0
	cmpl	%ebx, %ebp
	je	.L37
	leaq	.LC4(%rip), %rdx
.L37:
	movq	(%rsp), %rdi
	movl	$2, %esi
	movb	$1, %al
	addq	$4, %r13
	call	__fprintf_chk@PLT
	jmp	.L35
.L38:
	movq	(%rsp), %rdi
	leaq	.LC5(%rip), %rcx
	xorl	%eax, %eax
	incl	%r15d
	leaq	.LC6(%rip), %rdx
	movl	$2, %esi
	addl	%ebx, %r14d
	call	__fprintf_chk@PLT
	jmp	.L30
.L34:
	movq	(%rsp), %rdi
	addq	$24, %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
	jmp	fclose@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z4savePfiiPc, .-_Z4savePfiiPc
	.section	.rodata.str1.1
.LC7:
	.string	"---------------print matrix--------------\n"
.LC8:
	.string	"%f "
.LC9:
	.string	"\n"
	.text
	.globl	_Z5printPfii
	.type	_Z5printPfii, @function
_Z5printPfii:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	leaq	.LC7(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	movl	$2, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	__printf_chk@PLT
.L40:
	cmpl	%r14d, %r13d
	jge	.L39
	movslq	%r12d, %rax
	xorl	%r15d, %r15d
	leaq	0(%rbp,%rax,4), %rcx
.L43:
	cmpl	%r15d, %ebx
	jle	.L45
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%rcx,%r15,4), %xmm0
	movq	%rcx, 8(%rsp)
	incq	%r15
	call	__printf_chk@PLT
	movq	8(%rsp), %rcx
	jmp	.L43
.L45:
	leaq	.LC9(%rip), %rsi
	xorl	%eax, %eax
	incl	%r13d
	addl	%ebx, %r12d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L40
.L39:
	addq	$24, %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
.LFE2031:
	.size	_Z5printPfii, .-_Z5printPfii
	.globl	_Z34__device_stub__Z7multGPUPfiiS_iiS_PfiiS_iiS_
	.type	_Z34__device_stub__Z7multGPUPfiiS_iiS_PfiiS_iiS_, @function
_Z34__device_stub__Z7multGPUPfiiS_iiS_PfiiS_iiS_:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	192(%rsp), %rax
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	76(%rsp), %rsi
	movl	%edx, 32(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 24(%rsp)
	leaq	56(%rsp), %rcx
	movl	%r8d, 20(%rsp)
	movl	%r9d, 16(%rsp)
	movq	%rax, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L46
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z7multGPUPfiiS_iiS_(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L46:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z34__device_stub__Z7multGPUPfiiS_iiS_PfiiS_iiS_, .-_Z34__device_stub__Z7multGPUPfiiS_iiS_PfiiS_iiS_
	.globl	_Z7multGPUPfiiS_iiS_
	.type	_Z7multGPUPfiiS_iiS_, @function
_Z7multGPUPfiiS_iiS_:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z7multGPUPfiiS_iiS_PfiiS_iiS_
	.cfi_endproc
.LFE2058:
	.size	_Z7multGPUPfiiS_iiS_, .-_Z7multGPUPfiiS_iiS_
	.section	.rodata.str1.1
.LC10:
	.string	"Must be called with the names of the files\n"
.LC11:
	.string	"r"
.LC12:
	.string	"%d"
.LC13:
	.string	"Elasped time in CPU: %.2lf seconds.\n"
.LC14:
	.string	"Error al asignar memoria a d_A"
.LC15:
	.string	"Error al asignar memoria a d_B"
.LC16:
	.string	"Error al asignar memoria a d_C"
.LC18:
	.string	"Tiempo trasncurrido en GPU: %.2lf seconds.\n"
.LC19:
	.string	"Error al multiplicar\n"
.LC20:
	.string	"tiempo acelerado: %lf\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2032:
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	je	.L52
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	jmp	.L64
.L52:
	movq	8(%rsi), %rdi
	leaq	.LC11(%rip), %rbp
	movq	%rsi, %rbx
	movq	%rbp, %rsi
	call	fopen@PLT
	movq	16(%rbx), %rdi
	movq	%rbp, %rsi
	leaq	.LC12(%rip), %rbx
	movq	%rax, %r15
	call	fopen@PLT
	movq	%rbx, %rsi
	leaq	24(%rsp), %rdx
	movq	%r15, %rdi
	movq	%rax, %r13
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	%rbx, %rsi
	leaq	28(%rsp), %rdx
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	%rbx, %rsi
	leaq	32(%rsp), %rdx
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movq	%rbx, %rsi
	leaq	36(%rsp), %rdx
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movl	24(%rsp), %ebp
	movl	28(%rsp), %ecx
	movl	%ebp, %edi
	movl	%ecx, 8(%rsp)
	imull	%ecx, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movl	36(%rsp), %ebx
	movl	32(%rsp), %edi
	movq	%rax, %r12
	imull	%ebx, %edi
	imull	%ebp, %ebx
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movslq	%ebx, %rdi
	salq	$2, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movl	8(%rsp), %ecx
	movl	%ebp, %edx
	movq	%r15, %rsi
	movq	%r12, %rdi
	movq	%rax, %r14
	call	_Z4loadPfP8_IO_FILEii
	movl	36(%rsp), %ecx
	movl	32(%rsp), %edx
	movq	%r13, %rsi
	movq	(%rsp), %rdi
	call	_Z4loadPfP8_IO_FILEii
	movl	32(%rsp), %eax
	cmpl	%eax, 28(%rsp)
	je	.L54
.L53:
	movl	$1, %eax
	jmp	.L51
.L54:
	call	clock@PLT
	movq	%r12, %rdi
	pushq	%rsi
	.cfi_def_cfa_offset 168
	movq	%rax, %rbx
	pushq	%r14
	.cfi_def_cfa_offset 176
	movl	52(%rsp), %r9d
	movq	16(%rsp), %rcx
	movl	44(%rsp), %edx
	movl	48(%rsp), %r8d
	movl	40(%rsp), %esi
	call	_Z7multCPUPfiiS_iiS_
	call	clock@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	difftime@PLT
	popq	%rdi
	.cfi_def_cfa_offset 168
	leaq	.LC13(%rip), %rsi
	popq	%r8
	.cfi_def_cfa_offset 160
	movl	$2, %edi
	movb	$1, %al
	movq	%xmm0, %r15
	call	__printf_chk@PLT
	movl	24(%rsp), %ebx
	movl	36(%rsp), %edi
	imull	%ebx, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	imull	28(%rsp), %ebx
	leaq	40(%rsp), %rdi
	movq	%rax, %r13
	movslq	%ebx, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	.LC14(%rip), %rsi
	testl	%eax, %eax
	jne	.L65
	movl	32(%rsp), %esi
	imull	36(%rsp), %esi
	leaq	48(%rsp), %rdi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L57
	leaq	.LC15(%rip), %rsi
.L65:
	movl	$2, %edi
	xorl	%eax, %eax
.L64:
	call	__printf_chk@PLT
	jmp	.L53
.L57:
	movl	24(%rsp), %esi
	imull	36(%rsp), %esi
	leaq	56(%rsp), %rdi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	.LC16(%rip), %rsi
	testl	%eax, %eax
	jne	.L65
	movl	24(%rsp), %edx
	imull	28(%rsp), %edx
	movl	$1, %ecx
	movq	%r12, %rsi
	movq	40(%rsp), %rdi
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	32(%rsp), %edx
	imull	36(%rsp), %edx
	movl	$1, %ecx
	movq	(%rsp), %rsi
	movq	48(%rsp), %rdi
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	cvtsi2ssl	24(%rsp), %xmm0
	mulss	.LC17(%rip), %xmm0
	movabsq	$137438953504, %rax
	movq	%rax, 64(%rsp)
	movl	$1, 72(%rsp)
	call	ceilf@PLT
	movd	%xmm0, %ebx
	cvtsi2ssl	36(%rsp), %xmm0
	mulss	.LC17(%rip), %xmm0
	call	ceilf@PLT
	movd	%ebx, %xmm1
	movl	$1, 84(%rsp)
	cvttss2siq	%xmm0, %rax
	movl	%eax, 76(%rsp)
	cvttss2siq	%xmm1, %rax
	movl	%eax, 80(%rsp)
	call	clock@PLT
	movl	72(%rsp), %ecx
	movl	84(%rsp), %esi
	xorl	%r9d, %r9d
	movq	64(%rsp), %rdx
	movq	76(%rsp), %rdi
	xorl	%r8d, %r8d
	movq	%rax, %rbx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L59
	pushq	%rax
	.cfi_def_cfa_offset 168
	pushq	64(%rsp)
	.cfi_def_cfa_offset 176
	movl	52(%rsp), %r9d
	movl	48(%rsp), %r8d
	movq	64(%rsp), %rcx
	movl	44(%rsp), %edx
	movl	40(%rsp), %esi
	movq	56(%rsp), %rdi
	call	_Z34__device_stub__Z7multGPUPfiiS_iiS_PfiiS_iiS_
	popq	%rdx
	.cfi_def_cfa_offset 168
	popq	%rcx
	.cfi_def_cfa_offset 160
.L59:
	call	cudaDeviceSynchronize@PLT
	call	clock@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	difftime@PLT
	leaq	.LC18(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movsd	%xmm0, 8(%rsp)
	call	__printf_chk@PLT
	movl	24(%rsp), %edx
	imull	36(%rsp), %edx
	movq	%r13, %rdi
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	36(%rsp), %ecx
	movl	24(%rsp), %edx
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	_Z7comparePfS_ii
	testb	%al, %al
	jne	.L60
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L61
.L60:
	leaq	.LC20(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	movq	%r15, %xmm0
	divsd	8(%rsp), %xmm0
	call	__printf_chk@PLT
.L61:
	movq	%r12, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	xorl	%eax, %eax
.L51:
	movq	88(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L62
	call	__stack_chk_fail@PLT
.L62:
	addq	$104, %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
.LFE2032:
	.size	main, .-main
	.section	.rodata.str1.1
.LC21:
	.string	"_Z7multGPUPfiiS_iiS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.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	.LC21(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z7multGPUPfiiS_iiS_(%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
.LFE2060:
	.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
.LC17:
	.long	1023410176
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

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

typedef char* string;

__global__
void multGPU(float* A, int rowsA, int colsA, float* B, int rowsB, int colsB, float* C){
  int row = blockIdx.y * blockDim.y + threadIdx.y;
  int col = blockIdx.x * blockDim.x + threadIdx.x;
  if((col < colsB)&&(row < rowsA)) {
    for(int M = 0; M < rowsB; M++) {
        C[row * colsB + col]+= A[row * colsA + M] * B[M * colsB + col];
    }
  }
}

__host__
void multCPU(float* A, int rowsA, int colsA, float* B, int rowsB, int colsB, float* C){
  int i, j;
  for(i = 0; i < rowsA; i++){
    for(j = 0; j< colsB; j++){
      for(int M = 0; M < rowsB; M++){
        C[i * colsB + j] += A[i * colsA + M] * B[ M * colsB + j];
      }
    }
  }
}

__host__
bool compare(float *A, float *B, int rows, int cols){
  int i, j;
	for(i = 0; i < rows; i++) {
		for(j = 0; j < cols; j++) {
			if (A[ i * cols + j] != B[i * cols + j]) return false;
		}
	}
	return true;
}

__host__
void load(float *M, FILE *stream, int rows, int cols) {
  int i, j;
  for(i = 0; i < rows; i++) {
    for(j = 0; j < cols; j++) {
      fscanf(stream, "%f,", &M[i * cols + j]);
    }
  }
  fclose(stream);
}

__host__
void save(float *M, int rows, int cols, string file_name) {
  FILE *stream;
  int i, j;
  stream = fopen(file_name, "w");
  fprintf(stream, "%d\n", rows);
  fprintf(stream, "%d\n", cols);
  for(i = 0; i < rows; i++) {
    for(j = 0; j < cols; j++) {
      if (j + 1 == cols) fprintf(stream, "%.2f", M[i * cols + j]);
      else fprintf(stream, "%.2f,", M[i * cols + j]);
    }
    fprintf(stream, "%s\n","");
  }
  fclose(stream);
}

__host__
void print(float* M, int rows, int cols){
  printf("---------------print matrix--------------\n");
  for(int i = 0; i < rows; i++) {
    for(int j = 0; j < cols; j++) {
      printf("%f ", M[i * cols + j]);
    }
    printf("\n");
  }
}


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

	if (argc != 3) {
    printf("Must be called with the names of the files\n");
    return 1;
  }

  //-------------------------------CPU--------------------------------------

	time_t time_start, time_end;
	float *A, *B, *C;
	int rowsA, colsA, rowsB, colsB;
  double timeCPU, timeGPU;

  FILE *arc1, *arc2;
  arc1 = fopen(argv[1], "r");
  arc2 = fopen(argv[2], "r");

  fscanf(arc1, "%d", &rowsA);
  fscanf(arc1, "%d", &colsA);
  fscanf(arc2, "%d", &rowsB);
  fscanf(arc2, "%d", &colsB);

  //RESERVA MEMORIA EN CPU

  A = (float*)malloc(rowsA * colsA * sizeof(float));
  B = (float*)malloc(rowsB * colsB * sizeof(float));
	C = (float*)malloc(rowsA * colsB * sizeof(float));

	load(A, arc1, rowsA, colsA);
   // printf("rowsA: %d\n", rowsA);
  // printf("colsA: %d\n", colsA);
  // print(A, rowsA, colsA);

  load(B, arc2, rowsB, colsB);
  // printf("rowsA: %d\n", rowsB);
  // printf("colsA: %d\n", colsB);
  // print(B, rowsB, colsB);

	if (colsA != rowsB) return 1; // tiene que ser iguales filas M2 y col M1

	time_start = clock();
	multCPU(A, rowsA, colsA, B, rowsB, colsB, C);
	time_end = clock();

  // print(C, rowsA, colsB);

  timeCPU = difftime(time_end, time_start);
  printf ("Elasped time in CPU: %.2lf seconds.\n", timeCPU);

  // save(C, rowsA, colsB, "CPU.out");

	//-------------------------------GPU--------------------------------------
  hipError_t error = hipSuccess;
  float *d_A, *d_B, *d_C, *h_C;
	h_C = (float*)malloc(rowsA * colsB * sizeof(float));

	error = hipMalloc((void**)&d_A, rowsA * colsA * sizeof(float));
  if (error != hipSuccess) {
      printf("Error al asignar memoria a d_A");
      return 1;
  }

  error = hipMalloc((void**)&d_B, rowsB * colsB * sizeof(float));
  if (error != hipSuccess) {
      printf("Error al asignar memoria a d_B");
      return 1;
  }

  error = hipMalloc((void**)&d_C, rowsA * colsB * sizeof(float));
  if (error != hipSuccess) {
      printf("Error al asignar memoria a d_C");
      return 1;
  }

	hipMemcpy(d_A, A, rowsA * colsA * sizeof(float), hipMemcpyHostToDevice);
	hipMemcpy(d_B, B, rowsB * colsB * sizeof(float), hipMemcpyHostToDevice);

  int blockSize = 32;
	dim3 dimblock(blockSize, blockSize, 1);
  dim3 dimGrid(ceil((colsB) / float(blockSize)), ceil((rowsA) / float(blockSize)), 1);

  time_start = clock();
	multGPU<<<dimGrid,dimblock>>>(d_A, rowsA, colsA, d_B, rowsB, colsB, d_C);
	hipDeviceSynchronize();
  time_end = clock();

  timeGPU = difftime(time_end, time_start);
  printf ("Tiempo trasncurrido en GPU: %.2lf seconds.\n", timeGPU);

	hipMemcpy(h_C, d_C, rowsA * colsB * sizeof(float), hipMemcpyDeviceToHost);

	// print(h_C, rowsA, colsB);

	if (!compare(h_C, C, rowsA, colsB)) {
    printf("Error al multiplicar\n");
  } else {
    printf("tiempo acelerado: %lf\n", timeCPU / timeGPU);
    // save(h_C, rowsA, colsB, "GPU.out");
  }

	free(A); free(B); free(C); free(h_C);
	hipFree(d_A); hipFree(d_B); hipFree(d_C);
	return 0;
}

	.text
	.file	"multimatriz.hip"
	.globl	_Z22__device_stub__multGPUPfiiS_iiS_ # -- Begin function _Z22__device_stub__multGPUPfiiS_iiS_
	.type	_Z22__device_stub__multGPUPfiiS_iiS_,@function
_Z22__device_stub__multGPUPfiiS_iiS_:   # @_Z22__device_stub__multGPUPfiiS_iiS_
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	12(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	8(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	4(%rsp), %rcx
	movl	%r8d, (%rcx)
	movq	%rsp, %r8
	movl	%r9d, (%r8)
	leaq	80(%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	192(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z7multGPUPfiiS_iiS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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	_Z22__device_stub__multGPUPfiiS_iiS_, .Lfunc_end0-_Z22__device_stub__multGPUPfiiS_iiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z7multCPUPfiiS_iiS_            # -- Begin function _Z7multCPUPfiiS_iiS_
	.type	_Z7multCPUPfiiS_iiS_,@function
_Z7multCPUPfiiS_iiS_:                   # @_Z7multCPUPfiiS_iiS_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, -8(%rsp)                  # 8-byte Spill
	testl	%esi, %esi
	jle	.LBB1_9
# %bb.1:                                # %.preheader23.lr.ph
	movslq	%r9d, %r10
	movslq	%edx, %rdx
	movl	%esi, %esi
	movl	%r10d, %r11d
	movl	%r8d, %ebx
	shlq	$2, %rdx
	leaq	(,%r10,4), %r14
	xorl	%r15d, %r15d
.LBB1_2:                                # %.preheader23
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
                                        #       Child Loop BB1_6 Depth 3
	testl	%r9d, %r9d
	jle	.LBB1_8
# %bb.3:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movq	%r15, %rax
	imulq	%r10, %rax
	movq	56(%rsp), %rcx
	leaq	(%rcx,%rax,4), %r12
	movq	-8(%rsp), %rcx                  # 8-byte Reload
	xorl	%ebp, %ebp
.LBB1_4:                                # %.preheader
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_6 Depth 3
	testl	%r8d, %r8d
	jle	.LBB1_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB1_4 Depth=2
	movss	(%r12,%rbp,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	%rcx, %r13
	xorl	%eax, %eax
.LBB1_6:                                #   Parent Loop BB1_2 Depth=1
                                        #     Parent Loop BB1_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rdi,%rax,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r13), %xmm1
	addss	%xmm1, %xmm0
	movss	%xmm0, (%r12,%rbp,4)
	incq	%rax
	addq	%r14, %r13
	cmpq	%rax, %rbx
	jne	.LBB1_6
.LBB1_7:                                # %._crit_edge
                                        #   in Loop: Header=BB1_4 Depth=2
	incq	%rbp
	addq	$4, %rcx
	cmpq	%r11, %rbp
	jne	.LBB1_4
.LBB1_8:                                # %._crit_edge26
                                        #   in Loop: Header=BB1_2 Depth=1
	incq	%r15
	addq	%rdx, %rdi
	cmpq	%rsi, %r15
	jne	.LBB1_2
.LBB1_9:                                # %._crit_edge28
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z7multCPUPfiiS_iiS_, .Lfunc_end1-_Z7multCPUPfiiS_iiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z7comparePfS_ii                # -- Begin function _Z7comparePfS_ii
	.type	_Z7comparePfS_ii,@function
_Z7comparePfS_ii:                       # @_Z7comparePfS_ii
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB2_1
# %bb.3:                                # %.preheader.lr.ph
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	%edx, %edx
	movl	%ecx, %r8d
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
	xorl	%eax, %eax
.LBB2_4:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_7 Depth 2
	testl	%ecx, %ecx
	jle	.LBB2_8
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB2_4 Depth=1
	movl	%r9d, %ebx
	leaq	(%rsi,%rbx,4), %r11
	leaq	(%rdi,%rbx,4), %rbx
	xorl	%r14d, %r14d
.LBB2_7:                                #   Parent Loop BB2_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rbx,%r14,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	ucomiss	(%r11,%r14,4), %xmm0
	jne	.LBB2_9
	jp	.LBB2_9
# %bb.6:                                #   in Loop: Header=BB2_7 Depth=2
	incq	%r14
	cmpq	%r14, %r8
	jne	.LBB2_7
.LBB2_8:                                # %._crit_edge
                                        #   in Loop: Header=BB2_4 Depth=1
	incq	%r10
	cmpq	%rdx, %r10
	setae	%al
	addl	%ecx, %r9d
	cmpq	%rdx, %r10
	jne	.LBB2_4
.LBB2_9:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	jmp	.LBB2_2
.LBB2_1:
	movb	$1, %al
.LBB2_2:                                # %.loopexit
	andb	$1, %al
                                        # kill: def $al killed $al killed $rax
	retq
.Lfunc_end2:
	.size	_Z7comparePfS_ii, .Lfunc_end2-_Z7comparePfS_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z4loadPfP8_IO_FILEii           # -- Begin function _Z4loadPfP8_IO_FILEii
	.type	_Z4loadPfP8_IO_FILEii,@function
_Z4loadPfP8_IO_FILEii:                  # @_Z4loadPfP8_IO_FILEii
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	testl	%edx, %edx
	jle	.LBB3_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%ecx, %ebx
	movl	%edx, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%ecx, %eax
	movq	%rax, (%rsp)                    # 8-byte Spill
	xorl	%r15d, %r15d
	xorl	%ebp, %ebp
.LBB3_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB3_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB3_2 Depth=1
	movl	%r15d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r12
	movq	(%rsp), %r13                    # 8-byte Reload
.LBB3_4:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$.L.str, %esi
	movq	%r14, %rdi
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	addq	$4, %r12
	decq	%r13
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	incq	%rbp
	addl	%ebx, %r15d
	cmpq	16(%rsp), %rbp                  # 8-byte Folded Reload
	jne	.LBB3_2
.LBB3_6:                                # %._crit_edge15
	movq	%r14, %rdi
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end3:
	.size	_Z4loadPfP8_IO_FILEii, .Lfunc_end3-_Z4loadPfP8_IO_FILEii
	.cfi_endproc
                                        # -- End function
	.globl	_Z4savePfiiPc                   # -- Begin function _Z4savePfiiPc
	.type	_Z4savePfiiPc,@function
_Z4savePfiiPc:                          # @_Z4savePfiiPc
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.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	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, 16(%rsp)                  # 8-byte Spill
	movl	$.L.str.1, %esi
	movq	%rcx, %rdi
	callq	fopen
	movq	%rax, %r15
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	fprintf
	movl	$.L.str.2, %esi
	movq	%r15, %rdi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	fprintf
	testl	%ebp, %ebp
	jle	.LBB4_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebx, %r12d
	movl	%ebp, %eax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	leaq	-1(%r12), %rbp
	movl	$.L.str.3, %r14d
	movl	$0, 8(%rsp)                     # 4-byte Folded Spill
	xorl	%eax, %eax
	movl	%ebx, 12(%rsp)                  # 4-byte Spill
.LBB4_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_4 Depth 2
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	testl	%ebx, %ebx
	jle	.LBB4_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	8(%rsp), %eax                   # 4-byte Reload
	movq	16(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %r13
	xorl	%eax, %eax
.LBB4_4:                                #   Parent Loop BB4_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leaq	1(%rax), %rbx
	cmpq	%rax, %rbp
	movl	$.L.str.4, %esi
	cmoveq	%r14, %rsi
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%rax,4), %xmm0
	movq	%r15, %rdi
	movb	$1, %al
	callq	fprintf
	movq	%rbx, %rax
	cmpq	%rbx, %r12
	jne	.LBB4_4
.LBB4_5:                                # %._crit_edge
                                        #   in Loop: Header=BB4_2 Depth=1
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	fprintf
	movq	32(%rsp), %rax                  # 8-byte Reload
	incq	%rax
	movl	12(%rsp), %ebx                  # 4-byte Reload
	addl	%ebx, 8(%rsp)                   # 4-byte Folded Spill
	cmpq	24(%rsp), %rax                  # 8-byte Folded Reload
	jne	.LBB4_2
.LBB4_6:                                # %._crit_edge28
	movq	%r15, %rdi
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end4:
	.size	_Z4savePfiiPc, .Lfunc_end4-_Z4savePfiiPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z5printPfii                    # -- Begin function _Z5printPfii
	.type	_Z5printPfii,@function
_Z5printPfii:                           # @_Z5printPfii
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.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	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	movl	$.Lstr, %edi
	callq	puts@PLT
	testl	%ebp, %ebp
	jle	.LBB5_6
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebp, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%ebx, %r12d
	xorl	%r13d, %r13d
	xorl	%ebp, %ebp
.LBB5_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
	testl	%ebx, %ebx
	jle	.LBB5_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB5_2 Depth=1
	movl	%r13d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r15d, %r15d
.LBB5_4:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r15,4), %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r12
	jne	.LBB5_4
.LBB5_5:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%rbp
	addl	%ebx, %r13d
	cmpq	16(%rsp), %rbp                  # 8-byte Folded Reload
	jne	.LBB5_2
.LBB5_6:                                # %._crit_edge13
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z5printPfii, .Lfunc_end5-_Z5printPfii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI6_0:
	.long	0x3d000000                      # float 0.03125
	.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	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$3, %edi
	jne	.LBB6_4
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	movl	$.L.str.11, %esi
	callq	fopen
	movq	%rax, %r12
	movq	16(%rbx), %rdi
	movl	$.L.str.11, %esi
	callq	fopen
	movq	%rax, %rbx
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	leaq	12(%rsp), %r14
	movl	$.L.str.12, %esi
	movq	%r12, %rdi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	leaq	20(%rsp), %rdx
	movl	$.L.str.12, %esi
	movq	%r12, %rdi
	movq	%rdx, %r15
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	leaq	16(%rsp), %rdx
	movl	$.L.str.12, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	leaq	8(%rsp), %r13
	movl	$.L.str.12, %esi
	movq	%rbx, %rdi
	movq	%r13, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movslq	(%r14), %r14
	movl	(%r15), %ebp
	movl	%ebp, %eax
	imull	%r14d, %eax
	movslq	%eax, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %rbx
	leaq	16(%rsp), %rax
	movslq	(%rax), %rdi
	movslq	(%r13), %r15
	imulq	%r15, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %r13
	imulq	%r14, %r15
	shlq	$2, %r15
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%rbx, 24(%rsp)                  # 8-byte Spill
	movq	%rbx, %rdi
	movq	%r12, %rsi
	movl	%r14d, %edx
	movl	%ebp, %ecx
	callq	_Z4loadPfP8_IO_FILEii
	leaq	16(%rsp), %rbx
	movl	(%rbx), %edx
	leaq	8(%rsp), %rax
	movl	(%rax), %ecx
	movq	%r13, %rdi
	movq	32(%rsp), %rsi                  # 8-byte Reload
	callq	_Z4loadPfP8_IO_FILEii
	leaq	20(%rsp), %rax
	movl	(%rax), %ecx
	movl	$1, %eax
	cmpl	(%rbx), %ecx
	jne	.LBB6_11
# %bb.2:
	callq	clock
	movq	%rax, %rbx
	movl	12(%rsp), %esi
	movl	20(%rsp), %edx
	movl	16(%rsp), %r8d
	movl	8(%rsp), %r9d
	movq	%r15, (%rsp)
	movq	24(%rsp), %rdi                  # 8-byte Reload
	movq	%r13, %rcx
	callq	_Z7multCPUPfiiS_iiS_
	callq	clock
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	difftime
	movl	$.L.str.13, %edi
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movb	$1, %al
	callq	printf
	movslq	12(%rsp), %rbx
	movslq	8(%rsp), %rdi
	imulq	%rbx, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %r12
	movslq	20(%rsp), %rsi
	imulq	%rbx, %rsi
	shlq	$2, %rsi
	leaq	56(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB6_5
# %bb.3:
	movl	$.L.str.14, %edi
	jmp	.LBB6_9
.LBB6_4:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	jmp	.LBB6_10
.LBB6_5:
	movslq	16(%rsp), %rax
	movslq	8(%rsp), %rsi
	imulq	%rax, %rsi
	shlq	$2, %rsi
	leaq	48(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB6_7
# %bb.6:
	movl	$.L.str.15, %edi
	jmp	.LBB6_9
.LBB6_7:
	movslq	12(%rsp), %rax
	movslq	8(%rsp), %rsi
	imulq	%rax, %rsi
	shlq	$2, %rsi
	leaq	40(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB6_12
# %bb.8:
	movl	$.L.str.16, %edi
.LBB6_9:
	xorl	%eax, %eax
	callq	printf
.LBB6_10:
	movl	$1, %eax
.LBB6_11:
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB6_12:
	.cfi_def_cfa_offset 128
	movq	56(%rsp), %rdi
	movslq	12(%rsp), %rax
	movslq	20(%rsp), %rdx
	imulq	%rax, %rdx
	shlq	$2, %rdx
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	movq	48(%rsp), %rdi
	movslq	16(%rsp), %rax
	movslq	8(%rsp), %rdx
	imulq	%rax, %rdx
	shlq	$2, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	xorps	%xmm0, %xmm0
	cvtsi2ssl	8(%rsp), %xmm0
	mulss	.LCPI6_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %rbx
	xorps	%xmm0, %xmm0
	cvtsi2ssl	12(%rsp), %xmm0
	mulss	.LCPI6_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r14
	movl	%ebx, %eax
	shlq	$32, %r14
	orq	%rax, %r14
	callq	clock
	movq	%rax, %rbx
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movq	%r14, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB6_14
# %bb.13:
	movq	56(%rsp), %rdi
	movl	12(%rsp), %esi
	movl	20(%rsp), %edx
	movq	48(%rsp), %rcx
	movl	16(%rsp), %r8d
	movl	8(%rsp), %r9d
	movq	40(%rsp), %rax
	movq	%rax, (%rsp)
	callq	_Z22__device_stub__multGPUPfiiS_iiS_
.LBB6_14:
	callq	hipDeviceSynchronize
	callq	clock
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	difftime
	movl	$.L.str.17, %edi
	movsd	%xmm0, 64(%rsp)                 # 8-byte Spill
	movb	$1, %al
	callq	printf
	movq	40(%rsp), %rsi
	movslq	12(%rsp), %rax
	movslq	8(%rsp), %rdx
	imulq	%rax, %rdx
	shlq	$2, %rdx
	movq	%r12, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	12(%rsp), %eax
	testl	%eax, %eax
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	jle	.LBB6_22
# %bb.15:                               # %.preheader.lr.ph.i
	movl	8(%rsp), %ecx
	xorl	%edx, %edx
	xorl	%esi, %esi
	xorl	%edi, %edi
.LBB6_16:                               # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_18 Depth 2
	testl	%ecx, %ecx
	jle	.LBB6_20
# %bb.17:                               # %.lr.ph.i
                                        #   in Loop: Header=BB6_16 Depth=1
	movl	%edx, %r9d
	leaq	(%r15,%r9,4), %r8
	leaq	(%r12,%r9,4), %r9
	xorl	%r10d, %r10d
.LBB6_18:                               #   Parent Loop BB6_16 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%r9,%r10,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	ucomiss	(%r8,%r10,4), %xmm1
	jne	.LBB6_21
	jp	.LBB6_21
# %bb.19:                               #   in Loop: Header=BB6_18 Depth=2
	incq	%r10
	cmpq	%r10, %rcx
	jne	.LBB6_18
.LBB6_20:                               # %._crit_edge.i
                                        #   in Loop: Header=BB6_16 Depth=1
	incq	%rsi
	addl	%ecx, %edx
	cmpq	%rax, %rsi
	setae	%dil
	jne	.LBB6_16
.LBB6_21:                               # %_Z7comparePfS_ii.exit
	testb	$1, %dil
	je	.LBB6_23
.LBB6_22:                               # %_Z7comparePfS_ii.exit.thread
	divsd	64(%rsp), %xmm0                 # 8-byte Folded Reload
	movl	$.L.str.19, %edi
	movb	$1, %al
	callq	printf
	jmp	.LBB6_24
.LBB6_23:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
.LBB6_24:
	movq	24(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	jmp	.LBB6_11
.Lfunc_end6:
	.size	main, .Lfunc_end6-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	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7multGPUPfiiS_iiS_, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z7multGPUPfiiS_iiS_,@object    # @_Z7multGPUPfiiS_iiS_
	.section	.rodata,"a",@progbits
	.globl	_Z7multGPUPfiiS_iiS_
	.p2align	3, 0x0
_Z7multGPUPfiiS_iiS_:
	.quad	_Z22__device_stub__multGPUPfiiS_iiS_
	.size	_Z7multGPUPfiiS_iiS_, 8

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

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"w"
	.size	.L.str.1, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%d\n"
	.size	.L.str.2, 4

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"%.2f"
	.size	.L.str.3, 5

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%.2f,"
	.size	.L.str.4, 6

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.zero	1
	.size	.L.str.6, 1

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"%f "
	.size	.L.str.8, 4

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"r"
	.size	.L.str.11, 2

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

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Elasped time in CPU: %.2lf seconds.\n"
	.size	.L.str.13, 37

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Error al asignar memoria a d_A"
	.size	.L.str.14, 31

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Error al asignar memoria a d_B"
	.size	.L.str.15, 31

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Error al asignar memoria a d_C"
	.size	.L.str.16, 31

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Tiempo trasncurrido en GPU: %.2lf seconds.\n"
	.size	.L.str.17, 44

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"tiempo acelerado: %lf\n"
	.size	.L.str.19, 23

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7multGPUPfiiS_iiS_"
	.size	.L__unnamed_1, 21

	.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	"---------------print matrix--------------"
	.size	.Lstr, 42

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Error al multiplicar"
	.size	.Lstr.1, 21

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Must be called with the names of the files"
	.size	.Lstr.2, 43

	.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 _Z22__device_stub__multGPUPfiiS_iiS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z7multGPUPfiiS_iiS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7multGPUPfiiS_iiS_    ; -- Begin function _Z7multGPUPfiiS_iiS_
	.globl	_Z7multGPUPfiiS_iiS_
	.p2align	8
	.type	_Z7multGPUPfiiS_iiS_,@function
_Z7multGPUPfiiS_iiS_:                   ; @_Z7multGPUPfiiS_iiS_
; %bb.0:
	s_clause 0x2
	s_load_b32 s6, s[0:1], 0x34
	s_load_b64 s[4:5], s[0:1], 0x18
	s_load_b64 s[2:3], s[0:1], 0x8
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s7, s6, 16
	s_and_b32 s6, s6, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s6, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s7, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s5, v0
	v_cmp_gt_i32_e64 s2, s2, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s2, vcc_lo
	s_cmp_gt_i32 s4, 0
	s_cselect_b32 s6, -1, 0
	s_and_b32 s2, s2, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s6, s2
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.lr.ph
	s_load_b64 s[6:7], s[0:1], 0x20
	v_mad_u64_u32 v[2:3], null, v1, s5, v[0:1]
	v_mul_lo_u32 v4, v1, s3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v3, 31, v2
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v2, vcc_lo, s6, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo
	s_clause 0x1
	s_load_b64 s[6:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	global_load_b32 v6, v[2:3], off
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v4, vcc_lo, s6, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v5, vcc_lo
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v1, 31, v0
	s_add_i32 s4, s4, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_lg_u32 s4, 0
	v_lshlrev_b64 v[7:8], 2, v[0:1]
	v_add_nc_u32_e32 v0, s5, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v7, vcc_lo, s0, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s1, v8, vcc_lo
	global_load_b32 v1, v[4:5], off
	global_load_b32 v7, v[7:8], off
	v_add_co_u32 v4, vcc_lo, v4, 4
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v6, v1, v7
	global_store_b32 v[2:3], v6, off
	s_cbranch_scc1 .LBB0_2
.LBB0_3:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7multGPUPfiiS_iiS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 9
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z7multGPUPfiiS_iiS_, .Lfunc_end0-_Z7multGPUPfiiS_iiS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 352
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7multGPUPfiiS_iiS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7multGPUPfiiS_iiS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
