#include "stdio.h"
#include <time.h>
#include <sys/time.h>
typedef int DTYPE;

void matrix_multiplication_serial_1(DTYPE* a, DTYPE* b, DTYPE* c, int m, int n, int l)
{
    for(int i = 0; i < m; i++)
    {
        for(int j = 0; j < n; j++)
        {
            DTYPE temp = 0;
            for(int k = 0; k < l; k++)
            {
                temp += a[i*l+k] * b[k*n+j];
            }
            c[i*n+j] = temp;
        }
    }
}

void matrix_multiplication_serial_2(DTYPE* a, DTYPE* b, DTYPE* c, int m, int n, int l)
{
    //init c
    for(int row = 0; row < m; ++row)
    {
        for(int col = 0; col < n; ++col)
        {
            c[col + row * n] = 0;
        }
    }
    for(int i = 0; i < m; i++)
    {
        for(int k = 0; k < l; k++)
        {
            for(int j = 0; j < n; j++)
            {
                c[i*n+j] += a[i*l+k] * b[k*n+j];
            }
        }
    }
}

void matrix_multiplication_serial_3(DTYPE* a, DTYPE* b, DTYPE* c, int m, int n, int l)
{
    //transform b
    DTYPE* b1 = new DTYPE[n * l];
    for(int row = 0; row < l; ++row)
    {
        for(int col = 0; col < n; ++col)
        {
            b1[col + row * n] = b[col + row * n];
        }
    }
    for(int i = 0; i < m; i++)
    {
        for(int j = 0; j < n; j++)
        {
            c[i*n+j] = 0;
            for(int k = 0; k < l; k++)
            {
                c[i*n+j] += a[i*l+k] * b[k*n+j];
            }
        }
    }
}

int main()
{
    int m = 10;
    int l = 20;
    int n = 30;
    // a:m*l, b:l*n, c:m*n
    DTYPE *a = new DTYPE[m * l];
    DTYPE *b = new DTYPE[l * n];
    DTYPE *c = new DTYPE[m * n];
    // init a
    printf("a:\n");
    for(int row = 0; row < m; ++row)
    {
        for(int col = 0; col < l; ++col)
        {
            a[col + row * l] = (col + row) % 256;
            printf("%3d ",a[col + row * l]);
        }
        printf("\n");
    }
    //init b
    printf("b:\n");
    for(int row = 0; row < l; ++row)
    {
        for(int col = 0; col < n; ++col)
        {
            b[col + row * n] = (col * 2 + row + 3) % 256;
            printf("%3d ",b[col + row * n]);
        }
        printf("\n");
    }

    struct timeval startTime, endTime;
    gettimeofday(&startTime, NULL);
    int loopNum = 10000;
	for(int i = 0; i < loopNum; i++)
	{
        matrix_multiplication_serial_1(a, b, c, m, n, l);
    }
    gettimeofday(&endTime, NULL);
	printf("matrix_multiplication_serial_1 use time: %d\n",
        (endTime.tv_sec - startTime.tv_sec)*1000000 + (endTime.tv_usec - startTime.tv_usec));
        
    gettimeofday(&startTime, NULL);
    for(int i = 0; i < loopNum; i++)
	{
        matrix_multiplication_serial_2(a, b, c, m, n, l);
    }
    gettimeofday(&endTime, NULL);
    printf("matrix_multiplication_serial_2 use time: %d\n",
        (endTime.tv_sec - startTime.tv_sec)*1000000 + (endTime.tv_usec - startTime.tv_usec));
    
    gettimeofday(&startTime, NULL);
    for(int i = 0; i < loopNum; i++)
	{
        matrix_multiplication_serial_3(a, b, c, m, n, l);
    }
    gettimeofday(&endTime, NULL);
    printf("matrix_multiplication_serial_3 use time: %d\n",
        (endTime.tv_sec - startTime.tv_sec)*1000000 + (endTime.tv_usec - startTime.tv_usec));
    
    //result
    printf("result:\n");
    for(int row = 0; row < m; ++row)
    {
        for(int col = 0; col < n; ++col)
        {
            printf("%5d ",c[col + row * n]);
        }
        printf("\n");
    }
    return 0;
}

	.file	"tmpxft_0022e7a1_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z30matrix_multiplication_serial_1PiS_S_iii
	.type	_Z30matrix_multiplication_serial_1PiS_S_iii, @function
_Z30matrix_multiplication_serial_1PiS_S_iii:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%r8d, %rax
	movq	%rsi, %r11
	xorl	%r10d, %r10d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	salq	$2, %rax
	xorl	%esi, %esi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ecx, %ebx
	xorl	%ecx, %ecx
	movq	%rdx, -8(%rsp)
	movq	%rax, -16(%rsp)
