#include <cuda.h>
#include <iostream>

void genData(float * ptr, unsigned int size);//random data generation
void matrixMul(float * A, float * B, float * C, int HEIGHT,int WIDTH, int COMMON); //loading, transfer, execution(host code)
void printMatrix(float * matrix, int HEIGHT, int WIDTH);//print matrix

int main(int argc, char * argv[]){
    float* pA = NULL;
    float* pB = NULL;
    float* pC = NULL;
    int HEIGHT,COMMON, WIDTH;
    if(argc<4){
        printf("Not inserted Properly, Try again\n");
        printf("Ex: ./matmul_shared_gpu_ext <HEIGHT> <COMMON> <WIDTH>\n");
        exit(-1);
    }
    HEIGHT=atoi(argv[1]);
    COMMON=atoi(argv[2]);
    WIDTH=atoi(argv[3]);

    // malloc memories on the host-side
    pA = (float*)malloc(HEIGHT * COMMON * sizeof(float));
    pB = (float*)malloc(COMMON * WIDTH * sizeof(float));
    pC = (float*)malloc(HEIGHT * WIDTH * sizeof(float));
    genData(pA, HEIGHT * COMMON);
    genData(pB, COMMON * WIDTH);
    clock_t start=clock();
    
    matrixMul(pA,pB,pC,HEIGHT,WIDTH,COMMON);
    printMatrix(pC,HEIGHT,WIDTH);
    printf("Matrix Multiplication execution time(Serial): %fms\n",(double)(clock()-start));
  
    //free 2D array
    free(pA);
    free(pB);
    free(pC);
    return 0;
}


void genData(float* ptr, unsigned int size) {
    while (size) {
        *ptr++ = (float)size/(float)1000;
        size--;
     }
}

void matrixMul(float* A, float* B, float* C,int HEIGHT,int WIDTH,int COMMON)
{
    int x,y,k;
    float sum=0.0F;
    for(y=0;y<HEIGHT;y++){
        for(x=0;x<WIDTH;x++){
            sum=0;
            for(k=0;k<COMMON;k++){
                sum+=A[y*COMMON+k]*B[k*WIDTH+x];
            }
            C[y*WIDTH+x]=sum;
        }
    }
}

void printMatrix(float * matrix, int HEIGHT, int WIDTH){
    int i,j;
    FILE *fp=fopen("output(cpu).txt","wt");
    for(i=0;i<HEIGHT;i++)
        for(j=0;j<WIDTH;j++)
            fprintf(fp,"c[%4d][%4d] = %f\n", i, j, matrix[i * WIDTH + j]);
}

	.file	"tmpxft_00368d5d_00000000-6_matmul_host.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3641:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3641:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z7genDataPfj
	.type	_Z7genDataPfj, @function
_Z7genDataPfj:
.LFB3636:
	.cfi_startproc
	endbr64
	movss	.LC0(%rip), %xmm1
	movl	%esi, %ecx
	xorl	%eax, %eax
.L3:
	movl	%esi, %edx
	subl	%eax, %edx
	cmpq	%rcx, %rax
	je	.L8
	cvtsi2ssq	%rdx, %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, (%rdi,%rax,4)
	incq	%rax
	jmp	.L3
.L8:
	ret
	.cfi_endproc
.LFE3636:
	.size	_Z7genDataPfj, .-_Z7genDataPfj
	.globl	_Z9matrixMulPfS_S_iii
	.type	_Z9matrixMulPfS_S_iii, @function
_Z9matrixMulPfS_S_iii:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r10d, %r10d
	xorl	%r11d, %r11d
	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
	movl	%ecx, %r12d
	xorl	%ecx, %ecx
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	movq	%rdx, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	%r8d, %rbx
	salq	$2, %rbx
.L10:
	cmpl	%r12d, %r11d
	jge	.L9
	movslq	%r10d, %rax
	leaq	(%rsi,%rax,4), %r15
	movslq	%ecx, %rax
	leaq	(%rdi,%rax,4), %r14
	xorl	%eax, %eax
.L15:
	cmpl	%eax, %r8d
	jle	.L12
	leaq	0(%rbp,%rax,4), %r13
	xorl	%edx, %edx
	xorps	%xmm0, %xmm0
.L13:
	cmpl	%edx, %r9d
	jle	.L17
	movss	(%r14,%rdx,4), %xmm1
	mulss	0(%r13), %xmm1
	incq	%rdx
	addq	%rbx, %r13
	addss	%xmm1, %xmm0
	jmp	.L13
.L17:
	movss	%xmm0, (%r15,%rax,4)
	incq	%rax
	jmp	.L15
