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

#define Tile_size 2

int numARows, numAColumns;
int numBRows, numBColumns;
int numCRows, numCColumns;

__global__ void matrixMultiplyShared(float *A, float *B, float *C,
                                     int numARows, int numAColumns,
                                     int numBRows, int numBColumns,
                                     int numCRows, int numCColumns) {
    __shared__ float sA[Tile_size][Tile_size];   // Tile size to store elements in shared memory
    __shared__ float sB[Tile_size][Tile_size];

    int row = blockDim.y * blockIdx.y + threadIdx.y;
    int col = blockDim.x * blockIdx.x + threadIdx.x;
    float cvalue = 0.0;
    sA[threadIdx.y][threadIdx.x] = 0.0;
    sB[threadIdx.y][threadIdx.x] = 0.0;

    for (int k = 0; k < (((numAColumns - 1) / Tile_size) + 1); k++) {
        //Copy Data to Tile from Matrix (Global Memory to Shared Memory)
        if ((row < numARows) && (threadIdx.x + (k * Tile_size)) < numAColumns) {
            sA[threadIdx.y][threadIdx.x] = A[(row * numAColumns) + threadIdx.x + (k * Tile_size)];
        } else {
            sA[threadIdx.y][threadIdx.x] = 0.0;
        }
        //Copy Data to Tile from Matrix (Global Memory to Shared Memory)
        if (col < numBColumns && (threadIdx.y + k * Tile_size) < numBRows) {
            sB[threadIdx.y][threadIdx.x] = B[(threadIdx.y + k * Tile_size) * numBColumns + col];
        } else {
            sB[threadIdx.y][threadIdx.x] = 0.0;
        }
        __syncthreads();

        for (int j = 0; j < Tile_size; ++j)//Multiplying Elements present in tile
        {
            cvalue += sA[threadIdx.y][j] * sB[j][threadIdx.x];
        }
    }
    if (row < numCRows && col < numCColumns)//Saving Final result into Matrix C
    {
        C[row * numCColumns + col] = cvalue;
    }
}

void printMat(int row, int col, float *Mat) {
    for (int i = 0; i < row * col; i++) {
        printf("%f  ", *(Mat + i));
        if ((i % col) == 0 && i != 0) {
            printf("\n");
        }
    }
}

void matMultiplyOnHost(float *A, float *B, float *C, int numARows,
                       int numAColumns, int numBRows, int numBColumns,
                       int numCRows, int numCColumns) {
    for (int i = 0; i < numARows; i++) {
        for (int j = 0; j < numAColumns; j++) {
            C[i * numCColumns + j] = 0.0;
            for (int k = 0; k < numCColumns; k++) {
                C[i * numCColumns + j] += A[i * numAColumns + k] * B[k * numBColumns + j];
            }
        }
    }
}

int main(int argc, char **argv) {
    float *hostA, *hostB, *hostC;
    float *hostComputedC;
    float *deviceA, *deviceB, *deviceC;

    printf("\nEnter Rows and Columns of A:");
    scanf("%d %d", &numARows, &numAColumns);

    printf("\nEnter Rows and Columns of B:");
    scanf("%d %d", &numBRows, &numBColumns);

    hostA = (float *) malloc(sizeof(float) * numARows * numAColumns);
    hostB = (float *) malloc(sizeof(float) * numBRows * numBColumns);

    int lower = 10.0, upper = 20.0;
    for (int i = 0; i < numARows * numAColumns; i++)
        hostA[i] = (rand() % (upper - lower + 1)) + lower;
    for (int i = 0; i < numBRows * numBColumns; i++)
        hostB[i] = (rand() % (upper - lower + 1)) + lower;

    printf("\nMatrix A Values:\n");
    printMat(numARows, numAColumns, hostA);

    printf("\n\nMatrix B Values:\n");
    printMat(numBRows, numBColumns, hostB);

    numCRows = numARows;
    numCColumns = numBColumns;

    hostC = (float *) malloc(sizeof(float) * numCRows * numCColumns);
    hostComputedC = (float *) malloc(sizeof(float) * numCRows * numCColumns);

    // Allocating GPU memory
    cudaMalloc((void **) &deviceA, sizeof(float) * numARows * numAColumns);
    cudaMalloc((void **) &deviceB, sizeof(float) * numBRows * numBColumns);
    cudaMalloc((void **) &deviceC, sizeof(float) * numCRows * numCColumns);

    // Copy memory to the GPU
    cudaMemcpy(deviceA, hostA, sizeof(float) * numARows * numAColumns, cudaMemcpyHostToDevice);
    cudaMemcpy(deviceB, hostB, sizeof(float) * numBRows * numBColumns, cudaMemcpyHostToDevice);

    // Initialize the grid and block dimensions
    dim3 dimGrid((numCColumns / Tile_size) + 1, (numCRows / Tile_size) + 1, 1);//Number of Blocks required
    dim3 dimBlock(Tile_size, Tile_size, 1);//Number of threads in each block

    matrixMultiplyShared<<<dimGrid, dimBlock>>>(deviceA, deviceB, deviceC, numARows, numAColumns, numBRows, numBColumns, numCRows, numCColumns);

    cudaError_t err1 = cudaPeekAtLastError();//To capture last error in function call

    cudaDeviceSynchronize();//To synchronize the device

    // Copy the results in GPU memory back to the CPU
    cudaMemcpy(hostC, deviceC, sizeof(float) * numCRows * numCColumns, cudaMemcpyDeviceToHost);

    printf("\nMatrix C From Device\n");
    printMat(numCRows, numCColumns, hostC);//Function Call

    matMultiplyOnHost(hostA, hostB, hostComputedC, numARows, numAColumns, numBRows, numBColumns, numCRows, numCColumns);

    printf("\nMatrix C From Host\n");
    printMat(numCRows, numCColumns, hostComputedC);
    printf("\n\n");

    for (int i = 0; i < numCColumns *
                        numCRows; i++)//Compare both the result matrices 1. MatrixMultiplyonHost 2. MatrixMultiplyonDevice
    {
        if (hostComputedC[i] != hostC[i]) {
            printf("Mismatch at Row = %d Col = %d hostComputed[] = %f --device[] %f\n", i / numCColumns,
                   i % numCColumns, hostComputedC[i], hostC[i]);
            break;
        }
    }

    printf("\nNumber of Blocks Created:%d \n", ((numCColumns / Tile_size) + 1) * ((numCColumns / Tile_size) + 1));
    printf("\nNumber of Threads Per Block: %d \n", (Tile_size * Tile_size));

    // Free the GPU memory
    cudaFree(deviceA);
    cudaFree(deviceB);
    cudaFree(deviceC);
    //Free the Pointer Memory
    free(hostA);
    free(hostB);
    free(hostC);
    free(hostComputedC);
    return 0;
}

	.file	"tmpxft_002cc06d_00000000-6_mat_mul_shared_memory.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%f  "