.L3:
	cmpl	%ebx, %r10d
	jge	.L2
	movq	-8(%rsp), %rdx
	movslq	%esi, %rax
	leaq	(%rdx,%rax,4), %r15
	movslq	%ecx, %rax
	leaq	(%rdi,%rax,4), %r14
	xorl	%eax, %eax
.L8:
	cmpl	%eax, %r8d
	jle	.L5
	leaq	(%r11,%rax,4), %r12
	xorl	%edx, %edx
	xorl	%ebp, %ebp
.L6:
	cmpl	%edx, %r9d
	jle	.L11
	movl	(%r14,%rdx,4), %r13d
	imull	(%r12), %r13d
	incq	%rdx
	addl	%r13d, %ebp
	movq	-16(%rsp), %r13
	addq	%r13, %r12
	jmp	.L6
.L11:
	movl	%ebp, (%r15,%rax,4)
	incq	%rax
	jmp	.L8
.L5:
	incl	%r10d
	addl	%r8d, %esi
	addl	%r9d, %ecx
	jmp	.L3
.L2:
	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	_Z30matrix_multiplication_serial_1PiS_S_iii, .-_Z30matrix_multiplication_serial_1PiS_S_iii
	.globl	_Z30matrix_multiplication_serial_2PiS_S_iii
	.type	_Z30matrix_multiplication_serial_2PiS_S_iii, @function
_Z30matrix_multiplication_serial_2PiS_S_iii:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	xorl	%esi, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, -8(%rsp)
	xorl	%edi, %edi
.L13:
	cmpl	%ecx, %edi
	jl	.L15
	xorl	%r11d, %r11d
	xorl	%r12d, %r12d
	xorl	%ebx, %ebx
	jmp	.L16
.L15:
	movslq	%esi, %rax
	leaq	(%rdx,%rax,4), %r10
	xorl	%eax, %eax
.L17:
	cmpl	%eax, %r8d
	jle	.L24
	xorl	%r11d, %r11d
	movl	%r11d, (%r10,%rax,4)
	incq	%rax
	jmp	.L17
.L24:
	incl	%edi
	addl	%r8d, %esi
	jmp	.L13
.L19:
	incl	%ebx
	addl	%r9d, %r12d
	addl	%r8d, %r11d
.L16:
	cmpl	%ecx, %ebx
	jge	.L12
	movslq	%r11d, %rax
	xorl	%r10d, %r10d
	leaq	(%rdx,%rax,4), %rax
	movq	%rax, -16(%rsp)
	xorl	%eax, %eax
.L22:
	cmpl	%r9d, %eax
	jge	.L19
	movq	-8(%rsp), %rdi
	leal	(%rax,%r12), %esi
	movslq	%esi, %rsi
	leaq	(%rdi,%rsi,4), %r15
	movslq	%r10d, %rsi
	movq	-16(%rsp), %rdi
	leaq	0(%rbp,%rsi,4), %r14
	xorl	%esi, %esi
.L20:
	cmpl	%esi, %r8d
	jle	.L25
	movl	(%r15), %r13d
	imull	(%r14,%rsi,4), %r13d
	incq	%rsi
	addl	%r13d, (%rdi)
	addq	$4, %rdi
	jmp	.L20
.L25:
	incl	%eax
	addl	%r8d, %r10d
	jmp	.L22
.L12:
	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	_Z30matrix_multiplication_serial_2PiS_S_iii, .-_Z30matrix_multiplication_serial_2PiS_S_iii
	.globl	_Z30matrix_multiplication_serial_3PiS_S_iii
	.type	_Z30matrix_multiplication_serial_3PiS_S_iii, @function
_Z30matrix_multiplication_serial_3PiS_S_iii:
.LFB2029:
	.cfi_startproc
	endbr64
	movabsq	$2305843009213693950, %rax
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%rdi, 16(%rsp)
	movl	%r8d, %edi
	imull	%r9d, %edi
	movq	%rdx, 24(%rsp)
	movslq	%edi, %rdi
	cmpq	%rdi, %rax
	jb	.L27
	salq	$2, %rdi
	movq	%rsi, %r12
	movl	%ecx, %r13d
	movl	%r8d, %ebx
	movl	%r9d, %ebp
	call	_Znam@PLT
	xorl	%esi, %esi
	xorl	%edi, %edi
	jmp	.L28
.L27:
	call	__cxa_throw_bad_array_new_length@PLT
.L39:
	incl	%edi
	addl	%ebx, %esi
.L28:
	cmpl	%ebp, %edi
	jl	.L30
	movslq	%ebx, %rax
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	xorl	%r9d, %r9d
	salq	$2, %rax
	movq	%rax, 8(%rsp)
	jmp	.L31
.L30:
	movslq	%esi, %rdx
	xorl	%ecx, %ecx
	salq	$2, %rdx
