#include <stdio.h>
#include <cuda.h>

typedef float MatrixVal;

typedef struct matrix {
	MatrixVal *values;
	unsigned int rows, cols;
} Matrix;

typedef struct input {
	Matrix *A, *B;
} Input;

void setMatrixPosition(Matrix *matrix, unsigned int row, unsigned int col, MatrixVal value) {
	matrix->values[col + matrix->cols * row] = value;
}

MatrixVal getMatrixPosition(Matrix *matrix, unsigned int row, unsigned int col) {
	return matrix->values[col + matrix->cols * row];
}

void setMatrixSize(Matrix *matrix, unsigned int rows, unsigned int cols) {
	matrix->values = (MatrixVal *) malloc(rows * cols * sizeof(MatrixVal));
	matrix->cols = cols;
	matrix->rows = rows;
}

Matrix *newMatrix() {
	Matrix *matrix = (Matrix *) malloc(sizeof(Matrix));
	return matrix;
}

void deleteMatrix(Matrix *matrix) {
	free(matrix->values);
	free(matrix);
}

Matrix *readMatrixFrom(FILE *src) {
	unsigned int row, col, rows, cols;
	MatrixVal value;
	Matrix *matrix = newMatrix();
	fscanf(src, "%u %u", &rows, &cols);
	setMatrixSize(matrix, rows, cols);
	for (row = 0; row < rows; row++) {
		for (col = 0; col < cols; col++) {
			fscanf(src, "%f", &value);
			setMatrixPosition(matrix, row, col, value);
		}
	}
	return matrix;
}

void deleteInput(Input input) {
	deleteMatrix(input.A);
	deleteMatrix(input.B);
}

Input readMatricesFromFiles(char *fileName1, char *fileName2) {
	Input input;
	FILE *file1, *file2;
	file1 = fopen(fileName1, "r");
	input.A = readMatrixFrom(file1);
	fclose(file1);
	file2 = fopen(fileName2, "r");
	input.B = readMatrixFrom(file2);
	fclose(file2);
	return input;
}

Input readMatricesFromStdin() {
	Input input;
	input.A = readMatrixFrom(stdin);
	input.B = readMatrixFrom(stdin);
	return input;
}

void printUsage() {
	printf("Usage: matrix-multiply <cuda|cpu> [file-with-matrix1 file-with-matrix2]\n");
	printf("\nIf files are not passed, matrices are read from stdin.\n");
	printf("Input format: n-rows n-cols entries\n");
	printf("Output format: n-rows n-cols result-entries\n");
	printf("Output is always to stdout\n");
}

void processUsingCuda(Input input) {
}

void processUsingCpu(Input input) {
}

int main(int argc, char **argv) {
	Input input;
	if (argc == 2) {
		input = readMatricesFromStdin();
	} else if (argc == 4) {
		input = readMatricesFromFiles(argv[2], argv[3]);
	} else {
		printf("Error: wrong number of arguments: %d\n", argc);
		printUsage();
		return 1;
	}
	if (strcmp(argv[1], "cuda") == 0) {
		processUsingCuda(input);
	} else if (strcmp(argv[1], "cpu") == 0) {
		processUsingCpu(input);
	} else {
		printf("Error: %s is not a valid form of computation\n");
		printUsage();
		return 2;
	}
	return 0;
}

	.file	"tmpxft_00294299_00000000-6_matrix-multiply.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2042:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2042:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z17setMatrixPositionP6matrixjjf
	.type	_Z17setMatrixPositionP6matrixjjf, @function
_Z17setMatrixPositionP6matrixjjf:
.LFB2027:
	.cfi_startproc
	endbr64
	imull	12(%rdi), %esi
	movq	(%rdi), %rax
	addl	%esi, %edx
	movl	%edx, %edx
	movss	%xmm0, (%rax,%rdx,4)
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z17setMatrixPositionP6matrixjjf, .-_Z17setMatrixPositionP6matrixjjf
	.globl	_Z17getMatrixPositionP6matrixjj
	.type	_Z17getMatrixPositionP6matrixjj, @function