.LC1:
	.string	"\n"
	.text
	.globl	_Z8printMatiiPf
	.type	_Z8printMatiiPf, @function
_Z8printMatiiPf:
.LFB2027:
	.cfi_startproc
	endbr64
	imull	%esi, %edi
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L3:
	movl	%ebx, %r13d
	cmpl	%ebx, %r12d
	jle	.L14
	movq	%r15, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%r14,%rbx,4), %xmm0
	call	__printf_chk@PLT
	movl	%r13d, %eax
	cltd
	idivl	%ebp
	testl	%edx, %edx
	jne	.L4
	testl	%r13d, %r13d
	je	.L4
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L4:
	incq	%rbx
	jmp	.L3
.L14:
	popq	%rax
	.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
.LFE2027:
	.size	_Z8printMatiiPf, .-_Z8printMatiiPf
	.globl	_Z17matMultiplyOnHostPfS_S_iiiiii
	.type	_Z17matMultiplyOnHostPfS_S_iiiiii, @function
_Z17matMultiplyOnHostPfS_S_iiiiii:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdx, %r9
	xorl	%r10d, %r10d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%ecx, %r13d
	xorl	%ecx, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	56(%rsp), %r12
	movq	%rsi, %rbx
	salq	$2, %r12
.L16:
	cmpl	%r13d, %ebp
	jge	.L15
	movslq	%r10d, %rax
	movq	%rbx, %r11
	xorl	%edx, %edx
	leaq	(%r9,%rax,4), %rsi
	movslq	%ecx, %rax
	leaq	(%rdi,%rax,4), %r15
.L20:
	cmpl	%r8d, %edx
	jge	.L23
	movq	%r11, %r14
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
.L18:
	movss	%xmm0, (%rsi)
	cmpl	%eax, 72(%rsp)
	jle	.L24
	movss	(%r15,%rax,4), %xmm1
	mulss	(%r14), %xmm1
	incq	%rax
	addq	%r12, %r14
	addss	%xmm1, %xmm0
	jmp	.L18
.L24:
	incl	%edx
	addq	$4, %r11
	addq	$4, %rsi
	jmp	.L20
.L23:
	incl	%ebp
	addl	72(%rsp), %r10d
	addl	%r8d, %ecx
	jmp	.L16
.L15:
	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
.LFE2028:
	.size	_Z17matMultiplyOnHostPfS_S_iiiiii, .-_Z17matMultiplyOnHostPfS_S_iiiiii
	.globl	_Z50__device_stub__Z20matrixMultiplySharedPfS_S_iiiiiiPfS_S_iiiiii
	.type	_Z50__device_stub__Z20matrixMultiplySharedPfS_S_iiiiiiPfS_S_iiiiii, @function