.L32:
	cmpl	%ebx, %ecx
	jge	.L39
	movl	(%r12,%rdx), %r8d
	incl	%ecx
	movl	%r8d, (%rax,%rdx)
	addq	$4, %rdx
	jmp	.L32
.L40:
	incl	%r9d
	addl	%ebx, %edi
	addl	%ebp, %ecx
.L31:
	cmpl	%r13d, %r9d
	jge	.L26
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdx
	movslq	%edi, %rax
	movq	%r12, %r8
	leaq	(%rsi,%rax,4), %rsi
	movslq	%ecx, %rax
	leaq	(%rdx,%rax,4), %r15
	xorl	%edx, %edx
.L36:
	cmpl	%ebx, %edx
	jge	.L40
	movq	%r8, %r11
	xorl	%eax, %eax
	xorl	%r10d, %r10d
.L34:
	movl	%r10d, (%rsi)
	cmpl	%eax, %ebp
	jle	.L41
	movl	(%r15,%rax,4), %r14d
	imull	(%r11), %r14d
	incq	%rax
	addl	%r14d, %r10d
	movq	8(%rsp), %r14
	addq	%r14, %r11
	jmp	.L34
.L41:
	incl	%edx
	addq	$4, %r8
	addq	$4, %rsi
	jmp	.L36
.L26:
	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
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z30matrix_multiplication_serial_3PiS_S_iii, .-_Z30matrix_multiplication_serial_3PiS_S_iii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"a:\n"
.LC1:
	.string	"%3d "
.LC2:
	.string	"\n"
.LC3:
	.string	"b:\n"
.LC4:
	.string	"matrix_multiplication_serial_1 use time: %d\n"
.LC5:
	.string	"matrix_multiplication_serial_2 use time: %d\n"
.LC6:
	.string	"matrix_multiplication_serial_3 use time: %d\n"
.LC7:
	.string	"result:\n"
.LC8:
	.string	"%5d "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$800, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	_Znam@PLT
	movl	$2400, %edi
	movq	%rax, %r12
	call	_Znam@PLT
	movl	$1200, %edi
	movq	%rax, %r13
	call	_Znam@PLT
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rbx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L43:
	imulq	$80, %r14, %rbp
	movl	%r14d, %r8d
	xorl	%r15d, %r15d
	addq	%r12, %rbp
.L44:
	leal	(%r8,%r15), %edx
	xorl	%eax, %eax
	movl	$2, %edi
	movl	%r8d, 12(%rsp)
	movl	%edx, 0(%rbp,%r15,4)
	leaq	.LC1(%rip), %rsi
	incq	%r15
	call	__printf_chk@PLT
	cmpq	$20, %r15
	movl	12(%rsp), %r8d
	jne	.L44
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%r14
	call	__printf_chk@PLT
	cmpq	$10, %r14
	jne	.L43
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%r15d, %r15d
	call	__printf_chk@PLT
.L46:
	imulq	$120, %r15, %r14
	leal	3(%r15), %edx
	xorl	%ebp, %ebp
	addq	%r13, %r14
.L47:
	movl	%edx, (%r14,%rbp,4)
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movl	%edx, 12(%rsp)
	incq	%rbp
	call	__printf_chk@PLT
	movl	12(%rsp), %edx
	addl	$2, %edx
	cmpq	$30, %rbp
	jne	.L47
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%r15
	call	__printf_chk@PLT
	cmpq	$20, %r15
	jne	.L46
	leaq	24(%rsp), %r15
	xorl	%esi, %esi
	movl	$10000, %r14d
	movq	%r15, %rdi
	call	gettimeofday@PLT
.L49:
	movl	$20, %r9d
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	movl	$30, %r8d
	movl	$10, %ecx
	call	_Z30matrix_multiplication_serial_1PiS_S_iii
	decl	%r14d
	jne	.L49
	leaq	40(%rsp), %r14
	xorl	%esi, %esi
	movl	$10000, %ebp
	movq	%r14, %rdi
	call	gettimeofday@PLT
	movq	40(%rsp), %rdx
	subq	24(%rsp), %rdx
	xorl	%eax, %eax
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	imulq	$1000000, %rdx, %rdx
	addq	48(%rsp), %rdx
	subq	32(%rsp), %rdx
	call	__printf_chk@PLT
	xorl	%esi, %esi
	movq	%r15, %rdi
	call	gettimeofday@PLT
.L50:
	movl	$20, %r9d
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	movl	$30, %r8d
	movl	$10, %ecx
	call	_Z30matrix_multiplication_serial_2PiS_S_iii
	decl	%ebp
	jne	.L50
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	gettimeofday@PLT
	movq	40(%rsp), %rdx
	subq	24(%rsp), %rdx
	xorl	%eax, %eax
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	imulq	$1000000, %rdx, %rdx
	addq	48(%rsp), %rdx
	subq	32(%rsp), %rdx
	call	__printf_chk@PLT
	movq	%r15, %rdi
	xorl	%esi, %esi
	movl	$10000, %r15d
	call	gettimeofday@PLT