_Z17getMatrixPositionP6matrixjj:
.LFB2028:
	.cfi_startproc
	endbr64
	imull	12(%rdi), %esi
	movq	(%rdi), %rax
	addl	%esi, %edx
	movl	%edx, %edx
	movss	(%rax,%rdx,4), %xmm0
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z17getMatrixPositionP6matrixjj, .-_Z17getMatrixPositionP6matrixjj
	.globl	_Z13setMatrixSizeP6matrixjj
	.type	_Z13setMatrixSizeP6matrixjj, @function
_Z13setMatrixSizeP6matrixjj:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	movl	%esi, %edi
	imull	%edx, %edi
	salq	$2, %rdi
	call	malloc@PLT
	movl	%r12d, 12(%rbx)
	movq	%rax, (%rbx)
	movl	%ebp, 8(%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z13setMatrixSizeP6matrixjj, .-_Z13setMatrixSizeP6matrixjj
	.globl	_Z9newMatrixv
	.type	_Z9newMatrixv, @function
_Z9newMatrixv:
.LFB2030:
	.cfi_startproc
	endbr64
	movl	$16, %edi
	jmp	malloc@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z9newMatrixv, .-_Z9newMatrixv
	.globl	_Z12deleteMatrixP6matrix
	.type	_Z12deleteMatrixP6matrix, @function
_Z12deleteMatrixP6matrix:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	call	free@PLT
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z12deleteMatrixP6matrix, .-_Z12deleteMatrixP6matrix
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%u %u"
.LC1:
	.string	"%f"
	.text
	.globl	_Z14readMatrixFromP8_IO_FILE
	.type	_Z14readMatrixFromP8_IO_FILE, @function
_Z14readMatrixFromP8_IO_FILE:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC1(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	_Z9newMatrixv
	leaq	16(%rsp), %rcx
	leaq	12(%rsp), %rdx
	movq	%r12, %rdi
	movq	%rax, %rbx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movl	16(%rsp), %edx
	movl	12(%rsp), %esi
	movq	%rbx, %rdi
	call	_Z13setMatrixSizeP6matrixjj
.L10:
	cmpl	12(%rsp), %ebp
	jnb	.L17
	xorl	%r13d, %r13d
.L12:
	cmpl	16(%rsp), %r13d
	jnb	.L18
	leaq	20(%rsp), %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	movss	20(%rsp), %xmm0
	movl	%r13d, %edx
	movl	%ebp, %esi
	movq	%rbx, %rdi
	incl	%r13d
	call	_Z17setMatrixPositionP6matrixjjf
	jmp	.L12
.L18:
	incl	%ebp
	jmp	.L10
.L17:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z14readMatrixFromP8_IO_FILE, .-_Z14readMatrixFromP8_IO_FILE
	.globl	_Z11deleteInput5input
	.type	_Z11deleteInput5input, @function
_Z11deleteInput5input:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	call	_Z12deleteMatrixP6matrix
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_Z12deleteMatrixP6matrix
	.cfi_endproc
.LFE2033:
	.size	_Z11deleteInput5input, .-_Z11deleteInput5input
	.section	.rodata.str1.1
.LC2:
	.string	"r"
	.text
	.globl	_Z21readMatricesFromFilesPcS_
	.type	_Z21readMatricesFromFilesPcS_, @function
_Z21readMatricesFromFilesPcS_:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	movq	%r13, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rax
	.cfi_def_cfa_offset 48
	call	fopen@PLT
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	_Z14readMatrixFromP8_IO_FILE
	movq	%rbx, %rdi
	movq	%rax, %r12
	call	fclose@PLT
	movq	%r13, %rsi
	movq	%rbp, %rdi
	call	fopen@PLT
	movq	%rax, %rdi
	movq	%rax, %rbx
	call	_Z14readMatrixFromP8_IO_FILE
	movq	%rbx, %rdi
	movq	%rax, %rbp
	call	fclose@PLT
	popq	%rcx
	.cfi_def_cfa_offset 40
	movq	%r12, %rax
	popq	%rbx
	.cfi_def_cfa_offset 32
	movq	%rbp, %rdx
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z21readMatricesFromFilesPcS_, .-_Z21readMatricesFromFilesPcS_
	.globl	_Z21readMatricesFromStdinv
	.type	_Z21readMatricesFromStdinv, @function
_Z21readMatricesFromStdinv:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	stdin(%rip), %rdi
	call	_Z14readMatrixFromP8_IO_FILE
	movq	stdin(%rip), %rdi
	movq	%rax, %rbx
	call	_Z14readMatrixFromP8_IO_FILE
	movq	%rax, %rdx
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2035:
	.size	_Z21readMatricesFromStdinv, .-_Z21readMatricesFromStdinv
	.section	.rodata.str1.1
.LC3:
	.string	"Usage: matrix-multiply <cuda|cpu> [file-with-matrix1 file-with-matrix2]\n"
.LC4:
	.string	"\nIf files are not passed, matrices are read from stdin.\n"
.LC5:
	.string	"Input format: n-rows n-cols entries\n"
.LC6:
	.string	"Output format: n-rows n-cols result-entries\n"
.LC7:
	.string	"Output is always to stdout\n"
	.text
	.globl	_Z10printUsagev
	.type	_Z10printUsagev, @function
_Z10printUsagev:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC7(%rip), %rsi
	xorl	%eax, %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	movl	$2, %edi
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2036:
	.size	_Z10printUsagev, .-_Z10printUsagev
	.globl	_Z16processUsingCuda5input
	.type	_Z16processUsingCuda5input, @function
_Z16processUsingCuda5input:
.LFB2037:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE2037:
	.size	_Z16processUsingCuda5input, .-_Z16processUsingCuda5input
	.globl	_Z15processUsingCpu5input
	.type	_Z15processUsingCpu5input, @function
_Z15processUsingCpu5input:
.LFB2181:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE2181:
	.size	_Z15processUsingCpu5input, .-_Z15processUsingCpu5input
	.section	.rodata.str1.1
.LC8:
	.string	"Error: wrong number of arguments: %d\n"
.LC9:
	.string	"cuda"
.LC10:
	.string	"cpu"
.LC11:
	.string	"Error: %s is not a valid form of computation\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2039:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	cmpl	$2, %edi
	jne	.L30
	call	_Z21readMatricesFromStdinv
	jmp	.L31
.L30:
	movl	%edi, %edx
	cmpl	$4, %edi
	jne	.L32
	movq	24(%rsi), %rsi
	movq	16(%rbx), %rdi
	call	_Z21readMatricesFromFilesPcS_
	jmp	.L31
.L32:
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z10printUsagev
	movl	$1, %eax
	jmp	.L33
.L31:
	movq	8(%rbx), %rbx
	leaq	.LC9(%rip), %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L33
	leaq	.LC10(%rip), %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L33
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z10printUsagev
	movl	$2, %eax
.L33:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2039:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2065:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2065:
	.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
	.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 <hip/hip_runtime.h>

typedef float MatrixVal;

typedef struct matrix {
	MatrixVal *values;
	unsigned int rows, cols;
} Matrix;

typedef struct input {
	Matrix *A, *B;
} Input;

void setMatrixPosition(Matrix *matrix, unsigned int row, unsigned int col, MatrixVal value) {
	matrix->values[col + matrix->cols * row] = value;
}

MatrixVal getMatrixPosition(Matrix *matrix, unsigned int row, unsigned int col) {
	return matrix->values[col + matrix->cols * row];
}

void setMatrixSize(Matrix *matrix, unsigned int rows, unsigned int cols) {
	matrix->values = (MatrixVal *) malloc(rows * cols * sizeof(MatrixVal));
	matrix->cols = cols;
	matrix->rows = rows;
}

Matrix *newMatrix() {
	Matrix *matrix = (Matrix *) malloc(sizeof(Matrix));
	return matrix;
}

void deleteMatrix(Matrix *matrix) {
	free(matrix->values);
	free(matrix);
}

Matrix *readMatrixFrom(FILE *src) {
	unsigned int row, col, rows, cols;
	MatrixVal value;
	Matrix *matrix = newMatrix();
	fscanf(src, "%u %u", &rows, &cols);
	setMatrixSize(matrix, rows, cols);
	for (row = 0; row < rows; row++) {
		for (col = 0; col < cols; col++) {
			fscanf(src, "%f", &value);
			setMatrixPosition(matrix, row, col, value);
		}
	}
	return matrix;
}

void deleteInput(Input input) {
	deleteMatrix(input.A);
	deleteMatrix(input.B);
}

Input readMatricesFromFiles(char *fileName1, char *fileName2) {
	Input input;
	FILE *file1, *file2;
	file1 = fopen(fileName1, "r");
	input.A = readMatrixFrom(file1);
	fclose(file1);
	file2 = fopen(fileName2, "r");
	input.B = readMatrixFrom(file2);
	fclose(file2);
	return input;
}

Input readMatricesFromStdin() {
	Input input;
	input.A = readMatrixFrom(stdin);
	input.B = readMatrixFrom(stdin);
	return input;
}

void printUsage() {
	printf("Usage: matrix-multiply <cuda|cpu> [file-with-matrix1 file-with-matrix2]\n");
	printf("\nIf files are not passed, matrices are read from stdin.\n");
	printf("Input format: n-rows n-cols entries\n");
	printf("Output format: n-rows n-cols result-entries\n");
	printf("Output is always to stdout\n");
}

void processUsingCuda(Input input) {
}

void processUsingCpu(Input input) {
}

int main(int argc, char **argv) {
	Input input;
	if (argc == 2) {
		input = readMatricesFromStdin();
	} else if (argc == 4) {
		input = readMatricesFromFiles(argv[2], argv[3]);
	} else {
		printf("Error: wrong number of arguments: %d\n", argc);
		printUsage();
		return 1;
	}
	if (strcmp(argv[1], "cuda") == 0) {
		processUsingCuda(input);
	} else if (strcmp(argv[1], "cpu") == 0) {
		processUsingCpu(input);
	} else {
		printf("Error: %s is not a valid form of computation\n");
		printUsage();
		return 2;
	}
	return 0;
}

	.text
	.file	"matrix-multiply.hip"
	.globl	_Z17setMatrixPositionP6matrixjjf # -- Begin function _Z17setMatrixPositionP6matrixjjf
	.type	_Z17setMatrixPositionP6matrixjjf,@function
_Z17setMatrixPositionP6matrixjjf:       # @_Z17setMatrixPositionP6matrixjjf
	.cfi_startproc
# %bb.0:
                                        # kill: def $esi killed $esi def $rsi
	movq	(%rdi), %rax
	imull	12(%rdi), %esi
	addl	%edx, %esi
	movss	%xmm0, (%rax,%rsi,4)
	retq
.Lfunc_end0:
	.size	_Z17setMatrixPositionP6matrixjjf, .Lfunc_end0-_Z17setMatrixPositionP6matrixjjf
	.cfi_endproc
                                        # -- End function
	.globl	_Z17getMatrixPositionP6matrixjj # -- Begin function _Z17getMatrixPositionP6matrixjj
	.type	_Z17getMatrixPositionP6matrixjj,@function
_Z17getMatrixPositionP6matrixjj:        # @_Z17getMatrixPositionP6matrixjj
	.cfi_startproc
# %bb.0:
                                        # kill: def $esi killed $esi def $rsi
	imull	12(%rdi), %esi
	movq	(%rdi), %rax
	addl	%edx, %esi
	movss	(%rax,%rsi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	retq
.Lfunc_end1:
	.size	_Z17getMatrixPositionP6matrixjj, .Lfunc_end1-_Z17getMatrixPositionP6matrixjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z13setMatrixSizeP6matrixjj     # -- Begin function _Z13setMatrixSizeP6matrixjj
	.type	_Z13setMatrixSizeP6matrixjj,@function
_Z13setMatrixSizeP6matrixjj:            # @_Z13setMatrixSizeP6matrixjj
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, %r14
	movl	%edx, %edi
	imull	%esi, %edi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, (%r14)
	movl	%ebx, 12(%r14)
	movl	%ebp, 8(%r14)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z13setMatrixSizeP6matrixjj, .Lfunc_end2-_Z13setMatrixSizeP6matrixjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z9newMatrixv                   # -- Begin function _Z9newMatrixv
	.type	_Z9newMatrixv,@function
_Z9newMatrixv:                          # @_Z9newMatrixv
	.cfi_startproc
# %bb.0:
	movl	$16, %edi
	jmp	malloc                          # TAILCALL
.Lfunc_end3:
	.size	_Z9newMatrixv, .Lfunc_end3-_Z9newMatrixv
	.cfi_endproc
                                        # -- End function
	.globl	_Z12deleteMatrixP6matrix        # -- Begin function _Z12deleteMatrixP6matrix
	.type	_Z12deleteMatrixP6matrix,@function
_Z12deleteMatrixP6matrix:               # @_Z12deleteMatrixP6matrix
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	callq	free
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end4:
	.size	_Z12deleteMatrixP6matrix, .Lfunc_end4-_Z12deleteMatrixP6matrix
	.cfi_endproc
                                        # -- End function
	.globl	_Z14readMatrixFromP8_IO_FILE    # -- Begin function _Z14readMatrixFromP8_IO_FILE
	.type	_Z14readMatrixFromP8_IO_FILE,@function
_Z14readMatrixFromP8_IO_FILE:           # @_Z14readMatrixFromP8_IO_FILE
	.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
	movq	%rdi, %rbx
	movl	$16, %edi
	callq	malloc
	movq	%rax, %r14
	leaq	20(%rsp), %r15
	leaq	16(%rsp), %r12
	movl	$.L.str, %esi
	movq	%rbx, %rdi
	movq	%r15, %rdx
	movq	%r12, %rcx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movl	(%r15), %r13d
	movl	(%r12), %r12d
	movl	%r12d, %edi
	imull	%r13d, %edi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, (%r14)
	movq	%r12, 24(%rsp)                  # 8-byte Spill
	movl	%r12d, 12(%r14)
	movq	%r14, 32(%rsp)                  # 8-byte Spill
	movl	%r13d, 8(%r14)
	testl	%r13d, %r13d
	je	.LBB5_8
# %bb.1:                                # %.preheader.preheader
	movq	%rax, %r15
	leaq	12(%rsp), %r12
	xorl	%ebp, %ebp
	movq	24(%rsp), %rax                  # 8-byte Reload
                                        # kill: def $eax killed $eax killed $rax def $rax
	xorl	%r14d, %r14d
.LBB5_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_5 Depth 2
	testl	%eax, %eax
	je	.LBB5_3
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB5_2 Depth=1
	xorl	%r13d, %r13d
.LBB5_5:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$.L.str.1, %esi
	movq	%rbx, %rdi
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	movss	12(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	leal	(%rbp,%r13), %eax
	movss	%xmm0, (%r15,%rax,4)
	incq	%r13
	movl	16(%rsp), %eax
	cmpq	%rax, %r13
	jb	.LBB5_5
# %bb.6:                                # %._crit_edge.loopexit
                                        #   in Loop: Header=BB5_2 Depth=1
	movl	20(%rsp), %r13d
	jmp	.LBB5_7
.LBB5_3:                                #   in Loop: Header=BB5_2 Depth=1
	xorl	%eax, %eax
.LBB5_7:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	incl	%r14d
	addq	24(%rsp), %rbp                  # 8-byte Folded Reload
	cmpl	%r13d, %r14d
	jb	.LBB5_2
.LBB5_8:                                # %._crit_edge13
	movq	32(%rsp), %rax                  # 8-byte Reload
	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
	retq
.Lfunc_end5:
	.size	_Z14readMatrixFromP8_IO_FILE, .Lfunc_end5-_Z14readMatrixFromP8_IO_FILE
	.cfi_endproc
                                        # -- End function
	.globl	_Z11deleteInput5input           # -- Begin function _Z11deleteInput5input
	.type	_Z11deleteInput5input,@function
_Z11deleteInput5input:                  # @_Z11deleteInput5input
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movq	(%rdi), %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	(%rbx), %rdi
	callq	free
	movq	%rbx, %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end6:
	.size	_Z11deleteInput5input, .Lfunc_end6-_Z11deleteInput5input
	.cfi_endproc
                                        # -- End function
	.globl	_Z21readMatricesFromFilesPcS_   # -- Begin function _Z21readMatricesFromFilesPcS_
	.type	_Z21readMatricesFromFilesPcS_,@function
_Z21readMatricesFromFilesPcS_:          # @_Z21readMatricesFromFilesPcS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movl	$.L.str.2, %esi
	callq	fopen
	movq	%rax, %r14
	movq	%rax, %rdi
	callq	_Z14readMatrixFromP8_IO_FILE
	movq	%rax, %r15
	movq	%r14, %rdi
	callq	fclose
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	callq	fopen
	movq	%rax, %rbx
	movq	%rax, %rdi
	callq	_Z14readMatrixFromP8_IO_FILE
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	fclose
	movq	%r15, %rax
	movq	%r14, %rdx
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	_Z21readMatricesFromFilesPcS_, .Lfunc_end7-_Z21readMatricesFromFilesPcS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z21readMatricesFromStdinv      # -- Begin function _Z21readMatricesFromStdinv
	.type	_Z21readMatricesFromStdinv,@function
_Z21readMatricesFromStdinv:             # @_Z21readMatricesFromStdinv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	stdin(%rip), %rdi
	callq	_Z14readMatrixFromP8_IO_FILE
	movq	%rax, %rbx
	movq	stdin(%rip), %rdi
	callq	_Z14readMatrixFromP8_IO_FILE
	movq	%rax, %rdx
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z21readMatricesFromStdinv, .Lfunc_end8-_Z21readMatricesFromStdinv
	.cfi_endproc
                                        # -- End function
	.globl	_Z10printUsagev                 # -- Begin function _Z10printUsagev
	.type	_Z10printUsagev,@function
_Z10printUsagev:                        # @_Z10printUsagev
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end9:
	.size	_Z10printUsagev, .Lfunc_end9-_Z10printUsagev
	.cfi_endproc
                                        # -- End function
	.globl	_Z16processUsingCuda5input      # -- Begin function _Z16processUsingCuda5input
	.type	_Z16processUsingCuda5input,@function
_Z16processUsingCuda5input:             # @_Z16processUsingCuda5input
	.cfi_startproc
# %bb.0:
	retq
.Lfunc_end10:
	.size	_Z16processUsingCuda5input, .Lfunc_end10-_Z16processUsingCuda5input
	.cfi_endproc
                                        # -- End function
	.globl	_Z15processUsingCpu5input       # -- Begin function _Z15processUsingCpu5input
	.type	_Z15processUsingCpu5input,@function
_Z15processUsingCpu5input:              # @_Z15processUsingCpu5input
	.cfi_startproc
# %bb.0:
	retq
.Lfunc_end11:
	.size	_Z15processUsingCpu5input, .Lfunc_end11-_Z15processUsingCpu5input
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rbx
	cmpl	$4, %edi
	je	.LBB12_4
# %bb.1:
	movl	%edi, %esi
	cmpl	$2, %edi
	jne	.LBB12_3
# %bb.2:
	movq	stdin(%rip), %rdi
	callq	_Z14readMatrixFromP8_IO_FILE
	movq	stdin(%rip), %rdi
	callq	_Z14readMatrixFromP8_IO_FILE
	jmp	.LBB12_5
.LBB12_4:
	movq	16(%rbx), %rdi
	movq	24(%rbx), %rsi
	callq	_Z21readMatricesFromFilesPcS_
.LBB12_5:
	movq	8(%rbx), %r14
	movl	$.L.str.9, %esi
	movq	%r14, %rdi
	callq	strcmp
	xorl	%ebx, %ebx
	testl	%eax, %eax
	je	.LBB12_9
# %bb.6:
	movl	$.L.str.10, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB12_9
# %bb.7:
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$2, %ebx
	jmp	.LBB12_8
.LBB12_3:
	movl	$.L.str.8, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %ebx
.LBB12_8:                               # %.sink.split
	callq	_Z10printUsagev
.LBB12_9:
	movl	%ebx, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end12:
	.size	main, .Lfunc_end12-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%u %u"
	.size	.L.str, 6

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

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Error: wrong number of arguments: %d\n"
	.size	.L.str.8, 38

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"cuda"
	.size	.L.str.9, 5

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"cpu"
	.size	.L.str.10, 4

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Error: %s is not a valid form of computation\n"
	.size	.L.str.11, 46

	.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	"Usage: matrix-multiply <cuda|cpu> [file-with-matrix1 file-with-matrix2]"
	.size	.Lstr, 72

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"\nIf files are not passed, matrices are read from stdin."
	.size	.Lstr.1, 56

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Input format: n-rows n-cols entries"
	.size	.Lstr.2, 36

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Output format: n-rows n-cols result-entries"
	.size	.Lstr.3, 44

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Output is always to stdout"
	.size	.Lstr.4, 27

	.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_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