.L12:
	incl	%r11d
	addl	%r8d, %r10d
	addl	%r9d, %ecx
	jmp	.L10
.L9:
	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
.LFE3637:
	.size	_Z9matrixMulPfS_S_iii, .-_Z9matrixMulPfS_S_iii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"wt"
.LC3:
	.string	"output(cpu).txt"
.LC4:
	.string	"c[%4d][%4d] = %f\n"
	.text
	.globl	_Z11printMatrixPfii
	.type	_Z11printMatrixPfii, @function
_Z11printMatrixPfii:
.LFB3638:
	.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
	movl	%esi, %r14d
	leaq	.LC2(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	leaq	.LC3(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	xorl	%ecx, %ecx
	movq	%rax, (%rsp)
.L19:
	cmpl	%r14d, %ecx
	jge	.L18
	movslq	%r15d, %rax
	xorl	%ebx, %ebx
	leaq	(%r12,%rax,4), %r13
.L22:
	cmpl	%ebx, %ebp
	jle	.L24
	movq	(%rsp), %rdi
	movl	%ebx, %r8d
	leaq	.LC4(%rip), %rdx
	movb	$1, %al
	movl	$2, %esi
	movl	%ecx, 12(%rsp)
	cvtss2sd	0(%r13,%rbx,4), %xmm0
	incq	%rbx
	call	__fprintf_chk@PLT
	movl	12(%rsp), %ecx
	jmp	.L22
.L24:
	incl	%ecx
	addl	%ebp, %r15d
	jmp	.L19
.L18:
	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
.LFE3638:
	.size	_Z11printMatrixPfii, .-_Z11printMatrixPfii
	.section	.rodata.str1.1
.LC5:
	.string	"Not inserted Properly, Try again\n"
.LC6:
	.string	"Ex: ./matmul_shared_gpu_ext <HEIGHT> <COMMON> <WIDTH>\n"
.LC7:
	.string	"Matrix Multiplication execution time(Serial): %fms\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3635:
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	cmpl	$3, %edi
	jg	.L26
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %edi
	leaq	.LC6(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
.L26:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbp
	call	atoi@PLT
	movq	16(%rbp), %rdi
	movl	%eax, %ebx
	call	atoi@PLT
	movq	24(%rbp), %rdi
	movl	%eax, %r14d
	call	atoi@PLT
	movl	%ebx, %esi
	movl	%r14d, %r15d
	imull	%r14d, %esi
	movl	%eax, %ebp
	imull	%ebp, %r15d
	movslq	%esi, %rdi
	movl	%esi, 12(%rsp)
	salq	$2, %rdi
	call	malloc@PLT
	movslq	%r15d, %rdi
	salq	$2, %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movl	%ebx, %edi
	imull	%ebp, %edi
	movq	%rax, %r12
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movl	12(%rsp), %esi
	movq	%r13, %rdi
	movq	%rax, (%rsp)
	call	_Z7genDataPfj
	movl	%r15d, %esi
	movq	%r12, %rdi
	call	_Z7genDataPfj
	call	clock@PLT
	movq	(%rsp), %rdx
	movl	%r14d, %r9d
	movl	%ebp, %r8d
	movl	%ebx, %ecx
	movq	%r12, %rsi
	movq	%r13, %rdi
	movq	%rax, %r15
	call	_Z9matrixMulPfS_S_iii
	movq	(%rsp), %rdi
	movl	%ebp, %edx
	movl	%ebx, %esi
	call	_Z11printMatrixPfii
	call	clock@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	subq	%r15, %rax
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	call	__printf_chk@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3664:
	.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
.LFE3664:
	.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
.LC0:
	.long	1148846080
	.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 <iostream>

void genData(float * ptr, unsigned int size);//random data generation
void matrixMul(float * A, float * B, float * C, int HEIGHT,int WIDTH, int COMMON); //loading, transfer, execution(host code)
void printMatrix(float * matrix, int HEIGHT, int WIDTH);//print matrix

int main(int argc, char * argv[]){
    float* pA = NULL;
    float* pB = NULL;
    float* pC = NULL;
    int HEIGHT,COMMON, WIDTH;
    if(argc<4){
        printf("Not inserted Properly, Try again\n");
        printf("Ex: ./matmul_shared_gpu_ext <HEIGHT> <COMMON> <WIDTH>\n");
        exit(-1);
    }
    HEIGHT=atoi(argv[1]);
    COMMON=atoi(argv[2]);
    WIDTH=atoi(argv[3]);

    // malloc memories on the host-side
    pA = (float*)malloc(HEIGHT * COMMON * sizeof(float));
    pB = (float*)malloc(COMMON * WIDTH * sizeof(float));
    pC = (float*)malloc(HEIGHT * WIDTH * sizeof(float));
    genData(pA, HEIGHT * COMMON);
    genData(pB, COMMON * WIDTH);
    clock_t start=clock();
    
    matrixMul(pA,pB,pC,HEIGHT,WIDTH,COMMON);
    printMatrix(pC,HEIGHT,WIDTH);
    printf("Matrix Multiplication execution time(Serial): %fms\n",(double)(clock()-start));
  
    //free 2D array
    free(pA);
    free(pB);
    free(pC);
    return 0;
}


void genData(float* ptr, unsigned int size) {
    while (size) {
        *ptr++ = (float)size/(float)1000;
        size--;
     }
}

void matrixMul(float* A, float* B, float* C,int HEIGHT,int WIDTH,int COMMON)
{
    int x,y,k;
    float sum=0.0F;
    for(y=0;y<HEIGHT;y++){
        for(x=0;x<WIDTH;x++){
            sum=0;
            for(k=0;k<COMMON;k++){
                sum+=A[y*COMMON+k]*B[k*WIDTH+x];
            }
            C[y*WIDTH+x]=sum;
        }
    }
}

void printMatrix(float * matrix, int HEIGHT, int WIDTH){
    int i,j;
    FILE *fp=fopen("output(cpu).txt","wt");
    for(i=0;i<HEIGHT;i++)
        for(j=0;j<WIDTH;j++)
            fprintf(fp,"c[%4d][%4d] = %f\n", i, j, matrix[i * WIDTH + j]);
}

	.text
	.file	"matmul_host.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI0_0:
	.long	0x447a0000                      # float 1000
	.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	$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
	cmpl	$3, %edi
	jle	.LBB0_8
# %bb.1:
	movq	%rsi, %r14
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r13d
	movq	16(%r14), %rdi
	callq	atoi
	movl	%eax, %ebx
	movq	24(%r14), %rdi
	callq	atoi
	movl	%eax, %r12d
	movl	%ebx, %ebp
	imull	%r13d, %ebp
	movslq	%ebp, %r15
	leaq	(,%r15,4), %rdi
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%r12d, %r14d
	movl	%ebx, 12(%rsp)                  # 4-byte Spill
	imull	%ebx, %r14d
	movl	%r13d, %ebx
	movslq	%r14d, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movl	%r12d, %eax
	imull	%r13d, %eax
	movslq	%eax, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	testl	%r15d, %r15d
	movq	16(%rsp), %r15                  # 8-byte Reload
	je	.LBB0_4
# %bb.2:                                # %.lr.ph.i.preheader
	movss	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movq	%r15, %rax
.LBB0_3:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movl	%ebp, %ecx
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rcx, %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%rax)
	addq	$4, %rax
	decl	%ebp
	jne	.LBB0_3
.LBB0_4:                                # %_Z7genDataPfj.exit
	testl	%r14d, %r14d
	movq	32(%rsp), %r13                  # 8-byte Reload
	je	.LBB0_7
# %bb.5:                                # %.lr.ph.i30.preheader
	movss	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movq	%r13, %rax
.LBB0_6:                                # %.lr.ph.i30
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, %ecx
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rcx, %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%rax)
	addq	$4, %rax
	decl	%r14d
	jne	.LBB0_6
.LBB0_7:                                # %_Z7genDataPfj.exit34
	callq	clock
	movq	%rax, %r14
	movq	%r15, %rdi
	movq	%r13, %rsi
	movq	24(%rsp), %rbp                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	%ebx, %ecx
	movl	%r12d, %r8d
	movl	12(%rsp), %r9d                  # 4-byte Reload
	callq	_Z9matrixMulPfS_S_iii
	movq	%rbp, %rdi
	movl	%ebx, %esi
	movl	%r12d, %edx
	callq	_Z11printMatrixPfii
	callq	clock
	subq	%r14, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movq	%r15, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	xorl	%eax, %eax
	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
.LBB0_8:
	.cfi_def_cfa_offset 96
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$-1, %edi
	callq	exit
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z7genDataPfj
.LCPI1_0:
	.long	0x447a0000                      # float 1000
	.text
	.globl	_Z7genDataPfj
	.type	_Z7genDataPfj,@function
_Z7genDataPfj:                          # @_Z7genDataPfj
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	je	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	movss	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%esi, %eax
	xorps	%xmm1, %xmm1
	cvtsi2ss	%rax, %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%rdi)
	addq	$4, %rdi
	decl	%esi
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z7genDataPfj, .Lfunc_end1-_Z7genDataPfj
	.cfi_endproc
                                        # -- End function
	.globl	_Z9matrixMulPfS_S_iii           # -- Begin function _Z9matrixMulPfS_S_iii
	.type	_Z9matrixMulPfS_S_iii,@function