.L51:
	movl	$20, %r9d
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	movl	$30, %r8d
	movl	$10, %ecx
	call	_Z30matrix_multiplication_serial_3PiS_S_iii
	decl	%r15d
	jne	.L51
	xorl	%esi, %esi
	movq	%r14, %rdi
	leaq	.LC8(%rip), %r15
	xorl	%r13d, %r13d
	call	gettimeofday@PLT
	movq	40(%rsp), %rdx
	subq	24(%rsp), %rdx
	xorl	%eax, %eax
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	imulq	$1000000, %rdx, %rdx
	addq	48(%rsp), %rdx
	subq	32(%rsp), %rdx
	call	__printf_chk@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L52:
	imulq	$120, %r13, %r14
	xorl	%r12d, %r12d
	addq	%rbx, %r14
.L53:
	movl	(%r14,%r12,4), %edx
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%r12
	call	__printf_chk@PLT
	cmpq	$30, %r12
	jne	.L53
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%r13
	call	__printf_chk@PLT
	cmpq	$10, %r13
	jne	.L52
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L55
	call	__stack_chk_fail@PLT
.L55:
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2056:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include "stdio.h"
#include <time.h>
#include <sys/time.h>
typedef int DTYPE;

void matrix_multiplication_serial_1(DTYPE* a, DTYPE* b, DTYPE* c, int m, int n, int l)
{
    for(int i = 0; i < m; i++)
    {
        for(int j = 0; j < n; j++)
        {
            DTYPE temp = 0;
            for(int k = 0; k < l; k++)
            {
                temp += a[i*l+k] * b[k*n+j];
            }
            c[i*n+j] = temp;
        }
    }
}

void matrix_multiplication_serial_2(DTYPE* a, DTYPE* b, DTYPE* c, int m, int n, int l)
{
    //init c
    for(int row = 0; row < m; ++row)
    {
        for(int col = 0; col < n; ++col)
        {
            c[col + row * n] = 0;
        }
    }
    for(int i = 0; i < m; i++)
    {
        for(int k = 0; k < l; k++)
        {
            for(int j = 0; j < n; j++)
            {
                c[i*n+j] += a[i*l+k] * b[k*n+j];
            }
        }
    }
}

void matrix_multiplication_serial_3(DTYPE* a, DTYPE* b, DTYPE* c, int m, int n, int l)
{
    //transform b
    DTYPE* b1 = new DTYPE[n * l];
    for(int row = 0; row < l; ++row)
    {
        for(int col = 0; col < n; ++col)
        {
            b1[col + row * n] = b[col + row * n];
        }
    }
    for(int i = 0; i < m; i++)
    {
        for(int j = 0; j < n; j++)
        {
            c[i*n+j] = 0;
            for(int k = 0; k < l; k++)
            {
                c[i*n+j] += a[i*l+k] * b[k*n+j];
            }
        }
    }
}

int main()
{
    int m = 10;
    int l = 20;
    int n = 30;
    // a:m*l, b:l*n, c:m*n
    DTYPE *a = new DTYPE[m * l];
    DTYPE *b = new DTYPE[l * n];
    DTYPE *c = new DTYPE[m * n];
    // init a
    printf("a:\n");
    for(int row = 0; row < m; ++row)
    {
        for(int col = 0; col < l; ++col)
        {
            a[col + row * l] = (col + row) % 256;
            printf("%3d ",a[col + row * l]);
        }
        printf("\n");
    }
    //init b
    printf("b:\n");
    for(int row = 0; row < l; ++row)
    {
        for(int col = 0; col < n; ++col)
        {
            b[col + row * n] = (col * 2 + row + 3) % 256;
            printf("%3d ",b[col + row * n]);
        }
        printf("\n");
    }

    struct timeval startTime, endTime;
    gettimeofday(&startTime, NULL);
    int loopNum = 10000;
	for(int i = 0; i < loopNum; i++)
	{
        matrix_multiplication_serial_1(a, b, c, m, n, l);
    }
    gettimeofday(&endTime, NULL);
	printf("matrix_multiplication_serial_1 use time: %d\n",
        (endTime.tv_sec - startTime.tv_sec)*1000000 + (endTime.tv_usec - startTime.tv_usec));
        
    gettimeofday(&startTime, NULL);
    for(int i = 0; i < loopNum; i++)
	{
        matrix_multiplication_serial_2(a, b, c, m, n, l);
    }
    gettimeofday(&endTime, NULL);
    printf("matrix_multiplication_serial_2 use time: %d\n",
        (endTime.tv_sec - startTime.tv_sec)*1000000 + (endTime.tv_usec - startTime.tv_usec));
    
    gettimeofday(&startTime, NULL);
    for(int i = 0; i < loopNum; i++)
	{
        matrix_multiplication_serial_3(a, b, c, m, n, l);
    }
    gettimeofday(&endTime, NULL);
    printf("matrix_multiplication_serial_3 use time: %d\n",
        (endTime.tv_sec - startTime.tv_sec)*1000000 + (endTime.tv_usec - startTime.tv_usec));
    
    //result
    printf("result:\n");
    for(int row = 0; row < m; ++row)
    {
        for(int col = 0; col < n; ++col)
        {
            printf("%5d ",c[col + row * n]);
        }
        printf("\n");
    }
    return 0;
}

	.text
	.file	"main.hip"
	.globl	_Z30matrix_multiplication_serial_1PiS_S_iii # -- Begin function _Z30matrix_multiplication_serial_1PiS_S_iii
	.type	_Z30matrix_multiplication_serial_1PiS_S_iii,@function
