#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;

//matrix structure
typedef struct {
	int n;
	int *el;
} Matrix;


//KERNEL
// D = AxB
__global__ void calcD(int n, Matrix D, Matrix A, Matrix B, Matrix C)
{
	int Cv = 0;
	int row = blockIdx.y * blockDim.y + threadIdx.y;
	int col = blockIdx.x * blockDim.x + threadIdx.x;
	for (int e=0; e<n; ++e)
		Cv+=A.el[row*n+e] * B.el[e*n+col];	//calculate one value
	D.el[row*n+col]=Cv+C.el[row*n+col];		//add value from C and write to D
}

//HOST CODE
int main(int argc, char* argv[])
{
	if (argc<2) {
		cout << "Input file not specified. Please, specify it as a first argument." << endl;
		cout << "example: " << argv[0] << " matr.txt" << endl;
		return -1;
	} 	
	ifstream file(argv[1]);
	ofstream output("output.txt");

	if (!file)
	{
		cout << "Error opening file" << endl;
		return -1;
	}

	int n;
	file >> n;			//size N
	if (argc>2) cout << "N=" << n << endl;

	Matrix A, B, C, D;	//host matrices
	A.el = new int[n*n];	//....	
	B.el = new int[n*n];	//...
	C.el = new int[n*n];	//..
	D.el = new int[n*n];	//.

	//reading from file into matrices
	for (int i=0; i<(n*n); i++)
		file >> A.el[i];
	for (int i=0; i<n*n; i++)
		file >> B.el[i];
	for (int i=0; i<n*n; i++)
		file >> C.el[i];

	//preparing for the device
	Matrix d_A;
	d_A.n=n;
	size_t size = n*n*sizeof(int);
	cudaMalloc(&d_A.el, size);		//allocate memory for A
	cudaMemcpy(d_A.el, A.el, size, cudaMemcpyHostToDevice);	//copy A to deviceA (d_A)
	
	Matrix d_B;
	d_B.n=n;
	cudaMalloc(&d_B.el, size);		//same for B
	cudaMemcpy(d_B.el, B.el, size, cudaMemcpyHostToDevice);

	Matrix d_C;
	d_C.n=n;
	cudaMalloc(&d_C.el, size);		//same for C
	cudaMemcpy(d_C.el, C.el, size, cudaMemcpyHostToDevice);

	Matrix d_D;				//resulting matrix D
	d_D.n=n;
	size = n*n*sizeof(int);
	cudaMalloc(&d_D.el, size);		//only allocate memory
	
	//kernel call
	dim3 dimBlock(n,n);	// USING ONE BLOCK
	dim3 dimGrid(1,1);	// WITH NxN THREADS
	calcD<<<dimGrid, dimBlock>>>(n, d_D, d_A, d_B, d_C);

	//read matrix E back
	cudaMemcpy(D.el, d_D.el, size, cudaMemcpyDeviceToHost);

	//write output to file
	output << "Matrix D:" << endl;
	for (int i=0; i<n; i++)	{
		for (int j=0; j<n; j++)	
			output << D.el[(i*n+j)] << " ";
		output << endl;
	}
	
	//print out resulting matrix D if second argument was present
	if (argc>2) {
		cout << endl << "Matrix D:" << endl;
		for (int i=0; i<n; i++)	{
			for (int j=0; j<n; j++)	
				cout << D.el[(i*n+j)] << " ";
			cout << endl;
		}
	}
	
	//free the memory on device
	cudaFree(d_A.el);
	cudaFree(d_B.el);
	cudaFree(d_C.el);
	cudaFree(d_D.el);
	//free the memory on host
	delete[] A.el;
	delete[] B.el;
	delete[] C.el;
	delete[] D.el;
	file.close();
	output.close();
	cout << endl << "Done. " << endl;
	return 0;
}
	.file	"tmpxft_003731e4_00000000-6_matradd.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3769:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3769:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z36__device_stub__Z5calcDi6MatrixS_S_S_iR6MatrixS0_S0_S0_
	.type	_Z36__device_stub__Z5calcDi6MatrixS_S_S_iR6MatrixS0_S0_S0_, @function
