#include <algorithm>
#include <cstdio>
#include <cstring>

static void print_matrix(const char *name, const float *matrix, int h, int w) {
    int eff_h = std::min(h, 8);
    int eff_w = std::min(w, 8);
    std::printf("%s = [\n", name);
    for(int i = 0; i < eff_h; ++i) {
        for(int j = 0; j < eff_w; ++j) {
            std::printf(" %5g", matrix[i*w+j]);
        }
        if(eff_w == w) {
            std::puts("");
        } else {
            std::puts(" ...");
        }
    }
    if(eff_h == h) {
        std::puts("]\n");
    } else {
        std::puts("... ]\n");
    }
}

__global__ static void matrix_mul(float q[], const float a[], const float b[], int size) {
    int i = threadIdx.x, j = threadIdx.y;
    float s = 0;
    for(int k = 0; k < size; ++k) {
        s += a[i*size+k] * b[k*size+j];
    }
    q[i*size+j] = s;
}

static cudaError_t report_error(void) {
    cudaError_t err = cudaGetLastError();
    if(err != cudaSuccess) {
        std::fprintf(stderr, "CUDA Error: %s\n", cudaGetErrorString(err));
        std::abort();
    }
    return err;
}

int main(int argc, char *argv[]) {
    int size = 8;
    if(argc >= 2) {
        std::sscanf(argv[1], "%d", &size);
    }
    bool bench = argc >= 4 && std::strcmp(argv[3], "bench") == 0;

    float *a = new float[size*size];
    float *b = new float[size*size];
    for(int i = 0; i < size*size; ++i) {
        a[i] = i+1;
    }
    for(int i = 0; i < size*size; ++i) {
        b[i] = i+1;
    }
    if(!bench) {
        print_matrix("a", a, size, size);
        print_matrix("b", b, size, size);
    }

    float *d_a, *d_b, *d_c;
    cudaMalloc(&d_a, size*size*sizeof *d_a); report_error();
    cudaMalloc(&d_b, size*size*sizeof *d_b); report_error();
    cudaMalloc(&d_c, size*size*sizeof *d_c); report_error();
    cudaMemcpy(d_a, a, size*size*sizeof *a, cudaMemcpyHostToDevice); report_error();
    cudaMemcpy(d_b, b, size*size*sizeof *b, cudaMemcpyHostToDevice); report_error();

    cudaEvent_t start, end;
    cudaEventCreate(&start); report_error();
    cudaEventCreate(&end); report_error();
    cudaEventRecord(start); report_error();
    cudaEventSynchronize(start); report_error();

    matrix_mul<<<1, dim3(size, size)>>>(d_c, d_a, d_b, size); report_error();

    cudaEventRecord(end); report_error();
    cudaEventSynchronize(end); report_error();
    float elapsed;
    cudaEventElapsedTime(&elapsed, start, end); report_error();
    cudaEventDestroy(end); report_error();
    cudaEventDestroy(start); report_error();

    if(!bench) {
        float *c = new float[size*size];
        cudaMemcpy(c, d_c, size*size*sizeof *c, cudaMemcpyDeviceToHost); report_error();
        print_matrix("a * b", c, size, size);
        delete[] c;
        std::printf("%.9g s elapsed\n", elapsed * 0.001f);
    } else {
        std::printf("%.9g", elapsed * 0.001f);
    }

    cudaFree(d_c); report_error();
    cudaFree(d_b); report_error();
    cudaFree(d_a); report_error();
    delete[] b;
    delete[] a;

    return 0;
}

	.file	"tmpxft_002b481b_00000000-6_matmul_0.cudafe1.cpp"
	.text