_Z9matrixMulPfS_S_iii:                  # @_Z9matrixMulPfS_S_iii
	.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	%rdx, -8(%rsp)                  # 8-byte Spill
	movq	%rsi, -16(%rsp)                 # 8-byte Spill
	movq	%rdi, -24(%rsp)                 # 8-byte Spill
	testl	%ecx, %ecx
	jle	.LBB2_9
# %bb.1:                                # %.preheader27.lr.ph
	movslq	%r8d, %rdi
	movl	%ecx, %ecx
	movl	%edi, %r10d
	movl	%r9d, %r11d
	leaq	(,%rdi,4), %rbx
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB2_2:                                # %.preheader27
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
                                        #       Child Loop BB2_6 Depth 3
	testl	%r8d, %r8d
	jle	.LBB2_8
# %bb.3:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	%r14d, %eax
	movq	-24(%rsp), %rdx                 # 8-byte Reload
	leaq	(%rdx,%rax,4), %r12
	movq	%r15, %rax
	imulq	%rdi, %rax
	movq	-8(%rsp), %rdx                  # 8-byte Reload
	leaq	(%rdx,%rax,4), %r13
	movq	-16(%rsp), %rsi                 # 8-byte Reload
	xorl	%eax, %eax
.LBB2_4:                                # %.preheader
                                        #   Parent Loop BB2_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_6 Depth 3
	xorps	%xmm0, %xmm0
	testl	%r9d, %r9d
	jle	.LBB2_7