_Z36__device_stub__Z5calcDi6MatrixS_S_S_iR6MatrixS0_S0_S0_:
.LFB3791:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movl	%edi, 12(%rsp)
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rax
	movq	%rsi, 88(%rsp)
	leaq	44(%rsp), %rsi
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rdx, 96(%rsp)
	leaq	16(%rsp), %rdx
	movq	%rcx, 104(%rsp)
	leaq	24(%rsp), %rcx
	movq	%r8, 112(%rsp)
	movq	%rax, 32(%rsp)
	movl	$1, 40(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	24(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z5calcDi6MatrixS_S_S_(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 160
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L2:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3791:
	.size	_Z36__device_stub__Z5calcDi6MatrixS_S_S_iR6MatrixS0_S0_S0_, .-_Z36__device_stub__Z5calcDi6MatrixS_S_S_iR6MatrixS0_S0_S0_
	.globl	_Z5calcDi6MatrixS_S_S_
	.type	_Z5calcDi6MatrixS_S_S_, @function
_Z5calcDi6MatrixS_S_S_:
.LFB3792:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	%rsi, 16(%rsp)
	leaq	16(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	movq	%rsp, %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%r8, 8(%rsp)
	leaq	64(%rsp), %r8
	call	_Z36__device_stub__Z5calcDi6MatrixS_S_S_iR6MatrixS0_S0_S0_
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3792:
	.size	_Z5calcDi6MatrixS_S_S_, .-_Z5calcDi6MatrixS_S_S_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z5calcDi6MatrixS_S_S_"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3794:
	.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	.LC0(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z5calcDi6MatrixS_S_S_(%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
.LFE3794:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC1:
	.string	"Input file not specified. Please, specify it as a first argument."
.LC2:
	.string	"example: "
.LC3:
	.string	" matr.txt"
.LC4:
	.string	"output.txt"
.LC5:
	.string	"Error opening file"
.LC6:
	.string	"N="
.LC7:
	.string	"Matrix D:"
.LC8:
	.string	" "
.LC9:
	.string	"Done. "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3766:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3766
	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
	movq	%rsi, %rbx
	subq	$1240, %rsp
	.cfi_def_cfa_offset 1296
	movq	%fs:40, %rax
	movq	%rax, 1224(%rsp)
	xorl	%eax, %eax
	cmpl	$1, %edi
	jg	.L12
	leaq	_ZSt4cout(%rip), %rbp
	leaq	.LC1(%rip), %rsi
	movq	%rbp, %rdi
.LEHB0:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	(%rbx), %rsi
	orl	$-1, %ebx
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	jmp	.L11
.L12:
	leaq	704(%rsp), %rax
	movq	8(%rsi), %rsi
	movl	$8, %edx
	movl	%edi, %r13d
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE0:
	leaq	192(%rsp), %rax
	movl	$16, %edx
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
.LEHB1:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE1:
	movl	992(%rsp), %ebx
	andl	$5, %ebx
	je	.L14
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
.LEHB2:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	orl	$-1, %ebx
	jmp	.L15
.L14:
	movq	(%rsp), %rdi
	leaq	36(%rsp), %rsi
	call	_ZNSirsERi@PLT
	cmpl	$2, %r13d
	jne	.L16
.L18:
	movl	36(%rsp), %edi
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	_Znam@PLT
	movl	36(%rsp), %edi
	movq	%rax, %r12
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	_Znam@PLT
	jmp	.L53
.L16:
	leaq	.LC6(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	36(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	jmp	.L18
.L53:
	movl	36(%rsp), %edi
	movq	%rax, 16(%rsp)
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	_Znam@PLT
	movl	36(%rsp), %edi
	movq	%rax, 24(%rsp)
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	_Znam@PLT
	movq	%rax, %rbp
	movq	%r12, %r15
	xorl	%r14d, %r14d
.L19:
	movl	36(%rsp), %eax
	imull	%eax, %eax
	cmpl	%r14d, %eax
	jle	.L54
	movq	(%rsp), %rdi
	movq	%r15, %rsi
	call	_ZNSirsERi@PLT
	incl	%r14d
	addq	$4, %r15
	jmp	.L19
.L54:
	movq	16(%rsp), %r15
	xorl	%r14d, %r14d
.L21:
	movl	36(%rsp), %eax
	imull	%eax, %eax
	cmpl	%r14d, %eax
	jle	.L55
	movq	(%rsp), %rdi
	movq	%r15, %rsi
	call	_ZNSirsERi@PLT
	incl	%r14d
	addq	$4, %r15
	jmp	.L21
.L55:
	movq	24(%rsp), %r15
	xorl	%r14d, %r14d
.L23:
	movl	36(%rsp), %edx
	movl	%edx, %eax
	imull	%edx, %eax
	cmpl	%r14d, %eax
	jle	.L56
	movq	(%rsp), %rdi
	movq	%r15, %rsi
	call	_ZNSirsERi@PLT
	incl	%r14d
	addq	$4, %r15
	jmp	.L23
.L56:
	cltq
	leaq	72(%rsp), %rdi
	movl	%edx, 64(%rsp)
	leaq	0(,%rax,4), %r14
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movl	36(%rsp), %eax
	leaq	88(%rsp), %rdi
	movq	%r14, %rsi
	movl	%eax, 80(%rsp)
	call	cudaMalloc@PLT
	movq	16(%rsp), %rsi
	movq	88(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	movl	36(%rsp), %eax
	leaq	104(%rsp), %rdi
	movq	%r14, %rsi
	movl	%eax, 96(%rsp)
	call	cudaMalloc@PLT
	movq	24(%rsp), %rsi
	movq	104(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rdx
	call	cudaMemcpy@PLT
	movl	36(%rsp), %eax
	leaq	120(%rsp), %rdi
	movl	%eax, 112(%rsp)
	imull	%eax, %eax
	cltq
	leaq	0(,%rax,4), %r14
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	movl	36(%rsp), %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movl	%eax, 40(%rsp)
	movl	%eax, 44(%rsp)
	movq	40(%rsp), %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	movups	112(%rsp), %xmm0
	movups	64(%rsp), %xmm1
	leaq	160(%rsp), %rcx
	leaq	144(%rsp), %rdx
	movups	80(%rsp), %xmm2
	movups	96(%rsp), %xmm3
	leaq	128(%rsp), %rsi
	leaq	176(%rsp), %r8
	movl	36(%rsp), %edi
	movups	%xmm0, 128(%rsp)
	movups	%xmm1, 144(%rsp)
	movups	%xmm2, 160(%rsp)
	movups	%xmm3, 176(%rsp)
	call	_Z36__device_stub__Z5calcDi6MatrixS_S_S_iR6MatrixS0_S0_S0_
.L25:
	movq	120(%rsp), %rsi
	movl	$2, %ecx
	movq	%r14, %rdx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	leaq	.LC7(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	xorl	%r14d, %r14d
.L26:
	cmpl	%r14d, 36(%rsp)
	jle	.L57
	xorl	%r15d, %r15d
.L28:
	movl	36(%rsp), %eax
	cmpl	%r15d, %eax
	jle	.L58
	imull	%r14d, %eax
	movq	8(%rsp), %rdi
	addl	%r15d, %eax
	cltq
	movl	0(%rbp,%rax,4), %esi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	leaq	.LC8(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incl	%r15d
	jmp	.L28
.L58:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	8(%rsp), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	incl	%r14d
	jmp	.L26
.L57:
	cmpl	$2, %r13d
	je	.L29
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movq	%rax, %rdi
	leaq	.LC7(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	xorl	%r13d, %r13d
	leaq	.LC8(%rip), %r15
.L30:
	cmpl	%r13d, 36(%rsp)
	jle	.L29
	xorl	%r14d, %r14d
.L32:
	movl	36(%rsp), %eax
	cmpl	%r14d, %eax
	jle	.L59
	imull	%r13d, %eax
	leaq	_ZSt4cout(%rip), %rdi
	addl	%r14d, %eax
	cltq
	movl	0(%rbp,%rax,4), %esi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movq	%r15, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incl	%r14d
	jmp	.L32
.L59:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	incl	%r13d
	jmp	.L30
.L29:
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	104(%rsp), %rdi
	call	cudaFree@PLT
	movq	120(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r12, %rdi
	call	_ZdaPv@PLT
	movq	16(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	24(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	leaq	704(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
	leaq	192(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movq	%rax, %rdi
	leaq	.LC9(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
.LEHE2:
.L15:
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L11
.L43:
	endbr64
	movq	%rax, %rbx
.L33:
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L34
.L42:
	endbr64
	movq	%rax, %rbx
.L34:
	movq	(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	1224(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L52
	movq	%rbx, %rdi
.LEHB3:
	call	_Unwind_Resume@PLT
.LEHE3:
.L11:
	movq	1224(%rsp), %rax
	subq	%fs:40, %rax
	je	.L36
.L52:
	call	__stack_chk_fail@PLT
.L36:
	addq	$1240, %rsp
	.cfi_def_cfa_offset 56
	movl	%ebx, %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
.LFE3766:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3766:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3766-.LLSDACSB3766
.LLSDACSB3766:
	.uleb128 .LEHB0-.LFB3766
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3766
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L42-.LFB3766
	.uleb128 0
	.uleb128 .LEHB2-.LFB3766
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L43-.LFB3766
	.uleb128 0
	.uleb128 .LEHB3-.LFB3766
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
.LLSDACSE3766:
	.section	.text.startup
	.size	main, .-main
	.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
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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 <fstream>
#include <iostream>
using namespace std;

//matrix structure
typedef struct {
	int n;
	int *el;
} Matrix;


//KERNEL
// D = AxB
__global__ void calcD(int n, Matrix D, Matrix A, Matrix B, Matrix C)
{
	int Cv = 0;
	int row = blockIdx.y * blockDim.y + threadIdx.y;
	int col = blockIdx.x * blockDim.x + threadIdx.x;
	for (int e=0; e<n; ++e)
		Cv+=A.el[row*n+e] * B.el[e*n+col];	//calculate one value
	D.el[row*n+col]=Cv+C.el[row*n+col];		//add value from C and write to D
}

//HOST CODE
int main(int argc, char* argv[])
{
	if (argc<2) {
		cout << "Input file not specified. Please, specify it as a first argument." << endl;
		cout << "example: " << argv[0] << " matr.txt" << endl;
		return -1;
	} 	
	ifstream file(argv[1]);
	ofstream output("output.txt");

	if (!file)
	{
		cout << "Error opening file" << endl;
		return -1;
	}

	int n;
	file >> n;			//size N
	if (argc>2) cout << "N=" << n << endl;

	Matrix A, B, C, D;	//host matrices
	A.el = new int[n*n];	//....	
	B.el = new int[n*n];	//...
	C.el = new int[n*n];	//..
	D.el = new int[n*n];	//.

	//reading from file into matrices
	for (int i=0; i<(n*n); i++)
		file >> A.el[i];
	for (int i=0; i<n*n; i++)
		file >> B.el[i];
	for (int i=0; i<n*n; i++)
		file >> C.el[i];

	//preparing for the device
	Matrix d_A;
	d_A.n=n;
	size_t size = n*n*sizeof(int);
	hipMalloc(&d_A.el, size);		//allocate memory for A
	hipMemcpy(d_A.el, A.el, size, hipMemcpyHostToDevice);	//copy A to deviceA (d_A)
	
	Matrix d_B;
	d_B.n=n;
	hipMalloc(&d_B.el, size);		//same for B
	hipMemcpy(d_B.el, B.el, size, hipMemcpyHostToDevice);

	Matrix d_C;
	d_C.n=n;
	hipMalloc(&d_C.el, size);		//same for C
	hipMemcpy(d_C.el, C.el, size, hipMemcpyHostToDevice);

	Matrix d_D;				//resulting matrix D
	d_D.n=n;
	size = n*n*sizeof(int);
	hipMalloc(&d_D.el, size);		//only allocate memory
	
	//kernel call
	dim3 dimBlock(n,n);	// USING ONE BLOCK
	dim3 dimGrid(1,1);	// WITH NxN THREADS
	calcD<<<dimGrid, dimBlock>>>(n, d_D, d_A, d_B, d_C);

	//read matrix E back
	hipMemcpy(D.el, d_D.el, size, hipMemcpyDeviceToHost);

	//write output to file
	output << "Matrix D:" << endl;
	for (int i=0; i<n; i++)	{
		for (int j=0; j<n; j++)	
			output << D.el[(i*n+j)] << " ";
		output << endl;
	}
	
	//print out resulting matrix D if second argument was present
	if (argc>2) {
		cout << endl << "Matrix D:" << endl;
		for (int i=0; i<n; i++)	{
			for (int j=0; j<n; j++)	
				cout << D.el[(i*n+j)] << " ";
			cout << endl;
		}
	}
	
	//free the memory on device
	hipFree(d_A.el);
	hipFree(d_B.el);
	hipFree(d_C.el);
	hipFree(d_D.el);
	//free the memory on host
	delete[] A.el;
	delete[] B.el;
	delete[] C.el;
	delete[] D.el;
	file.close();
	output.close();
	cout << endl << "Done. " << endl;
	return 0;
}
	.text
	.file	"matradd.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z20__device_stub__calcDi6MatrixS_S_S_ # -- Begin function _Z20__device_stub__calcDi6MatrixS_S_S_
	.type	_Z20__device_stub__calcDi6MatrixS_S_S_,@function
_Z20__device_stub__calcDi6MatrixS_S_S_: # @_Z20__device_stub__calcDi6MatrixS_S_S_
	.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	80(%rsp), %rax
	movl	%esi, (%rax)
	movq	%rdx, 8(%rax)
	leaq	64(%rsp), %rdx
	movl	%ecx, (%rdx)
	movq	%r8, 8(%rdx)
	leaq	12(%rsp), %rcx
	movl	%edi, (%rcx)
	leaq	96(%rsp), %rbx
	movq	%rcx, (%rbx)
	movq	%rax, 8(%rbx)
	movq	%rdx, 16(%rbx)
	leaq	192(%rsp), %rax
	movq	%rax, 24(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 32(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%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	$_Z5calcDi6MatrixS_S_S_, %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	_Z20__device_stub__calcDi6MatrixS_S_S_, .Lfunc_end0-_Z20__device_stub__calcDi6MatrixS_S_S_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$1160, %rsp                     # imm = 0x488
	.cfi_def_cfa_offset 1216
	.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, %rbx
	cmpl	$1, %edi
	jg	.LBB1_5
# %bb.1:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$65, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %rbx
	testq	%rbx, %rbx
	je	.LBB1_2
# %bb.3:
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB1_4
.LBB1_5:
	movl	%edi, %ebp
	movq	8(%rbx), %rsi
	leaq	640(%rsp), %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
.Ltmp0:
	leaq	128(%rsp), %rdi
	movl	$.L.str.3, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
.Ltmp1:
# %bb.6:
	movq	640(%rsp), %rax
	movq	-24(%rax), %rax
	testb	$5, 672(%rsp,%rax)
	je	.LBB1_14
# %bb.7:
.Ltmp3:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$18, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp4:
# %bb.8:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit102
	movq	_ZSt4cout(%rip), %rax
	addq	-24(%rax), %rbx
.Ltmp5:
	movq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp6:
# %bb.9:                                # %.noexc
.Ltmp7:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp8:
# %bb.10:                               # %.noexc120
	movl	$-1, %ebx
.Ltmp9:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp10:
	jmp	.LBB1_11
.LBB1_2:
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cout(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB1_4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$-1, %ebx
	jmp	.LBB1_12
.LBB1_14:
.Ltmp12:
	leaq	640(%rsp), %rdi
	leaq	36(%rsp), %rsi
	callq	_ZNSirsERi
.Ltmp13:
# %bb.15:
	cmpl	$2, %ebp
	je	.LBB1_21
# %bb.16:
.Ltmp14:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$2, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp15:
# %bb.17:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit103
	movl	36(%rsp), %esi
.Ltmp16:
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
.Ltmp17:
# %bb.18:
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp18:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp19:
# %bb.19:                               # %.noexc122
.Ltmp20:
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
.Ltmp21:
# %bb.20:                               # %.noexc123
.Ltmp22:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp23:
.LBB1_21:                               # %_ZNSolsEPFRSoS_E.exit104
	movl	36(%rsp), %r14d
	movl	%r14d, %r12d
	imull	%r12d, %r12d
	shlq	$2, %r12
.Ltmp25:
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, 48(%rsp)                  # 8-byte Spill
.Ltmp26:
# %bb.22:
.Ltmp27:
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, 40(%rsp)                  # 8-byte Spill
.Ltmp28:
# %bb.23:
.Ltmp29:
	movq	%r12, %rdi
	callq	_Znam
.Ltmp30:
# %bb.24:
.Ltmp31:
	movq	%rax, %rbx
	movq	%r12, %rdi
	callq	_Znam
.Ltmp32:
# %bb.25:                               # %.preheader160
	movq	%rax, %r12
	movq	%rbx, 56(%rsp)                  # 8-byte Spill
	testl	%r14d, %r14d
	je	.LBB1_26
# %bb.95:                               # %.lr.ph.preheader
	xorl	%ebx, %ebx
	leaq	640(%rsp), %r14
	movq	48(%rsp), %r15                  # 8-byte Reload
.LBB1_96:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
.Ltmp34:
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_ZNSirsERi
.Ltmp35:
# %bb.97:                               #   in Loop: Header=BB1_96 Depth=1
	incq	%rbx
	movl	36(%rsp), %eax
	movl	%eax, %ecx
	imull	%ecx, %ecx
	addq	$4, %r15
	cmpq	%rcx, %rbx
	jb	.LBB1_96
# %bb.27:                               # %.preheader159
	testl	%eax, %eax
	je	.LBB1_26
# %bb.28:                               # %.lr.ph166.preheader
	xorl	%ebx, %ebx
	leaq	640(%rsp), %r14
	movq	40(%rsp), %r15                  # 8-byte Reload
.LBB1_29:                               # %.lr.ph166
                                        # =>This Inner Loop Header: Depth=1
.Ltmp37:
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_ZNSirsERi
.Ltmp38:
# %bb.30:                               #   in Loop: Header=BB1_29 Depth=1
	incq	%rbx
	movl	36(%rsp), %eax
	movl	%eax, %ecx
	imull	%ecx, %ecx
	addq	$4, %r15
	cmpq	%rcx, %rbx
	jb	.LBB1_29
# %bb.31:                               # %.preheader158
	testl	%eax, %eax
	je	.LBB1_26
# %bb.32:                               # %.lr.ph168.preheader
	xorl	%ebx, %ebx
	leaq	640(%rsp), %r15
	movq	56(%rsp), %r14                  # 8-byte Reload
.LBB1_33:                               # %.lr.ph168
                                        # =>This Inner Loop Header: Depth=1
.Ltmp40:
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_ZNSirsERi
.Ltmp41:
# %bb.34:                               #   in Loop: Header=BB1_33 Depth=1
	incq	%rbx
	movl	36(%rsp), %eax
	movl	%eax, %r13d
	imull	%r13d, %r13d
	addq	$4, %r14
	cmpq	%r13, %rbx
	jb	.LBB1_33
	jmp	.LBB1_35
.LBB1_26:
	xorl	%r13d, %r13d
	xorl	%eax, %eax
.LBB1_35:                               # %._crit_edge
	leaq	88(%rsp), %rdi
	movl	%eax, -8(%rdi)
	shlq	$2, %r13
.Ltmp43:
	movq	%r13, %rsi
	callq	hipMalloc
.Ltmp44:
# %bb.36:                               # %_ZL9hipMallocIiE10hipError_tPPT_m.exit
	movq	88(%rsp), %rdi
.Ltmp45:
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp46:
# %bb.37:
	movl	36(%rsp), %eax
	leaq	120(%rsp), %rdi
	movl	%eax, -8(%rdi)
.Ltmp48:
	movq	%r13, %rsi
	callq	hipMalloc
.Ltmp49:
	movq	56(%rsp), %rbx                  # 8-byte Reload
# %bb.38:                               # %_ZL9hipMallocIiE10hipError_tPPT_m.exit105
	movq	120(%rsp), %rdi
.Ltmp50:
	movq	40(%rsp), %rsi                  # 8-byte Reload
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp51:
# %bb.39:
	movl	36(%rsp), %eax
	leaq	104(%rsp), %rdi
	movl	%eax, -8(%rdi)
.Ltmp53:
	movq	%r13, %rsi
	callq	hipMalloc
.Ltmp54:
# %bb.40:                               # %_ZL9hipMallocIiE10hipError_tPPT_m.exit106
	movq	104(%rsp), %rdi
.Ltmp55:
	movq	%rbx, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp56:
# %bb.41:
	movl	36(%rsp), %r13d
	leaq	72(%rsp), %rdi
	movl	%r13d, -8(%rdi)
	imull	%r13d, %r13d
	shlq	$2, %r13
.Ltmp58:
	movq	%r13, %rsi
	callq	hipMalloc
.Ltmp59:
# %bb.42:                               # %_ZL9hipMallocIiE10hipError_tPPT_m.exit107
	movl	36(%rsp), %eax
	movq	%rax, %rdx
	shlq	$32, %rdx
	orq	%rax, %rdx
.Ltmp61:
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp62:
# %bb.43:
	testl	%eax, %eax
	jne	.LBB1_45
# %bb.44:
	movl	36(%rsp), %edi
	movl	64(%rsp), %esi
	movq	72(%rsp), %rdx
	movl	80(%rsp), %ecx
	movq	88(%rsp), %r8
.Ltmp63:
	movups	96(%rsp), %xmm0
	movups	%xmm0, 16(%rsp)
	movups	112(%rsp), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z20__device_stub__calcDi6MatrixS_S_S_
.Ltmp64:
.LBB1_45:
	movq	72(%rsp), %rsi
.Ltmp65:
	movq	%r12, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp66:
# %bb.46:
.Ltmp67:
	leaq	128(%rsp), %r14
	movl	$.L.str.6, %esi
	movl	$9, %edx
	movq	%r14, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp68:
# %bb.47:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit108
	movq	128(%rsp), %rax
	addq	-24(%rax), %r14
.Ltmp69:
	movq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp70:
# %bb.48:                               # %.noexc126
.Ltmp71:
	movsbl	%al, %esi
	leaq	128(%rsp), %r13
	movq	%r13, %rdi
	callq	_ZNSo3putEc
.Ltmp72:
# %bb.49:                               # %.noexc127
.Ltmp73:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp74:
# %bb.50:                               # %_ZNSolsEPFRSoS_E.exit109.preheader
	movl	36(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB1_61
# %bb.51:                               # %.preheader157.preheader
	xorl	%r14d, %r14d
.LBB1_52:                               # %.preheader157
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_54 Depth 2
	testl	%eax, %eax
	jle	.LBB1_57
# %bb.53:                               # %.lr.ph171.preheader
                                        #   in Loop: Header=BB1_52 Depth=1
	xorl	%r15d, %r15d
.LBB1_54:                               # %.lr.ph171
                                        #   Parent Loop BB1_52 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	imull	%r14d, %eax
	cltq
	addq	%r15, %rax
	movl	(%r12,%rax,4), %esi
.Ltmp75:
	movq	%r13, %rdi
	callq	_ZNSolsEi
.Ltmp76:
# %bb.55:                               #   in Loop: Header=BB1_54 Depth=2
.Ltmp77:
	movl	$.L.str.7, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp78:
# %bb.56:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit111
                                        #   in Loop: Header=BB1_54 Depth=2
	movl	36(%rsp), %eax
	incq	%r15
	cmpl	%eax, %r15d
	jl	.LBB1_54
.LBB1_57:                               # %._crit_edge172
                                        #   in Loop: Header=BB1_52 Depth=1
	movq	128(%rsp), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
.Ltmp80:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp81:
# %bb.58:                               # %.noexc130
                                        #   in Loop: Header=BB1_52 Depth=1
.Ltmp82:
	movsbl	%al, %esi
	movq	%r13, %rdi
	callq	_ZNSo3putEc
.Ltmp83:
# %bb.59:                               # %.noexc131
                                        #   in Loop: Header=BB1_52 Depth=1
.Ltmp84:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp85:
# %bb.60:                               # %_ZNSolsEPFRSoS_E.exit110
                                        #   in Loop: Header=BB1_52 Depth=1
	incl	%r14d
	movl	36(%rsp), %eax
	cmpl	%eax, %r14d
	jl	.LBB1_52
.LBB1_61:                               # %_ZNSolsEPFRSoS_E.exit109._crit_edge
	cmpl	$2, %ebp
	je	.LBB1_80
# %bb.62:
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %edi
	addq	-24(%rax), %rdi
.Ltmp87:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp88:
# %bb.63:                               # %.noexc134
.Ltmp89:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp90:
# %bb.64:                               # %.noexc135
.Ltmp91:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp92:
# %bb.65:                               # %_ZNSolsEPFRSoS_E.exit112
.Ltmp93:
	movq	%rax, %r13
	movl	$.L.str.6, %esi
	movl	$9, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp94:
# %bb.66:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit113
	movq	(%r13), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
.Ltmp95:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp96:
# %bb.67:                               # %.noexc138
.Ltmp97:
	movsbl	%al, %esi
	movq	%r13, %rdi
	callq	_ZNSo3putEc
.Ltmp98:
# %bb.68:                               # %.noexc139
.Ltmp99:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp100:
# %bb.69:                               # %_ZNSolsEPFRSoS_E.exit114.preheader
	movl	36(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB1_80
# %bb.70:                               # %.preheader.preheader
	xorl	%r14d, %r14d
	movl	$_ZSt4cout, %r15d
.LBB1_71:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_73 Depth 2
	testl	%eax, %eax
	jle	.LBB1_76
# %bb.72:                               # %.lr.ph175.preheader
                                        #   in Loop: Header=BB1_71 Depth=1
	xorl	%r13d, %r13d
.LBB1_73:                               # %.lr.ph175
                                        #   Parent Loop BB1_71 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	imull	%r14d, %eax
	cltq
	addq	%r13, %rax
	movl	(%r12,%rax,4), %esi
.Ltmp101:
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
.Ltmp102:
# %bb.74:                               #   in Loop: Header=BB1_73 Depth=2
.Ltmp103:
	movl	$.L.str.7, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp104:
# %bb.75:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit116
                                        #   in Loop: Header=BB1_73 Depth=2
	movl	36(%rsp), %eax
	incq	%r13
	cmpl	%eax, %r13d
	jl	.LBB1_73
.LBB1_76:                               # %._crit_edge176
                                        #   in Loop: Header=BB1_71 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
.Ltmp106:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp107:
# %bb.77:                               # %.noexc142
                                        #   in Loop: Header=BB1_71 Depth=1
.Ltmp108:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp109:
# %bb.78:                               # %.noexc143
                                        #   in Loop: Header=BB1_71 Depth=1
.Ltmp110:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp111:
# %bb.79:                               # %_ZNSolsEPFRSoS_E.exit115
                                        #   in Loop: Header=BB1_71 Depth=1
	incl	%r14d
	movl	36(%rsp), %eax
	cmpl	%eax, %r14d
	jl	.LBB1_71
.LBB1_80:                               # %.loopexit
	movq	88(%rsp), %rdi
.Ltmp113:
	callq	hipFree
.Ltmp114:
# %bb.81:
	movq	120(%rsp), %rdi
.Ltmp115:
	callq	hipFree
.Ltmp116:
# %bb.82:
	movq	104(%rsp), %rdi
.Ltmp117:
	callq	hipFree
.Ltmp118:
# %bb.83:
	movq	72(%rsp), %rdi
.Ltmp119:
	callq	hipFree
.Ltmp120:
# %bb.84:
	movq	48(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	40(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	%rbx, %rdi
	callq	_ZdaPv
	movq	%r12, %rdi
	callq	_ZdaPv
.Ltmp121:
	leaq	640(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp122:
# %bb.85:
.Ltmp123:
	leaq	128(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp124:
# %bb.86:
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %edi
	addq	-24(%rax), %rdi
.Ltmp125:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp126:
# %bb.87:                               # %.noexc146
.Ltmp127:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp128:
# %bb.88:                               # %.noexc147
.Ltmp129:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp130:
# %bb.89:                               # %_ZNSolsEPFRSoS_E.exit117
.Ltmp131:
	movq	%rax, %rbx
	movl	$.L.str.8, %esi
	movl	$6, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp132:
# %bb.90:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit118
	movq	(%rbx), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp133:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp134:
# %bb.91:                               # %.noexc150
.Ltmp135:
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
.Ltmp136:
# %bb.92:                               # %.noexc151
.Ltmp137:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp138:
# %bb.93:                               # %_ZNSolsEPFRSoS_E.exit119
	xorl	%ebx, %ebx
.LBB1_11:                               # %_ZNSolsEPFRSoS_E.exit
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	136(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 128(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	376(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	640(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
.LBB1_12:
	movl	%ebx, %eax
	addq	$1160, %rsp                     # imm = 0x488
	.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_104:
	.cfi_def_cfa_offset 1216
.Ltmp60:
	jmp	.LBB1_107
.LBB1_103:
.Ltmp57:
	jmp	.LBB1_107
.LBB1_102:
.Ltmp52:
	jmp	.LBB1_107
.LBB1_101:
.Ltmp47:
	jmp	.LBB1_107
.LBB1_13:
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB1_108
.LBB1_109:
.Ltmp24:
	jmp	.LBB1_107
.LBB1_94:
.Ltmp33:
	jmp	.LBB1_107
.LBB1_106:
.Ltmp11:
	jmp	.LBB1_107
.LBB1_100:
.Ltmp42:
	jmp	.LBB1_107
.LBB1_99:
.Ltmp39:
	jmp	.LBB1_107
.LBB1_98:
.Ltmp36:
	jmp	.LBB1_107
.LBB1_105:
.Ltmp139:
	jmp	.LBB1_107
.LBB1_113:
.Ltmp112:
	jmp	.LBB1_107
.LBB1_111:
.Ltmp86:
	jmp	.LBB1_107
.LBB1_112:
.Ltmp105:
	jmp	.LBB1_107
.LBB1_110:
.Ltmp79:
.LBB1_107:
	movq	%rax, %rbx
	leaq	128(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
.LBB1_108:
	leaq	640(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp10-.Ltmp3                 #   Call between .Ltmp3 and .Ltmp10
	.uleb128 .Ltmp11-.Lfunc_begin0          #     jumps to .Ltmp11
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp12-.Ltmp10                #   Call between .Ltmp10 and .Ltmp12
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp12-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp23-.Ltmp12                #   Call between .Ltmp12 and .Ltmp23
	.uleb128 .Ltmp24-.Lfunc_begin0          #     jumps to .Ltmp24
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp25-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp32-.Ltmp25                #   Call between .Ltmp25 and .Ltmp32
	.uleb128 .Ltmp33-.Lfunc_begin0          #     jumps to .Ltmp33
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp34-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp35-.Ltmp34                #   Call between .Ltmp34 and .Ltmp35
	.uleb128 .Ltmp36-.Lfunc_begin0          #     jumps to .Ltmp36
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp37-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp38-.Ltmp37                #   Call between .Ltmp37 and .Ltmp38
	.uleb128 .Ltmp39-.Lfunc_begin0          #     jumps to .Ltmp39
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp40-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp41-.Ltmp40                #   Call between .Ltmp40 and .Ltmp41
	.uleb128 .Ltmp42-.Lfunc_begin0          #     jumps to .Ltmp42
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp43-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp46-.Ltmp43                #   Call between .Ltmp43 and .Ltmp46
	.uleb128 .Ltmp47-.Lfunc_begin0          #     jumps to .Ltmp47
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp48-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp51-.Ltmp48                #   Call between .Ltmp48 and .Ltmp51
	.uleb128 .Ltmp52-.Lfunc_begin0          #     jumps to .Ltmp52
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp53-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp56-.Ltmp53                #   Call between .Ltmp53 and .Ltmp56
	.uleb128 .Ltmp57-.Lfunc_begin0          #     jumps to .Ltmp57
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp58-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Ltmp59-.Ltmp58                #   Call between .Ltmp58 and .Ltmp59
	.uleb128 .Ltmp60-.Lfunc_begin0          #     jumps to .Ltmp60
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp61-.Lfunc_begin0          # >> Call Site 14 <<
	.uleb128 .Ltmp74-.Ltmp61                #   Call between .Ltmp61 and .Ltmp74
	.uleb128 .Ltmp139-.Lfunc_begin0         #     jumps to .Ltmp139
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp75-.Lfunc_begin0          # >> Call Site 15 <<
	.uleb128 .Ltmp78-.Ltmp75                #   Call between .Ltmp75 and .Ltmp78
	.uleb128 .Ltmp79-.Lfunc_begin0          #     jumps to .Ltmp79
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp80-.Lfunc_begin0          # >> Call Site 16 <<
	.uleb128 .Ltmp85-.Ltmp80                #   Call between .Ltmp80 and .Ltmp85
	.uleb128 .Ltmp86-.Lfunc_begin0          #     jumps to .Ltmp86
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp87-.Lfunc_begin0          # >> Call Site 17 <<
	.uleb128 .Ltmp100-.Ltmp87               #   Call between .Ltmp87 and .Ltmp100
	.uleb128 .Ltmp139-.Lfunc_begin0         #     jumps to .Ltmp139
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp101-.Lfunc_begin0         # >> Call Site 18 <<
	.uleb128 .Ltmp104-.Ltmp101              #   Call between .Ltmp101 and .Ltmp104
	.uleb128 .Ltmp105-.Lfunc_begin0         #     jumps to .Ltmp105
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp106-.Lfunc_begin0         # >> Call Site 19 <<
	.uleb128 .Ltmp111-.Ltmp106              #   Call between .Ltmp106 and .Ltmp111
	.uleb128 .Ltmp112-.Lfunc_begin0         #     jumps to .Ltmp112
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp113-.Lfunc_begin0         # >> Call Site 20 <<
	.uleb128 .Ltmp138-.Ltmp113              #   Call between .Ltmp113 and .Ltmp138
	.uleb128 .Ltmp139-.Lfunc_begin0         #     jumps to .Ltmp139
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp138-.Lfunc_begin0         # >> Call Site 21 <<
	.uleb128 .Lfunc_end1-.Ltmp138           #   Call between .Ltmp138 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.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	$_Z5calcDi6MatrixS_S_S_, %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	_Z5calcDi6MatrixS_S_S_,@object  # @_Z5calcDi6MatrixS_S_S_
	.section	.rodata,"a",@progbits
	.globl	_Z5calcDi6MatrixS_S_S_
	.p2align	3, 0x0
_Z5calcDi6MatrixS_S_S_:
	.quad	_Z20__device_stub__calcDi6MatrixS_S_S_
	.size	_Z5calcDi6MatrixS_S_S_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Input file not specified. Please, specify it as a first argument."
	.size	.L.str, 66

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"example: "
	.size	.L.str.1, 10

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	" matr.txt"
	.size	.L.str.2, 10

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"output.txt"
	.size	.L.str.3, 11

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Error opening file"
	.size	.L.str.4, 19

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"N="
	.size	.L.str.5, 3

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Matrix D:"
	.size	.L.str.6, 10

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Done. "
	.size	.L.str.8, 7

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z5calcDi6MatrixS_S_S_"
	.size	.L__unnamed_1, 23

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z5calcDi6MatrixS_S_S_  ; -- Begin function _Z5calcDi6MatrixS_S_S_
	.globl	_Z5calcDi6MatrixS_S_S_
	.p2align	8
	.type	_Z5calcDi6MatrixS_S_S_,@function
_Z5calcDi6MatrixS_S_S_:                 ; @_Z5calcDi6MatrixS_S_S_
; %bb.0:
	s_clause 0x1
	s_load_b32 s7, s[0:1], 0x54
	s_load_b32 s6, s[0:1], 0x0
	v_bfe_u32 v1, v0, 10, 10
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x10
	s_load_b64 s[4:5], s[0:1], 0x40
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s8, s7, 16
	s_and_b32 s7, s7, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s8, v[1:2]
	v_and_b32_e32 v3, 0x3ff, v0
	s_cmp_lt_i32 s6, 1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_mad_u64_u32 v[0:1], null, s14, s7, v[3:4]
	v_mul_lo_u32 v1, v2, s6
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	s_clause 0x1
	s_load_b64 s[8:9], s[0:1], 0x20
	s_load_b64 s[0:1], s[0:1], 0x30
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v2, 31, v1
	s_mov_b32 s7, s6
	v_mov_b32_e32 v5, v0
	v_lshlrev_b64 v[3:4], 2, v[1:2]
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s8, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s9, v4, vcc_lo
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_ashrrev_i32_e32 v6, 31, v5
	s_add_i32 s7, s7, -1
	s_cmp_eq_u32 s7, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[6:7], 2, v[5:6]
	v_add_co_u32 v6, vcc_lo, s0, v6
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v7, vcc_lo, s1, v7, vcc_lo
	global_load_b32 v8, v[3:4], off
	global_load_b32 v9, v[6:7], off
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[6:7], null, v9, v8, v[2:3]
	v_add_co_u32 v3, vcc_lo, v3, 4
	v_add_co_ci_u32_e32 v4, vcc_lo, 0, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_dual_mov_b32 v2, v6 :: v_dual_add_nc_u32 v5, s6, v5
	s_cbranch_scc0 .LBB0_2
	s_branch .LBB0_4
.LBB0_3:
	v_mov_b32_e32 v2, 0
.LBB0_4:                                ; %Flow38
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, v1, v0
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_add_co_u32 v3, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_load_b32 v3, v[3:4], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v2, v3, v2
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z5calcDi6MatrixS_S_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 328
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 10
		.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	_Z5calcDi6MatrixS_S_S_, .Lfunc_end0-_Z5calcDi6MatrixS_S_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 372
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; 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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         8
        .size:           16
        .value_kind:     by_value
      - .offset:         24
        .size:           16
        .value_kind:     by_value
      - .offset:         40
        .size:           16
        .value_kind:     by_value
      - .offset:         56
        .size:           16
        .value_kind:     by_value
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         76
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         80
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         84
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         86
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         88
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         90
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         92
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         94
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         128
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         136
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 328
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z5calcDi6MatrixS_S_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z5calcDi6MatrixS_S_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