#APP

	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s = [\n"
.LC1:
	.string	" %5g"
.LC2:
	.string	""
.LC3:
	.string	" ..."
.LC4:
	.string	"]\n"
.LC5:
	.string	"... ]\n"
#NO_APP
	.text
	.type	_ZL12print_matrixPKcPKfii, @function
_ZL12print_matrixPKcPKfii:
.LFB2307:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$8, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	leaq	.LC0(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	$8, %r12d
	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
	movl	%ecx, %ebx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	cmpl	%r12d, %edx
	cmovle	%edx, %r12d
	cmpl	%eax, %ecx
	movq	%rdi, %rdx
	movl	$2, %edi
	cmovle	%ecx, %eax
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
	movl	%eax, 12(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L2:
	cmpl	%r12d, %r15d
	jge	.L6
	movslq	%r14d, %rax
	xorl	%edx, %edx
	leaq	0(%r13,%rax,4), %rcx
.L7:
	cmpl	%edx, 12(%rsp)
	jle	.L13
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%rcx,%rdx,4), %xmm0
	movq	%rcx, 24(%rsp)
	movq	%rdx, 16(%rsp)
	call	__printf_chk@PLT
	movq	16(%rsp), %rdx
	movq	24(%rsp), %rcx
	incq	%rdx
	jmp	.L7
.L13:
	leaq	.LC2(%rip), %rdi
	cmpl	$8, %ebx
	jle	.L10
	leaq	.LC3(%rip), %rdi
.L10:
	call	puts@PLT
	incl	%r15d
	addl	%ebx, %r14d
	jmp	.L2
.L6:
	leaq	.LC4(%rip), %rdi
	cmpl	$8, %ebp
	jle	.L11
	leaq	.LC5(%rip), %rdi
.L11:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	puts@PLT
	.cfi_endproc
.LFE2307:
	.size	_ZL12print_matrixPKcPKfii, .-_ZL12print_matrixPKcPKfii
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2313:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2313:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_ZL37__device_stub__Z10matrix_mulPfPKfS1_iPfPKfS1_i, @function
_ZL37__device_stub__Z10matrix_mulPfPKfS1_iPfPKfS1_i:
.LFB2335:
	.cfi_startproc
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_ZL10matrix_mulPfPKfS1_i(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L15:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2335:
	.size	_ZL37__device_stub__Z10matrix_mulPfPKfS1_iPfPKfS1_i, .-_ZL37__device_stub__Z10matrix_mulPfPKfS1_iPfPKfS1_i
	.type	_ZL10matrix_mulPfPKfS1_i, @function
_ZL10matrix_mulPfPKfS1_i:
.LFB2336:
	.cfi_startproc
	endbr64
	jmp	_ZL37__device_stub__Z10matrix_mulPfPKfS1_iPfPKfS1_i
	.cfi_endproc
.LFE2336:
	.size	_ZL10matrix_mulPfPKfS1_i, .-_ZL10matrix_mulPfPKfS1_i
	.section	.rodata.str1.1
.LC6:
	.string	"CUDA Error: %s\n"
	.text
	.type	_ZL12report_errorv.isra.0, @function
_ZL12report_errorv.isra.0:
.LFB2457:
	.cfi_startproc
	pushq	%rdx
	.cfi_def_cfa_offset 16
	call	cudaGetLastError@PLT
	testl	%eax, %eax
	je	.L20
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	leaq	.LC6(%rip), %rdx
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	call	abort@PLT
.L20:
	popq	%rax
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2457:
	.size	_ZL12report_errorv.isra.0, .-_ZL12report_errorv.isra.0
	.section	.rodata.str1.1
.LC7:
	.string	"%d"
.LC8:
	.string	"bench"
.LC9:
	.string	"a"
.LC10:
	.string	"b"
.LC11:
	.string	"a * b"
.LC13:
	.string	"%.9g s elapsed\n"
.LC14:
	.string	"%.9g"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2310:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$80, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	movl	$8, 4(%rsp)
	cmpl	$1, %edi
	jg	.L24
.L26:
	xorl	%r12d, %r12d
	jmp	.L25
.L24:
	movl	%edi, %ebp
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	leaq	.LC7(%rip), %rsi
	call	__isoc23_sscanf@PLT
	cmpl	$3, %ebp
	jle	.L26
	movq	24(%rbx), %rdi
	leaq	.LC8(%rip), %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	sete	%r12b
.L25:
	movl	4(%rsp), %edi
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	_Znam@PLT
	movl	4(%rsp), %edi
	movq	%rax, %rbx
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	_Znam@PLT
	movl	4(%rsp), %edx
	movq	%rax, %rbp
	xorl	%eax, %eax
	movl	%edx, %ecx
	imull	%edx, %ecx
.L27:
	cmpl	%eax, %ecx
	jle	.L38
	leal	1(%rax), %esi
	cvtsi2ssl	%esi, %xmm0
	movss	%xmm0, (%rbx,%rax,4)
	incq	%rax
	jmp	.L27
.L38:
	xorl	%eax, %eax
.L29:
	cmpl	%eax, %ecx
	jle	.L39
	leal	1(%rax), %esi
	cvtsi2ssl	%esi, %xmm0
	movss	%xmm0, 0(%rbp,%rax,4)
	incq	%rax
	jmp	.L29
.L39:
	testb	%r12b, %r12b
	jne	.L31
	movl	%edx, %ecx
	movq	%rbx, %rsi
	leaq	.LC9(%rip), %rdi
	call	_ZL12print_matrixPKcPKfii
	movl	4(%rsp), %edx
	movq	%rbp, %rsi
	leaq	.LC10(%rip), %rdi
	movl	%edx, %ecx
	call	_ZL12print_matrixPKcPKfii
.L31:
	movl	4(%rsp), %esi
	leaq	8(%rsp), %rdi
	imull	%esi, %esi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	call	_ZL12report_errorv.isra.0
	movl	4(%rsp), %esi
	leaq	16(%rsp), %rdi
	imull	%esi, %esi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	call	_ZL12report_errorv.isra.0
	movl	4(%rsp), %esi
	leaq	24(%rsp), %rdi
	imull	%esi, %esi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	call	_ZL12report_errorv.isra.0
	movl	4(%rsp), %edx
	movq	8(%rsp), %rdi
	movq	%rbx, %rsi
	movl	$1, %ecx
	imull	%edx, %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	call	_ZL12report_errorv.isra.0
	movl	4(%rsp), %edx
	movq	16(%rsp), %rdi
	movq	%rbp, %rsi
	movl	$1, %ecx
	imull	%edx, %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	call	_ZL12report_errorv.isra.0
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	call	_ZL12report_errorv.isra.0
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	call	_ZL12report_errorv.isra.0
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	call	_ZL12report_errorv.isra.0
	movq	32(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	call	_ZL12report_errorv.isra.0
	movl	4(%rsp), %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movl	$1, 68(%rsp)
	movl	%eax, 48(%rsp)
	movl	%eax, 52(%rsp)
	movq	48(%rsp), %rdx
	movq	%rdi, 60(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	movl	4(%rsp), %ecx
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_ZL37__device_stub__Z10matrix_mulPfPKfS1_iPfPKfS1_i
.L32:
	call	_ZL12report_errorv.isra.0
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	call	_ZL12report_errorv.isra.0
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	call	_ZL12report_errorv.isra.0
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	60(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	call	_ZL12report_errorv.isra.0
	movq	40(%rsp), %rdi
	call	cudaEventDestroy@PLT
	call	_ZL12report_errorv.isra.0
	movq	32(%rsp), %rdi
	call	cudaEventDestroy@PLT
	call	_ZL12report_errorv.isra.0
	testb	%r12b, %r12b
	jne	.L33
	movl	4(%rsp), %edi
	imull	%edi, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	_Znam@PLT
	movl	4(%rsp), %edx
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %r12
	imull	%edx, %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	call	_ZL12report_errorv.isra.0
	movl	4(%rsp), %edx
	movq	%r12, %rsi
	leaq	.LC11(%rip), %rdi
	movl	%edx, %ecx
	call	_ZL12print_matrixPKcPKfii
	movq	%r12, %rdi
	call	_ZdaPv@PLT
	movss	.LC12(%rip), %xmm0
	mulss	60(%rsp), %xmm0
	leaq	.LC13(%rip), %rsi
	cvtss2sd	%xmm0, %xmm0
	jmp	.L37
.L33:
	movss	.LC12(%rip), %xmm0
	mulss	60(%rsp), %xmm0
	leaq	.LC14(%rip), %rsi
	cvtss2sd	%xmm0, %xmm0
.L37:
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	call	_ZL12report_errorv.isra.0
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	call	_ZL12report_errorv.isra.0
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	call	_ZL12report_errorv.isra.0
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	addq	$80, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2310:
	.size	main, .-main
	.section	.rodata.str1.1
.LC15:
	.string	"_Z10matrix_mulPfPKfS1_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2338:
	.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	.LC15(%rip), %rdx
	movq	%rax, %rdi
	leaq	_ZL10matrix_mulPfPKfS1_i(%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
.LFE2338:
	.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
.LC12:
	.long	981668463
	.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 <algorithm>
#include <cstdio>
#include <cstring>

static void print_matrix(const char *name, const float *matrix, int h, int w) {
    int eff_h = std::min(h, 8);
    int eff_w = std::min(w, 8);
    std::printf("%s = [\n", name);
    for(int i = 0; i < eff_h; ++i) {
        for(int j = 0; j < eff_w; ++j) {
            std::printf(" %5g", matrix[i*w+j]);
        }
        if(eff_w == w) {
            std::puts("");
        } else {
            std::puts(" ...");
        }
    }
    if(eff_h == h) {
        std::puts("]\n");
    } else {
        std::puts("... ]\n");
    }
}

__global__ static void matrix_mul(float q[], const float a[], const float b[], int size) {
    int i = threadIdx.x, j = threadIdx.y;
    float s = 0;
    for(int k = 0; k < size; ++k) {
        s += a[i*size+k] * b[k*size+j];
    }
    q[i*size+j] = s;
}

static hipError_t report_error(void) {
    hipError_t err = hipGetLastError();
    if(err != hipSuccess) {
        std::fprintf(stderr, "CUDA Error: %s\n", hipGetErrorString(err));
        std::abort();
    }
    return err;
}

int main(int argc, char *argv[]) {
    int size = 8;
    if(argc >= 2) {
        std::sscanf(argv[1], "%d", &size);
    }
    bool bench = argc >= 4 && std::strcmp(argv[3], "bench") == 0;

    float *a = new float[size*size];
    float *b = new float[size*size];
    for(int i = 0; i < size*size; ++i) {
        a[i] = i+1;
    }
    for(int i = 0; i < size*size; ++i) {
        b[i] = i+1;
    }
    if(!bench) {
        print_matrix("a", a, size, size);
        print_matrix("b", b, size, size);
    }

    float *d_a, *d_b, *d_c;
    hipMalloc(&d_a, size*size*sizeof *d_a); report_error();
    hipMalloc(&d_b, size*size*sizeof *d_b); report_error();
    hipMalloc(&d_c, size*size*sizeof *d_c); report_error();
    hipMemcpy(d_a, a, size*size*sizeof *a, hipMemcpyHostToDevice); report_error();
    hipMemcpy(d_b, b, size*size*sizeof *b, hipMemcpyHostToDevice); report_error();

    hipEvent_t start, end;
    hipEventCreate(&start); report_error();
    hipEventCreate(&end); report_error();
    hipEventRecord(start); report_error();
    hipEventSynchronize(start); report_error();

    matrix_mul<<<1, dim3(size, size)>>>(d_c, d_a, d_b, size); report_error();

    hipEventRecord(end); report_error();
    hipEventSynchronize(end); report_error();
    float elapsed;
    hipEventElapsedTime(&elapsed, start, end); report_error();
    hipEventDestroy(end); report_error();
    hipEventDestroy(start); report_error();

    if(!bench) {
        float *c = new float[size*size];
        hipMemcpy(c, d_c, size*size*sizeof *c, hipMemcpyDeviceToHost); report_error();
        print_matrix("a * b", c, size, size);
        delete[] c;
        std::printf("%.9g s elapsed\n", elapsed * 0.001f);
    } else {
        std::printf("%.9g", elapsed * 0.001f);
    }

    hipFree(d_c); report_error();
    hipFree(d_b); report_error();
    hipFree(d_a); report_error();
    delete[] b;
    delete[] a;

    return 0;
}

	.text
	.file	"matmul_0.hip"
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI0_0:
	.long	0x3a83126f                      # float 0.00100000005
	.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	$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	$8, 4(%rsp)
	cmpl	$2, %edi
	jl	.LBB0_1
# %bb.2:
	movq	%rsi, %rbx
	movl	%edi, %ebp
	movq	8(%rsi), %rdi
	xorl	%r13d, %r13d
	leaq	4(%rsp), %rdx
	movl	$.L.str, %esi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$4, %ebp
	jb	.LBB0_4
# %bb.3:
	movq	24(%rbx), %rdi
	movl	$.L.str.1, %esi
	callq	strcmp
	testl	%eax, %eax
	sete	%r13b
.LBB0_4:                                # %.threadthread-pre-split
	movl	4(%rsp), %ebp
	jmp	.LBB0_5
.LBB0_1:
	movl	$8, %ebp
	xorl	%r13d, %r13d
.LBB0_5:                                # %.thread
	movl	%ebp, %r12d
	imull	%r12d, %r12d
	leaq	(,%r12,4), %r15
	movq	%r15, %rdi
	callq	_Znam
	movq	%rax, %rbx
	movq	%r15, %rdi
	callq	_Znam
	movq	%rax, %r14
	testl	%ebp, %ebp
	je	.LBB0_11
# %bb.6:                                # %.lr.ph.preheader
	cmpl	$1, %r12d
	movl	%r12d, %eax
	adcl	$0, %eax
	xorl	%ecx, %ecx
.LBB0_7:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leaq	1(%rcx), %rdx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%edx, %xmm0
	movss	%xmm0, (%rbx,%rcx,4)
	movq	%rdx, %rcx
	cmpq	%rdx, %rax
	jne	.LBB0_7
# %bb.8:                                # %.preheader
	testl	%ebp, %ebp
	je	.LBB0_11
# %bb.9:                                # %.lr.ph32.preheader
	cmpl	$1, %r12d
	adcl	$0, %r12d
	xorl	%eax, %eax
.LBB0_10:                               # %.lr.ph32
                                        # =>This Inner Loop Header: Depth=1
	leaq	1(%rax), %rcx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%ecx, %xmm0
	movss	%xmm0, (%r14,%rax,4)
	movq	%rcx, %rax
	cmpq	%rcx, %r12
	jne	.LBB0_10
.LBB0_11:                               # %._crit_edge
	testb	%r13b, %r13b
	jne	.LBB0_13
# %bb.12:
	movl	$.L.str.2, %edi
	movq	%rbx, %rsi
	movl	%ebp, %edx
	movl	%ebp, %ecx
	callq	_ZL12print_matrixPKcPKfii
	movl	4(%rsp), %ecx
	movl	$.L.str.3, %edi
	movq	%r14, %rsi
	movl	%ecx, %edx
	callq	_ZL12print_matrixPKcPKfii
	movl	4(%rsp), %r15d
	imull	%r15d, %r15d
	shlq	$2, %r15
.LBB0_13:
	leaq	48(%rsp), %r12
	movq	%r12, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	callq	_ZL12report_errorv
	movl	4(%rsp), %esi
	imull	%esi, %esi
	shlq	$2, %rsi
	leaq	40(%rsp), %r15
	movq	%r15, %rdi
	callq	hipMalloc
	callq	_ZL12report_errorv
	movl	4(%rsp), %esi
	imull	%esi, %esi
	shlq	$2, %rsi
	leaq	16(%rsp), %rdi
	callq	hipMalloc
	callq	_ZL12report_errorv
	movq	(%r12), %rdi
	movl	4(%rsp), %edx
	imull	%edx, %edx
	shlq	$2, %rdx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	callq	_ZL12report_errorv
	movq	(%r15), %rdi
	movl	4(%rsp), %edx
	imull	%edx, %edx
	shlq	$2, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	callq	_ZL12report_errorv
	leaq	32(%rsp), %r15
	movq	%r15, %rdi
	callq	hipEventCreate
	callq	_ZL12report_errorv
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	callq	_ZL12report_errorv
	movq	(%r15), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	callq	_ZL12report_errorv
	movq	(%r15), %rdi
	callq	hipEventSynchronize
	callq	_ZL12report_errorv
	movl	4(%rsp), %eax
	movq	%rax, %rdx
	shlq	$32, %rdx
	orq	%rax, %rdx
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_15
# %bb.14:
	movq	16(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdx
	movl	4(%rsp), %ecx
	callq	_ZL25__device_stub__matrix_mulPfPKfS1_i
.LBB0_15:
	callq	_ZL12report_errorv
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	callq	_ZL12report_errorv
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	callq	_ZL12report_errorv
	movq	32(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	28(%rsp), %rdi
	callq	hipEventElapsedTime
	callq	_ZL12report_errorv
	movq	8(%rsp), %rdi
	callq	hipEventDestroy
	callq	_ZL12report_errorv
	movq	32(%rsp), %rdi
	callq	hipEventDestroy
	callq	_ZL12report_errorv
	movl	$.L.str.6, %edi
	testb	%r13b, %r13b
	jne	.LBB0_17
# %bb.16:
	movl	4(%rsp), %r15d
	imull	%r15d, %r15d
	shlq	$2, %r15
	movq	%r15, %rdi
	callq	_Znam
	movq	%rax, %r12
	movq	16(%rsp), %rsi
	movq	%rax, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	_ZL12report_errorv
	movl	4(%rsp), %ecx
	movl	$.L.str.4, %edi
	movq	%r12, %rsi
	movl	%ecx, %edx
	callq	_ZL12print_matrixPKcPKfii
	movq	%r12, %rdi
	callq	_ZdaPv
	movl	$.L.str.5, %edi
.LBB0_17:
	movss	28(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	mulss	.LCPI0_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	movb	$1, %al
	callq	printf
	movq	16(%rsp), %rdi
	callq	hipFree
	callq	_ZL12report_errorv
	movq	40(%rsp), %rdi
	callq	hipFree
	callq	_ZL12report_errorv
	movq	48(%rsp), %rdi
	callq	hipFree
	callq	_ZL12report_errorv
	movq	%r14, %rdi
	callq	_ZdaPv
	movq	%rbx, %rdi
	callq	_ZdaPv
	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_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	_ZL12print_matrixPKcPKfii,@function # -- Begin function _ZL12print_matrixPKcPKfii
_ZL12print_matrixPKcPKfii:              # @_ZL12print_matrixPKcPKfii
	.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	%ecx, %ebp
	movl	%edx, %ebx
	movq	%rsi, 8(%rsp)                   # 8-byte Spill
	movq	%rdi, %rsi
	xorl	%r15d, %r15d
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	testl	%ebx, %ebx
	jle	.LBB1_1
# %bb.2:                                # %.preheader.lr.ph
	movl	$8, %eax
	cmpl	%eax, %ebp
	movl	$8, %r13d
	cmovll	%ebp, %r13d
	cmpl	%eax, %ebx
	movl	%ebx, 4(%rsp)                   # 4-byte Spill
	cmovll	%ebx, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	xorl	%ebx, %ebx
.LBB1_3:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_5 Depth 2
	testl	%ebp, %ebp
	jle	.LBB1_7
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB1_3 Depth=1
	movl	%r15d, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	xorl	%r12d, %r12d
.LBB1_5:                                #   Parent Loop BB1_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14,%r12,4), %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	incq	%r12
	cmpq	%r12, %r13
	jne	.LBB1_5
# %bb.6:                                # %._crit_edge
                                        #   in Loop: Header=BB1_3 Depth=1
	cmpl	$9, %ebp
	jge	.LBB1_8
.LBB1_7:                                # %._crit_edge.thread
                                        #   in Loop: Header=BB1_3 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	jmp	.LBB1_9
.LBB1_8:                                #   in Loop: Header=BB1_3 Depth=1
	movl	$.L.str.10, %edi
	callq	puts
.LBB1_9:                                #   in Loop: Header=BB1_3 Depth=1
	incq	%rbx
	addl	%ebp, %r15d
	cmpq	16(%rsp), %rbx                  # 8-byte Folded Reload
	jne	.LBB1_3
# %bb.10:                               # %._crit_edge28
	cmpl	$9, 4(%rsp)                     # 4-byte Folded Reload
	movl	$.L.str.11, %eax
	movl	$.L.str.12, %edi
	cmovlq	%rax, %rdi
	jmp	.LBB1_11
.LBB1_1:
	movl	$.L.str.11, %edi
.LBB1_11:                               # %._crit_edge28.thread
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	puts                            # TAILCALL
.Lfunc_end1:
	.size	_ZL12print_matrixPKcPKfii, .Lfunc_end1-_ZL12print_matrixPKcPKfii
	.cfi_endproc
                                        # -- End function
	.type	_ZL12report_errorv,@function    # -- Begin function _ZL12report_errorv
_ZL12report_errorv:                     # @_ZL12report_errorv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.1:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB2_2:
	.cfi_def_cfa_offset 16
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.13, %esi
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	callq	abort
.Lfunc_end2:
	.size	_ZL12report_errorv, .Lfunc_end2-_ZL12report_errorv
	.cfi_endproc
                                        # -- End function
	.type	_ZL25__device_stub__matrix_mulPfPKfS1_i,@function # -- Begin function _ZL25__device_stub__matrix_mulPfPKfS1_i
_ZL25__device_stub__matrix_mulPfPKfS1_i: # @_ZL25__device_stub__matrix_mulPfPKfS1_i
	.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	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	4(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_ZL10matrix_mulPfPKfS1_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	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_end3:
	.size	_ZL25__device_stub__matrix_mulPfPKfS1_i, .Lfunc_end3-_ZL25__device_stub__matrix_mulPfPKfS1_i
	.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	$_ZL10matrix_mulPfPKfS1_i, %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	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%d"
	.size	.L.str, 3

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"bench"
	.size	.L.str.1, 6

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

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

	.type	_ZL10matrix_mulPfPKfS1_i,@object # @_ZL10matrix_mulPfPKfS1_i
	.section	.rodata,"a",@progbits
	.p2align	3, 0x0
_ZL10matrix_mulPfPKfS1_i:
	.quad	_ZL25__device_stub__matrix_mulPfPKfS1_i
	.size	_ZL10matrix_mulPfPKfS1_i, 8

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"a * b"
	.size	.L.str.4, 6

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%.9g s elapsed\n"
	.size	.L.str.5, 16

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%.9g"
	.size	.L.str.6, 5

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"%s = [\n"
	.size	.L.str.7, 8

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	" %5g"
	.size	.L.str.8, 5

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

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"]\n"
	.size	.L.str.11, 3

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"... ]\n"
	.size	.L.str.12, 7

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"CUDA Error: %s\n"
	.size	.L.str.13, 16

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_ZL10matrix_mulPfPKfS1_i"
	.size	.L__unnamed_1, 25

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.section	.text._ZL10matrix_mulPfPKfS1_i,"axG",@progbits,_ZL10matrix_mulPfPKfS1_i,comdat
	.globl	_ZL10matrix_mulPfPKfS1_i        ; -- Begin function _ZL10matrix_mulPfPKfS1_i
	.p2align	8
	.type	_ZL10matrix_mulPfPKfS1_i,@function
_ZL10matrix_mulPfPKfS1_i:               ; @_ZL10matrix_mulPfPKfS1_i
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x18
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	v_and_b32_e32 v1, 0x3ff, v0
	v_bfe_u32 v0, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2)
	v_mul_lo_u32 v1, v1, s2
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	v_mov_b32_e32 v3, 0
	s_mov_b32 s3, s2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v2, v3
	v_lshlrev_b64 v[4:5], 2, v[1:2]
	v_mov_b32_e32 v2, v0
	v_mov_b32_e32 v6, v3
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v4, vcc_lo, s6, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v5, vcc_lo
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_lshlrev_b64 v[7:8], 2, v[2:3]
	v_add_nc_u32_e32 v2, s2, v2
	s_add_i32 s3, s3, -1
	s_cmp_eq_u32 s3, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v7, vcc_lo, s0, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s1, v8, vcc_lo
	global_load_b32 v9, v[4:5], off
	global_load_b32 v7, v[7:8], off
	v_add_co_u32 v4, vcc_lo, v4, 4
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v6, v9, v7
	s_cbranch_scc0 .LBB0_2
	s_branch .LBB0_4
.LBB0_3:
	v_mov_b32_e32 v6, 0
.LBB0_4:                                ; %Flow37
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, v1, v0
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_add_co_u32 v0, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	global_store_b32 v[0:1], v6, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _ZL10matrix_mulPfPKfS1_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 28
		.amdhsa_user_sgpr_count 15
		.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 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 10
		.amdhsa_next_free_sgpr 8
		.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
	.section	.text._ZL10matrix_mulPfPKfS1_i,"axG",@progbits,_ZL10matrix_mulPfPKfS1_i,comdat
.Lfunc_end0:
	.size	_ZL10matrix_mulPfPKfS1_i, .Lfunc_end0-_ZL10matrix_mulPfPKfS1_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 264
; NumSgprs: 10
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 10
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; 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
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 28
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _ZL10matrix_mulPfPKfS1_i
    .private_segment_fixed_size: 0
    .sgpr_count:     10
    .sgpr_spill_count: 0
    .symbol:         _ZL10matrix_mulPfPKfS1_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