_Z30matrix_multiplication_serial_1PiS_S_iii: # @_Z30matrix_multiplication_serial_1PiS_S_iii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r8d, -36(%rsp)                 # 4-byte Spill
	movq	%rdx, -8(%rsp)                  # 8-byte Spill
	movq	%rsi, -16(%rsp)                 # 8-byte Spill
	movq	%rdi, -24(%rsp)                 # 8-byte Spill
	testl	%ecx, %ecx
	jle	.LBB0_7
# %bb.1:                                # %.preheader27.lr.ph
	movslq	-36(%rsp), %rax                 # 4-byte Folded Reload
	movl	%ecx, %r8d
	movl	%eax, %r10d
	movl	%r9d, %r11d
	movq	%rax, -32(%rsp)                 # 8-byte Spill
	leaq	(,%rax,4), %rbx
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB0_2:                                # %.preheader27
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_4 Depth 2
                                        #       Child Loop BB0_9 Depth 3
	cmpl	$0, -36(%rsp)                   # 4-byte Folded Reload
	jle	.LBB0_6
# %bb.3:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB0_2 Depth=1
	movl	%r14d, %eax
	movq	-24(%rsp), %rcx                 # 8-byte Reload
	leaq	(%rcx,%rax,4), %r12
	movq	%r15, %rax
	imulq	-32(%rsp), %rax                 # 8-byte Folded Reload
	movq	-8(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %r13
	movq	-16(%rsp), %rdi                 # 8-byte Reload
	xorl	%eax, %eax
.LBB0_4:                                # %.preheader
                                        #   Parent Loop BB0_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_9 Depth 3
	testl	%r9d, %r9d
	jle	.LBB0_5
# %bb.8:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB0_4 Depth=2
	xorl	%esi, %esi
	movq	%rdi, %rbp
	xorl	%edx, %edx
.LBB0_9:                                # %.lr.ph
                                        #   Parent Loop BB0_2 Depth=1
                                        #     Parent Loop BB0_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%rbp), %ecx
	imull	(%r12,%rsi,4), %ecx
	addl	%ecx, %edx
	incq	%rsi
	addq	%rbx, %rbp
	cmpq	%rsi, %r11
	jne	.LBB0_9
	jmp	.LBB0_10
.LBB0_5:                                #   in Loop: Header=BB0_4 Depth=2
	xorl	%edx, %edx
.LBB0_10:                               # %._crit_edge
                                        #   in Loop: Header=BB0_4 Depth=2
	movl	%edx, (%r13,%rax,4)
	incq	%rax
	addq	$4, %rdi
	cmpq	%r10, %rax
	jne	.LBB0_4
.LBB0_6:                                # %._crit_edge31
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%r15
	addl	%r9d, %r14d
	cmpq	%r8, %r15
	jne	.LBB0_2
.LBB0_7:                                # %._crit_edge33
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z30matrix_multiplication_serial_1PiS_S_iii, .Lfunc_end0-_Z30matrix_multiplication_serial_1PiS_S_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z30matrix_multiplication_serial_2PiS_S_iii # -- Begin function _Z30matrix_multiplication_serial_2PiS_S_iii
	.type	_Z30matrix_multiplication_serial_2PiS_S_iii,@function
_Z30matrix_multiplication_serial_2PiS_S_iii: # @_Z30matrix_multiplication_serial_2PiS_S_iii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, 16(%rsp)                  # 8-byte Spill
	testl	%ecx, %ecx
	jle	.LBB1_14
# %bb.1:                                # %.preheader39.lr.ph
	movl	%r8d, %ebp
	movq	%rsi, %r15
	movq	%rdi, 24(%rsp)                  # 8-byte Spill
	movl	%r9d, 12(%rsp)                  # 4-byte Spill
	movl	%r8d, %r12d
	leaq	(,%r12,4), %r13
	movl	%ecx, 8(%rsp)                   # 4-byte Spill
	movl	%ecx, %r14d
	xorl	%ebx, %ebx
	movq	%r14, 32(%rsp)                  # 8-byte Spill
.LBB1_2:                                # %.preheader39
                                        # =>This Inner Loop Header: Depth=1
	testl	%ebp, %ebp
	jle	.LBB1_4
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	%ebx, %eax
	movq	16(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rdi
	xorl	%esi, %esi
	movq	%r13, %rdx
	callq	memset@PLT
.LBB1_4:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	addl	%ebp, %ebx
	decq	%r14
	jne	.LBB1_2
# %bb.5:                                # %.preheader38
	cmpl	$0, 8(%rsp)                     # 4-byte Folded Reload
	movl	12(%rsp), %r14d                 # 4-byte Reload
	movq	24(%rsp), %r13                  # 8-byte Reload
	jle	.LBB1_14
# %bb.6:                                # %.preheader37.lr.ph
	movl	%r14d, %eax
	xorl	%ecx, %ecx
	xorl	%edx, %edx
.LBB1_7:                                # %.preheader37
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_9 Depth 2
                                        #       Child Loop BB1_11 Depth 3
	testl	%r14d, %r14d
	jle	.LBB1_13
# %bb.8:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB1_7 Depth=1
	movl	%ecx, %esi
	movq	16(%rsp), %rdi                  # 8-byte Reload
	leaq	(%rdi,%rsi,4), %rsi
	movl	%edx, %edi
	imull	%r14d, %edi
	leaq	(,%rdi,4), %rdi
	addq	%r13, %rdi
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
.LBB1_9:                                # %.preheader
                                        #   Parent Loop BB1_7 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_11 Depth 3
	testl	%ebp, %ebp
	jle	.LBB1_12
# %bb.10:                               # %.lr.ph43
                                        #   in Loop: Header=BB1_9 Depth=2
	movl	%r8d, %r10d
	leaq	(%r15,%r10,4), %r10
	xorl	%r11d, %r11d
.LBB1_11:                               #   Parent Loop BB1_7 Depth=1
                                        #     Parent Loop BB1_9 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%r10,%r11,4), %ebx
	imull	(%rdi,%r9,4), %ebx
	addl	%ebx, (%rsi,%r11,4)
	incq	%r11
	cmpq	%r11, %r12
	jne	.LBB1_11
.LBB1_12:                               # %._crit_edge44
                                        #   in Loop: Header=BB1_9 Depth=2
	incq	%r9
	addl	%ebp, %r8d
	cmpq	%rax, %r9
	jne	.LBB1_9
.LBB1_13:                               # %._crit_edge46
                                        #   in Loop: Header=BB1_7 Depth=1
	incq	%rdx
	addl	%ebp, %ecx
	cmpq	32(%rsp), %rdx                  # 8-byte Folded Reload
	jne	.LBB1_7
.LBB1_14:                               # %._crit_edge48
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z30matrix_multiplication_serial_2PiS_S_iii, .Lfunc_end1-_Z30matrix_multiplication_serial_2PiS_S_iii
	.cfi_endproc
                                        # -- End function
	.globl	_Z30matrix_multiplication_serial_3PiS_S_iii # -- Begin function _Z30matrix_multiplication_serial_3PiS_S_iii
	.type	_Z30matrix_multiplication_serial_3PiS_S_iii,@function
_Z30matrix_multiplication_serial_3PiS_S_iii: # @_Z30matrix_multiplication_serial_3PiS_S_iii
	.cfi_startproc
# %bb.0:                                # %.preheader46
	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
	movl	%r8d, -36(%rsp)                 # 4-byte Spill
	movq	%rdx, -8(%rsp)                  # 8-byte Spill
	movq	%rsi, -16(%rsp)                 # 8-byte Spill
	movq	%rdi, -24(%rsp)                 # 8-byte Spill
	testl	%ecx, %ecx
	jle	.LBB2_9
# %bb.1:                                # %.preheader.lr.ph
	movslq	-36(%rsp), %rax                 # 4-byte Folded Reload
	movl	%ecx, %r8d
	movl	%eax, %r10d
	movl	%r9d, %r11d
	movq	%rax, -32(%rsp)                 # 8-byte Spill
	leaq	(,%rax,4), %rbx
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
                                        #       Child Loop BB2_6 Depth 3
	cmpl	$0, -36(%rsp)                   # 4-byte Folded Reload
	jle	.LBB2_8
# %bb.3:                                # %.lr.ph51
                                        #   in Loop: Header=BB2_2 Depth=1
	movl	%r14d, %eax
	movq	-24(%rsp), %rcx                 # 8-byte Reload
	leaq	(%rcx,%rax,4), %r12
	movq	%r15, %rax
	imulq	-32(%rsp), %rax                 # 8-byte Folded Reload
	movq	-8(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %r13
	movq	-16(%rsp), %rsi                 # 8-byte Reload
	xorl	%eax, %eax
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_6 Depth 3
	movl	$0, (%r13,%rax,4)
	testl	%r9d, %r9d
	jle	.LBB2_7
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB2_4 Depth=2
	xorl	%edx, %edx
	movq	%rsi, %rbp
	xorl	%edi, %edi
.LBB2_6:                                #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%rbp), %ecx
	imull	(%r12,%rdx,4), %ecx
	addl	%ecx, %edi
	movl	%edi, (%r13,%rax,4)
	incq	%rdx
	addq	%rbx, %rbp
	cmpq	%rdx, %r11
	jne	.LBB2_6
.LBB2_7:                                # %._crit_edge
                                        #   in Loop: Header=BB2_4 Depth=2
	incq	%rax
	addq	$4, %rsi
	cmpq	%r10, %rax
	jne	.LBB2_4
.LBB2_8:                                # %._crit_edge52
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%r15
	addl	%r9d, %r14d
	cmpq	%r8, %r15
	jne	.LBB2_2
.LBB2_9:                                # %._crit_edge54
	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	_Z30matrix_multiplication_serial_3PiS_S_iii, .Lfunc_end2-_Z30matrix_multiplication_serial_3PiS_S_iii
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$800, %edi                      # imm = 0x320
	callq	_Znam
	movq	%rax, %r14
	movl	$2400, %edi                     # imm = 0x960
	callq	_Znam
	movq	%rax, %r15
	movl	$1200, %edi                     # imm = 0x4B0
	callq	_Znam
	movq	%rax, %rbx
	movl	$.Lstr, %edi
	callq	puts@PLT
	movq	%r14, %r12
	xorl	%r13d, %r13d
.LBB3_1:                                # %.preheader98
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_2 Depth 2
	xorl	%ebp, %ebp
.LBB3_2:                                #   Parent Loop BB3_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r13,%rbp), %esi
	movl	%esi, (%r12,%rbp,4)
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%rbp
	cmpq	$20, %rbp
	jne	.LBB3_2
# %bb.3:                                #   in Loop: Header=BB3_1 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r13
	addq	$80, %r12
	cmpq	$10, %r13
	jne	.LBB3_1
# %bb.4:
	movq	%r14, 16(%rsp)                  # 8-byte Spill
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$3, %r12d
	movq	%r15, %r13
	xorl	%ebp, %ebp
.LBB3_5:                                # %.preheader97
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_6 Depth 2
	xorl	%r14d, %r14d
.LBB3_6:                                #   Parent Loop BB3_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%r12,%r14), %esi
	movl	%esi, (%r13,%r14,2)
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	addq	$2, %r14
	cmpq	$60, %r14
	jne	.LBB3_6
# %bb.7:                                #   in Loop: Header=BB3_5 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%rbp
	addq	$120, %r13
	incq	%r12
	cmpq	$20, %rbp
	jne	.LBB3_5
# %bb.8:
	xorl	%r12d, %r12d
	movq	%rsp, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	16(%rsp), %r14                  # 8-byte Reload
.LBB3_9:                                # %.preheader27.i.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_10 Depth 2
                                        #       Child Loop BB3_11 Depth 3
                                        #         Child Loop BB3_12 Depth 4
	movq	%r14, %rax
	xorl	%ecx, %ecx
.LBB3_10:                               # %.preheader27.i
                                        #   Parent Loop BB3_9 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_11 Depth 3
                                        #         Child Loop BB3_12 Depth 4
	imulq	$120, %rcx, %rdx
	addq	%rbx, %rdx
	movq	%r15, %rsi
	xorl	%edi, %edi
.LBB3_11:                               # %.preheader.i
                                        #   Parent Loop BB3_9 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB3_12 Depth 4
	xorl	%r8d, %r8d
	movq	%rsi, %r9
	xorl	%r10d, %r10d
.LBB3_12:                               # %.lr.ph.i
                                        #   Parent Loop BB3_9 Depth=1
                                        #     Parent Loop BB3_10 Depth=2
                                        #       Parent Loop BB3_11 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movl	(%r9), %r11d
	imull	(%rax,%r8,4), %r11d
	addl	%r11d, %r10d
	incq	%r8
	addq	$120, %r9
	cmpq	$20, %r8
	jne	.LBB3_12
# %bb.13:                               # %._crit_edge.i
                                        #   in Loop: Header=BB3_11 Depth=3
	movl	%r10d, (%rdx,%rdi,4)
	incq	%rdi
	addq	$4, %rsi
	cmpq	$30, %rdi
	jne	.LBB3_11
# %bb.14:                               # %._crit_edge31.i
                                        #   in Loop: Header=BB3_10 Depth=2
	incq	%rcx
	addq	$80, %rax
	cmpq	$10, %rcx
	jne	.LBB3_10
# %bb.15:                               # %_Z30matrix_multiplication_serial_1PiS_S_iii.exit
                                        #   in Loop: Header=BB3_9 Depth=1
	incl	%r12d
	cmpl	$10000, %r12d                   # imm = 0x2710
	jne	.LBB3_9
# %bb.16:
	leaq	24(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r12), %rax
	movq	8(%r12), %rsi
	movq	%rsp, %r12
	subq	(%r12), %rax
	imulq	$1000000, %rax, %rax            # imm = 0xF4240
	subq	8(%r12), %rsi
	addq	%rax, %rsi
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	$10000, %ebp                    # imm = 0x2710
.LBB3_17:                               # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%rbx, %rdx
	movl	$10, %ecx
	movl	$30, %r8d
	movl	$20, %r9d
	callq	_Z30matrix_multiplication_serial_2PiS_S_iii
	decl	%ebp
	jne	.LBB3_17
# %bb.18:
	xorl	%r13d, %r13d
	leaq	24(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r12), %rax
	movq	8(%r12), %rsi
	movq	%rsp, %r12
	subq	(%r12), %rax
	imulq	$1000000, %rax, %rax            # imm = 0xF4240
	subq	8(%r12), %rsi
	addq	%rax, %rsi
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
.LBB3_19:                               # %.preheader.i87.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_20 Depth 2
                                        #       Child Loop BB3_21 Depth 3
                                        #         Child Loop BB3_22 Depth 4
	movq	%r14, %rax
	xorl	%ecx, %ecx
.LBB3_20:                               # %.preheader.i87
                                        #   Parent Loop BB3_19 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB3_21 Depth 3
                                        #         Child Loop BB3_22 Depth 4
	imulq	$120, %rcx, %rdx
	addq	%rbx, %rdx
	movq	%r15, %rsi
	xorl	%edi, %edi
.LBB3_21:                               #   Parent Loop BB3_19 Depth=1
                                        #     Parent Loop BB3_20 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB3_22 Depth 4
	xorl	%r8d, %r8d
	movq	%rsi, %r9
	xorl	%r10d, %r10d
.LBB3_22:                               #   Parent Loop BB3_19 Depth=1
                                        #     Parent Loop BB3_20 Depth=2
                                        #       Parent Loop BB3_21 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movl	(%r9), %r11d
	imull	(%rax,%r8,4), %r11d
	addl	%r11d, %r10d
	incq	%r8
	addq	$120, %r9
	cmpq	$20, %r8
	jne	.LBB3_22
# %bb.23:                               # %._crit_edge.i94
                                        #   in Loop: Header=BB3_21 Depth=3
	movl	%r10d, (%rdx,%rdi,4)
	incq	%rdi
	addq	$4, %rsi
	cmpq	$30, %rdi
	jne	.LBB3_21
# %bb.24:                               # %._crit_edge52.i
                                        #   in Loop: Header=BB3_20 Depth=2
	incq	%rcx
	addq	$80, %rax
	cmpq	$10, %rcx
	jne	.LBB3_20
# %bb.25:                               # %_Z30matrix_multiplication_serial_3PiS_S_iii.exit
                                        #   in Loop: Header=BB3_19 Depth=1
	incl	%r13d
	cmpl	$10000, %r13d                   # imm = 0x2710
	jne	.LBB3_19
# %bb.26:
	leaq	24(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r14), %rax
	movq	8(%r14), %rsi
	subq	(%rsp), %rax
	imulq	$1000000, %rax, %rax            # imm = 0xF4240
	subq	8(%rsp), %rsi
	addq	%rax, %rsi
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	xorl	%r14d, %r14d
.LBB3_27:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_28 Depth 2
	xorl	%r15d, %r15d
.LBB3_28:                               #   Parent Loop BB3_27 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rbx,%r15,4), %esi
	movl	$.L.str.8, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	$30, %r15
	jne	.LBB3_28
# %bb.29:                               #   in Loop: Header=BB3_27 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incq	%r14
	addq	$120, %rbx
	cmpq	$10, %r14
	jne	.LBB3_27
# %bb.30:
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"%3d "
	.size	.L.str.1, 5

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"matrix_multiplication_serial_1 use time: %d\n"
	.size	.L.str.4, 45

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"matrix_multiplication_serial_2 use time: %d\n"
	.size	.L.str.5, 45

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"matrix_multiplication_serial_3 use time: %d\n"
	.size	.L.str.6, 45

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

	.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	"a:"
	.size	.Lstr, 3

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"b:"
	.size	.Lstr.1, 3

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"result:"
	.size	.Lstr.2, 8

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

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