# %bb.5:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_4 Depth=2
	movq	%rsi, %rbp
	xorl	%edx, %edx
.LBB2_6:                                # %.lr.ph
                                        #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r12,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%rbp), %xmm1
	addss	%xmm1, %xmm0
	incq	%rdx
	addq	%rbx, %rbp
	cmpq	%rdx, %r11
	jne	.LBB2_6
.LBB2_7:                                # %._crit_edge
                                        #   in Loop: Header=BB2_4 Depth=2
	movss	%xmm0, (%r13,%rax,4)
	incq	%rax
	addq	$4, %rsi
	cmpq	%r10, %rax
	jne	.LBB2_4
.LBB2_8:                                # %._crit_edge31
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r15
	addl	%r9d, %r14d
	cmpq	%rcx, %r15
	jne	.LBB2_2
.LBB2_9:                                # %._crit_edge33
	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_end2:
	.size	_Z9matrixMulPfS_S_iii, .Lfunc_end2-_Z9matrixMulPfS_S_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11printMatrixPfii             # -- Begin function _Z11printMatrixPfii
	.type	_Z11printMatrixPfii,@function
_Z11printMatrixPfii:                    # @_Z11printMatrixPfii
	.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	$.L.str.3, %edi
	movl	$.L.str.4, %esi
	callq	fopen
	testl	%ebp, %ebp
	jle	.LBB3_6
# %bb.1:                                # %.preheader.lr.ph
	movq	%rax, %r15
	movl	%ebp, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%ebx, %r14d
	xorl	%ebp, %ebp
	xorl	%r12d, %r12d
	movl	%ebx, 4(%rsp)                   # 4-byte Spill
.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	%ebp, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %rbx
	xorl	%r13d, %r13d
.LBB3_4:                                #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r13,4), %xmm0
	movl	$.L.str.5, %esi
	movq	%r15, %rdi
	movl	%r12d, %edx
	movl	%r13d, %ecx
	movb	$1, %al
	callq	fprintf
	incq	%r13
	cmpq	%r13, %r14
	jne	.LBB3_4
.LBB3_5:                                # %._crit_edge
                                        #   in Loop: Header=BB3_2 Depth=1
	incq	%r12
	movl	4(%rsp), %ebx                   # 4-byte Reload
	addl	%ebx, %ebp
	cmpq	16(%rsp), %r12                  # 8-byte Folded Reload
	jne	.LBB3_2
.LBB3_6:                                # %._crit_edge16
	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_end3:
	.size	_Z11printMatrixPfii, .Lfunc_end3-_Z11printMatrixPfii
	.cfi_endproc
                                        # -- End function
	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"Matrix Multiplication execution time(Serial): %fms\n"
	.size	.L.str.2, 52

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"output(cpu).txt"
	.size	.L.str.3, 16

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"wt"
	.size	.L.str.4, 3

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"c[%4d][%4d] = %f\n"
	.size	.L.str.5, 18

	.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	"Not inserted Properly, Try again"
	.size	.Lstr, 33

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Ex: ./matmul_shared_gpu_ext <HEIGHT> <COMMON> <WIDTH>"
	.size	.Lstr.1, 54

	.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