_Z50__device_stub__Z20matrixMultiplySharedPfS_S_iiiiiiPfS_S_iiiiii:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	56(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	216(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	224(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	pushq	56(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z20matrixMultiplySharedPfS_S_iiiiii(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 224
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L25:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z50__device_stub__Z20matrixMultiplySharedPfS_S_iiiiiiPfS_S_iiiiii, .-_Z50__device_stub__Z20matrixMultiplySharedPfS_S_iiiiiiPfS_S_iiiiii
	.globl	_Z20matrixMultiplySharedPfS_S_iiiiii
	.type	_Z20matrixMultiplySharedPfS_S_iiiiii, @function
_Z20matrixMultiplySharedPfS_S_iiiiii:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z50__device_stub__Z20matrixMultiplySharedPfS_S_iiiiiiPfS_S_iiiiii
	.cfi_endproc
.LFE2055:
	.size	_Z20matrixMultiplySharedPfS_S_iiiiii, .-_Z20matrixMultiplySharedPfS_S_iiiiii
	.section	.rodata.str1.1
.LC3:
	.string	"\nEnter Rows and Columns of A:"
.LC4:
	.string	"%d %d"
.LC5:
	.string	"\nEnter Rows and Columns of B:"
.LC6:
	.string	"\nMatrix A Values:\n"
.LC7:
	.string	"\n\nMatrix B Values:\n"
.LC8:
	.string	"\nMatrix C From Device\n"
.LC9:
	.string	"\nMatrix C From Host\n"
.LC10:
	.string	"\n\n"
.LC11:
	.string	"Mismatch at Row = %d Col = %d hostComputed[] = %f --device[] %f\n"
.LC12:
	.string	"\nNumber of Blocks Created:%d \n"
.LC13:
	.string	"\nNumber of Threads Per Block: %d \n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	$11, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC4(%rip), %rbx
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	numAColumns(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%eax, %eax
	leaq	numARows(%rip), %rsi
	call	__isoc23_scanf@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	numBColumns(%rip), %rdx
	leaq	numBRows(%rip), %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	call	__isoc23_scanf@PLT
	movslq	numARows(%rip), %rdi
	movslq	numAColumns(%rip), %rax
	imulq	%rax, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movslq	numBRows(%rip), %rdi
	movq	%rax, %rbp
	movslq	numBColumns(%rip), %rax
	imulq	%rax, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %rbx
.L31:
	movl	numARows(%rip), %eax
	imull	numAColumns(%rip), %eax
	cmpl	%r12d, %eax
	jle	.L44
	call	rand@PLT
	cltd
	idivl	%r13d
	addl	$10, %edx
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, 0(%rbp,%r12,4)
	incq	%r12
	jmp	.L31
.L44:
	xorl	%r12d, %r12d
	movl	$11, %r13d
.L33:
	movl	numBRows(%rip), %eax
	imull	numBColumns(%rip), %eax
	cmpl	%r12d, %eax
	jle	.L45
	call	rand@PLT
	cltd
	idivl	%r13d
	addl	$10, %edx
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%rbx,%r12,4)
	incq	%r12
	jmp	.L33
.L45:
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	numAColumns(%rip), %esi
	movl	numARows(%rip), %edi
	movq	%rbp, %rdx
	call	_Z8printMatiiPf
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	numBColumns(%rip), %esi
	movl	numBRows(%rip), %edi
	movq	%rbx, %rdx
	call	_Z8printMatiiPf
	movslq	numARows(%rip), %r14
	movslq	numBColumns(%rip), %r12
	movl	%r12d, numCColumns(%rip)
	imulq	%r14, %r12
	movl	%r14d, numCRows(%rip)
	salq	$2, %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	%r12, %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movslq	numAColumns(%rip), %rsi
	leaq	8(%rsp), %rdi
	movq	%rax, %r12
	imulq	%r14, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movslq	numBRows(%rip), %rsi
	leaq	16(%rsp), %rdi
	movslq	numBColumns(%rip), %rax
	imulq	%rax, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movslq	numCRows(%rip), %rsi
	leaq	24(%rsp), %rdi
	movslq	numCColumns(%rip), %rax
	imulq	%rax, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movslq	numARows(%rip), %rdx
	movq	8(%rsp), %rdi
	movq	%rbp, %rsi
	movslq	numAColumns(%rip), %rax
	movl	$1, %ecx
	imulq	%rax, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movslq	numBRows(%rip), %rdx
	movq	16(%rsp), %rdi
	movq	%rbx, %rsi
	movslq	numBColumns(%rip), %rax
	movl	$1, %ecx
	imulq	%rax, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	$2, %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	numCRows(%rip), %eax
	cltd
	idivl	%esi
	leal	1(%rax), %ecx
	movl	numCColumns(%rip), %eax
	movl	%ecx, 36(%rsp)
	movl	$1, %ecx
	cltd
	idivl	%esi
	movabsq	$8589934594, %rdx
	movl	$1, %esi
	incl	%eax
	movl	%eax, 32(%rsp)
	movq	32(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	movl	numCColumns(%rip), %eax
	movl	numBRows(%rip), %r9d
	pushq	%rdx
	.cfi_def_cfa_offset 120
	movl	numAColumns(%rip), %r8d
	movl	numARows(%rip), %ecx
	pushq	%rax
	.cfi_def_cfa_offset 128
	movl	numCRows(%rip), %eax
	pushq	%rax
	.cfi_def_cfa_offset 136
	movl	numBColumns(%rip), %eax
	pushq	%rax
	.cfi_def_cfa_offset 144
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z50__device_stub__Z20matrixMultiplySharedPfS_S_iiiiiiPfS_S_iiiiii
	addq	$32, %rsp
	.cfi_def_cfa_offset 112
.L35:
	call	cudaPeekAtLastError@PLT
	call	cudaDeviceSynchronize@PLT
	movslq	numCRows(%rip), %rdx
	movq	24(%rsp), %rsi
	movq	%r13, %rdi
	movslq	numCColumns(%rip), %rax
	movl	$2, %ecx
	imulq	%rax, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	numCColumns(%rip), %esi
	movl	numCRows(%rip), %edi
	movq	%r13, %rdx
	call	_Z8printMatiiPf
	movq	%r12, %rdx
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	movl	numARows(%rip), %ecx
	movl	numBRows(%rip), %r9d
	pushq	%rax
	.cfi_def_cfa_offset 120
	movl	numCColumns(%rip), %eax
	movl	numAColumns(%rip), %r8d
	pushq	%rax
	.cfi_def_cfa_offset 128
	movl	numCRows(%rip), %eax
	pushq	%rax
	.cfi_def_cfa_offset 136
	movl	numBColumns(%rip), %eax
	pushq	%rax
	.cfi_def_cfa_offset 144
	call	_Z17matMultiplyOnHostPfS_S_iiiiii
	addq	$32, %rsp
	.cfi_def_cfa_offset 112
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC9(%rip), %rsi
	call	__printf_chk@PLT
	movl	numCColumns(%rip), %esi
	movl	numCRows(%rip), %edi
	movq	%r12, %rdx
	call	_Z8printMatiiPf
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	numCColumns(%rip), %esi
	movl	numCRows(%rip), %ecx
	xorl	%eax, %eax
	imull	%esi, %ecx
.L36:
	cmpl	%eax, %ecx
	jle	.L38
	leaq	1(%rax), %rdx
	movss	(%r12,%rax,4), %xmm0
	movss	-4(%r13,%rdx,4), %xmm1
	ucomiss	%xmm1, %xmm0
	jp	.L42
	je	.L41
.L42:
	cltd
	movl	$2, %edi
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	idivl	%esi
	leaq	.LC11(%rip), %rsi
	movl	%edx, %ecx
	movl	%eax, %edx
	movb	$2, %al
	call	__printf_chk@PLT
	jmp	.L38
.L41:
	movq	%rdx, %rax
	jmp	.L36
.L38:
	movl	numCColumns(%rip), %eax
	movl	$2, %ecx
	movl	$2, %edi
	leaq	.LC12(%rip), %rsi
	cltd
	idivl	%ecx
	leal	1(%rax), %edx
	xorl	%eax, %eax
	imull	%edx, %edx
	call	__printf_chk@PLT
	movl	$4, %edx
	leaq	.LC13(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L40
	call	__stack_chk_fail@PLT
.L40:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z20matrixMultiplySharedPfS_S_iiiiii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z20matrixMultiplySharedPfS_S_iiiiii(%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
.LFE2057:
	.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
	.globl	numCColumns
	.bss
	.align 4
	.type	numCColumns, @object
	.size	numCColumns, 4
numCColumns:
	.zero	4
	.globl	numCRows
	.align 4
	.type	numCRows, @object
	.size	numCRows, 4
numCRows:
	.zero	4
	.globl	numBColumns
	.align 4
	.type	numBColumns, @object
	.size	numBColumns, 4
numBColumns:
	.zero	4
	.globl	numBRows
	.align 4
	.type	numBRows, @object
	.size	numBRows, 4
numBRows:
	.zero	4
	.globl	numAColumns
	.align 4
	.type	numAColumns, @object
	.size	numAColumns, 4
numAColumns:
	.zero	4
	.globl	numARows
	.align 4
	.type	numARows, @object
	.size	numARows, 4
numARows:
	.zero	4
	.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>
#include <stdlib.h>

#define Tile_size 2

int numARows, numAColumns;
int numBRows, numBColumns;
int numCRows, numCColumns;

__global__ void matrixMultiplyShared(float *A, float *B, float *C,
                                     int numARows, int numAColumns,
                                     int numBRows, int numBColumns,
                                     int numCRows, int numCColumns) {
    __shared__ float sA[Tile_size][Tile_size];   // Tile size to store elements in shared memory
    __shared__ float sB[Tile_size][Tile_size];

    int row = blockDim.y * blockIdx.y + threadIdx.y;
    int col = blockDim.x * blockIdx.x + threadIdx.x;
    float cvalue = 0.0;
    sA[threadIdx.y][threadIdx.x] = 0.0;
    sB[threadIdx.y][threadIdx.x] = 0.0;

    for (int k = 0; k < (((numAColumns - 1) / Tile_size) + 1); k++) {
        //Copy Data to Tile from Matrix (Global Memory to Shared Memory)
        if ((row < numARows) && (threadIdx.x + (k * Tile_size)) < numAColumns) {
            sA[threadIdx.y][threadIdx.x] = A[(row * numAColumns) + threadIdx.x + (k * Tile_size)];
        } else {
            sA[threadIdx.y][threadIdx.x] = 0.0;
        }
        //Copy Data to Tile from Matrix (Global Memory to Shared Memory)
        if (col < numBColumns && (threadIdx.y + k * Tile_size) < numBRows) {
            sB[threadIdx.y][threadIdx.x] = B[(threadIdx.y + k * Tile_size) * numBColumns + col];
        } else {
            sB[threadIdx.y][threadIdx.x] = 0.0;
        }
        __syncthreads();

        for (int j = 0; j < Tile_size; ++j)//Multiplying Elements present in tile
        {
            cvalue += sA[threadIdx.y][j] * sB[j][threadIdx.x];
        }
    }
    if (row < numCRows && col < numCColumns)//Saving Final result into Matrix C
    {
        C[row * numCColumns + col] = cvalue;
    }
}

void printMat(int row, int col, float *Mat) {
    for (int i = 0; i < row * col; i++) {
        printf("%f  ", *(Mat + i));
        if ((i % col) == 0 && i != 0) {
            printf("\n");
        }
    }
}

void matMultiplyOnHost(float *A, float *B, float *C, int numARows,
                       int numAColumns, int numBRows, int numBColumns,
                       int numCRows, int numCColumns) {
    for (int i = 0; i < numARows; i++) {
        for (int j = 0; j < numAColumns; j++) {
            C[i * numCColumns + j] = 0.0;
            for (int k = 0; k < numCColumns; k++) {
                C[i * numCColumns + j] += A[i * numAColumns + k] * B[k * numBColumns + j];
            }
        }
    }
}

int main(int argc, char **argv) {
    float *hostA, *hostB, *hostC;
    float *hostComputedC;
    float *deviceA, *deviceB, *deviceC;

    printf("\nEnter Rows and Columns of A:");
    scanf("%d %d", &numARows, &numAColumns);

    printf("\nEnter Rows and Columns of B:");
    scanf("%d %d", &numBRows, &numBColumns);

    hostA = (float *) malloc(sizeof(float) * numARows * numAColumns);
    hostB = (float *) malloc(sizeof(float) * numBRows * numBColumns);

    int lower = 10.0, upper = 20.0;
    for (int i = 0; i < numARows * numAColumns; i++)
        hostA[i] = (rand() % (upper - lower + 1)) + lower;
    for (int i = 0; i < numBRows * numBColumns; i++)
        hostB[i] = (rand() % (upper - lower + 1)) + lower;

    printf("\nMatrix A Values:\n");
    printMat(numARows, numAColumns, hostA);

    printf("\n\nMatrix B Values:\n");
    printMat(numBRows, numBColumns, hostB);

    numCRows = numARows;
    numCColumns = numBColumns;

    hostC = (float *) malloc(sizeof(float) * numCRows * numCColumns);
    hostComputedC = (float *) malloc(sizeof(float) * numCRows * numCColumns);

    // Allocating GPU memory
    hipMalloc((void **) &deviceA, sizeof(float) * numARows * numAColumns);
    hipMalloc((void **) &deviceB, sizeof(float) * numBRows * numBColumns);
    hipMalloc((void **) &deviceC, sizeof(float) * numCRows * numCColumns);

    // Copy memory to the GPU
    hipMemcpy(deviceA, hostA, sizeof(float) * numARows * numAColumns, hipMemcpyHostToDevice);
    hipMemcpy(deviceB, hostB, sizeof(float) * numBRows * numBColumns, hipMemcpyHostToDevice);

    // Initialize the grid and block dimensions
    dim3 dimGrid((numCColumns / Tile_size) + 1, (numCRows / Tile_size) + 1, 1);//Number of Blocks required
    dim3 dimBlock(Tile_size, Tile_size, 1);//Number of threads in each block

    matrixMultiplyShared<<<dimGrid, dimBlock>>>(deviceA, deviceB, deviceC, numARows, numAColumns, numBRows, numBColumns, numCRows, numCColumns);

    hipError_t err1 = hipPeekAtLastError();//To capture last error in function call

    hipDeviceSynchronize();//To synchronize the device

    // Copy the results in GPU memory back to the CPU
    hipMemcpy(hostC, deviceC, sizeof(float) * numCRows * numCColumns, hipMemcpyDeviceToHost);

    printf("\nMatrix C From Device\n");
    printMat(numCRows, numCColumns, hostC);//Function Call

    matMultiplyOnHost(hostA, hostB, hostComputedC, numARows, numAColumns, numBRows, numBColumns, numCRows, numCColumns);

    printf("\nMatrix C From Host\n");
    printMat(numCRows, numCColumns, hostComputedC);
    printf("\n\n");

    for (int i = 0; i < numCColumns *
                        numCRows; i++)//Compare both the result matrices 1. MatrixMultiplyonHost 2. MatrixMultiplyonDevice
    {
        if (hostComputedC[i] != hostC[i]) {
            printf("Mismatch at Row = %d Col = %d hostComputed[] = %f --device[] %f\n", i / numCColumns,
                   i % numCColumns, hostComputedC[i], hostC[i]);
            break;
        }
    }

    printf("\nNumber of Blocks Created:%d \n", ((numCColumns / Tile_size) + 1) * ((numCColumns / Tile_size) + 1));
    printf("\nNumber of Threads Per Block: %d \n", (Tile_size * Tile_size));

    // Free the GPU memory
    hipFree(deviceA);
    hipFree(deviceB);
    hipFree(deviceC);
    //Free the Pointer Memory
    free(hostA);
    free(hostB);
    free(hostC);
    free(hostComputedC);
    return 0;
}

	.text
	.file	"mat_mul_shared_memory.hip"
	.globl	_Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii # -- Begin function _Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii
	.type	_Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii,@function
_Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii: # @_Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii
	.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	$176, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	20(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	16(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	224(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	232(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	240(%rsp), %rax
	movq	%rax, 64(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z20matrixMultiplySharedPfS_S_iiiiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$192, %rsp
	.cfi_adjust_cfa_offset -192
	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	_Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii, .Lfunc_end0-_Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8printMatiiPf                 # -- Begin function _Z8printMatiiPf
	.type	_Z8printMatiiPf,@function
_Z8printMatiiPf:                        # @_Z8printMatiiPf
	.cfi_startproc
# %bb.0:
	imull	%esi, %edi
	testl	%edi, %edi
	jle	.LBB1_7
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %rbx
	movl	%esi, %ebp
	movl	%edi, %r15d
	xorl	%r14d, %r14d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%r14,4), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	movl	%r14d, %eax
	cltd
	idivl	%ebp
	testq	%r14, %r14
	je	.LBB1_5
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	testl	%edx, %edx
	jne	.LBB1_5
# %bb.4:                                #   in Loop: Header=BB1_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
.LBB1_5:                                #   in Loop: Header=BB1_2 Depth=1
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB1_2
# %bb.6:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB1_7:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z8printMatiiPf, .Lfunc_end1-_Z8printMatiiPf
	.cfi_endproc
                                        # -- End function
	.globl	_Z17matMultiplyOnHostPfS_S_iiiiii # -- Begin function _Z17matMultiplyOnHostPfS_S_iiiiii
	.type	_Z17matMultiplyOnHostPfS_S_iiiiii,@function
_Z17matMultiplyOnHostPfS_S_iiiiii:      # @_Z17matMultiplyOnHostPfS_S_iiiiii
	.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
	testl	%ecx, %ecx
	jle	.LBB2_9
# %bb.1:                                # %.preheader.lr.ph
	movl	72(%rsp), %eax
	movslq	56(%rsp), %r9
	movslq	%eax, %r10
	movslq	%r8d, %r11
	movl	%ecx, %ecx
	movl	%r11d, %ebx
	movl	%r10d, %r14d
	shlq	$2, %r11
	shlq	$2, %r9
	xorl	%r15d, %r15d
.LBB2_2:                                # %.preheader
                                        # =>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:                                # %.lr.ph29
                                        #   in Loop: Header=BB2_2 Depth=1
	movq	%r15, %rdx
	imulq	%r10, %rdx
	movq	-8(%rsp), %rsi                  # 8-byte Reload
	leaq	(%rsi,%rdx,4), %r12
	movq	-16(%rsp), %rsi                 # 8-byte Reload
	xorl	%ebp, %ebp
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_6 Depth 3
	movl	$0, (%r12,%rbp,4)
	testl	%eax, %eax
	jle	.LBB2_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB2_4 Depth=2
	xorps	%xmm0, %xmm0
	movq	%rsi, %r13
	xorl	%edx, %edx
.LBB2_6:                                #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rdi,%rdx,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r13), %xmm1
	addss	%xmm1, %xmm0
	movss	%xmm0, (%r12,%rbp,4)
	incq	%rdx
	addq	%r9, %r13
	cmpq	%rdx, %r14
	jne	.LBB2_6
.LBB2_7:                                # %._crit_edge
                                        #   in Loop: Header=BB2_4 Depth=2
	incq	%rbp
	addq	$4, %rsi
	cmpq	%rbx, %rbp
	jne	.LBB2_4
.LBB2_8:                                # %._crit_edge30
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r15
	addq	%r11, %rdi
	cmpq	%rcx, %r15
	jne	.LBB2_2
.LBB2_9:                                # %._crit_edge32
	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	_Z17matMultiplyOnHostPfS_S_iiiiii, .Lfunc_end2-_Z17matMultiplyOnHostPfS_S_iiiiii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$56, %rsp
	.cfi_def_cfa_offset 112
	.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	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.3, %edi
	movl	$numARows, %esi
	movl	$numAColumns, %edx
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.3, %edi
	movl	$numBRows, %esi
	movl	$numBColumns, %edx
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movslq	numARows(%rip), %r13
	movslq	numAColumns(%rip), %rbp
	movq	%r13, %rdi
	imulq	%rbp, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %rbx
	movslq	numBRows(%rip), %r15
	movslq	numBColumns(%rip), %r12
	movq	%r15, %rdi
	imulq	%r12, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %r14
	imull	%r13d, %ebp
	testl	%ebp, %ebp
	jle	.LBB3_4
# %bb.1:                                # %.lr.ph.preheader
	xorl	%r15d, %r15d
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$780903145, %rax, %rcx          # imm = 0x2E8BA2E9
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$33, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,4), %edx
	leal	(%rcx,%rdx,2), %ecx
	negl	%ecx
	addl	%ecx, %eax
	addl	$10, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r15
	movslq	numARows(%rip), %rax
	movslq	numAColumns(%rip), %rcx
	imulq	%rax, %rcx
	cmpq	%rcx, %r15
	jl	.LBB3_2
# %bb.3:                                # %.preheader.loopexit
	movl	numBRows(%rip), %r15d
	movl	numBColumns(%rip), %r12d
.LBB3_4:                                # %.preheader
	imull	%r15d, %r12d
	testl	%r12d, %r12d
	jle	.LBB3_7
# %bb.5:                                # %.lr.ph62.preheader
	xorl	%r15d, %r15d
.LBB3_6:                                # %.lr.ph62
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$780903145, %rax, %rcx          # imm = 0x2E8BA2E9
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$33, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,4), %edx
	leal	(%rcx,%rdx,2), %ecx
	negl	%ecx
	addl	%ecx, %eax
	addl	$10, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	movss	%xmm0, (%r14,%r15,4)
	incq	%r15
	movslq	numBRows(%rip), %rax
	movslq	numBColumns(%rip), %rcx
	imulq	%rax, %rcx
	cmpq	%rcx, %r15
	jl	.LBB3_6
.LBB3_7:                                # %._crit_edge
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	numARows(%rip), %edi
	movl	numAColumns(%rip), %esi
	movq	%rbx, %rdx
	callq	_Z8printMatiiPf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	numBRows(%rip), %edi
	movl	numBColumns(%rip), %esi
	movq	%r14, %rdx
	callq	_Z8printMatiiPf
	movslq	numARows(%rip), %r13
	movl	%r13d, numCRows(%rip)
	movslq	numBColumns(%rip), %r12
	movl	%r12d, numCColumns(%rip)
	shlq	$2, %r13
	imulq	%r13, %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r12
	movslq	numAColumns(%rip), %rsi
	imulq	%r13, %rsi
	leaq	48(%rsp), %rbp
	movq	%rbp, %rdi
	callq	hipMalloc
	movslq	numBRows(%rip), %rax
	movslq	numBColumns(%rip), %rsi
	imulq	%rax, %rsi
	shlq	$2, %rsi
	leaq	40(%rsp), %r13
	movq	%r13, %rdi
	callq	hipMalloc
	movslq	numCRows(%rip), %rax
	movslq	numCColumns(%rip), %rsi
	imulq	%rax, %rsi
	shlq	$2, %rsi
	leaq	32(%rsp), %rdi
	callq	hipMalloc
	movq	(%rbp), %rdi
	movslq	numARows(%rip), %rax
	movslq	numAColumns(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$2, %rdx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r13), %rdi
	movslq	numBRows(%rip), %rax
	movslq	numBColumns(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$2, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	numCColumns(%rip), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%eax, %ecx
	sarl	%ecx
	incl	%ecx
	movl	numCRows(%rip), %eax
	movl	%eax, %edi
	shrl	$31, %edi
	addl	%eax, %edi
	sarl	%edi
	incl	%edi
	shlq	$32, %rdi
	orq	%rcx, %rdi
	movabsq	$8589934594, %rdx               # imm = 0x200000002
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_9
# %bb.8:
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdx
	movl	numARows(%rip), %ecx
	movl	numAColumns(%rip), %r8d
	movl	numBRows(%rip), %r9d
	movl	numBColumns(%rip), %eax
	movl	numCRows(%rip), %r10d
	movl	numCColumns(%rip), %r11d
	movl	%r11d, 16(%rsp)
	movl	%r10d, 8(%rsp)
	movl	%eax, (%rsp)
	callq	_Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii
.LBB3_9:
	callq	hipPeekAtLastError
	callq	hipDeviceSynchronize
	movq	32(%rsp), %rsi
	movslq	numCRows(%rip), %rax
	movslq	numCColumns(%rip), %rdx
	imulq	%rax, %rdx
	shlq	$2, %rdx
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	numCRows(%rip), %edi
	movl	numCColumns(%rip), %esi
	movq	%r15, %rdx
	callq	_Z8printMatiiPf
	movl	numARows(%rip), %ecx
	movl	numAColumns(%rip), %r8d
	movl	numBColumns(%rip), %eax
	movl	numCColumns(%rip), %edx
	movl	%edx, 16(%rsp)
	movl	%eax, (%rsp)
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r12, %rdx
	callq	_Z17matMultiplyOnHostPfS_S_iiiiii
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	numCRows(%rip), %edi
	movl	numCColumns(%rip), %esi
	movq	%r12, %rdx
	callq	_Z8printMatiiPf
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	numCColumns(%rip), %ecx
	movl	numCRows(%rip), %eax
	imull	%ecx, %eax
	testl	%eax, %eax
	jle	.LBB3_14
# %bb.10:                               # %.lr.ph65.preheader
	movl	%eax, %edx
	xorl	%eax, %eax
.LBB3_11:                               # %.lr.ph65
                                        # =>This Inner Loop Header: Depth=1
	movss	(%r12,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	(%r15,%rax,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm1, %xmm0
	jne	.LBB3_12
	jp	.LBB3_12
# %bb.13:                               #   in Loop: Header=BB3_11 Depth=1
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB3_11
	jmp	.LBB3_14
.LBB3_12:
                                        # kill: def $eax killed $eax killed $rax
	cltd
	idivl	%ecx
	cvtss2sd	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.10, %edi
	movl	%eax, %esi
	movb	$2, %al
	callq	printf
	movl	numCColumns(%rip), %ecx
.LBB3_14:                               # %.loopexit
	movl	%ecx, %esi
	shrl	$31, %esi
	addl	%ecx, %esi
	sarl	%esi
	incl	%esi
	imull	%esi, %esi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.12, %edi
	movl	$4, %esi
	xorl	%eax, %eax
	callq	printf
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$56, %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	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z20matrixMultiplySharedPfS_S_iiiiii, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	numARows,@object                # @numARows
	.bss
	.globl	numARows
	.p2align	2, 0x0
numARows:
	.long	0                               # 0x0
	.size	numARows, 4

	.type	numAColumns,@object             # @numAColumns
	.globl	numAColumns
	.p2align	2, 0x0
numAColumns:
	.long	0                               # 0x0
	.size	numAColumns, 4

	.type	numBRows,@object                # @numBRows
	.globl	numBRows
	.p2align	2, 0x0
numBRows:
	.long	0                               # 0x0
	.size	numBRows, 4

	.type	numBColumns,@object             # @numBColumns
	.globl	numBColumns
	.p2align	2, 0x0
numBColumns:
	.long	0                               # 0x0
	.size	numBColumns, 4

	.type	numCRows,@object                # @numCRows
	.globl	numCRows
	.p2align	2, 0x0
numCRows:
	.long	0                               # 0x0
	.size	numCRows, 4

	.type	numCColumns,@object             # @numCColumns
	.globl	numCColumns
	.p2align	2, 0x0
numCColumns:
	.long	0                               # 0x0
	.size	numCColumns, 4

	.type	_Z20matrixMultiplySharedPfS_S_iiiiii,@object # @_Z20matrixMultiplySharedPfS_S_iiiiii
	.section	.rodata,"a",@progbits
	.globl	_Z20matrixMultiplySharedPfS_S_iiiiii
	.p2align	3, 0x0
_Z20matrixMultiplySharedPfS_S_iiiiii:
	.quad	_Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii
	.size	_Z20matrixMultiplySharedPfS_S_iiiiii, 8

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"\nEnter Rows and Columns of A:"
	.size	.L.str.2, 30

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"\nEnter Rows and Columns of B:"
	.size	.L.str.4, 30

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Mismatch at Row = %d Col = %d hostComputed[] = %f --device[] %f\n"
	.size	.L.str.10, 65

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"\nNumber of Blocks Created:%d \n"
	.size	.L.str.11, 31

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"\nNumber of Threads Per Block: %d \n"
	.size	.L.str.12, 35

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z20matrixMultiplySharedPfS_S_iiiiii"
	.size	.L__unnamed_1, 37

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"\nMatrix A Values:"
	.size	.Lstr, 18

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"\n\nMatrix B Values:"
	.size	.Lstr.1, 19

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"\nMatrix C From Device"
	.size	.Lstr.2, 22

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\nMatrix C From Host"
	.size	.Lstr.3, 20

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"\n"
	.size	.Lstr.4, 2

	.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 _Z35__device_stub__matrixMultiplySharedPfS_S_iiiiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym numARows
	.addrsig_sym numAColumns
	.addrsig_sym numBRows
	.addrsig_sym numBColumns
	.addrsig_sym _Z20matrixMultiplySharedPfS_S_iiiiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z20matrixMultiplySharedPfS_S_iiiiii ; -- Begin function _Z20matrixMultiplySharedPfS_S_iiiiii
	.globl	_Z20matrixMultiplySharedPfS_S_iiiiii
	.p2align	8
	.type	_Z20matrixMultiplySharedPfS_S_iiiiii,@function
_Z20matrixMultiplySharedPfS_S_iiiiii:   ; @_Z20matrixMultiplySharedPfS_S_iiiiii
; %bb.0:
	s_clause 0x4
	s_load_b32 s16, s[0:1], 0x3c
	s_load_b128 s[4:7], s[0:1], 0x18
	s_load_b128 s[8:11], s[0:1], 0x0
	s_load_b64 s[2:3], s[0:1], 0x10
	s_load_b64 s[12:13], s[0:1], 0x28
	v_and_b32_e32 v6, 0x3ff, v0
	v_bfe_u32 v2, v0, 10, 10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mov_b32 v8, 0 :: v_dual_lshlrev_b32 v3, 2, v6
	v_lshl_add_u32 v7, v2, 3, v3
	ds_store_2addr_b32 v7, v8, v8 offset1:4
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s0, s16, 16
	s_and_b32 s1, s16, 0xffff
	v_mad_u64_u32 v[0:1], null, s15, s0, v[2:3]
	s_mul_i32 s14, s14, s1
	s_cmp_lt_i32 s5, 0
	v_add_nc_u32_e32 v1, s14, v6
	s_cbranch_scc1 .LBB0_11
; %bb.1:                                ; %.lr.ph
	v_mul_lo_u32 v3, v2, s7
	s_add_i32 s0, s5, -1
	s_delay_alu instid0(VALU_DEP_3)
	v_mul_lo_u32 v10, v0, s5
	s_lshr_b32 s1, s0, 31
	v_dual_mov_b32 v8, 0 :: v_dual_add_nc_u32 v9, 16, v7
	s_add_i32 s0, s0, s1
	v_cmp_gt_i32_e32 vcc_lo, s4, v0
	s_ashr_i32 s1, s0, 1
	v_cmp_gt_i32_e64 s0, s7, v1
	v_lshlrev_b32_e32 v11, 3, v2
	v_lshl_add_u32 v12, v6, 2, 16
	v_add3_u32 v3, v6, v3, s14
	v_mov_b32_e32 v5, 0
	s_add_i32 s4, s1, 1
	s_lshl_b32 s7, s7, 1
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	v_mov_b32_e32 v4, 0
	s_and_saveexec_b32 s14, vcc_lo
	s_cbranch_execz .LBB0_6
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v4, 0
	s_mov_b32 s15, exec_lo
	v_cmpx_gt_u32_e64 s5, v6
	s_cbranch_execz .LBB0_5
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v4, v10, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[13:14], 2, v[4:5]
	v_add_co_u32 v13, s1, s8, v13
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v14, s1, s9, v14, s1
	global_load_b32 v4, v[13:14], off
.LBB0_5:                                ; %Flow86
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s15
.LBB0_6:                                ;   in Loop: Header=BB0_2 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s14
	v_mov_b32_e32 v13, 0
	s_waitcnt vmcnt(0)
	ds_store_b32 v7, v4
	s_and_saveexec_b32 s14, s0
	s_cbranch_execz .LBB0_10
; %bb.7:                                ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v13, 0
	s_mov_b32 s15, exec_lo
	v_cmpx_gt_u32_e64 s6, v2
	s_cbranch_execz .LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v4, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[13:14], 2, v[3:4]
	v_add_co_u32 v13, s1, s10, v13
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v14, s1, s11, v14, s1
	global_load_b32 v13, v[13:14], off
.LBB0_9:                                ; %Flow
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s15
.LBB0_10:                               ;   in Loop: Header=BB0_2 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s14
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v13
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_b64 v[13:14], v11
	ds_load_2addr_b32 v[15:16], v12 offset1:2
	v_add_nc_u32_e32 v6, 2, v6
	v_add_nc_u32_e32 v2, 2, v2
	s_add_i32 s4, s4, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s4, 0
	s_waitcnt lgkmcnt(0)
	v_fmac_f32_e32 v8, v13, v15
	v_dual_fmac_f32 v8, v14, v16 :: v_dual_add_nc_u32 v3, s7, v3
	s_cbranch_scc0 .LBB0_2
.LBB0_11:                               ; %Flow88
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s12, v0
	v_cmp_gt_i32_e64 s0, s13, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, vcc_lo, s0
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_13
; %bb.12:
	v_mad_u64_u32 v[2:3], null, v0, s13, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v8, off
.LBB0_13:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20matrixMultiplySharedPfS_S_iiiiii
		.amdhsa_group_segment_fixed_size 32
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.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 17
		.amdhsa_next_free_sgpr 17
		.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	_Z20matrixMultiplySharedPfS_S_iiiiii, .Lfunc_end0-_Z20matrixMultiplySharedPfS_S_iiiiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 580
; NumSgprs: 19
; NumVgprs: 17
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 32 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 19
; NumVGPRsForWavesPerEU: 17
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         44
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 32
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z20matrixMultiplySharedPfS_S_iiiiii
    .private_segment_fixed_size: 0
    .sgpr_count:     19
    .sgpr_spill_count: 0
    .symbol:         _Z20matrixMultiplySharedPfS_S_iiiiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     17
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
